Lab 6.10 · 35 min

Lab: viscosity by hand

Viscosity says how hard it is to shear a liquid, and it controls diffusion, conductivity and flow. In equilibrium MD there is no flow, yet the viscosity is hidden in the small, random shear stresses of the box. We compute the shear stress by hand, do the Green–Kubo and Einstein routes on ten numbers, then measure the viscosity of the LJ liquid of Lab 6.9, check it against the Yeh–Hummer slope and Stokes–Einstein, and see why it converges so slowly.

The setup

A shear flow (layers sliding past each other) is resisted by a shear stress, the off-diagonal pressure P_xy. At rest its average is zero, but it fluctuates. The time these fluctuations take to die away is the viscosity:

P_xy = (1/V) [ Σ m vₓ v_y + Σ_pairs xᵢⱼ F_y,ᵢⱼ ] Green–Kubo: η = V/(k_BT) ∫₀^∞ ⟨P_xy(0) P_xy(t)⟩ dt Einstein: η = V/(2k_BT) × slope of ⟨[∫P_xy dt]²⟩ in time

System: the 3D LJ liquid of Lab 6.9 (256 atoms, ρ = 0.8, T = 1.0, cutoff 1.6, V = 320), 100 000 steps with a gentle Bussi thermostat. In an isotropic liquid five combinations of the pressure tensor carry the same information: P_xy, P_xz, P_yz, (P_xx − P_yy)/2 and (P_yy − P_zz)/2.

Step 1

The shear stress by hand

Why: P_xy measures how much x-momentum crosses a plane perpendicular to y, per unit area and time. Atoms carry momentum across by moving (kinetic part) and push across by forces (virial part). Both are needed, and both come from quantities the simulation already has.

two atoms, V = 27, mass 1 r₁ = (1, 1, 1), v₁ = (0.5, −0.3, 0) r₂ = (2, 1.5, 1), v₂ = (−0.2, 0.4, 0.1) kinetic: Σ m vₓ v_y = 0.5 × (−0.3) + (−0.2) × 0.4 = −0.2300 d = r₂ − r₁ = (1, 0.5, 0), r = 1.1180 F(r) = 24(2/r¹³ − 1/r⁷) = 0.2638 (repulsive) force on atom 2 = 0.2638 × d/r = (0.2359, 0.1180, 0) virial: dₓ F_y = 1.0 × 0.1180 = 0.1180 P_xy = (−0.2300 + 0.1180) / 27 = −0.00415

What the numbers say: One configuration gives a small number of either sign. In the LJ liquid P_xy averages to zero (−0.02 ± 0.27 per step, the mean is pure noise) and fluctuates by ±0.27, larger than any shear stress a flow would create in a simulation. The viscosity is not in the average but in how long a fluctuation lasts. Note that the diagonal pressure of Lab 3.8 is the same formula with x and x instead of x and y.

Step 2

Green–Kubo by hand

Why: The stress autocorrelation C(t) = ⟨P_xy(0)P_xy(t)⟩ starts at the size of the fluctuations and decays as the liquid relaxes. The longer it takes, the more viscous the liquid. Its integral, times V/k_BT, is η: the same recipe as D from the VACF in Lab 6.7.

P_xy every 0.1 time units (V = 100, k_BT = 1): 0.30 0.24 0.20 0.10 0.02 −0.06 −0.10 −0.08 −0.02 0.04 lag 0: C = 0.02200 (mean of 10 products) lag 1: C = 0.01729 (9) lag 2: C = 0.01045 (8) lag 3: C = 0.00120 (7) lag 4: C = −0.00653 (6) trapezoid, lags 0–4: 0.1 × (0.01100 + 0.01729 + 0.01045 + 0.00120 − 0.00327) = 0.003667 η = V/k_BT × 0.003667 = 100 × 0.003667 = 0.367 Einstein: A(t) = ∫P_xy dt = 0, 0.030, 0.054, 0.074, 0.084, ... ⟨ΔA²⟩ at lags 1, 2, 3: 0.000220, 0.000733, 0.001332 slope (lags 2–3) = 0.00600 -> η = V/(2k_BT) × 0.00600 = 0.300

What the numbers say: Both routes are a few multiplications. The factor V is the important difference from diffusion: the viscosity is a property of the whole box, one number per time origin, like the conductivity in Lab 6.7, so it is a collective quantity and as noisy as one. With only ten numbers the two routes disagree (0.367 vs 0.300); the question of where to stop the integral is already visible, since C turns negative at lag 4.

Step 3

The LJ liquid: where to stop the integral

Why: Now the real data: 100 000 steps, all five stress components averaged. The running integral η(t) should rise and level off once C(t) has decayed. In practice the noise in C(t) keeps adding to the integral, so the plateau has to be chosen.

C(0) = 0.07218; C(t)/C(0) = 0.307 (t = 0.1), 0.101 (0.2), 0.030 (0.5)
upper limit t0.050.10.20.51.01.52.04.08.0
running η(t)0.971.521.952.272.402.432.462.863.66
5 blocks of 20 000 steps, integral to t = 1.5: 2.06 2.75 2.22 2.57 2.51 -> η = 2.42 ± 0.12 Einstein (slope of ⟨ΔA²⟩ for t = 1–3): η = 2.44

