Write parameters#

Writing the topology file for GROMACS.

The objective of this tutorial is to write the force field parameters (.itp files) for a simple system. If follows directly the writing of the gro file in Create conf.gro tutorial.

The parameter files created here will be used in Bulk salt solution. If you are only interested in running GROMACS, jump directly to Bulk salt solution.

Looking for help with your project?

See the Contact page.

Default parameters#

Create a folder called ff/. Within ff/, create a new empty file named forcefield.itp, and copy the following in it:

to be copied in ff/forcefield.itp#
[ defaults ]
; nbfunc  comb-rule  gen-pairs  fudgeLJ  fudgeQQ
  1       2          no         1.0      0.833

[ atomtypes ]
; name  at.num  mass      charge  ptype  sigma    epsilon
  Na    11      22.9900   1.0000  A      0.23100  0.45000
  OS     8      15.9994  -1.0000  A      0.38600  0.12
  SO    16      32.0600   2.0000  A      0.35500  1.0465
  HW     1       1.0079   0.5270  A      0.00000  0.00000
  OW     8      15.9994   0.0000  A      0.31650  0.77323
  MW     0       0.0000  -1.0540  D      0.00000  0.00000

[ bondtypes ]
; i   j   func  b0    kb
  SO  OS  1     0.15  3.7656e4

[ angletypes ]
; i   j   k   func  theta  k0
  OS  SO  OS  1     109.5  520

The forcefield.itp file is used to define basic combination rules, as well as atom types, bond types, and angle types.

With comb-rule = 2, the mixing rule is calculated as \(\epsilon_{ij} = \sqrt{\epsilon_{ii} \epsilon_{jj}}\), \(\sigma_{ij} = (\sigma_{ii}+\sigma_{jj})/2\). FudgeLJ and fudgeQQ are the factors by which to multiply Lennard-Jones and Coulomb 1-4 interactions, respectively. You can refer to the GROMACS manual for more information.

The forcefield.itp file also contains information about the atoms, such their masses and Lennard-Jones parameters sigma and epsilon, as well as some parameters for the bond and angle constraints that will be necessary for the SO4 ions.

Notice that the particle with name MW is of type ‘D’ when all the other particles are of type ‘A’ for atoms. This is because MW is the virtual massless site of our 4 points rigid water model, see this wiki page for details.

Sodium ion#

Let us create a file named na.itp for the Sodium ion:

to be copied in ff/na.itp#
[ moleculetype ]
; molname nrexcl
  Na      1

[ atoms ]
; id  at-type  res-nr  res-name  at-name  cg-nr  charge  mass
  1   Na       1       Na        Na1      1      1.000   22.9900

The ‘molecule’ named Na for a residue with one single atom, of type Na and name Na1, charge +1.0 and mass 22.990 g/mol.

Sulfate ion#

The file so4.itp for the sulfate ion is more complicated, as the residue is made of 5 atoms that are bonded together and maintained by angular constrained.

The exclusions ensures that atoms from the same residue do not interact through LJ and Coulomb interactions.

to be copied in ff/so4.itp#
[moleculetype]
; name  nrexcl
  SO4   1

[ atoms ]
; id  at-type  res-nr  res-name  at-name  cg-nr  charge  mass
  1   OS       1       SO4       O1       1     -1.000   15.9994
  2   OS       1       SO4       O2       1     -1.000   15.9994
  3   OS       1       SO4       O3       1     -1.000   15.9994
  4   OS       1       SO4       O4       1     -1.000   15.9994
  5   SO       1       SO4       S1       1      2.000   32.0600

[ bonds ]
;  ai   aj  funct   c0         c1
   1    5   1       0.1520     3.7656e4
   2    5   1       0.1520     3.7656e4
   3    5   1       0.1520     3.7656e4
   4    5   1       0.1520     3.7656e4

[ angles ]
;  ai   aj   ak  funct   angle     fc
   1    5    2    1    109.5  520
   1    5    3    1    109.5  520
   1    5    4    1    109.5  520
   2    5    3    1    109.5  520
   2    5    4    1    109.5  520
   3    5    4    1    109.5  520

[exclusions]
1       2       3       4       5
2       1       3       4       5
3       1       2       4       5
4       1       2       3       5
5       1       2       3       4

Support me for 1 euro per month

Become a Patreon and support the creation of content for GROMACS

Water molecule#

Finally, create a file named h2o.itp for the water molecule. Settle parameters are added to ensure that the residue remains rigid:

to be copied in ff/h2o.itp#
[ moleculetype ]
; molname  nrexcl
SOL      2

[ atoms ]
; id  at-type  res-nr  res-name  at-name  cg-nr  charge  mass
  1   OW       1       SOL       OW1      1      0.000    15.9994
  2   HW       1       SOL       HW1      1      0.527     1.0079
  3   HW       1       SOL       HW2      1      0.527     1.0079
  4   MW       1       SOL       MW1      1     -1.054     0.0000

[ settles ]
; i  funct  doh      dhh
  1  1      0.09572  0.15139

[ virtual_sites3 ]
; Vsite from          funct        a               b
  4     1     2     3     1       0.089608       0.089608

[ exclusions ]
1 2 3 4
2 1 3 4
3 1 2 4
4 1 2 3

To continue and use those files for running a molecular dynamics simulation with GROMACS, go to Bulk salt solution.

Contact me

Contact me if you have any question or suggestion about these tutorials.