# Problem using Position restraints for multiple groups

**URL:** <https://gromacs.bioexcel.eu/t/problem-using-position-restraints-for-multiple-groups/13340>\
**Category:** User discussions\
**Tags:** simulation-setup\
**Created:** [March 27, 2026, 3:52pm UTC](https://gromacs.bioexcel.eu/t/problem-using-position-restraints-for-multiple-groups/13340 "2026-03-27T15:52:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fredpontes20](https://avatars.discourse-cdn.com/v4/letter/f/f1d935/32.png) [@fredpontes20](https://gromacs.bioexcel.eu/u/fredpontes20)\
**Post date:** [March 27, 2026, 3:52pm UTC](https://gromacs.bioexcel.eu/t/problem-using-position-restraints-for-multiple-groups/13340/1 "2026-03-27T15:52:16Z")

</div>

GROMACS version: 2023.2  
GROMACS modification: No

I have a membrane-protein system and during the pre-equilibration I’m applying different values of positional restraints for lipids (6 different species) and the protein.

In my mdp, I included:

define = -DPOSRES\_PT

And in my topology, for each lipid, I created the following ifdef structure:

#include “./ITPs/martini\_v3.0.0\_phospholipids\_PS\_v2\_openbeta.itp”  
#ifdef POSRES\_PT  
#include “posre\_POPS.itp”  
#endif

#include “./ITPs/martini\_v3.0.0\_phospholipids\_PI\_v2\_openbeta.itp”  
#ifdef POSRES\_PT  
#include “posre\_POP2.itp”  
#endif

each posre\_\*\*.\*itp file (created with gmx genrest) file has the following structure:

; position restraints for POP2.

; i funct fcx fcy fcz  
1 1 200 200 200  
2 1 200 200 200  
3 1 200 200 200  
4 1 200 200 200  
5 1 200 200 200  
6 1 200 200 200  
7 1 200 200 200  
8 1 200 200 200  
9 1 200 200 200  
10 1 200 200 200  
11 1 200 200 200  
12 1 200 200 200  
13 1 200 200 200  
14 1 200 200 200  
15 1 200 200 200  
16 1 200 200 200  
17 1 200 200 200

Basically, when I execute gmx grompp (gmx grompp -f full-pr-md.mdp -c min.gro -r min.gro -p teste\_update.top -n index.ndx -o pr\_md.tpr), I always got the same error for the second if statement in my topology file.

ERROR 1 [file posre\_POP2.itp, line 13]:  
Atom index (9) in position\_restraints out of bounds (1-8).  
This probably means that you have inserted topology section  
“position\_restraints”  
in a part belonging to a different molecule than you intended to.  
In that case move the “position\_restraints” section to the right  
molecule.

Could someone help me to understand what I’m doing wrong? I’m able to create the tpr file without the position restraints sections.

Thanks in advance,

Fred

---

<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:** [March 27, 2026, 6:59pm UTC](https://gromacs.bioexcel.eu/t/problem-using-position-restraints-for-multiple-groups/13340/2 "2026-03-27T18:59:01Z")

</div>

This mean the you included the file posre\_POP2.itp after a declaration of a moleculetype with 8 atoms. You must have mixed up the files or made a typo.

---

<div class="post-metadata">

**Author:** ![fredpontes20](https://avatars.discourse-cdn.com/v4/letter/f/f1d935/32.png) [@fredpontes20](https://gromacs.bioexcel.eu/u/fredpontes20)\
**Post date:** [March 30, 2026, 10:49am UTC](https://gromacs.bioexcel.eu/t/problem-using-position-restraints-for-multiple-groups/13340/3 "2026-03-30T10:49:29Z")

</div>

hi Hess!

Thank you so much for your message. Apparently I solved the problem and I’d like to let here registered. I kept my topology file like this:

#include “./ITPs/martini\_v3.0.0.itp”  
#include “./ITPs/martini\_v3.0.0\_ffbonded\_v2\_openbeta.itp”  
#include “./ITPs/martini\_v3.0.0\_phospholipids\_PS\_v2\_openbeta.itp”  
#include “./ITPs/martini\_v3.0.0\_phospholipids\_PI\_v2\_openbeta.itp”  
#include “./ITPs/martini\_v3.0.0\_phospholipids\_PC\_v2\_openbeta.itp”  
#include “./ITPs/martini\_v3.0.0\_phospholipids\_PE\_v2\_openbeta.itp”  
#include “./ITPs/martini\_v3.0.0\_phospholipids\_SM\_v2\_openbeta.itp”  
#include “./ITPs/martini\_v3.0.0\_sterols\_v1.itp”  
#include “./ITPs/martini\_v3.0.0\_solvents\_v1.itp”  
#include “./ITPs/martini\_v3.0.0\_ions\_v1.itp”  
#include “molecule\_0.itp”

but now I included a position restraint section inside each lipid’s itp file, like this:

#ifdef POSRES\_PT  
; i funct fcx fcy fcz  
1 1 200 200 200  
2 1 200 200 200  
3 1 200 200 200  
4 1 200 200 200  
5 1 200 200 200  
6 1 200 200 200  
7 1 200 200 200  
8 1 200 200 200  
9 1 200 200 200  
#endif
