Add equation numbers in reference manual
[alexxy/gromacs.git] / docs / reference-manual / special / pulling.rst
1 Non-equilibrium pulling
2 -----------------------
3
4 When the distance between two groups is changed continuously, work is
5 applied to the system, which means that the system is no longer in
6 equilibrium. Although in the limit of very slow pulling the system is
7 again in equilibrium, for many systems this limit is not reachable
8 within reasonable computational time. However, one can use the Jarzynski
9 relation \ :ref:`135 <refJarzynski1997a>` to obtain the equilibrium free-energy difference
10 :math:`\Delta G` between two distances from many non-equilibrium
11 simulations:
12
13 .. math:: \Delta G_{AB} = -k_BT \log \left\langle e^{-\beta W_{AB}} \right\rangle_A
14           :label: eqJarz
15
16 where :math:`W_{AB}` is the work performed to force the system along
17 one path from state A to B, the angular bracket denotes averaging over a
18 canonical ensemble of the initial state A and :math:`\beta=1/k_B T`.
19
20 .. _pull:
21
22 The pull code
23 -------------
24
25 :ref:`pull` The pull code applies forces or constraints between the
26 centers of mass of one or more pairs of groups of atoms. Each pull
27 reaction coordinate is called a “coordinate” and it operates on usually
28 two, but sometimes more, pull groups. A pull group can be part of one or
29 more pull coordinates. Furthermore, a coordinate can also operate on a
30 single group and an absolute reference position in space. The distance
31 between a pair of groups can be determined in 1, 2 or 3 dimensions, or
32 can be along a user-defined vector. The reference distance can be
33 constant or can change linearly with time. Normally all atoms are
34 weighted by their mass, but an additional weighting factor can also be
35 used.
36
37 .. _fig-pull:
38
39 .. figure:: plots/pull.*
40    :width: 6.00000cm
41
42    Schematic picture of pulling a lipid out of a lipid bilayer with
43    umbrella pulling. :math:`V_{rup}` is the velocity at which the spring
44    is retracted, :math:`Z_{link}` is the atom to which the spring is
45    attached and :math:`Z_{spring}` is the location of the spring.
46
47 Several different pull types, i.e. ways to apply the pull force, are
48 supported, and in all cases the reference distance can be constant or
49 linearly changing with time.
50
51 #. **Umbrella pulling** A harmonic potential is applied between the
52    centers of mass of two groups. Thus, the force is proportional to the
53    displacement.
54
55 #. **Constraint pulling** The distance between the centers of mass of
56    two groups is constrained. The constraint force can be written to a
57    file. This method uses the SHAKE algorithm but only needs 1 iteration
58    to be exact if only two groups are constrained.
59
60 #. **Constant force pulling** A constant force is applied between the
61    centers of mass of two groups. Thus, the potential is linear. In this
62    case there is no reference distance of pull rate.
63
64 #. **Flat bottom pulling** Like umbrella pulling, but the potential and
65    force are zero for coordinate values below
66    (``pull-coord?-type = flat-bottom``) or above
67    (``pull-coord?-type = flat-bottom-high``) a reference
68    value. This is useful for restraining e.g. the distance between two
69    molecules to a certain region.
70
71 In addition, there are different types of reaction coordinates,
72 so-called pull geometries. These are set with the :ref:`mdp`
73 option ``pull-coord?-geometry``.
74
75 Definition of the center of mass
76 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
77
78 In |Gromacs|, there are three ways to define the center of mass of a
79 group. The standard way is a “plain” center of mass, possibly with
80 additional weighting factors. With periodic boundary conditions it is no
81 longer possible to uniquely define the center of mass of a group of
82 atoms. Therefore, a reference atom is used. For determining the center
83 of mass, for all other atoms in the group, the closest periodic image to
84 the reference atom is used. This uniquely defines the center of mass. By
85 default, the middle (determined by the order in the topology) atom is
86 used as a reference atom, but the user can also select any other atom if
87 it would be closer to center of the group.
88
89 When there are large pull groups, such as a
90 lipid bilayer, ``pull-pbc-ref-prev-step-com`` can be used to avoid potential
91 large movements of the center of mass in case that atoms in the pull group
92 move so much that the reference atom is too far from the intended center of mass.
93 With this option enabled the center of mass from the previous step is used,
94 instead of the position of the reference atom, to determine the reference position.
95 The position of the reference atom is still used for the first step. For large pull
96 groups it is important to select a reference atom that is close to the intended
97 center of mass, i.e. do not use ``pull-group?-pbcatom = 0``.
98
99 For a layered system, for instance a lipid bilayer, it may be of
100 interest to calculate the PMF of a lipid as function of its distance
101 from the whole bilayer. The whole bilayer can be taken as reference
102 group in that case, but it might also be of interest to define the
103 reaction coordinate for the PMF more locally. The :ref:`mdp`
104 option ``pull-coord?-geometry = cylinder`` does not use all
105 the atoms of the reference group, but instead dynamically only those
106 within a cylinder with radius ``pull-cylinder-r`` around the
107 pull vector going through the pull group. This only works for distances
108 defined in one dimension, and the cylinder is oriented with its long
109 axis along this one dimension. To avoid jumps in the pull force,
110 contributions of atoms are weighted as a function of distance (in
111 addition to the mass weighting):
112
113 .. math:: \begin{aligned}
114           w(r < r_\mathrm{cyl}) & = &
115           1-2 \left(\frac{r}{r_\mathrm{cyl}}\right)^2 + \left(\frac{r}{r_\mathrm{cyl}}\right)^4 \\
116           w(r \geq r_\mathrm{cyl}) & = & 0\end{aligned}
117           :label: eqnpulldistmassweight
118
119 Note that the radial dependence on the weight causes a radial force on
120 both cylinder group and the other pull group. This is an undesirable,
121 but unavoidable effect. To minimize this effect, the cylinder radius
122 should be chosen sufficiently large. The effective mass is 0.47 times
123 that of a cylinder with uniform weights and equal to the mass of uniform
124 cylinder of 0.79 times the radius.
125
126 .. _fig-pullref:
127
128 .. figure:: plots/pullref.*
129    :width: 6.00000cm
130
131    Comparison of a plain center of mass reference group versus a
132    cylinder reference group applied to interface systems. C is the
133    reference group. The circles represent the center of mass of two
134    groups plus the reference group, :math:`d_c` is the reference
135    distance.
136
137 For a group of molecules in a periodic system, a plain reference group
138 might not be well-defined. An example is a water slab that is connected
139 periodically in :math:`x` and :math:`y`, but has two liquid-vapor
140 interfaces along :math:`z`. In such a setup, water molecules can
141 evaporate from the liquid and they will move through the vapor, through
142 the periodic boundary, to the other interface. Such a system is
143 inherently periodic and there is no proper way of defining a “plain”
144 center of mass along :math:`z`. A proper solution is to using a cosine
145 shaped weighting profile for all atoms in the reference group. The
146 profile is a cosine with a single period in the unit cell. Its phase is
147 optimized to give the maximum sum of weights, including mass weighting.
148 This provides a unique and continuous reference position that is nearly
149 identical to the plain center of mass position in case all atoms are all
150 within a half of the unit-cell length. See ref :ref:`136 <refEngin2010a>`
151 for details.
152
153 When relative weights :math:`w_i` are used during the calculations,
154 either by supplying weights in the input or due to cylinder geometry or
155 due to cosine weighting, the weights need to be scaled to conserve
156 momentum:
157
158 .. math:: w'_i = w_i
159           \left. \sum_{j=1}^N w_j \, m_j \right/ \sum_{j=1}^N w_j^2 \, m_j
160           :label: eqnpullmassscale
161
162 where :math:`m_j` is the mass of atom :math:`j` of the group. The mass
163 of the group, required for calculating the constraint force, is:
164
165 .. math:: M = \sum_{i=1}^N w'_i \, m_i
166           :label: eqnpullconstraint
167
168 The definition of the weighted center of mass is:
169
170 .. math:: \mathbf{r}_{com} = \left. \sum_{i=1}^N w'_i \, m_i \, \mathbf{r}_i \right/ M
171           :label: eqnpullcom
172
173 From the centers of mass the AFM, constraint, or umbrella force
174 :math:`\mathbf{F}_{\!com}` on each group can be
175 calculated. The force on the center of mass of a group is redistributed
176 to the atoms as follows:
177
178 .. math:: \mathbf{F}_{\!i} = \frac{w'_i \, m_i}{M} \, \mathbf{F}_{\!com}
179           :label: eqnpullcomforce
180
181 Definition of the pull direction
182 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
183
184 The most common setup is to pull along the direction of the vector
185 containing the two pull groups, this is selected with
186 ``pull-coord?-geometry = distance``. You might want to pull
187 along a certain vector instead, which is selected with
188 ``pull-coord?-geometry = direction``. But this can cause
189 unwanted torque forces in the system, unless you pull against a
190 reference group with (nearly) fixed orientation, e.g. a membrane protein
191 embedded in a membrane along x/y while pulling along z. If your
192 reference group does not have a fixed orientation, you should probably
193 use ``pull-coord?-geometry = direction-relative``, see
194 :numref:`Fig. %s <fig-pulldirrel>`. Since the potential now depends
195 on the coordinates of two additional groups defining the orientation,
196 the torque forces will work on these two groups.
197
198 .. _fig-pulldirrel:
199
200 .. figure:: plots/pulldirrel.*
201    :width: 5.00000cm
202
203    The pull setup for geometry ``direction-relative``. The
204    “normal” pull groups are 1 and 2. Groups 3 and 4 define the pull
205    direction and thus the direction of the normal pull forces (red).
206    This leads to reaction forces (blue) on groups 3 and 4, which are
207    perpendicular to the pull direction. Their magnitude is given by the
208    “normal” pull force times the ratio of :math:`d_p` and the distance
209    between groups 3 and 4.
210
211 Definition of the angle and dihedral pull geometries
212 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
213
214 Four pull groups are required for ``pull-coord?-geometry =
215 angle``. In the same way as for geometries with two groups, each
216 consecutive pair of groups :math:`i` and :math:`i+1` define a vector
217 connecting the COMs of groups :math:`i` and :math:`i+1`. The angle is
218 defined as the angle between the two resulting vectors. E.g., the
219 :ref:`mdp` option ``pull-coord?-groups = 1 2 2 4``
220 defines the angle between the vector from the COM of group 1 to the COM
221 of group 2 and the vector from the COM of group 2 to the COM of group 4.
222 The angle takes values in the closed interval [0, 180] deg. For
223 ``pull-coord?-geometry = angle-axis`` the angle is defined
224 with respect to a reference axis given by
225 ``pull-coord?-vec`` and only two groups need to be given.
226 The dihedral geometry requires six pull groups. These pair up in the
227 same way as described above and so define three vectors. The dihedral
228 angle is defined as the angle between the two planes spanned by the two
229 first and the two last vectors. Equivalently, the dihedral angle can be
230 seen as the angle between the first and the third vector when these
231 vectors are projected onto a plane normal to the second vector (the axis
232 vector). As an example, consider a dihedral angle involving four groups:
233 1, 5, 8 and 9. Here, the :ref:`mdp` option
234 ``pull-coord?-groups = 8 1 1 5 5 9`` specifies the three
235 vectors that define the dihedral angle: the first vector is the COM
236 distance vector from group 8 to 1, the second vector is the COM distance
237 vector from group 1 to 5, and the third vector is the COM distance
238 vector from group 5 to 9. The dihedral angle takes values in the
239 interval (-180, 180] deg and has periodic boundaries.
240
241 Limitations
242 ^^^^^^^^^^^
243
244 There is one theoretical limitation: strictly speaking, constraint
245 forces can only be calculated between groups that are not connected by
246 constraints to the rest of the system. If a group contains part of a
247 molecule of which the bond lengths are constrained, the pull constraint
248 and LINCS or SHAKE bond constraint algorithms should be iterated
249 simultaneously. This is not done in |Gromacs|. This means that for
250 simulations with ``constraints = all-bonds`` in the :ref:`mdp` file pulling is,
251 strictly speaking, limited to whole molecules or groups of molecules. In
252 some cases this limitation can be avoided by using the free energy code,
253 see sec. :ref:`fepmf`. In practice, the errors caused by not iterating
254 the two constraint algorithms can be negligible when the pull group
255 consists of a large amount of atoms and/or the pull force is small. In
256 such cases, the constraint correction displacement of the pull group is
257 small compared to the bond lengths.