a37c54b2014db739f581813ae0660f7e286e8636
[alexxy/gromacs.git] / docs / reference-manual / viscosity-calculation.rst
1 Viscosity calculation
2 ---------------------
3
4 The shear viscosity is a property of liquids that can be determined
5 easily by experiment. It is useful for parameterizing a force field
6 because it is a kinetic property, while most other properties which are
7 used for parameterization are thermodynamic. The viscosity is also an
8 important property, since it influences the rates of conformational
9 changes of molecules solvated in the liquid.
10
11 The viscosity can be calculated from an equilibrium simulation using an
12 Einstein relation:
13
14 .. math::
15
16    \eta = \frac{1}{2}\frac{V}{k_B T} \lim_{t \rightarrow \infty}
17    \frac{\mbox{d}}{\mbox{d} t} \left\langle 
18    \left( \int_{t_0}^{{t_0}+t} P_{xz}(t') \mbox{d} t' \right)^2
19    \right\rangle_{t_0}
20
21 This can be done with :ref:`gmx energy <gmx energy>`. This method converges
22 very slowly \ :ref:`149 <refHess2002a>`, and as such a nanosecond simulation might not
23 be long enough for an accurate determination of the viscosity. The
24 result is very dependent on the treatment of the electrostatics. Using a
25 (short) cut-off results in large noise on the off-diagonal pressure
26 elements, which can increase the calculated viscosity by an order of
27 magnitude.
28
29 |Gromacs| also has a non-equilibrium method for determining the
30 viscosity \ :ref:`149 <refHess2002a>`. This makes use of the fact that energy, which is
31 fed into system by external forces, is dissipated through viscous
32 friction. The generated heat is removed by coupling to a heat bath. For
33 a Newtonian liquid adding a small force will result in a velocity
34 gradient according to the following equation:
35
36 .. math:: a_x(z) + \frac{\eta}{\rho} \frac{\partial^2 v_x(z)}{\partial z^2} = 0
37
38 Here we have applied an acceleration :math:`a_x(z)` in the
39 :math:`x`-direction, which is a function of the :math:`z`-coordinate. In
40 |Gromacs| the acceleration profile is:
41
42 .. math:: a_x(z) = A \cos\left(\frac{2\pi z}{l_z}\right)
43
44 where :math:`l_z` is the height of the box. The generated velocity
45 profile is:
46
47 .. math:: v_x(z) = V \cos\left(\frac{2\pi z}{l_z}\right)
48
49 .. math:: V = A \frac{\rho}{\eta}\left(\frac{l_z}{2\pi}\right)^2
50
51 The viscosity can be calculated from :math:`A` and :math:`V`:
52
53 .. math:: \eta = \frac{A}{V}\rho \left(\frac{l_z}{2\pi}\right)^2
54           :label: eqvisc
55
56 In the simulation :math:`V` is defined as:
57
58 .. math::
59
60    V = \frac{\displaystyle \sum_{i=1}^N m_i v_{i,x} 2 \cos\left(\frac{2\pi z}{l_z}\right)}
61             {\displaystyle \sum_{i=1}^N m_i}
62
63 The generated velocity profile is not coupled to the heat bath.
64 Moreover, the velocity profile is excluded from the kinetic energy. One
65 would like :math:`V` to be as large as possible to get good statistics.
66 However, the shear rate should not be so high that the system gets too
67 far from equilibrium. The maximum shear rate occurs where the cosine is
68 zero, the rate being:
69
70 .. math::
71
72    \mbox{sh}_{\max} =  \max_z \left| \frac{\partial v_x(z)}{\partial z} \right|
73    = A \frac{\rho}{\eta} \frac{l_z}{2\pi}
74
75 For a simulation with: :math:`\eta=10^{-3}`
76 [kgm:math:`^{-1}`\ s\ :math:`^{-1}`],
77 :math:`\rho=10^3`\ [kgm:math:`^{-3}`] and :math:`l_z=2\pi`\ [nm],
78 :math:`\mbox{sh}_{\max}=1`\ [psnm:math:`^{-1}`] :math:`A`. This shear
79 rate should be smaller than one over the longest correlation time in the
80 system. For most liquids, this will be the rotation correlation time,
81 which is around 10 ps. In this case, :math:`A` should be smaller than
82 0.1[nmps\ :math:`^{-2}`]. When the shear rate is too high, the observed
83 viscosity will be too low. Because :math:`V` is proportional to the
84 square of the box height, the optimal box is elongated in the
85 :math:`z`-direction. In general, a simulation length of 100 ps is enough
86 to obtain an accurate value for the viscosity.
87
88 The heat generated by the viscous friction is removed by coupling to a
89 heat bath. Because this coupling is not instantaneous the real
90 temperature of the liquid will be slightly lower than the observed
91 temperature. Berendsen derived this temperature
92 shift \ :ref:`31 <refBerendsen91>`, which can be written in terms of the
93 shear rate as:
94
95 .. math:: T_s = \frac{\eta\,\tau}{2 \rho\,C_v} \mbox{sh}_{\max}^2
96
97 where :math:`\tau` is the coupling time for the Berendsen thermostat
98 and :math:`C_v` is the heat capacity. Using the values of the example
99 above, :math:`\tau=10^{-13}` [s] and :math:`C_v=2 \cdot 10^3`\ [J
100 kg\ :math:`^{-1}`\ K\ :math:`^{-1}`], we get:
101 :math:`T_s=25`\ [Kps:math:`^{-2}`]sh\ :math:`_{\max}^2`. When we want
102 the shear rate to be smaller than :math:`1/10`\ [ps:math:`^{-1}`],
103 :math:`T_s` is smaller than 0.25[K], which is negligible.
104
105 **Note** that the system has to build up the velocity profile when
106 starting from an equilibrium state. This build-up time is of the order
107 of the correlation time of the liquid.
108
109 Two quantities are written to the energy file, along with their averages
110 and fluctuations: :math:`V` and :math:`1/\eta`, as obtained from
111 (:eq:`%s <eqvisc>`).
112