Split up analysis chapter in reference manual
[alexxy/gromacs.git] / docs / reference-manual / functions / long-range-vdw.rst
1 Long Range Van der Waals interactions
2 -------------------------------------
3
4 Dispersion correction
5 ~~~~~~~~~~~~~~~~~~~~~
6
7 In this section, we derive long-range corrections due to the use of a
8 cut-off for Lennard-Jones or Buckingham interactions. We assume that the
9 cut-off is so long that the repulsion term can safely be neglected, and
10 therefore only the dispersion term is taken into account. Due to the
11 nature of the dispersion interaction (we are truncating a potential
12 proportional to :math:`-r^{-6}`), energy and pressure corrections are
13 both negative. While the energy correction is usually small, it may be
14 important for free energy calculations where differences between two
15 different Hamiltonians are considered. In contrast, the pressure
16 correction is very large and can not be neglected under any
17 circumstances where a correct pressure is required, especially for any
18 NPT simulations. Although it is, in principle, possible to parameterize
19 a force field such that the pressure is close to the desired
20 experimental value without correction, such a method makes the
21 parameterization dependent on the cut-off and is therefore undesirable.
22
23 .. _ecorr:
24
25 Energy
26 ^^^^^^
27
28 The long-range contribution of the dispersion interaction to the virial
29 can be derived analytically, if we assume a homogeneous system beyond
30 the cut-off distance :math:`r_c`. The dispersion energy between two
31 particles is written as:
32
33 .. math:: V({r_{ij}}) ~=~- C_6\,{r_{ij}}^{-6}
34
35 and the corresponding force is:
36
37 .. math:: \mathbf{F}_ij ~=~- 6\,C_6\,r_{ij}^{-8}\mathbf{r}_ij
38
39 In a periodic system it is not easy to calculate the full potentials,
40 so usually a cut-off is applied, which can be abrupt or smooth. We will
41 call the potential and force with cut-off :math:`V_c` and
42 :math:`\mathbf{F}_c`. The long-range contribution to the
43 dispersion energy in a system with :math:`N` particles and particle
44 density :math:`\rho` = :math:`N/V` is:
45
46 .. math:: V_{lr} ~=~ {\frac{1}{2}}N \rho\int_0^{\infty}   4\pi r^2 g(r) \left( V(r) -V_c(r) \right) {{{\rm d}r}}
47           :label: eqnenercorr
48
49 We will integrate this for the shift function, which is the most
50 general form of van der Waals interaction available in |Gromacs|. The
51 shift function has a constant difference :math:`S` from 0 to :math:`r_1`
52 and is 0 beyond the cut-off distance :math:`r_c`. We can integrate
53 :eq:`eqn. %s <eqnenercorr>`, assuming that the density in the sphere within
54 :math:`r_1` is equal to the global density and the radial distribution
55 function :math:`g(r)` is 1 beyond :math:`r_1`:
56
57 .. math::
58
59    \begin{aligned}
60    \nonumber
61    V_{lr}  &=& {\frac{1}{2}}N \left(
62      \rho\int_0^{r_1}  4\pi r^2 g(r) \, C_6 \,S\,{{{\rm d}r}}
63    + \rho\int_{r_1}^{r_c}  4\pi r^2 \left( V(r) -V_c(r) \right) {{{\rm d}r}}
64    + \rho\int_{r_c}^{\infty}  4\pi r^2 V(r) \, {{{\rm d}r}}
65    \right) \\
66    & = & {\frac{1}{2}}N \left(\left(\frac{4}{3}\pi \rho r_1^{3} - 1\right) C_6 \,S
67    + \rho\int_{r_1}^{r_c} 4\pi r^2 \left( V(r) -V_c(r) \right) {{{\rm d}r}}
68    -\frac{4}{3} \pi N \rho\, C_6\,r_c^{-3}
69    \right)\end{aligned}
70
71 where the term :math:`-1` corrects for the self-interaction. For a
72 plain cut-off we only need to assume that :math:`g(r)` is 1 beyond
73 :math:`r_c` and the correction reduces to \ :ref:`108 <refAllen87>`:
74
75 .. math::
76
77    \begin{aligned}
78    V_{lr} & = & -\frac{2}{3} \pi N \rho\, C_6\,r_c^{-3}\end{aligned}
79
80 If we consider, for example, a box of pure water, simulated with a
81 cut-off of 0.9 nm and a density of 1 g cm\ :math:`^{-3}` this correction
82 is :math:`-0.75` kJ mol\ :math:`^{-1}` per molecule.
83
84 For a homogeneous mixture we need to define an *average dispersion constant*:
85
86 .. math:: {\left< C_6 \right>}= \frac{2}{N(N-1)}\sum_i^N\sum_{j>i}^N C_6(i,j)\\
87           :label: eqnavcsix
88
89 In |Gromacs|, excluded pairs of atoms do not contribute to the average.
90
91 In the case of inhomogeneous simulation systems, *e.g.* a system with a
92 lipid interface, the energy correction can be applied if
93 :math:`{\left< C_6 \right>}` for both components is comparable.
94
95 .. _virial:
96
97 Virial and pressure
98 ^^^^^^^^^^^^^^^^^^^
99
100 The scalar virial of the system due to the dispersion interaction
101 between two particles :math:`i` and :math:`j` is given by:
102
103 .. math:: \Xi~=~-{\frac{1}{2}} \mathbf{r}_ij \cdot \mathbf{F}_ij ~=~ 3\,C_6\,r_{ij}^{-6}
104
105 The pressure is given by:
106
107 .. math:: P~=~\frac{2}{3\,V}\left(E_{kin} - \Xi\right)
108
109 The long-range correction to the virial is given by:
110
111 .. math:: \Xi_{lr} ~=~ {\frac{1}{2}}N \rho \int_0^{\infty} 4\pi r^2 g(r) (\Xi -\Xi_c) \,{{\rm d}r}
112
113 We can again integrate the long-range contribution to the virial
114 assuming :math:`g(r)` is 1 beyond :math:`r_1`:
115
116 .. math::
117
118    \begin{aligned}
119    \Xi_{lr}&=&  {\frac{1}{2}}N \rho \left(
120        \int_{r_1}^{r_c}  4 \pi r^2 (\Xi -\Xi_c)  \,{{\rm d}r}+ \int_{r_c}^{\infty} 4 \pi r^2 3\,C_6\,{r_{ij}}^{-6}\,  {{\rm d}r}\right) \nonumber\\
121            &=&     {\frac{1}{2}}N \rho \left(
122        \int_{r_1}^{r_c} 4 \pi r^2 (\Xi -\Xi_c) \, {{\rm d}r}+ 4 \pi C_6 \, r_c^{-3} \right)\end{aligned}
123
124 For a plain cut-off the correction to the pressure
125 is \ :ref:`108 <refAllen87>`:
126
127 .. math:: P_{lr}~=~-\frac{4}{3} \pi C_6\, \rho^2 r_c^{-3}
128
129 Using the same example of a water box, the correction to the virial is
130 0.75 kJ mol\ :math:`^{-1}` per molecule, the corresponding correction to
131 the pressure for SPC water is approximately :math:`-280` bar.
132
133 For homogeneous mixtures, we can again use the average dispersion
134 constant :math:`{\left< C_6 \right>}` (:eq:`eqn. %s <eqnavcsix>`):
135
136 .. math:: P_{lr}~=~-\frac{4}{3} \pi {\left< C_6 \right>}\rho^2 r_c^{-3}
137           :label: eqnpcorr
138
139 For inhomogeneous systems, :eq:`eqn. %s <eqnpcorr>` can be applied under the
140 same restriction as holds for the energy (see sec. :ref:`ecorr`).
141
142 Lennard-Jones PME
143 ~~~~~~~~~~~~~~~~~
144
145 In order to treat systems, using Lennard-Jones potentials, that are
146 non-homogeneous outside of the cut-off distance, we can instead use the
147 Particle-mesh Ewald method as discussed for electrostatics above. In
148 this case the modified Ewald equations become
149
150 .. math:: \begin{aligned}
151           V &=& V_{\mathrm{dir}} + V_{\mathrm{rec}} + V_{0} \\[0.5ex]
152           V_{\mathrm{dir}} &=& -\frac{1}{2} \sum_{i,j}^{N}
153           \sum_{n_x}\sum_{n_y}
154           \sum_{n_{z}*} \frac{C^{ij}_6 g(\beta {r}_{ij,{\bf n}})}{{r_{ij,{\bf n}}}^6}
155           \end{aligned}
156           :label: eqnljpmerealspace
157
158 .. math::
159    \begin{aligned} 
160    V_{\mathrm{rec}} &=& \frac{{\pi}^{\frac{3}{2}} \beta^{3}}{2V} \sum_{m_x}\sum_{m_y}\sum_{m_{z}*}
161    f(\pi |{\mathbf m}|/\beta) \times \sum_{i,j}^{N} C^{ij}_6 {\mathrm{exp}}\left[-2\pi i {\bf m}\cdot({\bf r_i}-{\bf r_j})\right] \\[0.5ex]
162    V_{0} &=& -\frac{\beta^{6}}{12}\sum_{i}^{N} C^{ii}_6\end{aligned}
163
164 where :math:`{\bf m}=(m_x,m_y,m_z)`, :math:`\beta` is the parameter
165 determining the weight between direct and reciprocal space, and
166 :math:`{C^{ij}_6}` is the combined dispersion parameter for particle
167 :math:`i` and :math:`j`. The star indicates that terms with
168 :math:`i = j` should be omitted when :math:`((n_x,n_y,n_z)=(0,0,0))`,
169 and :math:`{\bf r}_{ij,{\bf n}}` is the real distance between the
170 particles. Following the derivation by
171 Essmann \ :ref:`15 <refEssmann95>`, the functions :math:`f` and :math:`g`
172 introduced above are defined as
173
174 .. math::
175
176    \begin{aligned}
177    f(x)&=&1/3\left[(1-2x^2){\mathrm{exp}}(-x^2) + 2{x^3}\sqrt{\pi}\,{\mathrm{erfc}}(x) \right] \\
178    g(x)&=&{\mathrm{exp}}(-x^2)(1+x^2+\frac{x^4}{2}).\end{aligned}
179
180 The above methodology works fine as long as the dispersion parameters
181 can be combined geometrically (:eq:`eqn. %s <eqncomb>`) in the same way as the
182 charges for electrostatics
183
184 .. math:: C^{ij}_{6,\mathrm{geom}} = \left(C^{ii}_6 \, C^{jj}_6\right)^{1/2}
185
186 For Lorentz-Berthelot combination rules (:eq:`eqn. %s <eqnlorentzberthelot>`),
187 the reciprocal part of this sum has to be calculated seven times due to
188 the splitting of the dispersion parameter according to
189
190 .. math:: C^{ij}_{6,\mathrm{L-B}} = (\sigma_i+\sigma_j)^6=\sum_{n=0}^{6} P_{n}\sigma_{i}^{n}\sigma_{j}^{(6-n)},
191
192 for :math:`P_{n}` the Pascal triangle coefficients. This introduces a
193 non-negligible cost to the reciprocal part, requiring seven separate
194 FFTs, and therefore this has been the limiting factor in previous
195 attempts to implement LJ-PME. A solution to this problem is to use
196 geometrical combination rules in order to calculate an approximate
197 interaction parameter for the reciprocal part of the potential, yielding
198 a total interaction of
199
200 .. math::
201
202    \begin{aligned}
203    V(r<r_c) & = & \underbrace{C^{\mathrm{dir}}_6 g(\beta r) r^{-6}}_{\mathrm{Direct \  space}} + \underbrace{C^\mathrm{recip}_{6,\mathrm{geom}} [1 - g(\beta r)] r^{-6}}_{\mathrm{Reciprocal \  space}} \nonumber \\
204    &=& C^\mathrm{recip}_{6,\mathrm{geom}}r^{-6} + \left(C^{\mathrm{dir}}_6-C^\mathrm{recip}_{6,\mathrm{geom}}\right)g(\beta r)r^{-6} \\
205    V(r>r_c) & = & \underbrace{C^\mathrm{recip}_{6,\mathrm{geom}} [1 - g(\beta r)] r^{-6}}_{\mathrm{Reciprocal \  space}}.\end{aligned}
206
207 This will preserve a well-defined Hamiltonian and significantly
208 increase the performance of the simulations. The approximation does
209 introduce some errors, but since the difference is located in the
210 interactions calculated in reciprocal space, the effect will be very
211 small compared to the total interaction energy. In a simulation of a
212 lipid bilayer, using a cut-off of 1.0 nm, the relative error in total
213 dispersion energy was below 0.5%. A more thorough discussion of this can
214 be found in :ref:`109 <refWennberg13>`.
215
216 In |Gromacs| we now perform the proper calculation of this interaction by
217 subtracting, from the direct-space interactions, the contribution made
218 by the approximate potential that is used in the reciprocal part
219
220 .. math:: V_\mathrm{dir} = C^{\mathrm{dir}}_6 r^{-6} - C^\mathrm{recip}_6 [1 - g(\beta r)] r^{-6}.
221           :label: eqnljpmedirectspace
222
223 This potential will reduce to the expression in
224 :eq:`eqn. %s <eqnljpmerealspace>` when
225 :math:`C^{\mathrm{dir}}_6 = C^\mathrm{recip}_6`, and the total
226 interaction is given by
227
228 .. math:: \begin{aligned}
229           \nonumber V(r<r_c) &=& \underbrace{C^{\mathrm{dir}}_6 r^{-6} - C^\mathrm{recip}_6 [1 - g(\beta r)] r^{-6}}_{\mathrm{Direct \  space}} + \underbrace{C^\mathrm{recip}_6 [1 - g(\beta r)] r^{-6}}_{\mathrm{Reciprocal \  space}} \\ 
230           &=&C^{\mathrm{dir}}_6 r^{-6}
231           \end{aligned}
232           :label: eqnljpmecorr2
233
234 .. math::
235
236    \begin{aligned} 
237    V(r>r_c) &=& C^\mathrm{recip}_6 [1 - g(\beta r)] r^{-6}.\end{aligned}
238
239 For the case when :math:`C^{\mathrm{dir}}_6 \neq C^\mathrm{recip}_6`
240 this will retain an unmodified LJ force up to the cut-off, and the error
241 is an order of magnitude smaller than in simulations where the
242 direct-space interactions do not account for the approximation used in
243 reciprocal space. When using a VdW interaction modifier of
244 potential-shift, the constant
245
246 .. math:: \left(-C^{\mathrm{dir}}_6 + C^\mathrm{recip}_6 [1 - g(\beta r_c)]\right) r_c^{-6}
247
248 is added to :eq:`eqn. %s <eqnljpmecorr2>` in order to ensure that the potential
249 is continuous at the cutoff. Note that, in the same way as
250 :eq:`eqn. %s <eqnljpmedirectspace>`, this degenerates into the expected
251 :math:`-C_6g(\beta r_c)r^{-6}_c` when :math:`C^{\mathrm{dir}}_6 =
252 C^\mathrm{recip}_6`. In addition to this, a long-range dispersion
253 correction can be applied to correct for the approximation using a
254 combination rule in reciprocal space. This correction assumes, as for
255 the cut-off LJ potential, a uniform particle distribution. But since the
256 error of the combination rule approximation is very small this
257 long-range correction is not necessary in most cases. Also note that
258 this homogenous correction does not correct the surface tension, which
259 is an inhomogeneous property.
260
261 Using LJ-PME
262 ^^^^^^^^^^^^
263
264 As an example for using Particle-mesh Ewald summation for Lennard-Jones
265 interactions in |Gromacs|, specify the following lines in your :ref:`mdp` file:
266
267 ::
268
269     vdwtype          = PME
270     rvdw             = 0.9
271     vdw-modifier     = Potential-Shift
272     rlist            = 0.9
273     rcoulomb         = 0.9
274     fourierspacing   = 0.12
275     pme-order        = 4
276     ewald-rtol-lj    = 0.001
277     lj-pme-comb-rule = geometric
278
279 The same Fourier grid and interpolation order are used if both LJ-PME
280 and electrostatic PME are active, so the settings for
281 ``fourierspacing`` and ``pme-order`` are common
282 to both. ``ewald-rtol-lj`` controls the splitting between
283 direct and reciprocal space in the same way as
284 ``ewald-rtol``. In addition to this, the combination rule to
285 be used in reciprocal space is determined by
286 ``lj-pme-comb-rule``. If the current force field uses
287 Lorentz-Berthelot combination rules, it is possible to set
288 ``lj-pme-comb-rule = geometric`` in order to gain a
289 significant increase in performance for a small loss in accuracy. The
290 details of this approximation can be found in the section above.
291
292 Note that the use of a complete long-range dispersion correction means
293 that as with Coulomb PME, ``rvdw`` is now a free parameter
294 in the method, rather than being necessarily restricted by the
295 force-field parameterization scheme. Thus it is now possible to optimize
296 the cutoff, spacing, order and tolerance terms for accuracy and best
297 performance.
298
299 Naturally, the use of LJ-PME rather than LJ cut-off adds computation and
300 communication done for the reciprocal-space part, so for best
301 performance in balancing the load of parallel simulations using PME-only
302 ranks, more such ranks should be used. It may be possible to improve
303 upon the automatic load-balancing used by :ref:`mdrun <gmx mdrun>`.