c6b219b4e581a8a8f2a16c493f2cec068778ac8a
[alexxy/gromacs.git] / docs / reference-manual / functions / interaction-methods.rst
1 Methods
2 -------
3
4 Exclusions and 1-4 Interactions.
5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6
7 Atoms within a molecule that are close by in the chain, *i.e.* atoms
8 that are covalently bonded, or linked by one or two atoms are called
9 *first neighbors, second neighbors* and *third neighbors*, respectively
10 (see :numref:`Fig. %s <fig-chain>`). Since the interactions of atom **i** with atoms
11 **i+1** and **i+2** are mainly quantum mechanical, they can not be
12 modeled by a Lennard-Jones potential. Instead it is assumed that these
13 interactions are adequately modeled by a harmonic bond term or
14 constraint (**i, i+1**) and a harmonic angle term (**i, i+2**). The
15 first and second neighbors (atoms **i+1** and **i+2**) are therefore
16 *excluded* from the Lennard-Jones interaction list of atom **i**; atoms
17 **i+1** and **i+2** are called *exclusions* of atom **i**.
18
19 .. _fig-chain:
20
21 .. figure:: plots/chain.*
22    :width: 8.00000cm
23
24    Atoms along an alkane chain.
25
26 For third neighbors, the normal Lennard-Jones repulsion is sometimes
27 still too strong, which means that when applied to a molecule, the
28 molecule would deform or break due to the internal strain. This is
29 especially the case for carbon-carbon interactions in a
30 *cis*-conformation (*e.g.* *cis*-butane). Therefore, for some of these
31 interactions, the Lennard-Jones repulsion has been reduced in the GROMOS
32 force field, which is implemented by keeping a separate list of 1-4 and
33 normal Lennard-Jones parameters. In other force fields, such as
34 OPLS \ :ref:`103 <refJorgensen88>`, the standard Lennard-Jones
35 parameters are reduced by a factor of two, but in that case also the
36 dispersion (r:math:`^{-6}`) and the Coulomb interaction are scaled.
37 |Gromacs| can use either of these methods.
38
39 Charge Groups
40 ~~~~~~~~~~~~~
41
42 In principle, the force calculation in MD is an :math:`O(N^2)` problem.
43 Therefore, we apply a cut-off for non-bonded force (NBF) calculations;
44 only the particles within a certain distance of each other are
45 interacting. This reduces the cost to :math:`O(N)` (typically
46 :math:`100N` to :math:`200N`) of the NBF. It also introduces an error,
47 which is, in most cases, acceptable, except when applying the cut-off
48 implies the creation of charges, in which case you should consider using
49 the lattice sum methods provided by |Gromacs|.
50
51 Consider a water molecule interacting with another atom. If we would
52 apply a plain cut-off on an atom-atom basis we might include the
53 atom-oxygen interaction (with a charge of :math:`-0.82`) without the
54 compensating charge of the protons, and as a result, induce a large
55 dipole moment over the system. Therefore, we have to keep groups of
56 atoms with total charge 0 together. These groups are called *charge
57 groups*. Note that with a proper treatment of long-range electrostatics
58 (e.g. particle-mesh Ewald (sec. :ref:`pme`), keeping charge groups
59 together is not required.
60
61 Treatment of Cut-offs in the group scheme
62 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63
64 |Gromacs| is quite flexible in treating cut-offs, which implies there can
65 be quite a number of parameters to set. These parameters are set in the
66 input file for grompp. There are two sort of parameters that affect the
67 cut-off interactions; you can select which type of interaction to use in
68 each case, and which cut-offs should be used in the neighbor searching.
69
70 For both Coulomb and van der Waals interactions there are interaction
71 type selectors (termed vdwtype and coulombtype) and two parameters, for
72 a total of six non-bonded interaction parameters. See the User Guide for
73 a complete description of these parameters.
74
75 In the group cut-off scheme, all of the interaction functions in
76 :numref:`Table %s <tab-funcparm>` require that neighbor searching be done with a
77 radius at least as large as the :math:`r_c` specified for the functional
78 form, because of the use of charge groups. The extra radius is typically
79 of the order of 0.25 nm (roughly the largest distance between two atoms
80 in a charge group plus the distance a charge group can diffuse within
81 neighbor list updates).
82
83 .. |CPCOP| replace:: :math:`r_c`, :math:`{\varepsilon}_{r}`
84 .. |CRFP|  replace:: :math:`r_c`, :math:`{\varepsilon}_{rf}`
85 .. |CSHFP| replace:: :math:`r_1`, :math:`r_c`, :math:`{\varepsilon}_{r}`
86 .. |CSWFP| replace:: :math:`r_1`, :math:`r_c`, :math:`{\varepsilon}_{r}`
87 .. |VPCOP| replace:: :math:`r_c`
88 .. |VSHFP| replace:: :math:`r_1`, :math:`r_c`
89 .. |VSWFP| replace:: :math:`r_1`, :math:`r_c`
90
91 .. _tab-funcparm:
92
93 .. table:: Parameters for the different functional forms of the
94            non-bonded interactions.
95
96            +----------------------------+------------+
97            | Type                       | Parameters |
98            +=========+==================+============+
99            | Coulomb | Plain cut-off    | |CPCOP|    |
100            |         +------------------+------------+
101            |         | Reaction field   | |CRFP|     |
102            |         +------------------+------------+
103            |         | Shift function   | |CSHFP|    |
104            |         +------------------+------------+ 
105            |         | Switch function  | |CSWFP|    | 
106            +---------+------------------+------------+
107            | VdW     | Plain cut-off    | |VPCOP|    |
108            |         +------------------+------------+ 
109            |         | Shift function   | |VSHFP|    |
110            |         +------------------+------------+ 
111            |         | Switch function  | |VSWFP|    | 
112            +---------+------------------+------------+
113
114 .. _virtualsites:
115
116 Virtual interaction sites
117 -------------------------
118
119 Virtual interaction sites (called dummy atoms in
120 |Gromacs| versions before 3.3) can be used in |Gromacs| in a number of ways.
121 We write the position of the virtual site :math:`\mathbf{r}_s` as a function
122 of the positions of other particles
123 :math:`\mathbf{r}`\ :math:`_i`: :math:`\mathbf{r}_s =
124 f(\mathbf{r}_1..\mathbf{r}_n)`. The virtual site, which may carry charge or be
125 involved in other interactions, can now be used in the force
126 calculation. The force acting on the virtual site must be redistributed
127 over the particles with mass in a consistent way. A good way to do this
128 can be found in ref. \ :ref:`104 <refBerendsen84b>`. We can write the
129 potential energy as:
130
131 .. math:: V = V(\mathbf{r}_s,\mathbf{r}_1,\ldots,\mathbf{r}_n) = V^*(\mathbf{r}_1,\ldots,\mathbf{r}_n)
132           :label: eqnvsiteepot
133
134 The force on the particle :math:`i` is then:
135
136 .. math:: \mathbf{F}_i = -\frac{\partial V^*}{\partial \mathbf{r}_i} 
137           = -\frac{\partial V}{\partial \mathbf{r}_i} - 
138              \frac{\partial V}{\partial \mathbf{r}_s} 
139              \frac{\partial \mathbf{r}_s}{\partial \mathbf{r}_i}
140           = \mathbf{F}_i^{direct} + \mathbf{F}_i
141           :label: eqnvsiteforce
142
143 The first term is the normal force. The second term is the force on
144 particle :math:`i` due to the virtual site, which can be written in
145 tensor notation:
146
147 .. math::  \mathbf{F}_i = \left[\begin{array}{ccc}
148            {\displaystyle\frac{\partial x_s}{\partial x_i}} & {\displaystyle\frac{\partial y_s}{\partial x_i}} & {\displaystyle\frac{\partial z_s}{\partial x_i}} \\[1ex]
149            {\displaystyle\frac{\partial x_s}{\partial y_i}} & {\displaystyle\frac{\partial y_s}{\partial y_i}} & {\displaystyle\frac{\partial z_s}{\partial y_i}} \\[1ex]
150            {\displaystyle\frac{\partial x_s}{\partial z_i}} & {\displaystyle\frac{\partial y_s}{\partial z_i}} & {\displaystyle\frac{\partial z_s}{\partial z_i}} \end{array}\right]\mathbf{F}_{s}
151            :label: eqnfvsite
152
153 where :math:`\mathbf{F}_{s}` is the force on the virtual site and
154 :math:`x_s`, :math:`y_s` and :math:`z_s` are the coordinates of the
155 virtual site. In this way, the total force and the total torque are
156 conserved \ :ref:`104 <refBerendsen84b>`.
157
158 The computation of the virial (:eq:`eqn. %s <eqnXi>`) is non-trivial when
159 virtual sites are used. Since the virial involves a summation over all
160 the atoms (rather than virtual sites), the forces must be redistributed
161 from the virtual sites to the atoms (using  :eq:`eqn. %s <eqnfvsite>`) *before*
162 computation of the virial. In some special cases where the forces on the
163 atoms can be written as a linear combination of the forces on the
164 virtual sites (types 2 and 3 below) there is no difference between
165 computing the virial before and after the redistribution of forces.
166 However, in the general case redistribution should be done first.
167
168 .. _fig-vsites:
169
170 .. figure:: plots/dummies.*
171    :width: 15.00000cm
172
173    The seven different types of virtual site construction. The
174    constructing atoms are shown as black circles, the virtual sites in
175    gray.
176
177 There are six ways to construct virtual sites from surrounding atoms in
178 |Gromacs|, which we classify by the number of constructing atoms. **Note**
179 that all site types mentioned can be constructed from types 3fd
180 (normalized, in-plane) and 3out (non-normalized, out of plane). However,
181 the amount of computation involved increases sharply along this list, so
182 we strongly recommended using the first adequate virtual site type that
183 will be sufficient for a certain purpose. :numref:`Fig. %s <fig-vsites>` depicts 6 of
184 the available virtual site constructions. The conceptually simplest
185 construction types are linear combinations:
186
187 .. math:: \mathbf{r}_s = \sum_{i=1}^N w_i \, \mathbf{r}_i
188           :label: eqnvsitelincomb
189
190 The force is then redistributed using the same weights:
191
192 .. math:: \mathbf{F}_i = w_i \, \mathbf{F}_{s}
193           :label: eqnvsitelincombforce
194
195 The types of virtual sites supported in |Gromacs| are given in the list
196 below. Constructing atoms in virtual sites can be virtual sites
197 themselves, but only if they are higher in the list, i.e. virtual sites
198 can be constructed from “particles” that are simpler virtual sites.
199
200 -  As a linear combination of two atoms
201    (:numref:`Fig. %s <fig-vsites>` 2):
202
203    .. math:: w_i = 1 - a ~,~~ w_j = a
204              :label: eqnvsitelin2atom
205
206 -  In this case the virtual site is on the line through atoms :math:`i`
207    and :math:`j`.
208
209 -  On the line through two atoms, with a fixed distance
210    (:numref:`Fig. %s <fig-vsites>` 2fd):
211
212    .. math:: \mathbf{r}_s ~=~ \mathbf{r}_i + a \frac{ \mathbf{r}_{ij} }
213                                                   { | \mathbf{r}_{ij} | }
214              :label: eqnvsite2fdatom
215
216 -  In this case the virtual site is on the line through the other two
217    particles at a distance of :math:`|a|` from :math:`i`. The force on
218    particles :math:`i` and :math:`j` due to the force on the virtual site
219    can be computed as:
220
221    .. math:: \begin{array}{lcr}
222                      \mathbf{F}_i &=& \displaystyle \mathbf{F}_{s} - \gamma ( \mathbf{F}_{is} - \mathbf{p} ) \\[1ex]
223                      \mathbf{F}_j &=& \displaystyle \gamma (\mathbf{F}_{s} - \mathbf{p})      \\[1ex]
224                      \end{array}
225                      ~\mbox{ where }~
226                      \begin{array}{c}
227              \displaystyle \gamma = \frac{a}{ | \mathbf{r}_{ij} | } \\[2ex]
228              \displaystyle \mathbf{p} = \frac{ \mathbf{r}_{is} \cdot \mathbf{F}_{s} }
229                                    { \mathbf{r}_{is} \cdot \mathbf{r}_{is} } \mathbf{r}_{is}
230              \end{array}
231              :label: eqnvsite2fdforce
232
233 -  As a linear combination of three atoms
234    (:numref:`Fig. %s <fig-vsites>` 3):
235
236    .. math:: w_i = 1 - a - b ~,~~ w_j = a ~,~~ w_k = b
237              :label: eqnvsitelin3atom
238
239 -  In this case the virtual site is in the plane of the other three
240    particles.
241
242 -  In the plane of three atoms, with a fixed distance
243    (:numref:`Fig. %s <fig-vsites>` 3fd):
244
245    .. math:: \mathbf{r}_s ~=~ \mathbf{r}_i + b \frac{  (1 - a) \mathbf{r}_{ij} + a \mathbf{r}_{jk}  }
246                                                   { | (1 - a) \mathbf{r}_{ij} + a \mathbf{r}_{jk} | }
247              :label: eqnvsiteplane3atom
248
249 -  In this case the virtual site is in the plane of the other three
250    particles at a distance of :math:`|b|` from :math:`i`. The force on
251    particles :math:`i`, :math:`j` and :math:`k` due to the force on the
252    virtual site can be computed as:
253
254    .. math:: \begin{array}{lcr}
255                      \mathbf{F}_i &=& \displaystyle \mathbf{F}_{s} - \gamma ( \mathbf{F}_{is} - \mathbf{p} ) \\[1ex]
256                      \mathbf{F}_j &=& \displaystyle (1-a)\gamma (\mathbf{F}_{s} - \mathbf{p})      \\[1ex]
257                      \mathbf{F}_k &=& \displaystyle a \gamma (\mathbf{F}_{s} - \mathbf{p})         \\
258                      \end{array}
259                      ~\mbox{ where }~
260                      \begin{array}{c}
261              \displaystyle \gamma = \frac{b}{ | \mathbf{r}_{ij} + a \mathbf{r}_{jk} | } \\[2ex]
262              \displaystyle \mathbf{p} = \frac{ \mathbf{r}_{is} \cdot \mathbf{F}_{s} }
263                                    { \mathbf{r}_{is} \cdot \mathbf{r}_{is} } \mathbf{r}_{is}
264              \end{array}
265              :label: eqnvsiteplane3atomforce
266
267 -  In the plane of three atoms, with a fixed angle and
268    distance (:numref:`Fig. %s <fig-vsites>` 3fad):
269
270    .. math:: \mathbf{r}_s ~=~ \mathbf{r}_i +
271              d \cos \theta \frac{\mathbf{r}_{ij}}{ | \mathbf{r}_{ij} | } +
272              d \sin \theta \frac{\mathbf{r}_\perp}{ | \mathbf{r}_\perp | }
273              ~\mbox{ where }~
274              \mathbf{r}_\perp ~=~ \mathbf{r}_{jk} - 
275              \frac{ \mathbf{r}_{ij} \cdot \mathbf{r}_{jk} }
276              { \mathbf{r}_{ij} \cdot \mathbf{r}_{ij} }
277              \mathbf{r}_{ij}
278              :label: eqnvsite2fadF
279
280 -  In this case the virtual site is in the plane of the other three
281    particles at a distance of :math:`|d|` from :math:`i` at an angle of
282    :math:`\alpha` with :math:`\mathbf{r}_{ij}`. Atom
283    :math:`k` defines the plane and the direction of the angle. **Note**
284    that in this case :math:`b` and :math:`\alpha` must be specified,
285    instead of :math:`a` and :math:`b` (see also sec. :ref:`vsitetop`).
286    The force on particles :math:`i`, :math:`j` and :math:`k` due to the
287    force on the virtual site can be computed as (with
288    :math:`\mathbf{r}_\perp` as defined in
289    :eq:`eqn. %s <eqnvsite2fadF>`):
290
291    .. math:: \begin{array}{c}
292                      \begin{array}{lclllll}
293                      \mathbf{F}_i &=& \mathbf{F}_{s} &-& 
294                              \dfrac{d \cos \theta}{ | \mathbf{r}_{ij} | } \mathbf{F}_1 &+&
295                              \dfrac{d \sin \theta}{ | \mathbf{r}_\perp | } \left( 
296                              \dfrac{ \mathbf{r}_{ij} \cdot \mathbf{r}_{jk} }
297                                   { \mathbf{r}_{ij} \cdot \mathbf{r}_{ij} } \mathbf{F}_2     +
298                              \mathbf{F}_3 \right)                                \\[3ex]
299                      \mathbf{F}_j &=& &&
300                              \dfrac{d \cos \theta}{ | \mathbf{r}_{ij} | } \mathbf{F}_1 &-&
301                              \dfrac{d \sin \theta}{ | \mathbf{r}_\perp | } \left(
302                               \mathbf{F}_2 + 
303                               \dfrac{ \mathbf{r}_{ij} \cdot \mathbf{r}_{jk} }
304                                      { \mathbf{r}_{ij} \cdot \mathbf{r}_{ij} } \mathbf{F}_2 +
305                              \mathbf{F}_3 \right)                                \\[3ex]
306                      \mathbf{F}_k &=& && &&
307                              \dfrac{d \sin \theta}{ | \mathbf{r}_\perp | } \mathbf{F}_2  \\[3ex]
308                      \end{array}                                             \\[5ex]
309                      ~\mbox{where }~
310                      \mathbf{F}_1 = \mathbf{F}_{s} -
311                                \dfrac{ \mathbf{r}_{ij} \cdot \mathbf{F}_{s} }
312                                      { \mathbf{r}_{ij} \cdot \mathbf{r}_{ij} } \mathbf{r}_{ij}
313                      ~\mbox{, }~
314                      \mathbf{F}_2 = \mathbf{F}_1 -
315                                \dfrac{ \mathbf{r}_\perp \cdot \mathbf{F}_{s} }
316                                      { \mathbf{r}_\perp \cdot \mathbf{r}_\perp } \mathbf{r}_\perp
317                      ~\mbox{and }~
318                      \mathbf{F}_3 = \dfrac{ \mathbf{r}_{ij} \cdot \mathbf{F}_{s} }
319                                       { \mathbf{r}_{ij} \cdot \mathbf{r}_{ij} } \mathbf{r}_\perp
320              \end{array}
321              :label: eqnvsite2fadFforce
322
323 -  As a non-linear combination of three atoms, out of
324    plane (:numref:`Fig. %s <fig-vsites>` 3out):
325
326    .. math:: \mathbf{r}_s ~=~ \mathbf{r}_i + a \mathbf{r}_{ij} + b \mathbf{r}_{ik} +
327                               c (\mathbf{r}_{ij} \times \mathbf{r}_{ik})
328              :label: eqnvsitenonlin3atom
329
330 -  This enables the construction of virtual sites out of the plane of
331    the other atoms. The force on particles :math:`i,j` and :math:`k` due
332    to the force on the virtual site can be computed as:
333
334    .. math:: \begin{array}{lcl}
335              \mathbf{F}_j &=& \left[\begin{array}{ccc}
336               a              &  -c\,z_{ik}   & c\,y_{ik}     \\[0.5ex]
337               c\,z_{ik}      &   a           & -c\,x_{ik}    \\[0.5ex]
338              -c\,y_{ik}      &   c\,x_{ik}   & a
339              \end{array}\right]\mathbf{F}_{s}                                 \\
340              \mathbf{F}_k &=& \left[\begin{array}{ccc}
341               b              &   c\,z_{ij}   & -c\,y_{ij}    \\[0.5ex]
342              -c\,z_{ij}      &   b           & c\,x_{ij}     \\[0.5ex]
343               c\,y_{ij}      &  -c\,x_{ij}   & b
344              \end{array}\right]\mathbf{F}_{s}                                 \\
345              \mathbf{F}_i &=& \mathbf{F}_{s} - \mathbf{F}_j - \mathbf{F}_k
346              \end{array}
347              :label: eqnvsitenonlin3atomforce
348
349 -  From four atoms, with a fixed distance, see
350    separate :numref:`Fig. %s <fig-vsite4fdn>`. This construction is a bit complex,
351    in particular since the previous type (4fd) could be unstable which
352    forced us to introduce a more elaborate construction:
353
354 .. _fig-vsite4fdn:
355
356 .. figure:: plots/vsite-4fdn.*
357       :width: 5.00000cm
358
359       The new 4fdn virtual site construction, which is stable even when
360       all constructing atoms are in the same plane.
361
362 -
363       .. math::   \begin{aligned}
364                   \mathbf{r}_{ja} &=& a\, \mathbf{r}_{ik} - \mathbf{r}_{ij} = a\, (\mathbf{x}_k - \mathbf{x}_i) - (\mathbf{x}_j - \mathbf{x}_i) \nonumber \\
365                   \mathbf{r}_{jb} &=& b\, \mathbf{r}_{il} - \mathbf{r}_{ij} = b\, (\mathbf{x}_l - \mathbf{x}_i) - (\mathbf{x}_j - \mathbf{x}_i) \nonumber \\
366                   \mathbf{r}_m &=& \mathbf{r}_{ja} \times \mathbf{r}_{jb} \nonumber \\
367                   \mathbf{x}_s &=& \mathbf{x}_i + c \frac{\mathbf{r}_m}{ | \mathbf{r}_m | }
368                   \end{aligned}
369                   :label: eqnvsite
370
371 -  In this case the virtual site is at a distance of :math:`|c|` from
372    :math:`i`, while :math:`a` and :math:`b` are parameters. **Note**
373    that the vectors :math:`\mathbf{r}_{ik}` and :math:`\mathbf{r}_{ij}`
374    are not normalized to save floating-point operations. The force on
375    particles :math:`i`, :math:`j`, :math:`k` and :math:`l` due to the
376    force on the virtual site are computed through chain rule derivatives
377    of the construction expression. This is exact and conserves energy,
378    but it does lead to relatively lengthy expressions that we do not
379    include here (over 200 floating-point operations). The interested
380    reader can look at the source code in ``vsite.c``. Fortunately, this
381    vsite type is normally only used for chiral centers such as
382    :math:`C_{\alpha}` atoms in proteins.
383
384    The new 4fdn construct is identified with a ‘type’ value of 2 in the
385    topology. The earlier 4fd type is still supported internally (‘type’
386    value 1), but it should not be used for new simulations. All current
387    |Gromacs| tools will automatically generate type 4fdn instead.
388
389 -  A linear combination of :math:`N` atoms with relative
390    weights :math:`a_i`. The weight for atom :math:`i` is:
391
392    .. math:: w_i = a_i \left(\sum_{j=1}^N a_j \right)^{-1}
393              :label: eqnvsiterelweight
394
395 -   There are three options for setting the weights:
396
397    -  center of geometry: equal weights
398
399    -  center of mass: :math:`a_i` is the mass of atom :math:`i`; when in
400       free-energy simulations the mass of the atom is changed, only the
401       mass of the A-state is used for the weight
402
403    -  center of weights: :math:`a_i` is defined by the user
404