Tabulated interaction functions#
Cubic splines for potentials#
In some of the inner loops of GROMACS, look-up tables are used for
computation of potential and forces. The tables are interpolated using a
cubic spline algorithm. There are separate tables for electrostatic,
dispersion, and repulsion interactions, but for the sake of caching
performance these have been combined into a single array. The cubic
spline interpolation for
where the table spacing
so that
The four coefficients are determined from the four conditions that
V and V’ are continuous, while V” is the first discontinuous derivative. The number of points per nanometer is 500 and 2000 for mixed- and double-precision versions of GROMACS, respectively. This means that the errors in the potential and force will usually be smaller than the mixed precision accuracy.
GROMACS stores
Calculate distance vector (
) and distanceMultiply
by and truncate to an integer value to get a table indexCalculate fractional component (
= ) andDo the interpolation to calculate the potential
and the scalar forceCalculate the vector force
by multiplying with
Note that table look-up is significantly slower than computation of the most simple Lennard-Jones and Coulomb interaction. However, it is much faster than the shifted Coulomb function used in conjunction with the PPPM method. Finally, it is much easier to modify a table for the potential (and get a graphical representation of it) than to modify the inner loops of the MD program.
User-specified potential functions#
You can also use your own potential functions without editing the GROMACS code. The potential function should be according to the following equation
where
When you add the following lines in your mdp file:
rlist = 1.0
coulombtype = User
rcoulomb = 1.0
vdwtype = User
rvdw = 1.0
mdrun will read a single non-bonded table file, or
multiple when energygrp-table
is set (see below). The
name of the file(s) can be set with the mdrun option
-table
. The table file should contain seven columns of
table look-up data in the order: table_extension
can be changed in the mdp file). You can
choose the spacing you like; for the standard tables GROMACS uses a
spacing of 0.002 and 0.0005 nm when you run in mixed and double
precision, respectively. In this context, rvdw
and rcoulomb
(see above). These
variables need not be the same (and need not be 1.0 either). Some
functions used for potentials contain a singularity at coulombtype = Cut-off
or
coulombtype = PME
, combined with vdwtype = User
. The table file must
always contain the 7 columns however, and meaningful data (i.e. not
zeroes) must be entered in all columns. A number of pre-built table
files can be found in the GMXLIB
directory for 6-8, 6-9, 6-10, 6-11, and
6-12 Lennard-Jones potentials combined with a normal Coulomb.
If you want to have different functional forms between different groups
of atoms, this can be set through energy groups. Different tables can be
used for non-bonded interactions between different energy groups pairs
through the mdp option energygrp-table
(see details in the User Guide).
Atoms that should interact with a different potential should be put into
different energy groups. Between group pairs which are not listed in
energygrp-table
, the normal user tables will be used. This makes it easy
to use a different functional form between a few types of atoms.