How to apply position constraint for a particular molecule?

Hi everyone
I am working on a problem containg few acid molecules at air water interface. I want to apply position restraint for acid during NVT/NPT equilibrium phase.
So, I prepared the interface and placed the acid on its surface manually. To apply the position restraint i created the posre.itp file by using genresre command. when i am using grompp to equilibrate this system i am getting error as follows:
Fatal error:
Syntax error - File restr.itp, line 3
Last line read:
‘[ position_restraints ]’
Invalid order for directive position_restraints
It seems that there is some problem in my itp file or in topology. I don’t know how to solve it.
--------------------------------------------------------.top file---------------------------------------------------------------------
#include “oplsaa.ff/forcefield.itp”

#ifdef POSRES
#include “restr.itp”
#endif

#include “oplsaa.ff/tip3p.itp”
[ system ]
; Name
HNO3 in water

[ molecules ]
; Compound #mols
SOL 499
HNO3 1

---------------------------------------------------------------posre.itp-------------------------------------------------------------
; position restraints for non-Water of 216H2O,WATJP01,SPC216,SPC-MODEL,300K,BOX(M)=1.86206NM,WFVG,MAR. 1984

[ position_restraints ]
; i funct fcx fcy fcz
1498 1 1000 1000 1000
1499 1 1000 1000 1000
1500 1 1000 1000 1000
1501 1 1000 1000 1000
1502 1 1000 1000 1000
~
This problem has bothered me for one week. Any suggestion would be of great help to me. Thanks a lot!

You need to append the directive to your acid itp file (which seems not included). e.g.,

; normal itp
.......

[ position_restraints ]
; note the index
1 1 1000 1000 1000
2 1 1000 1000 1000
3 1 1000 1000 1000
4 1 1000 1000 1000
5 1 1000 1000 1000

Hi nano,
Thank for the message. As you pointed out, I added the directive to acid itp file but i am getting the error
“ERROR 1 [file topo_h.top, line 28]:
Atom index (1) in position_restraints out of bounds (1-0). This probably means that you have inserted topology section “position_restraints” in a part belonging to a different molecule than you intended to.”

i want to restraint the acid molecule. Here is my topology file

#include “oplsaa.ff/forcefield.itp”
[ moleculetype ]
; name nrexcl
HNO3 3

[ atoms ]
N opls_966 0.968 1
O1 opls_761 -0.408 1
O2 opls_761 -0.497 1
O3 opls_023 -0.526 1
H opls_024 0.463 1

[ bonds ]
N O1
N O2
N O3
O2 H

[ angles ]
O3 N O2
O1 N O2
O1 N O3
H O2 N

[ position_restraints ]
; note the index
1 1 1000 1000 1000
2 1 1000 1000 1000
3 1 1000 1000 1000
4 1 1000 1000 1000
5 1 1000 1000 1000

#include “oplsaa.ff/tip3p.itp”

[ system ]
; Name
HNO3 in water

[ molecules ]
; Compound #mols
SOL 499
HNO3 1

I tried checking it twice-thrice but couldn’t find error. Kindly help me to figure out what’s wrong in my topol.top file?

This [moleculetype] definition is syntactically incorrect. It appears to be somewhat of a hybrid of .rtp and actual topology entry. Atoms need to be numbered, and all bonds, angles, etc. need to be specified by numbers, not atom names. You’re getting a fatal error because there are essentially zero atoms correctly defined, so you cannot apply restraints.