# Spherical position restraints

**URL:** <https://gromacs.bioexcel.eu/t/spherical-position-restraints/951>\
**Category:** User discussions\
**Created:** [October 13, 2020, 9:05am UTC](https://gromacs.bioexcel.eu/t/spherical-position-restraints/951 "2020-10-13T09:05:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yasser.almeida](https://avatars.discourse-cdn.com/v4/letter/y/76d3ee/32.png) [@yasser.almeida](https://gromacs.bioexcel.eu/u/yasser.almeida)\
**Post date:** [October 13, 2020, 9:05am UTC](https://gromacs.bioexcel.eu/t/spherical-position-restraints/951/1 "2020-10-13T09:05:41Z")

</div>

GROMACS version: 2020.x  
GROMACS modification: Yes/No

Hi all,

I am setting a system similar to [https://pubs.acs.org/doi/10.1021/acs.jctc.5b00499](https://pubs.acs.org/doi/10.1021/acs.jctc.5b00499) where the atomistic (AA) waters are surrounded by CG water. In order to avoid the AA water to mix with the CG solvent harmonic restraints are imposed to keep them together.  
Reading the manual ([http://manual.gromacs.org/current/reference-manual/functions/restraints.html](http://manual.gromacs.org/current/reference-manual/functions/restraints.html)) I think the (attractive) sphere flat-bottomed position restraints are appropriate for my problem since I want they are applied when the molecules get too close to the boundary.  
Earlier in the manual, it states “For spherical shells, it is a wise procedure to make the force constant depend on the radius, increasing from zero at the inner boundary to a large value at the outer boundary. **This feature has not, however, been implemented in GROMACS.** ” Is there an example on the .mdp options to implement this in 2020.x versions? They use Gromacs 4.6.5 in the previous paper.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![alevilla](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/alevilla/32/439_2.png) [@alevilla](https://gromacs.bioexcel.eu/u/alevilla)\
**Post date:** [October 13, 2020, 9:25am UTC](https://gromacs.bioexcel.eu/t/spherical-position-restraints/951/2 "2020-10-13T09:25:42Z")

</div>

Hi,

you can can define flat-bottomed position restraints in the topology file (for syntax see [http://manual.gromacs.org/current/reference-manual/topologies/topology-file-formats.html?highlight=position%20restrain](http://manual.gromacs.org/current/reference-manual/topologies/topology-file-formats.html?highlight=position%20restrain) Table 14).

Kind regards  
Alessandra

---

<div class="post-metadata">

**Author:** ![yasser.almeida](https://avatars.discourse-cdn.com/v4/letter/y/76d3ee/32.png) [@yasser.almeida](https://gromacs.bioexcel.eu/u/yasser.almeida)\
**Post date:** [October 13, 2020, 9:37am UTC](https://gromacs.bioexcel.eu/t/spherical-position-restraints/951/3 "2020-10-13T09:37:11Z")

</div>

Thank you very much.

---

<div class="post-metadata">

**Author:** ![yasser.almeida](https://avatars.discourse-cdn.com/v4/letter/y/76d3ee/32.png) [@yasser.almeida](https://gromacs.bioexcel.eu/u/yasser.almeida)\
**Post date:** [October 16, 2020, 9:48am UTC](https://gromacs.bioexcel.eu/t/spherical-position-restraints/951/4 "2020-10-16T09:48:25Z")

</div>

Hi Alessandra,

I followed the link in the manual to try to set the restraints but still doesn’t work.

I have an equilibrated water box generated with CHARMM-GUI. Now, I want to perform a production run, where all molecules in a radius of 20 A (from the system COM) are flat-bottom half-harmonic restrained (something like [https://pubs.acs.org/doi/10.1021/acs.jctc.5b00499](https://pubs.acs.org/doi/10.1021/acs.jctc.5b00499)).

My topology is:

```
; Include forcefield parameters
#include "toppar/forcefield.itp"

; Include Flat-bottom position restraint file for oxygens
#ifdef POSRES
#include "posre_flat-bottom_spherical_restraints_O.itp"
#endif

; Include forcefield parameters for TIP3 water
#include "toppar/TIP3.itp"

(...)

```

My restraints .itp file is:

```
; Flat-bottom position restrains to all Oxygens to				
; keep them in the sphere of 20 A radius from COM
				
[position_restraints]
; atom	type	g	r	k
	288	2	1	2	1000
	337	2	1	2	1000
	338	2	1	2	1000
    (...)

```

When I run grompp I get:

```
Fatal error:
Syntax error - File posre_flat-bottom_spherical_restraints_O_new.itp, line 4
Last line read:
'[position_restraints]'
Invalid order for directive position_restraints

```

What am I missing?

Thanks in advance.

Best

---

<div class="post-metadata">

**Author:** ![alevilla](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/alevilla/32/439_2.png) [@alevilla](https://gromacs.bioexcel.eu/u/alevilla)\
**Post date:** [October 19, 2020, 7:36am UTC](https://gromacs.bioexcel.eu/t/spherical-position-restraints/951/5 "2020-10-19T07:36:17Z")

</div>

Hi,

I understood that you apply restrains to water molecules. In this case, the water definition should go before the restrain definition in the topology file. That is

```auto
; Include forcefield parameters for TIP3 water
#include "toppar/TIP3.itp"

```

then

```auto
; Include Flat-bottom position restraint file for oxygens
#ifdef POSRES
#include "posre_flat-bottom_spherical_restraints_O.itp"
#endif

```

Kind regards  
Alessandra

---

<div class="post-metadata">

**Author:** ![yasser.almeida](https://avatars.discourse-cdn.com/v4/letter/y/76d3ee/32.png) [@yasser.almeida](https://gromacs.bioexcel.eu/u/yasser.almeida)\
**Post date:** [October 19, 2020, 8:03am UTC](https://gromacs.bioexcel.eu/t/spherical-position-restraints/951/6 "2020-10-19T08:03:22Z")

</div>

Hi Alessandra,

thanks for your reply.

Yes, digging a bit more I think I could do it that way and by defining the restrains directly in the .top file as:

```
#ifdef POSRES_WATER_SPH
[position_restraints]
;	atom	type	g	r	k
	1	2	1	2	1000

```

where `atom 1` refers to the oxygen atoms in `TIP3.itp` file. Then in the .mdp file, I defined `define = -DPOSRES_WATER_SPH` to apply the restrains during the run.

Best regards,  
Yasser
