Lab 2.8 · 35 min

Lab: packing and equilibrating a liquid

Lab 2.7 started from a neat lattice of 9 atoms. A real project starts from a target density and a few hundred or thousand molecules that must be put in a box without overlapping, relaxed, heated and equilibrated before anything is measured. We do every stage for 256 Lennard-Jones atoms (liquid argon): box size from the density, random insertion and why it fails, steepest descent by hand, NVT and NPT, and three tests that tell you when the system is ready.

The setup

The recipe used by every real setup (Packmol, gmx insert-molecules, LAMMPS create_atoms random):

1. box size from the target density 2. place molecules without bad overlaps 3. minimize the energy (remove the remaining clashes) 4. NVT: give velocities, heat to the target temperature 5. NPT: let the density find its own value (if unknown) 6. decide when equilibrium is reached; only then measure

System: N = 256 LJ atoms, cutoff 2.5σ, k_BT = 0.722 and ρ* = 0.8442 (the liquid near the triple point, the classic test state). Bussi thermostat (τ = 0.5), C-rescale barostat, Δt = 0.005. Argon: σ = 3.405 Å, ε = 0.996 kJ/mol.

Step 1

Box size from the target density

Why: Experiments give density in g/cm³; a simulation needs a number of molecules and a box length. The conversion is one line, but getting it wrong by a few percent shifts every property you compute (pressure most of all).

volume per molecule v = M / (ρ N_A) argon: M = 39.948 g/mol, ρ = 1.40 g/cm³ v = 39.948 / (1.40 × 6.022×10²³) = 4.738×10⁻²³ cm³ = 47.38 ų (1 cm³ = 10²⁴ ų) 256 atoms: V = 12 130 ų, L = V^(1/3) = 22.98 Å in LJ units: L = 22.98/3.405 = 6.748 σ, ρ* = 0.833 water: M = 18.015, ρ = 0.997 v = 30.00 ų; 1000 molecules: L = 31.07 Å 1 mol/kg NaCl in 500 waters: n = 500 × 0.018015 kg/mol × 1 mol/kg = 9.0 ion pairs density of the solution: not known in advance

What the numbers say: Pure liquids with a known density can be built at the right size directly. For a solution, a mixture or a new force field, the density is part of the answer: build at a guess, then let NPT (Step 4) find it. Our test state ρ* = 0.8442 is the same liquid as argon at 1.42 g/cm³.

Step 2

Random positions: why they fail, and why a tolerance only partly helps

Why: The obvious way to fill a box is to put each atom at a random point. In a dense liquid, that makes many atoms land almost on top of each other, and the LJ repulsion grows as r⁻¹².

expected pairs closer than 0.8σ for random points: (N/2) × ρ × (4/3)π(0.8)³ = 128 × 0.8442 × 2.145 = 232 measured (one random box): 231 closest pair: r = 0.077σ U/N = 3.9×10¹¹, largest force = 1.5×10¹⁶ (equilibrium liquid: U/N ≈ −5, forces ≈ 10) NVE, Δt = 0.005, straight from this start: step 1: T = 3.8×10²⁴ step 50: T = 2.4×10³⁰ (target 0.722)

Insertion with a tolerance: a new atom is refused if it is closer than d to any placed atom (give up after 20 000 refusals in a row).

d (σ)placedtrialsρ* reachedpacking of d-spheres
0.82561 6210.8440.226
0.925620 7360.8440.322
1.0203119 6240.6690.351
1.114467 7460.4750.331
packing fraction φ = ρ × (π/6) d³ random insertion jams at φ ≈ 0.38 (no room left for one more) d = 1.0 at ρ* = 0.8442 needs φ = 0.8442 × 0.524 = 0.442 > 0.38

What the numbers say: Fully random positions give forces 10¹⁵ times too large and the first step sends atoms flying. A tolerance removes the worst clashes, but a tolerance equal to the atom size cannot reach a liquid density: random filling jams long before. That is why Packmol uses a tolerance smaller than the molecules (2 Å) and why a minimization always follows. A lattice start (Lab 2.7) avoids the problem entirely, at the price of having to melt it.

Step 3

Steepest descent by hand

Why: Minimization moves every atom downhill along its force until no force is large. GROMACS uses a simple, robust rule: move the atom with the largest force by a step h, others in proportion; grow h when the energy falls, cut it hard when it rises.

x_new = x + h F / |F|max U fell: accept, h → 1.2 h U rose: reject, h → 0.2 h dimer, r = 0.9: U = 6.6361, F = 138.66 on each atom both atoms move h apart, so r grows by 2h iter h new r U new decision 1 0.0100 0.9200 4.2826 accept 2 0.0120 0.9440 2.3349 accept 3 0.0144 0.9728 0.8493 accept 4 0.0173 1.0074 −0.1648 accept 5 0.0207 1.0488 −0.7476 accept (the minimum is at 2^(1/6) = 1.1225)

The random 256-atom box, stopped at the GROMACS default emtol = 10 kJ/mol/nm = 10/(0.996/0.3405) = 3.42 ε/σ:

