Feature #1167

trjconv -center would be more intuitive if it centered the center of mass, not the midpoint between minimum and maximum values

Added by Chris Neale about 8 years ago. Updated over 6 years ago.

analysis tools
Target version:


I have included a patch that changes trjconv 4.5.3 so that the -center option now acts on the center of mass of the selected group. It's a new function, so only minor additional modifications would be required to change it so that both types of centering were possible with different flags. Note that this counter-intuitive centering behaviour of trjconv -center still exists in version 4.6.

I originally mentioned this on the users list:

this.patch (1.57 KB) this.patch Chris Neale, 02/28/2013 12:39 AM

Related issues

Related to GROMACS - Task #2115: trjconv does too many things, and combinations of them work poorlyNew


#1 Updated by Erik Lindahl over 6 years ago

First, the present behavior is documented, and it definitely says "geometrical center" in the help text, so I don't think it's entirely counter-intuitive :-)

In general I think it's much better to center based on geometry rather than mass. A typical reason for centering both in editconf and trjconv is that we want to make sure something appears in the middle of the box, in particular if we want to guarantee a minimum distance to the cell edge (for whatever reason). Here, I think it would be more confusing if we started having a larger margin on the side of the box that fewer atoms in an asymmetric molecule?

Second, for almost all practical simulations we will add the solvent around the solute, and then the mass would make even less sense since it no longer corresponds to the mass of the entire system. trjconv already has 25 program-specific options, so I'd prefer if we can solve the challenge without adding more.

Perhaps it would be easier if you explain what you want to achieve?

#2 Updated by Chris Neale over 6 years ago

My usage is centering a bilayer in the box in the dimension of the bilayer normal (usually the Z axis) to do things like then using g_density to compute density profiles of selected groups along the bilayer normal. When making such a plot, the x-axis of the plot is usually distance from the bilayer's center of mass, not its center of geometry, since a single lipid popping a bit out of the membrane may drastically affect the center of geometry and not much affect the center of mass.

Actually, to get what I want without error I need to use my own modified version of trjconv to get the centering based on mass and then a modified version of g_density because that tool is also incorrect for any simulation in which there are fluctuations of the Z box dimension (i.e., constant pressure simulations). Therefore, I'm actually not requesting this for myself since I already have a working solution. I just thought that this would be more useful for other users, but if you disagree then I am fine with that.

Thank you.

#3 Updated by Mark Abraham about 4 years ago

  • Related to Task #2115: trjconv does too many things, and combinations of them work poorly added

Also available in: Atom PDF