Split up analysis chapter in reference manual
[alexxy/gromacs.git] / docs / reference-manual / 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 For a layered system, for instance a lipid bilayer, it may be of
90 interest to calculate the PMF of a lipid as function of its distance
91 from the whole bilayer. The whole bilayer can be taken as reference
92 group in that case, but it might also be of interest to define the
93 reaction coordinate for the PMF more locally. The :ref:`mdp`
94 option ``pull-coord?-geometry = cylinder`` does not use all
95 the atoms of the reference group, but instead dynamically only those
96 within a cylinder with radius ``pull-cylinder-r`` around the
97 pull vector going through the pull group. This only works for distances
98 defined in one dimension, and the cylinder is oriented with its long
99 axis along this one dimension. To avoid jumps in the pull force,
100 contributions of atoms are weighted as a function of distance (in
101 addition to the mass weighting):
102
103 .. math::
104
105    \begin{aligned}
106    w(r < r_\mathrm{cyl}) & = &
107    1-2 \left(\frac{r}{r_\mathrm{cyl}}\right)^2 + \left(\frac{r}{r_\mathrm{cyl}}\right)^4 \\
108    w(r \geq r_\mathrm{cyl}) & = & 0\end{aligned}
109
110 Note that the radial dependence on the weight causes a radial force on
111 both cylinder group and the other pull group. This is an undesirable,
112 but unavoidable effect. To minimize this effect, the cylinder radius
113 should be chosen sufficiently large. The effective mass is 0.47 times
114 that of a cylinder with uniform weights and equal to the mass of uniform
115 cylinder of 0.79 times the radius.
116
117 .. _fig-pullref:
118
119 .. figure:: plots/pullref.*
120    :width: 6.00000cm
121
122    Comparison of a plain center of mass reference group versus a
123    cylinder reference group applied to interface systems. C is the
124    reference group. The circles represent the center of mass of two
125    groups plus the reference group, :math:`d_c` is the reference
126    distance.
127
128 For a group of molecules in a periodic system, a plain reference group
129 might not be well-defined. An example is a water slab that is connected
130 periodically in :math:`x` and :math:`y`, but has two liquid-vapor
131 interfaces along :math:`z`. In such a setup, water molecules can
132 evaporate from the liquid and they will move through the vapor, through
133 the periodic boundary, to the other interface. Such a system is
134 inherently periodic and there is no proper way of defining a “plain”
135 center of mass along :math:`z`. A proper solution is to using a cosine
136 shaped weighting profile for all atoms in the reference group. The
137 profile is a cosine with a single period in the unit cell. Its phase is
138 optimized to give the maximum sum of weights, including mass weighting.
139 This provides a unique and continuous reference position that is nearly
140 identical to the plain center of mass position in case all atoms are all
141 within a half of the unit-cell length. See ref :ref:`136 <refEngin2010a>`
142 for details.
143
144 When relative weights :math:`w_i` are used during the calculations,
145 either by supplying weights in the input or due to cylinder geometry or
146 due to cosine weighting, the weights need to be scaled to conserve
147 momentum:
148
149 .. math::
150
151    w'_i = w_i
152    \left. \sum_{j=1}^N w_j \, m_j \right/ \sum_{j=1}^N w_j^2 \, m_j
153
154 where :math:`m_j` is the mass of atom :math:`j` of the group. The mass
155 of the group, required for calculating the constraint force, is:
156
157 .. math:: M = \sum_{i=1}^N w'_i \, m_i
158
159 The definition of the weighted center of mass is:
160
161 .. math:: \mathbf{r}_{com} = \left. \sum_{i=1}^N w'_i \, m_i \, \mathbf{r}_i \right/ M
162
163 From the centers of mass the AFM, constraint, or umbrella force
164 :math:`\mathbf{F}_{\!com}` on each group can be
165 calculated. The force on the center of mass of a group is redistributed
166 to the atoms as follows:
167
168 .. math:: \mathbf{F}_{\!i} = \frac{w'_i \, m_i}{M} \, \mathbf{F}_{\!com}
169
170 Definition of the pull direction
171 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
172
173 The most common setup is to pull along the direction of the vector
174 containing the two pull groups, this is selected with
175 ``pull-coord?-geometry = distance``. You might want to pull
176 along a certain vector instead, which is selected with
177 ``pull-coord?-geometry = direction``. But this can cause
178 unwanted torque forces in the system, unless you pull against a
179 reference group with (nearly) fixed orientation, e.g. a membrane protein
180 embedded in a membrane along x/y while pulling along z. If your
181 reference group does not have a fixed orientation, you should probably
182 use ``pull-coord?-geometry = direction-relative``, see
183 :numref:`Fig. %s <fig-pulldirrel>`. Since the potential now depends
184 on the coordinates of two additional groups defining the orientation,
185 the torque forces will work on these two groups.
186
187 .. _fig-pulldirrel:
188
189 .. figure:: plots/pulldirrel.*
190    :width: 5.00000cm
191
192    The pull setup for geometry ``direction-relative``. The
193    “normal” pull groups are 1 and 2. Groups 3 and 4 define the pull
194    direction and thus the direction of the normal pull forces (red).
195    This leads to reaction forces (blue) on groups 3 and 4, which are
196    perpendicular to the pull direction. Their magnitude is given by the
197    “normal” pull force times the ratio of :math:`d_p` and the distance
198    between groups 3 and 4.
199
200 Definition of the angle and dihedral pull geometries
201 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
202
203 Four pull groups are required for ``pull-coord?-geometry =
204 angle``. In the same way as for geometries with two groups, each
205 consecutive pair of groups :math:`i` and :math:`i+1` define a vector
206 connecting the COMs of groups :math:`i` and :math:`i+1`. The angle is
207 defined as the angle between the two resulting vectors. E.g., the
208 :ref:`mdp` option ``pull-coord?-groups = 1 2 2 4``
209 defines the angle between the vector from the COM of group 1 to the COM
210 of group 2 and the vector from the COM of group 2 to the COM of group 4.
211 The angle takes values in the closed interval [0, 180] deg. For
212 ``pull-coord?-geometry = angle-axis`` the angle is defined
213 with respect to a reference axis given by
214 ``pull-coord?-vec`` and only two groups need to be given.
215 The dihedral geometry requires six pull groups. These pair up in the
216 same way as described above and so define three vectors. The dihedral
217 angle is defined as the angle between the two planes spanned by the two
218 first and the two last vectors. Equivalently, the dihedral angle can be
219 seen as the angle between the first and the third vector when these
220 vectors are projected onto a plane normal to the second vector (the axis
221 vector). As an example, consider a dihedral angle involving four groups:
222 1, 5, 8 and 9. Here, the :ref:`mdp` option
223 ``pull-coord?-groups = 8 1 1 5 5 9`` specifies the three
224 vectors that define the dihedral angle: the first vector is the COM
225 distance vector from group 8 to 1, the second vector is the COM distance
226 vector from group 1 to 5, and the third vector is the COM distance
227 vector from group 5 to 9. The dihedral angle takes values in the
228 interval (-180, 180] deg and has periodic boundaries.
229
230 Limitations
231 ^^^^^^^^^^^
232
233 There is one theoretical limitation: strictly speaking, constraint
234 forces can only be calculated between groups that are not connected by
235 constraints to the rest of the system. If a group contains part of a
236 molecule of which the bond lengths are constrained, the pull constraint
237 and LINCS or SHAKE bond constraint algorithms should be iterated
238 simultaneously. This is not done in |Gromacs|. This means that for
239 simulations with ``constraints = all-bonds`` in the :ref:`mdp` file pulling is,
240 strictly speaking, limited to whole molecules or groups of molecules. In
241 some cases this limitation can be avoided by using the free energy code,
242 see sec. :ref:`fepmf`. In practice, the errors caused by not iterating
243 the two constraint algorithms can be negligible when the pull group
244 consists of a large amount of atoms and/or the pull force is small. In
245 such cases, the constraint correction displacement of the pull group is
246 small compared to the bond lengths.