iterationU/N|F|maxh
03.9×10¹¹1.6×10¹⁶0.010
52.1×10⁷5.7×10¹⁰0.025
201341.1×10⁵0.38
50−4.97810.070
100−5.78310.082
160 (done)−6.002.2
closest pair after minimization: 1.05σ NVE from here with velocities at T = 0.722: 1000 steps: E/N −4.9182 → −4.9177 (stable) but T drops to 0.401 near a minimum, kinetic energy is shared equally with potential energy (equipartition): T → 0.722 / 2 = 0.361 for a harmonic system 0.401 here (the liquid is not harmonic)

What the numbers say: Steepest descent removed every clash in 160 iterations; the start that exploded now conserves energy. But a minimized structure is not an equilibrium liquid: it sits at T = 0, at an energy (−6.00) far below the liquid at T = 0.722 (−5.20), and velocities given at T lose about half their energy to the potential. That is why minimization is always followed by a thermostatted run, not by a measurement.

Step 4

NVT from two starts, then NPT to find the density

Why: The thermostat brings the temperature to the target within a few τ. Whether the structure follows depends on the start: a lattice has to melt, a minimized random box is already disordered. The FCC order parameter (1 on the lattice, about 1/N in a liquid) shows how far along the melting is.

tFCC: U/NTFCC orderrandom: U/NT
0−6.3310.7170.999−5.9930.723
1−5.5830.5520.528−5.3500.700
2−5.4800.6290.450−5.2320.682
5−5.3860.7320.411−5.1420.708
10−5.1550.7370.124−5.2700.696
20−5.2580.7030.009−5.1750.751
40−5.1530.7490.009−5.1980.717
FCC: T dips to 0.55 at t = 1: melting absorbs heat the crystal survives at order ≈ 0.4 until t ≈ 5–10 NVT pressure (second halves, 4 runs): P* = 0.874 NPT test: start at ρ* = 0.70 (easy to pack), C-rescale at P* = 0.874, τ_p = 2 t ρ* P 0 0.700 −4.78 1 0.787 −0.37 5 0.832 0.61 10 0.861 0.66 50 0.835 0.91 second half: ρ* = 0.8421 ± 0.0019 (true 0.8442)

What the numbers say: The temperature is right after t ≈ 1 in both runs, but the lattice start keeps crystal order until t ≈ 10: temperature alone says nothing about whether the structure has relaxed. NPT started 17% too dilute and found the density to 0.25% (1 error bar) within t ≈ 10. This is how the density of the NaCl solution in Step 1 would be found.

Step 5

When is it equilibrated? Three tests

Why: Everything before equilibrium must be thrown away, and everything after kept. Throwing away too little biases the average; too much wastes data. The tests below replace “it looks flat”.

(i) Choose t₀ to maximize the number of independent samples after it: N_eff = (n − n₀)/g, with g the statistical inefficiency of the data after t₀ (Lab 6.8).

seriest₀g after t₀N_eff
U/N, FCC start8.015.242
U/N, random start2.016.646
FCC order, FCC start10.021.927
ρ*, NPT from 0.7011.318.243

(ii) Half-split: compare the means of the first and second halves of what is kept.

U/N, FCC start, all data: −5.302 ± 0.084 vs −5.190 ± 0.012: 1.3 errors, "passes" U/N, FCC start, t > 12: −5.189 ± 0.016 vs −5.195 ± 0.008: 0.3 errors the first test should have failed: the melting trend makes the first half look very noisy, which inflates its error bar

(iii) Independent replicas (different starts and seeds), t > 12 kept:

startU/NP*
FCC−5.192 ± 0.0090.89 ± 0.05
random + minimized−5.200 ± 0.0090.87 ± 0.05
FCC, seed 2−5.202 ± 0.0160.84 ± 0.09
random + minimized, seed 2−5.204 ± 0.0100.83 ± 0.06
spread of the four U/N means: 0.005 typical error bar: 0.010 → consistent

What the numbers say: Different quantities equilibrate at different times: the energy of the lattice start at t₀ ≈ 8, its structure at t₀ ≈ 10, the random start already at 2. Discard by the slowest quantity you care about. The half-split test can be fooled by the very trend it is meant to detect, so look at the trace as well. Replicas from different starts are the strongest test: if they agree within their error bars, no memory of the start is left.

Summary

stagewhat goes wrong without itnumber
box from densitywrong pressure, wrong everythingL = 22.98 Å for 256 argon
careful insertionoverlaps: forces 10¹⁶, T = 10²⁴ after 1 step231 pairs closer than 0.8σ
tolerance dd ≥ σ jams below liquid densityd = 1.0 stops at ρ* = 0.67
minimizationexplosion; it does not equilibrate160 iterations, U/N −6.00 (T = 0)
NVTT right in t ≈ 1, structure in t ≈ 10FCC order 0.999 → 0.009
NPTunknown density stays wrong0.70 → 0.8421 ± 0.0019 (true 0.8442)
equilibration testsbiased averagest₀ = 2–11; replicas agree to 0.005