What the numbers say: Most of the viscosity comes from the first 0.2 time units, where the stress correlation decays; by t = 1–2 the integral sits at 2.40–2.46, and both routes agree on about 2.42. Beyond that the integral drifts (2.86 at t = 4, 3.66 at t = 8), not because the liquid has a long memory but because the noisy tail of C(t) is integrated too: the random walk of the noise wins. Practical rules: plot η(t), choose the plateau where C(t) has decayed to the noise, and take the error bar from independent blocks or runs (here ±0.12). In viscous liquids such as ionic liquids the plateau comes much later, and fitting C(t) or using many independent runs becomes necessary.

Step 4

Cross-checks: Yeh–Hummer and Stokes–Einstein

Why: A viscosity should be consistent with diffusion. Two checks: the box-size dependence of D in Lab 6.9 must follow the Yeh–Hummer slope ξk_BT/(6πη), and Stokes–Einstein, D = k_BT/(cπηR), should give a sensible particle radius R.

predicted Yeh–Hummer slope: ξ T / (6π η) = 2.837 / (6π × 2.42) = 0.0621 D from Lab 6.9 + 0.0621/L: N = 32: 0.0440 + 0.0182 = 0.0622 (box too small) N = 108: 0.0567 + 0.0121 = 0.0688 N = 256: 0.0596 + 0.0091 = 0.0687 N = 500: 0.0615 + 0.0073 = 0.0688 (fit of the three larger boxes alone gave η = 2.43) Stokes–Einstein with D_∞ = 0.0688: stick (c = 6): R = 1/(6π × 2.42 × 0.0688) = 0.318 σ (diameter 0.64σ) slip (c = 4): R = 1/(4π × 2.42 × 0.0688) = 0.478 σ (diameter 0.96σ)

What the numbers say: Two independent routes agree: the viscosity from stress fluctuations (2.42) predicts exactly how D changes with box size (the three larger boxes collapse onto 0.0688), and the slope of D vs 1/L gives back 2.43. Stokes–Einstein, a formula for a sphere in a continuum, works surprisingly well for atoms if the "slip" boundary condition is used: it gives a diameter of 0.96σ, almost exactly the LJ size. With "stick" the particle comes out too small. Limitation: Stokes–Einstein is a continuum law; it fails for small solutes in large solvents, in supercooled liquids, and for ions with strong local structure, which is exactly where deviations from it are interesting.

Step 5

Convergence: why viscosity needs long runs

Why: Viscosity, like conductivity, is a property of the whole box, so it does not get more samples from more atoms. How long must the run be for a given precision, and how much do the five equivalent stress components help?

run length (time units)spread of η: 5 componentsspread: 1 componentpieces
200.721.1920
400.380.7410
800.280.685
2000.070.382 (unreliable)
target 5 % (±0.12): about 400 time units with 5 components (100 000 steps here; spread falls roughly as 1/√length) 1 component instead of 5: spread about √5 ≈ 2.2 times larger

What the numbers say: A run of 20 time units, plenty for D of this liquid, gives η only to ±30 %; it takes about 400 time units (100 000 steps) to reach ±5 %, and the error falls only as one over the square root of the run length. Using all five shear components is free and is worth five times more simulation. Larger boxes do not help much: the fluctuations shrink as 1/V while the V in front of the integral grows, so the relative noise is about the same. For viscous liquids, where the stress correlation lasts 100–1000 times longer, people use many independent runs, the "time-decomposition" method, or nonequilibrium shear (NEMD) instead.

Step 6

Units: from LJ to mPa s

Why: Like every reduced quantity, the viscosity becomes physical once we pick a substance. For argon the LJ unit of viscosity is √(mε)/σ².

argon: m = 6.6335×10⁻²⁶ kg, ε = 1.6540×10⁻²¹ J, σ = 3.405×10⁻¹⁰ m unit = √(m ε) / σ² = √(1.0972×10⁻⁴⁶) / 1.1594×10⁻¹⁹ = 9.035×10⁻⁵ Pa s η* = 2.42 -> η = 2.42 × 9.035×10⁻⁵ = 0.219 mPa s (at T = 119.8 K and 0.8/σ³ = 1.344 g/cm³) real units (GROMACS/LAMMPS): pressure in bar or atm, V in nm³ or ų, time in ps or fs: check every factor, 1 bar = 10⁵ Pa, 1 mPa s = 1 cP

What the numbers say: A liquid of LJ argon at these conditions comes out at about 0.22 mPa s, a quarter of water's viscosity, a sensible value for a simple liquid of small atoms (with our shortened cutoff it is a model, not a precise prediction for argon). In real-unit codes the Green–Kubo prefactor V/k_BT and the pressure units are the usual sources of factor-of-10⁵ mistakes; checking a code's viscosity on the LJ liquid against a published value is a good first test. LAMMPS: fix ave/correlate on the pressure tensor; GROMACS: gmx energy -vis.

Summary

method / checkmerit (number)limitation (number)
Green–Kubo (stress ACF)η = 2.42 ± 0.12 from one runintegral drifts after t ≈ 2 (3.66 at t = 8)
Einstein (∫P dt)²2.44, agreessame noise; slope region to choose
Yeh–Hummer slopelarger boxes give 2.43tiny box (32 atoms) gives a wrong 1.50
Stokes–Einstein (slip)diameter 0.96σ from η and Dcontinuum law; fails for small solutes, ions
5 stress components√5 smaller error for free—
run length±5 % after ~400 time units±30 % after 20 (enough for D)