Centering a molecule that crosses periodic boundaries — single-atom trick

GROMACS version:2025
GROMACS modification: Yes/No
Sharing a workaround in case it helps others. The problem: - single solute molecule, a few hundred atoms, cubic box - over a long trajectory it drifted toward the box edge - in many frames part of the atoms ended up on the opposite side through PBC Standard pipeline pbc mol then center then fit, with the whole molecule as centering group) did not move the molecule to the box center. Why? becase when atoms are split across the boundary, the geometric center of the selection falls into empty space between the two halves. Center then moves that empty point to the middle of the box, while the atoms stay where they were. Selecting a smaller chunk (dore example one residue) did not help. If any atom of that chunk happened to be on the other side, the center still fell in the void.

What worked index group containing a single atom near the molecule’s center - use that single atom as the centering selection. After that, standard pbc mol / center / fit pipeline produced a clean centered trajectory. For fitting later, use a multi-atom group (single atom cannot constrain rotation). Full topology matching the gmx version is needed for pbc mol to glue the molecule across the boundary - the choice of which central atom matters less than picking one - not a bug, just a workaround that is not obvious from the docs Hope it saves someone time.

Because then you end up searching for it again yourself — I’d actually done this once before but never wrote it down. And if it’s floating around online, the LLMs will pick it up too, which makes things easier.

Did you try -pbc whole? This should remove all splits in molecules across the box edge; you can then run the resulting trajectory through trjconv again with “center” to re-center the box around your molecule of interest. “pbc mol” by itself (after centering on a single atom) does not guarantee that your molecule remains unbroken, I think.