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.

4. Structure and thermodynamics in NVE: equipartition, virial pressure, and g(r)

School of Engineering and Digital Sciences, Nazarbayev University

Track: core  ·  Prerequisites: Chapters 1–3, statistical mechanics

This chapter builds and verifies the core algorithms for structure and thermodynamics in nve: equipartition, virial pressure, and g(r) in plain Python and NumPy, checking every result against an exact statistical-mechanics limit or published benchmark.

4.1 Physical principles and governing equations

In an NVENVE simulation, instantaneous temperature follows equipartition Tinst=2K3N−3T_{\text{inst}} = \frac{2K}{3N - 3} (removing 3 center-of-mass momentum degrees of freedom), and hydrostatic pressure follows the Clausius virial theorem:

P=ρTinst+13V∑i<jrij⋅fij.(4.1)P = \rho T_{\text{inst}} + \frac{1}{3V} \sum_{i < j} \mathbf{r}_{ij} \cdot \mathbf{f}_{ij}. \tag{4.1}

Local liquid structure is quantified by the radial distribution function g(r)g(r) normalized by the ideal-gas shell count 43π[(r+Δr)3−r3]ρ\frac{4}{3}\pi[(r+\Delta r)^3 - r^3]\rho, and correlated trajectory uncertainties are estimated by Flyvbjerg–Petersen blocking.

4.2 Inside the algorithm

4.3 Checks

NVE fluid (rho=0.80): <T*> = 0.741, <P*> = 0.023, peak g(r) = 2.50
<Figure size 1120x430 with 2 Axes>

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

4.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 virial limit: Simulate a dilute gas (ρ=0.01,T=2.0\rho = 0.01, T = 2.0) and verify that ⟨P⟩≈ρT\langle P \rangle \approx \rho T to within 5%5\%.

  2. Coordination number: Integrate nc=4πρ∫0rmin⁡r2g(r) drn_c = 4\pi\rho \int_0^{r_{\min}} r^2 g(r)\,dr up to the first minimum of g(r)g(r) to obtain the first-shell coordination number (~12 in dense LJ).

  3. Block error on uncorrelated noise: Verify that flyvbjerg_petersen_block_errors stays flat across block sizes for i.i.d. Gaussian noise.

Worked solutions are provided in 04_solutions.ipynb.

Suggested references

  • D. Frenkel and B. Smit, Understanding Molecular Simulation (3rd ed., Academic Press, 2023).

  • M. P. Allen and D. J. Tildesley, Computer Simulation of Liquids (2nd ed., Oxford University Press, 2017).