Fixed manual for dihedral restraints.
[gromacs.git] / docs / reference-manual / functions / restraints.rst
blob885c40fac0fc752bba80a396cc3539b6aa0ebdf1
1 Restraints
2 ----------
4 Special potentials are used for imposing restraints on the motion of the
5 system, either to avoid disastrous deviations, or to include knowledge
6 from experimental data. In either case they are not really part of the
7 force field and the reliability of the parameters is not important. The
8 potential forms, as implemented in |Gromacs|, are mentioned just for the
9 sake of completeness. Restraints and constraints refer to quite
10 different algorithms in |Gromacs|.
12 .. _positionrestraint:
14 Position restraints
15 ~~~~~~~~~~~~~~~~~~~
17 These are used to restrain particles to fixed reference positions
18 :math:`\mathbf{R}_i`. They can be used during
19 equilibration in order to avoid drastic rearrangements of critical parts
20 (*e.g.* to restrain motion in a protein that is subjected to large
21 solvent forces when the solvent is not yet equilibrated). Another
22 application is the restraining of particles in a shell around a region
23 that is simulated in detail, while the shell is only approximated
24 because it lacks proper interaction from missing particles outside the
25 shell. Restraining will then maintain the integrity of the inner part.
26 For spherical shells, it is a wise procedure to make the force constant
27 depend on the radius, increasing from zero at the inner boundary to a
28 large value at the outer boundary. This feature has not, however, been
29 implemented in |Gromacs|.
31 The following form is used:
33 .. math:: V_{pr}(\mathbf{r}_i) = {\frac{1}{2}}k_{pr}|\mathbf{r}_i-\mathbf{R}_i|^2
34           :label: eqnposrestform
36 The potential is plotted in :numref:`Fig. %s <fig-positionrestraint>`.
38 .. _fig-positionrestraint:
40 .. figure:: plots/f-pr.*
41    :width: 8.00000cm
43    Position restraint potential.
45 The potential form can be rewritten without loss of generality as:
47 .. math:: V_{pr}(\mathbf{r}_i) = {\frac{1}{2}} \left[ k_{pr}^x (x_i-X_i)^2 ~{\hat{\bf x}} + k_{pr}^y (y_i-Y_i)^2 ~{\hat{\bf y}} + k_{pr}^z (z_i-Z_i)^2 ~{\hat{\bf z}}\right]
48          :label: eqnposrestgeneral
50 Now the forces are:
52 .. math:: \begin{array}{rcl}
53           F_i^x &=& -k_{pr}^x~(x_i - X_i) \\
54           F_i^y &=& -k_{pr}^y~(y_i - Y_i) \\
55           F_i^z &=& -k_{pr}^z~(z_i - Z_i)
56           \end{array}
57           :label: eqnposrestforce
59 Using three different force constants the position restraints can be
60 turned on or off in each spatial dimension; this means that atoms can be
61 harmonically restrained to a plane or a line. Position restraints are
62 applied to a special fixed list of atoms. Such a list is usually
63 generated by the :ref:`pdb2gmx <gmx pdb2gmx>` program.
65 Flat-bottomed position restraints
66 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68 Flat-bottomed position restraints can be used to restrain particles to
69 part of the simulation volume. No force acts on the restrained particle
70 within the flat-bottomed region of the potential, however a harmonic
71 force acts to move the particle to the flat-bottomed region if it is
72 outside it. It is possible to apply normal and flat-bottomed position
73 restraints on the same particle (however, only with the same reference
74 position :math:`\mathbf{R}_i`). The following general
75 potential is used (:numref:`Figure %s <fig-fbposres>` A):
77 .. math:: V_\mathrm{fb}(\mathbf{r}_i) = \frac{1}{2}k_\mathrm{fb} [d_g(\mathbf{r}_i;\mathbf{R}_i) - r_\mathrm{fb}]^2\,H[d_g(\mathbf{r}_i;\mathbf{R}_i) - r_\mathrm{fb}],
78           :label: eqnflatbottomposrest
80 where :math:`\mathbf{R}_i` is the reference position,
81 :math:`r_\mathrm{fb}` is the distance from the center with a flat
82 potential, :math:`k_\mathrm{fb}` the force constant, and :math:`H` is
83 the Heaviside step function. The distance
84 :math:`d_g(\mathbf{r}_i;\mathbf{R}_i)` from
85 the reference position depends on the geometry :math:`g` of the
86 flat-bottomed potential.
88 .. _fig-fbposres:
90 .. figure:: plots/fbposres.*
91    :width: 10.00000cm
93    Flat-bottomed position restraint potential. (A) Not inverted, (B)
94    inverted.
96 | The following geometries for the flat-bottomed potential are
97   supported:
99 | **Sphere** (:math:`g =1`): The
100   particle is kept in a sphere of given radius. The force acts towards
101   the center of the sphere. The following distance calculation is used:
103   .. math:: d_g(\mathbf{r}_i;\mathbf{R}_i) = | \mathbf{r}_i-\mathbf{R}_i |
104             :label: eqnfbsphereposrest
106 | **Cylinder** (:math:`g=6,7,8`): The particle is kept in a cylinder of
107   given radius parallel to the :math:`x` (:math:`g=6`), :math:`y`
108   (:math:`g=7`), or :math:`z`-axis (:math:`g=8`). For backwards
109   compatibility, setting :math:`g=2` is mapped to :math:`g=8` in the
110   code so that old :ref:`tpr` files and topologies work. The
111   force from the flat-bottomed potential acts towards the axis of the
112   cylinder. The component of the force parallel to the cylinder axis is
113   zero. For a cylinder aligned along the :math:`z`-axis:
115   .. math:: d_g(\mathbf{r}_i;\mathbf{R}_i) = \sqrt{ (x_i-X_i)^2 + (y_i - Y_i)^2 }
116             :label: eqnfbcylinderposrest
118 | **Layer** (:math:`g=3,4,5`): The particle is kept in a layer defined
119   by the thickness and the normal of the layer. The layer normal can be
120   parallel to the :math:`x`, :math:`y`, or :math:`z`-axis. The force
121   acts parallel to the layer normal.
123   .. math:: d_g(\mathbf{r}_i;\mathbf{R}_i) = |x_i-X_i|, \;\;\;\mbox{or}\;\;\; 
124             d_g(\mathbf{r}_i;\mathbf{R}_i) = |y_i-Y_i|, \;\;\;\mbox{or}\;\;\; 
125             d_g(\mathbf{r}_i;\mathbf{R}_i) = |z_i-Z_i|.
126             :label: eqnfblayerposrest
128 It is possible to apply multiple independent flat-bottomed position
129 restraints of different geometry on one particle. For example, applying
130 a cylinder and a layer in :math:`z` keeps a particle within a disk.
131 Applying three layers in :math:`x`, :math:`y`, and :math:`z` keeps the
132 particle within a cuboid.
134 In addition, it is possible to invert the restrained region with the
135 unrestrained region, leading to a potential that acts to keep the
136 particle *outside* of the volume defined by
137 :math:`\mathbf{R}_i`, :math:`g`, and
138 :math:`r_\mathrm{fb}`. That feature is switched on by defining a
139 negative :math:`r_\mathrm{fb}` in the topology. The following potential
140 is used (:numref:`Figure %s <fig-fbposres>` B):
142 .. math:: V_\mathrm{fb}^{\mathrm{inv}}(\mathbf{r}_i) = \frac{1}{2}k_\mathrm{fb}
143           [d_g(\mathbf{r}_i;\mathbf{R}_i) - | r_\mathrm{fb} | ]^2\,
144           H[ -(d_g(\mathbf{r}_i;\mathbf{R}_i) - | r_\mathrm{fb} | )].
145           :label: eqninvertrest
147 Angle restraints
148 ~~~~~~~~~~~~~~~~
150 These are used to restrain the angle between two pairs of particles or
151 between one pair of particles and the :math:`z`-axis. The functional
152 form is similar to that of a proper dihedral. For two pairs of atoms:
154 .. math:: V_{ar}(\mathbf{r}_i,\mathbf{r}_j,\mathbf{r}_k,\mathbf{r}_l)
155                   = k_{ar}(1 - \cos(n (\theta - \theta_0))
156                   )
157           ,~~~~\mbox{where}~~
158           \theta = \arccos\left(\frac{\mathbf{r}_j -\mathbf{r}_i}{\|\mathbf{r}_j -\mathbf{r}_i\|}
159           \cdot \frac{\mathbf{r}_l -\mathbf{r}_k}{\|\mathbf{r}_l -\mathbf{r}_k\|} \right)
160           :label: eqnanglerest
162 For one pair of atoms and the :math:`z`-axis:
164 .. math:: V_{ar}(\mathbf{r}_i,\mathbf{r}_j) = k_{ar}(1 - \cos(n (\theta - \theta_0))
165                   )
166           ,~~~~\mbox{where}~~
167           \theta = \arccos\left(\frac{\mathbf{r}_j -\mathbf{r}_i}{\|\mathbf{r}_j -\mathbf{r}_i\|}
168           \cdot \left( \begin{array}{c} 0 \\ 0 \\ 1 \\ \end{array} \right) \right)
169           :label: eqnanglerestzaxis
171 A multiplicity (:math:`n`) of 2 is useful when you do not want to
172 distinguish between parallel and anti-parallel vectors. The equilibrium
173 angle :math:`\theta` should be between 0 and 180 degrees for
174 multiplicity 1 and between 0 and 90 degrees for multiplicity 2.
176 .. _dihedralrestraint:
178 Dihedral restraints
179 ~~~~~~~~~~~~~~~~~~~
181 These are used to restrain the dihedral angle :math:`\phi` defined by
182 four particles as in an improper dihedral (sec. :ref:`imp`) but with a
183 slightly modified potential. Using:
185 .. math:: \phi' = \left(\phi-\phi_0\right) ~{\rm MOD}~ 2\pi
186           :label: eqndphi
188 where :math:`\phi_0` is the reference angle, the potential is defined
191 .. math:: V_{dihr}(\phi') ~=~ \left\{
192           \begin{array}{lcllll}
193           {\frac{1}{2}}k_{dihr}(\phi'-\Delta\phi)^2      
194                           &\mbox{for}&     \|\phi'\| & >   & \Delta\phi       \\[1.5ex]
195           0               &\mbox{for}&     \|\phi'\| & \le & \Delta\phi       \\[1.5ex]
196           \end{array}\right.
197           :label: eqndihre
199 where :math:`\Delta\phi` is a user defined angle and :math:`k_{dihr}`
200 is the force constant. **Note** that in the input in topology files,
201 angles are given in degrees and force constants in
202 kJ/mol/rad\ :math:`^2`.
204 .. _distancerestraint:
206 Distance restraints
207 ~~~~~~~~~~~~~~~~~~~
209 Distance restraints add a penalty to the potential when the distance
210 between specified pairs of atoms exceeds a threshold value. They are
211 normally used to impose experimental restraints from, for instance,
212 experiments in nuclear magnetic resonance (NMR), on the motion of the
213 system. Thus, MD can be used for structure refinement using NMR data. In
214 |Gromacs| there are three ways to impose restraints on pairs of atoms:
216 -  Simple harmonic restraints: use ``[ bonds ]`` type 6 (see sec. :ref:`excl`).
218 -  Piecewise linear/harmonic restraints: ``[ bonds ]`` type
219    10.
221 -  Complex NMR distance restraints, optionally with pair, time and/or
222    ensemble averaging.
224 The last two options will be detailed now.
226 The potential form for distance restraints is quadratic below a
227 specified lower bound and between two specified upper bounds, and linear
228 beyond the largest bound (see :numref:`Fig. %s <fig-dist>`).
230 .. math:: V_{dr}(r_{ij}) ~=~ \left\{
231           \begin{array}{lcllllll}
232           {\frac{1}{2}}k_{dr}(r_{ij}-r_0)^2      
233                           &\mbox{for}&     &     & r_{ij} & < & r_0       \\[1.5ex]
234           0               &\mbox{for}& r_0 & \le & r_{ij} & < & r_1       \\[1.5ex]
235           {\frac{1}{2}}k_{dr}(r_{ij}-r_1)^2      
236                           &\mbox{for}& r_1 & \le & r_{ij} & < & r_2       \\[1.5ex]
237           {\frac{1}{2}}k_{dr}(r_2-r_1)(2r_{ij}-r_2-r_1)  
238                           &\mbox{for}& r_2 & \le & r_{ij} &   &
239           \end{array}\right.
240           :label: eqndisre
242 .. _fig-dist:
244 .. figure:: plots/f-dr.*
245    :width: 8.00000cm
247    Distance Restraint potential.
249 The forces are
251 .. math:: \mathbf{F}_i~=~ \left\{
252           \begin{array}{lcllllll}
253           -k_{dr}(r_{ij}-r_0)\frac{\mathbf{r}_ij}{r_{ij}} 
254                           &\mbox{for}&     &     & r_{ij} & < & r_0       \\[1.5ex]
255           0               &\mbox{for}& r_0 & \le & r_{ij} & < & r_1       \\[1.5ex]
256           -k_{dr}(r_{ij}-r_1)\frac{\mathbf{r}_ij}{r_{ij}} 
257                           &\mbox{for}& r_1 & \le & r_{ij} & < & r_2       \\[1.5ex]
258           -k_{dr}(r_2-r_1)\frac{\mathbf{r}_ij}{r_{ij}}    
259                           &\mbox{for}& r_2 & \le & r_{ij} &   &
260           \end{array} \right.
261           :label: eqndisreforce
263 For restraints not derived from NMR data, this functionality will
264 usually suffice and a section of ``[ bonds ]`` type 10 can be used to apply individual
265 restraints between pairs of atoms, see :ref:`topfile`. For applying
266 restraints derived from NMR measurements, more complex functionality
267 might be required, which is provided through the ``[ distance_restraints ]`` section and is
268 described below.
270 Time averaging
271 ^^^^^^^^^^^^^^
273 Distance restraints based on instantaneous distances can potentially
274 reduce the fluctuations in a molecule significantly. This problem can be
275 overcome by restraining to a *time averaged*
276 distance \ :ref:`91 <refTorda89>`. The forces with time averaging are:
278 .. math:: \mathbf{F}_i~=~ \left\{
279           \begin{array}{lcllllll}
280           -k^a_{dr}(\bar{r}_{ij}-r_0)\frac{\mathbf{r}_ij}{r_{ij}}   
281                           &\mbox{for}&     &     & \bar{r}_{ij} & < & r_0 \\[1.5ex]
282           0               &\mbox{for}& r_0 & \le & \bar{r}_{ij} & < & r_1 \\[1.5ex]
283           -k^a_{dr}(\bar{r}_{ij}-r_1)\frac{\mathbf{r}_ij}{r_{ij}}   
284                           &\mbox{for}& r_1 & \le & \bar{r}_{ij} & < & r_2 \\[1.5ex]
285           -k^a_{dr}(r_2-r_1)\frac{\mathbf{r}_ij}{r_{ij}}    
286                           &\mbox{for}& r_2 & \le & \bar{r}_{ij} &   &
287           \end{array} \right.
288           :label: eqntimeaveragerest
290 where :math:`\bar{r}_{ij}` is given by an exponential running average
291 with decay time :math:`\tau`:
293 .. math:: \bar{r}_{ij} ~=~ < r_{ij}^{-3} >^{-1/3}
294           :label: eqnrav
296 The force constant :math:`k^a_{dr}` is switched on slowly to compensate
297 for the lack of history at the beginning of the simulation:
299 .. math:: k^a_{dr} = k_{dr} \left(1-\exp\left(-\frac{t}{\tau}\right)\right)
300           :label: eqnforceconstantswitch
302 Because of the time averaging, we can no longer speak of a distance
303 restraint potential.
305 This way an atom can satisfy two incompatible distance restraints *on
306 average* by moving between two positions. An example would be an amino
307 acid side-chain that is rotating around its :math:`\chi` dihedral angle,
308 thereby coming close to various other groups. Such a mobile side chain
309 can give rise to multiple NOEs that can not be fulfilled by a single
310 structure.
312 The computation of the time averaged distance in the
313 :ref:`mdrun <gmx mdrun>` program is done in the following fashion:
315 .. math:: \begin{array}{rcl}
316           \overline{r^{-3}}_{ij}(0)       &=& r_{ij}(0)^{-3}      \\
317           \overline{r^{-3}}_{ij}(t)       &=& \overline{r^{-3}}_{ij}(t-\Delta t)~\exp{\left(-\frac{\Delta t}{\tau}\right)} + r_{ij}(t)^{-3}\left[1-\exp{\left(-\frac{\Delta t}{\tau}\right)}\right]
318           \end{array}
319           :label: eqnravdisre
321 When a pair is within the bounds, it can still feel a force because the
322 time averaged distance can still be beyond a bound. To prevent the
323 protons from being pulled too close together, a mixed approach can be
324 used. In this approach, the penalty is zero when the instantaneous
325 distance is within the bounds, otherwise the violation is the square
326 root of the product of the instantaneous violation and the time averaged
327 violation:
329 .. math:: \mathbf{F}_i~=~ \left\{
330           \begin{array}{lclll}
331           k^a_{dr}\sqrt{(r_{ij}-r_0)(\bar{r}_{ij}-r_0)}\frac{\mathbf{r}_ij}{r_{ij}}   
332               & \mbox{for} & r_{ij} < r_0 & \mbox{and} & \bar{r}_{ij} < r_0 \\[1.5ex]
333           -k^a _{dr} \,
334             \mbox{min}\left(\sqrt{(r_{ij}-r_1)(\bar{r}_{ij}-r_1)},r_2-r_1\right)
335             \frac{\mathbf{r}_ij}{r_{ij}}   
336               & \mbox{for} & r_{ij} > r_1 & \mbox{and} & \bar{r}_{ij} > r_1 \\[1.5ex]
337           0               &\mbox{otherwise}
338           \end{array} \right.
339           :label: eqntimeaverageviolation
341 Averaging over multiple pairs
342 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
344 Sometimes it is unclear from experimental data which atom pair gives
345 rise to a single NOE, in other occasions it can be obvious that more
346 than one pair contributes due to the symmetry of the system, *e.g.* a
347 methyl group with three protons. For such a group, it is not possible to
348 distinguish between the protons, therefore they should all be taken into
349 account when calculating the distance between this methyl group and
350 another proton (or group of protons). Due to the physical nature of
351 magnetic resonance, the intensity of the NOE signal is inversely
352 proportional to the sixth power of the inter-atomic distance. Thus, when
353 combining atom pairs, a fixed list of :math:`N` restraints may be taken
354 together, where the apparent “distance” is given by:
356 .. math:: r_N(t) = \left [\sum_{n=1}^{N} \bar{r}_{n}(t)^{-6} \right]^{-1/6}
357           :label: eqnrsix
359 where we use :math:`r_{ij}` or :eq:`eqn. %s <eqnrav>` for the
360 :math:`\bar{r}_{n}`. The :math:`r_N` of the instantaneous and
361 time-averaged distances can be combined to do a mixed restraining, as
362 indicated above. As more pairs of protons contribute to the same NOE
363 signal, the intensity will increase, and the summed “distance” will be
364 shorter than any of its components due to the reciprocal summation.
366 There are two options for distributing the forces over the atom pairs.
367 In the conservative option, the force is defined as the derivative of
368 the restraint potential with respect to the coordinates. This results in
369 a conservative potential when time averaging is not used. The force
370 distribution over the pairs is proportional to :math:`r^{-6}`. This
371 means that a close pair feels a much larger force than a distant pair,
372 which might lead to a molecule that is “too rigid.” The other option is
373 an equal force distribution. In this case each pair feels :math:`1/N` of
374 the derivative of the restraint potential with respect to :math:`r_N`.
375 The advantage of this method is that more conformations might be
376 sampled, but the non-conservative nature of the forces can lead to local
377 heating of the protons.
379 It is also possible to use *ensemble averaging* using multiple (protein)
380 molecules. In this case the bounds should be lowered as in:
382 .. math:: \begin{array}{rcl}
383           r_1     &~=~&   r_1 * M^{-1/6}  \\
384           r_2     &~=~&   r_2 * M^{-1/6}
385           \end{array}
386           :label: eqnrestforceensembleaverage
388 where :math:`M` is the number of molecules. The |Gromacs| preprocessor
389 :ref:`grompp <gmx grompp>` can do this automatically when the appropriate
390 option is given. The resulting “distance” is then used to calculate the
391 scalar force according to:
393 .. math:: \mathbf{F}_i~=~\left\{
394           \begin{array}{rcl}
395           ~& 0 \hspace{4cm}  & r_{N} < r_1         \\
396            & k_{dr}(r_{N}-r_1)\frac{\mathbf{r}_ij}{r_{ij}} & r_1 \le r_{N} < r_2 \\
397            & k_{dr}(r_2-r_1)\frac{\mathbf{r}_ij}{r_{ij}}    & r_{N} \ge r_2 
398           \end{array} \right.
399           :label: eqnrestscalarforce
401 where :math:`i` and :math:`j` denote the atoms of all the pairs that
402 contribute to the NOE signal.
404 Using distance restraints
405 ^^^^^^^^^^^^^^^^^^^^^^^^^
407 A list of distance restrains based on NOE data can be added to a
408 molecule definition in your topology file, like in the following
409 example:
413     [ distance_restraints ]
414     ; ai   aj   type   index   type'      low     up1     up2     fac
415     10     16      1       0       1      0.0     0.3     0.4     1.0
416     10     28      1       1       1      0.0     0.3     0.4     1.0
417     10     46      1       1       1      0.0     0.3     0.4     1.0
418     16     22      1       2       1      0.0     0.3     0.4     2.5
419     16     34      1       3       1      0.0     0.5     0.6     1.0
421 In this example a number of features can be found. In columns ai and aj
422 you find the atom numbers of the particles to be restrained. The type
423 column should always be 1. As explained in  :ref:`distancerestraint`,
424 multiple distances can contribute to a single NOE signal. In the
425 topology this can be set using the index column. In our example, the
426 restraints 10-28 and 10-46 both have index 1, therefore they are treated
427 simultaneously. An extra requirement for treating restraints together is
428 that the restraints must be on successive lines, without any other
429 intervening restraint. The type’ column will usually be 1, but can be
430 set to 2 to obtain a distance restraint that will never be time- and
431 ensemble-averaged; this can be useful for restraining hydrogen bonds.
432 The columns ``low``, ``up1``, and
433 ``up2`` hold the values of :math:`r_0`, :math:`r_1`, and
434 :math:`r_2` from  :eq:`eqn. %s <eqndisre>`. In some cases it
435 can be useful to have different force constants for some restraints;
436 this is controlled by the column ``fac``. The force constant
437 in the parameter file is multiplied by the value in the column
438 ``fac`` for each restraint. Information for each restraint
439 is stored in the energy file and can be processed and plotted with
440 :ref:`gmx nmr`.
442 Orientation restraints
443 ~~~~~~~~~~~~~~~~~~~~~~
445 This section describes how orientations between vectors, as measured in
446 certain NMR experiments, can be calculated and restrained in MD
447 simulations. The presented refinement methodology and a comparison of
448 results with and without time and ensemble averaging have been
449 published \ :ref:`92 <refHess2003>`.
451 Theory
452 ^^^^^^
454 In an NMR experiment, orientations of vectors can be measured when a
455 molecule does not tumble completely isotropically in the solvent. Two
456 examples of such orientation measurements are residual dipolar couplings
457 (between two nuclei) or chemical shift anisotropies. An observable for a
458 vector :math:`\mathbf{r}_i` can be written as follows:
460 .. math:: \delta_i = \frac{2}{3} \mbox{tr}({{\mathbf S}}{{\mathbf D}}_i)
461           :label: eqnorrestvector
463 where :math:`{{\mathbf S}}` is the dimensionless order tensor of the
464 molecule. The tensor :math:`{{\mathbf D}}_i` is given by:
466 .. math:: {{\mathbf D}}_i = \frac{c_i}{\|\mathbf{r}_i\|^\alpha} \left(
467           \begin{array}{lll}
468           3 x x - 1 & 3 x y     & 3 x z     \\
469           3 x y     & 3 y y - 1 & 3 y z     \\
470           3 x z     & 3 y z     & 3 z z - 1 \\
471           \end{array} \right)
472           :label: eqnorientdef
474 .. math:: \mbox{with:} \quad 
475           x=\frac{r_{i,x}}{\|\mathbf{r}_i\|}, \quad
476           y=\frac{r_{i,y}}{\|\mathbf{r}_i\|}, \quad 
477           z=\frac{r_{i,z}}{\|\mathbf{r}_i\|}
478           :label: eqnorientdef2
480 For a dipolar coupling :math:`\mathbf{r}_i` is the vector
481 connecting the two nuclei, :math:`\alpha=3` and the constant :math:`c_i`
482 is given by:
484 .. math:: c_i = \frac{\mu_0}{4\pi} \gamma_1^i \gamma_2^i \frac{\hbar}{4\pi}
485           :label: eqnorrestconstant
487 where :math:`\gamma_1^i` and :math:`\gamma_2^i` are the gyromagnetic
488 ratios of the two nuclei.
490 The order tensor is symmetric and has trace zero. Using a rotation
491 matrix :math:`{\mathbf T}` it can be transformed into the following
492 form:
494 .. math:: {\mathbf T}^T {{\mathbf S}}{\mathbf T} = s \left( \begin{array}{ccc}
495           -\frac{1}{2}(1-\eta) & 0                    & 0 \\
496           0                    & -\frac{1}{2}(1+\eta) & 0 \\
497           0                    & 0                    & 1
498           \end{array} \right)
499           :label: eqnorresttensor
501 where :math:`-1 \leq s \leq 1` and :math:`0 \leq \eta \leq 1`.
502 :math:`s` is called the order parameter and :math:`\eta` the asymmetry
503 of the order tensor :math:`{{\mathbf S}}`. When the molecule tumbles
504 isotropically in the solvent, :math:`s` is zero, and no orientational
505 effects can be observed because all :math:`\delta_i` are zero.
507 Calculating orientations in a simulation
508 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
510 For reasons which are explained below, the :math:`{{\mathbf D}}`
511 matrices are calculated which respect to a reference orientation of the
512 molecule. The orientation is defined by a rotation matrix
513 :math:`{{\mathbf R}}`, which is needed to least-squares fit the current
514 coordinates of a selected set of atoms onto a reference conformation.
515 The reference conformation is the starting conformation of the
516 simulation. In case of ensemble averaging, which will be treated later,
517 the structure is taken from the first subsystem. The calculated
518 :math:`{{\mathbf D}}_i^c` matrix is given by:
520 .. math:: {{\mathbf D}}_i^c(t) = {{\mathbf R}}(t) {{\mathbf D}}_i(t) {{\mathbf R}}^T(t)
521           :label: eqnDrot
523 The calculated orientation for vector :math:`i` is given by:
525 .. math:: \delta^c_i(t) = \frac{2}{3} \mbox{tr}({{\mathbf S}}(t){{\mathbf D}}_i^c(t))
526           :label: eqnDrotvector
528 The order tensor :math:`{{\mathbf S}}(t)` is usually unknown. A
529 reasonable choice for the order tensor is the tensor which minimizes the
530 (weighted) mean square difference between the calculated and the
531 observed orientations:
533 .. math:: MSD(t) = \left(\sum_{i=1}^N w_i\right)^{-1} \sum_{i=1}^N w_i (\delta_i^c (t) -\delta_i^{exp})^2
534           :label: eqnSmsd
536 To properly combine different types of measurements, the unit of
537 :math:`w_i` should be such that all terms are dimensionless. This means
538 the unit of :math:`w_i` is the unit of :math:`\delta_i` to the power
539 :math:`-2`. **Note** that scaling all :math:`w_i` with a constant factor
540 does not influence the order tensor.
542 Time averaging
543 ^^^^^^^^^^^^^^
545 Since the tensors :math:`{{\mathbf D}}_i` fluctuate rapidly in time,
546 much faster than can be observed in an experiment, they should be
547 averaged over time in the simulation. However, in a simulation the time
548 and the number of copies of a molecule are limited. Usually one can not
549 obtain a converged average of the :math:`{{\mathbf D}}_i` tensors over
550 all orientations of the molecule. If one assumes that the average
551 orientations of the :math:`\mathbf{r}_i` vectors within
552 the molecule converge much faster than the tumbling time of the
553 molecule, the tensor can be averaged in an axis system that rotates with
554 the molecule, as expressed by :eq:`equation %s <eqnDrot>`). The time-averaged
555 tensors are calculated using an exponentially decaying memory function:
557 .. math:: {{\mathbf D}}^a_i(t) = \frac{\displaystyle
558           \int_{u=t_0}^t {{\mathbf D}}^c_i(u) \exp\left(-\frac{t-u}{\tau}\right)\mbox{d} u
559           }{\displaystyle
560           \int_{u=t_0}^t \exp\left(-\frac{t-u}{\tau}\right)\mbox{d} u
561           }
562           :label: eqnorresttimeaverage
564 Assuming that the order tensor :math:`{{\mathbf S}}` fluctuates slower
565 than the :math:`{{\mathbf D}}_i`, the time-averaged orientation can be
566 calculated as:
568 .. math:: \delta_i^a(t) = \frac{2}{3} \mbox{tr}({{\mathbf S}}(t) {{\mathbf D}}_i^a(t))
569           :label: eqnorresttimeaveorient
571 where the order tensor :math:`{{\mathbf S}}(t)` is calculated using
572 expression :eq:`%s <eqnSmsd>` with :math:`\delta_i^c(t)` replaced by
573 :math:`\delta_i^a(t)`.
575 Restraining
576 ^^^^^^^^^^^
578 The simulated structure can be restrained by applying a force
579 proportional to the difference between the calculated and the
580 experimental orientations. When no time averaging is applied, a proper
581 potential can be defined as:
583 .. math:: V = \frac{1}{2} k \sum_{i=1}^N w_i (\delta_i^c (t) -\delta_i^{exp})^2
584           :label: eqnorrestsimrest
586 where the unit of :math:`k` is the unit of energy. Thus the effective
587 force constant for restraint :math:`i` is :math:`k w_i`. The forces are
588 given by minus the gradient of :math:`V`. The force
589 :math:`\mathbf{F}\!_i` working on vector
590 :math:`\mathbf{r}_i` is:
592 .. math:: \begin{aligned}
593           \mathbf{F}\!_i(t) 
594           & = & - \frac{\mbox{d} V}{\mbox{d}\mathbf{r}_i} \\
595           & = & -k w_i (\delta_i^c (t) -\delta_i^{exp}) \frac{\mbox{d} \delta_i (t)}{\mbox{d}\mathbf{r}_i} \\
596           & = & -k w_i (\delta_i^c (t) -\delta_i^{exp})
597           \frac{2 c_i}{\|\mathbf{r}\|^{2+\alpha}} \left(2 {{\mathbf R}}^T {{\mathbf S}}{{\mathbf R}}\mathbf{r}_i - \frac{2+\alpha}{\|\mathbf{r}\|^2} \mbox{tr}({{\mathbf R}}^T {{\mathbf S}}{{\mathbf R}}\mathbf{r}_i \mathbf{r}_i^T) \mathbf{r}_i \right)\end{aligned}
598           :label: eqnorrestsimrestforce
600 Ensemble averaging
601 ^^^^^^^^^^^^^^^^^^
603 Ensemble averaging can be applied by simulating a system of :math:`M`
604 subsystems that each contain an identical set of orientation restraints.
605 The systems only interact via the orientation restraint potential which
606 is defined as:
608 .. math:: V = M \frac{1}{2} k \sum_{i=1}^N w_i 
609           \langle \delta_i^c (t) -\delta_i^{exp} \rangle^2
610           :label: eqnorrestensembleave
612 The force on vector :math:`\mathbf{r}_{i,m}` in subsystem
613 :math:`m` is given by:
615 .. math:: \mathbf{F}\!_{i,m}(t) = - \frac{\mbox{d} V}{\mbox{d}\mathbf{r}_{i,m}} =
616           -k w_i \langle \delta_i^c (t) -\delta_i^{exp} \rangle \frac{\mbox{d} \delta_{i,m}^c (t)}{\mbox{d}\mathbf{r}_{i,m}}
617           :label: eqnorrestensaveforce 
619 Time averaging
620 ^^^^^^^^^^^^^^
622 When using time averaging it is not possible to define a potential. We
623 can still define a quantity that gives a rough idea of the energy stored
624 in the restraints:
626 .. math:: V = M \frac{1}{2} k^a \sum_{i=1}^N w_i 
627           \langle \delta_i^a (t) -\delta_i^{exp} \rangle^2
628           :label: eqntimeavepot
630 The force constant :math:`k_a` is switched on slowly to compensate for
631 the lack of history at times close to :math:`t_0`. It is exactly
632 proportional to the amount of average that has been accumulated:
634 .. math:: k^a =
635           k \, \frac{1}{\tau}\int_{u=t_0}^t \exp\left(-\frac{t-u}{\tau}\right)\mbox{d} u
636           :label: eqntimeaveforceswitch
638 What really matters is the definition of the force. It is chosen to be
639 proportional to the square root of the product of the time-averaged and
640 the instantaneous deviation. Using only the time-averaged deviation
641 induces large oscillations. The force is given by:
643 .. math:: \mathbf{F}\!_{i,m}(t) =
644           \left\{ \begin{array}{ll}
645           0 & \quad \mbox{for} \quad a\, b \leq 0 \\
646           \displaystyle
647           k^a w_i \frac{a}{|a|} \sqrt{a\, b} \, \frac{\mbox{d} \delta_{i,m}^c (t)}{\mbox{d}\mathbf{r}_{i,m}}
648           & \quad \mbox{for} \quad a\, b > 0 
649           \end{array}
650           \right.
651           :label: eqntimeaveforce
653 .. math:: \begin{aligned}
654           a &=& \langle \delta_i^a (t) -\delta_i^{exp} \rangle \\
655           b &=& \langle \delta_i^c (t) -\delta_i^{exp} \rangle\end{aligned}
656           :label: eqntimeaveforce2
658 Using orientation restraints
659 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
661 Orientation restraints can be added to a molecule definition in the
662 topology file in the section ``[ orientation_restraints ]``.
663 Here we give an example section containing five N-H residual dipolar
664 coupling restraints:
668     [ orientation_restraints ]
669     ; ai   aj  type  exp.  label  alpha    const.     obs.   weight
670     ;                                Hz      nm^3       Hz    Hz^-2
671       31   32     1     1      3      3     6.083    -6.73      1.0
672       43   44     1     1      4      3     6.083    -7.87      1.0
673       55   56     1     1      5      3     6.083    -7.13      1.0
674       65   66     1     1      6      3     6.083    -2.57      1.0
675       73   74     1     1      7      3     6.083    -2.10      1.0
677 The unit of the observable is Hz, but one can choose any other unit. In
678 columns ``ai`` and ``aj`` you find the atom numbers of the particles to be
679 restrained. The ``type`` column should always be 1. The ``exp.`` column denotes
680 the experiment number, starting at 1. For each experiment a separate
681 order tensor :math:`{{\mathbf S}}` is optimized. The label should be a
682 unique number larger than zero for each restraint. The ``alpha`` column
683 contains the power :math:`\alpha` that is used in
684 :eq:`equation %s <eqnorientdef>`) to calculate the orientation. The ``const.`` column
685 contains the constant :math:`c_i` used in the same equation. The
686 constant should have the unit of the observable times
687 nm\ :math:`^\alpha`. The column ``obs.`` contains the observable, in any
688 unit you like. The last column contains the weights :math:`w_i`; the
689 unit should be the inverse of the square of the unit of the observable.
691 Some parameters for orientation restraints can be specified in the
692 :ref:`grompp <gmx grompp>` :ref:`mdp` file, for a study of the effect of different
693 force constants and averaging times and ensemble averaging see \ :ref:`92 <refHess2003>`.
694 Information for each restraint is stored in the energy
695 file and can be processed and plotted with :ref:`gmx nmr`.
697 .. raw:: latex
699     \clearpage