# Using dynamic index groups for gmx mdrun -rerun

**URL:** <https://gromacs.bioexcel.eu/t/using-dynamic-index-groups-for-gmx-mdrun-rerun/6598>\
**Category:** User discussions\
**Tags:** mdrun\
**Created:** [June 13, 2023, 8:25am UTC](https://gromacs.bioexcel.eu/t/using-dynamic-index-groups-for-gmx-mdrun-rerun/6598 "2023-06-13T08:25:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saumyak](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/saumyak/32/2240_2.png) [@Saumyak](https://gromacs.bioexcel.eu/u/Saumyak)\
**Post date:** [June 13, 2023, 8:25am UTC](https://gromacs.bioexcel.eu/t/using-dynamic-index-groups-for-gmx-mdrun-rerun/6598/1 "2023-06-13T08:25:38Z")

</div>

GROMACS version: 2020.1  
GROMACS modification: No

Hi,

I want to calculate the interaction energy between a solute and the water molecules within 0.5 nm of the solute. First I have used gmx select to create a dynamic index file for the hydration water molecules (using the flag -on). Now I want to use gmx mdrun -rerun to calculate the desired energies. But I am not sure how to define the energy groups in the rerun.mdp file. One group will obviously be the solute itself. But how do I mention the hydration layer waters as a group, since it changes every time frame in the ndx file?

I understand that for a post processing script like gmx dipoles, gmx hbond etc., I can use dynamic index group frame by frame using a shell script. But how to do that in a rerun?

Any advice is much appreciated. Thanks.

Best,  
Saumyak

---

<div class="post-metadata">

**Author:** ![ebriand](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/ebriand/32/2314_2.png) [@ebriand](https://gromacs.bioexcel.eu/u/ebriand)\
**Post date:** [June 13, 2023, 8:33am UTC](https://gromacs.bioexcel.eu/t/using-dynamic-index-groups-for-gmx-mdrun-rerun/6598/2 "2023-06-13T08:33:48Z")

</div>

As far as I know, you can only do index groups with a fixed list of atoms during simulation - there is not the same machinery as used in the analysis tool.

You might need to go frame by frame (extract one frame, generate the correct index using `gmx select` and your selection query, rerun for a single frame, extract energies), which is a bit inconvenient and slow, but should work.

(There is also the concern of whether the quantity is meaningful in itself - interaction energy accuracy is generally not a target of forcefields - but you know your method best)

---

<div class="post-metadata">

**Author:** ![Saumyak](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/saumyak/32/2240_2.png) [@Saumyak](https://gromacs.bioexcel.eu/u/Saumyak)\
**Post date:** [June 13, 2023, 8:37am UTC](https://gromacs.bioexcel.eu/t/using-dynamic-index-groups-for-gmx-mdrun-rerun/6598/3 "2023-06-13T08:37:02Z")

</div>

Thanks for your reply. I guess there’s no way to avoid the tedious path.

I agree, the values are completely dependent on the force field and might not be experimentally accurate. But I am not concerned about the values as such. My intention is to look into the amplitude of fluctuations. So that should not be a huge problem. But the technicality of the problem bothers me.

---

<div class="post-metadata">

**Author:** ![hess](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/hess/32/416_2.png) [@hess](https://gromacs.bioexcel.eu/u/hess)\
**Post date:** [June 15, 2023, 7:18am UTC](https://gromacs.bioexcel.eu/t/using-dynamic-index-groups-for-gmx-mdrun-rerun/6598/4 "2023-06-15T07:18:07Z")

</div>

This is not possible to do with GROMACS, unless you create a new tpr file for every frame.

But note that looking at potential energy alone is nearly meaningless. Interactions in many solvents, and water in particular, show very large enthalpy/entropy compensation. So the enthalpy will not tell you much.

---

<div class="post-metadata">

**Author:** ![Saumyak](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/saumyak/32/2240_2.png) [@Saumyak](https://gromacs.bioexcel.eu/u/Saumyak)\
**Post date:** [June 15, 2023, 9:03am UTC](https://gromacs.bioexcel.eu/t/using-dynamic-index-groups-for-gmx-mdrun-rerun/6598/5 "2023-06-15T09:03:58Z")

</div>

Thanks for your reply.
