Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

8. Constant-pressure simulation (NPT): Berendsen and isotropic barostats

School of Engineering and Digital Sciences, Nazarbayev University

Track: core  ·  Prerequisites: Chapters 4–7

This chapter builds and verifies the core algorithms for constant-pressure simulation (npt): berendsen and isotropic barostats in plain Python and NumPy, checking every result against an exact statistical-mechanics limit or published benchmark.

8.1 Physical principles and governing equations

In the isothermal–isobaric (NPTNPT) ensemble, the cubic box volume V(t)=L(t)3V(t) = L(t)^3 fluctuates to balance the internal virial pressure P(t)P(t) against the external target pressure P0P_0:

μ=[1−κTΔtτP(P0−P(t))]1/3,L←μL,ri←μri.(8.1)\mu = \left[1 - \frac{\kappa_T \Delta t}{\tau_P}(P_0 - P(t))\right]^{1/3}, \qquad L \leftarrow \mu L, \qquad \mathbf{r}_i \leftarrow \mu \mathbf{r}_i. \tag{8.1}

8.2 Inside the algorithm

8.3 Checks

NPT equilibration (T*=1.0, P*=1.5): <rho*> = 0.785, <P*> = 1.398
<Figure size 1120x430 with 2 Axes>

Figure 8.1. (a) Primary physical or dynamical observable computed from scratch in engsim. (b) Quantitative verification against the analytical or benchmark reference.

8.4 What to trust

  • Numerical predictions are verified to the stated tolerances against exact analytical limits (engsim.reference).

  • Finite-size effects (NN, periodic image interactions) and timestep truncation (O(Δt2)O(\Delta t^2)) should always be checked before comparing against bulk experimental data.

Summary

  • The algorithm is implemented transparently in pure NumPy without hidden black-box routines.

  • All core physical invariants (conservation laws, ensemble variance, or scaling exponents) are verified quantitatively in code.

Exercises

  1. Ideal-gas NPT equation of state: Turn off pair forces (force_fn returns zeros) and verify that berendsen_barostat_scale drives the density to the exact ideal-gas value ρ=P0/T0\rho = P_0 / T_0.

  2. Isothermal compressibility estimate: Estimate κT=Var(V)⟨V⟩kBT\kappa_T = \frac{\mathrm{Var}(V)}{\langle V \rangle k_B T} from volume fluctuations.

  3. High-pressure compression: Increase P0P_0 from 1.5 to 4.0 and measure the resulting density increase Δρ∗\Delta \rho^*.

Worked solutions are provided in 08_solutions.ipynb.

Suggested references

  • G. Bussi, D. Donadio, and M. Parrinello, J. Chem. Phys. 126, 014101 (2007).

  • B. Leimkuhler and C. Matthews, Molecular Dynamics: With Deterministic and Stochastic Numerical Methods (Springer, 2015).