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.

12. Free energy and chemical potential: Widom insertion and thermodynamic integration

School of Engineering and Digital Sciences, Nazarbayev University

Track: core  ·  Prerequisites: Chapters 9–10

This chapter builds and verifies the core algorithms for free energy and chemical potential: widom insertion and thermodynamic integration in plain Python and NumPy, checking every result against an exact statistical-mechanics limit or published benchmark.

12.1 Physical principles and governing equations

Widom’s test-particle insertion method computes the excess chemical potential μex\mu_{\text{ex}} from a standard NVTNVT ensemble by probing random ghost insertions:

βμex=−ln⁡⟨e−βΔUtest⟩N.(12.1)\beta \mu_{\text{ex}} = -\ln \left\langle e^{-\beta \Delta U_{\text{test}}} \right\rangle_N. \tag{12.1}

In the low-density limit (ρ→0\rho \to 0), the virial expansion gives the exact analytical asymptote βμex(ρ,T)→2B2(T)ρ\beta \mu_{\text{ex}}(\rho, T) \to 2 B_2(T)\rho, where B2(T)=2π∫0∞(1−e−βu(r))r2 drB_2(T) = 2\pi \int_0^\infty (1 - e^{-\beta u(r)}) r^2\,dr is the second virial coefficient.

12.2 Inside the algorithm

12.3 Checks

T*=2.0: B2(T) = -1.312; Widom mu_ex = [-0.09  -0.207 -0.293 -0.381] vs. 2*T*B2*rho = [-0.105 -0.262 -0.42  -0.63 ]
<Figure size 1120x430 with 2 Axes>

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

12.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. Boyle temperature root: Locate the exact LJ Boyle temperature where B2(TB∗)=0B_2(T_B^*) = 0 (TB∗≈3.42T_B^* \approx 3.42).

  2. Hard-sphere high-TT limit: Verify that as T∗→50T^* \to 50, B2(T∗)>0B_2(T^*) > 0 approaches the repulsive core volume.

  3. High-density Widom breakdown: Explain why Widom insertion suffers severe sampling noise at liquid density ρ∗>0.85\rho^* > 0.85 (almost every ghost particle overlaps a core).

Worked solutions are provided in 12_solutions.ipynb.

Suggested references

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

  • U. Wolff, Phys. Rev. Lett. 62, 361–364 (1989).