Writing the trajectory of a smaller volume of the simulation box

GROMACS version: > = 2019.5
GROMACS modification:
Here post your question :

Hi all,
How can I write the trajectory of a smaller volume (box and/or sphere) around the COM of a simulation box?

Thanks in advance.


Hi Yasser,

This is a bit more tricky than it seems, because the number of atoms will change dynamically for that and the most widely used trajectory format .xtc does not support this.

You can however patch together such a trajectory using gmx select to define a matching selection, see

and use something like
within 1 of [1.2, 3.1, 2.4]

together with -on that will give you an index file for a specific frame that you then can write out using trjconv or similar tools.

You can also use these dynamic selections in a bunch of analysis tools, so you might be able to skip writing the trajectory at all and just analyse the properties you want directly from the unfiltered trajectory.

Hi cblau,

Thank you very much for the tip. In my case, I do need the trajectory because I need to analyze some properties during the simulation in a certain region of the box.

I haven’t used gmx select before, but if I got it properly, in principle, with that command I could write the content of that region in a certain frame, and then concatenate all frames in a trajectory, right?


Hi Yasser,

Only to some extent - you will be able to write out all the coordinates, but concatenating is more difficult. If you use .pdb or .gro for writing out the frames and then concatenate them to a trajectory that should work, but most other trajectory formats expect the same number of atoms for every frame.

Hi cblau,

In that case, it should be fine in principle, because the tool I am using for the trajectory characterization only accepts .gro format.

Thanks again.