The mechanics of particles and the statistical mechanics built on it: entropy and temperature, the Boltzmann distribution, ensembles and free energy, fluctuations, phase transitions and liquids.
0 of 8 read
Mechanics
Newtonian and Hamiltonian mechanics, phase space, and quantised energy levels.
1Classical mechanics and phase space
The classical mechanics every simulation rests on: velocity and momentum, Newton's second law, forces as slopes of a potential, conservation of energy, and phase space, the map in which a whole motion becomes a single curve. Hamilton's equations included.
about 12 min read
Why start with a ball on a hill
A molecular dynamics simulation of a protein or a crystal follows millions of atoms, but each atom obeys the same laws as a single ball rolling in a valley. If you understand one particle moving in one dimension, its position, velocity, momentum, force and energy, and the picture called phase space, you understand what every MD code computes, and why its results can be trusted. This chapter builds that picture.
Describing motion
The positionx(t) says where the particle is at time t. Its rate of change is the velocity, and the rate of change of velocity is the acceleration:
v=dtdx=x˙,a=dtdv=x¨.
Newton recognised that the quantity a force changes is not velocity alone but velocity weighted by how much matter is moving, the momentum:
The second law is a differential equation: given the position and velocity now, and the force as a function of position, it determines the entire future and past. This determinism is what lets a computer predict motion step by step.
Forces from a landscape
For atoms, forces are not arbitrary: they come from a potential energyV(x), a landscape that depends on where the particles are (the chapter on potential energy surfaces shows where atomic landscapes come from). The force is the downhill slope:
Three landscapes appear in the lab. A spring, V=21kx2, gives a force F=−kx that always pulls back towards the centre (Hooke’s law), the model of a chemical bond near equilibrium. A double well has two valleys separated by a barrier, the simplest model of a chemical reaction, a conformational change or a phase transition. A pendulum, V=1−cosx, is a model of a rotating chemical group with a periodic barrier.
A particle in a potential, and its path in phase space
Loading the interactive figure…
Left: the landscape V(x), the particle, its force (orange arrow) and velocity (teal arrow), and a bar showing kinetic (K) and potential (V) energy. Right: phase space, momentum against position. Click in the phase plane to start a new motion; add friction and watch the trajectory spiral inwards.
Energy, and why it is conserved
Watch the energy bar while the particle moves. As it rolls downhill, potential energy turns into kinetic energyK=21mv2=p2/2m; as it climbs, kinetic turns back into potential; and without friction their sum never changes.
Conservation gives a lot for free. The particle can only be where V(x)≤E; the points where V(x)=E are turning points, where it momentarily stops and reverses. With E below the barrier of the double well, it is trapped in one valley forever; above it, it crosses back and forth. In molecular dynamics, the fact that a correct integrator keeps the total energy constant is the first and most important test of a simulation (the MD chapter).
Add friction in the lab: energy now leaks away, and the particle settles into a minimum. That is what an energy minimisation does to a structure, and what a thermostat has to counteract when it adds the right amount of random kicks back.
Phase space
Here is the central picture of this volume. The state of the particle at any instant is not its position alone, because two particles at the same place moving in opposite directions have different futures. The complete state is the pair (x,p), a point in a plane called phase space. Newton’s law moves that point along a curve, the trajectory, and because the state determines the future uniquely, trajectories never cross.
Since energy is conserved, the trajectory stays on a curve of constant E: the energy contourp=±2m(E−V(x)). In the lab:
the spring gives ellipses: the particle oscillates forever around the centre;
the double well shows two families of loops, one inside each valley, enclosed by a figure-of-eight called the separatrix; outside it, large loops circle both valleys;
the pendulum shows closed loops (swinging) inside wavy open curves (rotating all the way round);
friction turns closed loops into spirals that end at a minimum.
For N atoms in three dimensions phase space has 6N dimensions, three positions and three momenta per atom, and a molecular dynamics run traces one trajectory through it. Statistical mechanics, the subject of the chapters after next, is the art of saying what fraction of that enormous space a system visits.
Hamilton’s formulation
Writing the energy as a function of position and momentum, H(x,p)=p2/2m+V(x), called the Hamiltonian, puts Newton’s law in a beautifully symmetric form:
Hamiltonian flow has a deep property, Liouville’s theorem: a small blob of initial conditions changes shape as it flows but never changes its area (volume, in many dimensions). This is why the integrators used in molecular dynamics are built to be symplectic, preserving phase-space volume exactly, and it is the foundation on which statistical mechanics builds its probabilities.
Check yourself
A particle sits at a point where V(x) has its minimum. What is the force on it?
F=−dV/dx vanishes at any minimum or maximum of the potential.
In the harmonic potential, what shape is a trajectory in phase space?
p2/2m+21kx2=E is the equation of an ellipse. With friction it becomes a spiral.
Why can two different phase-space trajectories never cross?
Newton’s equations are first order in phase space: one state, one future.
In the double well, the particle’s energy is just below the barrier top. What happens?
It can only reach positions where V(x)≤E. In real molecules thermal kicks occasionally lift it over the barrier: that is a rare event, the subject of rate theory and enhanced sampling.
References and further reading
L. D. Landau and E. M. Lifshitz, Mechanics, 3rd ed., Course of Theoretical Physics vol. 1, Butterworth-Heinemann (1976), chapters 1–2 and 7.
J. R. Taylor, Classical Mechanics, University Science Books (2005), chapters 1–4 and 13 (Hamiltonian mechanics).
H. Goldstein, C. P. Poole and J. L. Safko, Classical Mechanics, 3rd ed., Addison-Wesley (2002), chapters 8–9.
M. E. Tuckerman, Statistical Mechanics: Theory and Molecular Simulation, 2nd ed., Oxford University Press (2023), chapter 1 (classical mechanics, phase space and Liouville’s theorem).
R. P. Feynman, R. B. Leighton and M. Sands, The Feynman Lectures on Physics, vol. I, chapters 9 and 14 (Newton’s laws, work and potential energy), free online at feynmanlectures.caltech.edu.
2Quantum energy levels
Why energy comes in steps: the Schrödinger equation, the particle in a box, the harmonic oscillator and zero-point energy, how quantum turns into classical at high energy, and how temperature populates the levels. The bridge from quantum mechanics to statistical mechanics.
Molecular dynamics moves nuclei with Newton’s laws, as in the previous chapter. Yet the forces between atoms come from electrons, which obey quantum mechanics, and even the nuclei are quantum particles. This chapter answers two questions every simulator should be able to answer. Where does quantisation come from? And when is it safe to forget about it?
Waves of matter
In 1924 de Broglie proposed that every particle with momentum p behaves like a wave of wavelength λ=h/p, where h=6.626×10−34 J s is Planck’s constant. For a cricket ball the wavelength is absurdly small; for an electron in an atom it is about the size of the atom, and wave behaviour dominates. The state of a quantum particle is described by a wavefunctionψ(x), and the probability of finding the particle near x is ∣ψ(x)∣2dx (Born’s rule).
States of definite energy satisfy the time-independent Schrödinger equation, in which the classical energy p2/2m+V becomes an operator:
The equation itself is not mysterious: it says that a wave curves more sharply where the kinetic energy E−V is larger. What creates quantisation is the boundary condition. A confined wave has to fit inside its container, like the standing wave on a guitar string, and only a discrete set of wavelengths do.
The particle in a box
Trap a particle between two impenetrable walls, V=0 for 0<x<L and V=∞ outside. The wavefunction must vanish at both walls, so it must be a sine wave with a whole number of half-wavelengths in the box:
Three consequences matter for materials. Energy is quantised. The lowest energy is not zero: squeezing a particle into a small space forces short wavelengths and therefore kinetic energy, the reason electrons do not collapse into the nucleus. And the spacing falls as 1/L2, so in a big box the levels are so close that the energy looks continuous. Quantum dots exploit the 1/L2 law: the smaller the nanocrystal, the larger its gap and the bluer its light.
The harmonic oscillator
Near the bottom of any valley the potential is a parabola, V=21mω2x2, so the harmonic oscillator describes every chemical bond vibration and every phonon in a crystal. Its levels are equally spaced:
Energy levels, wavefunctions and thermal populations
Loading the interactive figure…
Left: the potential (blue), the levels (dashed) and each level’s wavefunction drawn at its energy; the highlighted level is orange. Switch to |ψ|² and turn on the classical overlay to compare with where a classical particle of the same energy spends its time. The bars show how temperature shares the system among the levels (units with ħ = m = 1).
Zero-point energy is measurable and important. It is why liquid helium does not freeze at normal pressure, it shifts reaction barriers and bond lengths, and it makes deuterated molecules react more slowly than ordinary ones (the kinetic isotope effect), because the heavier isotope has a lower 21ℏω.
From quantum to classical
Highlight a high level in the lab and switch to ∣ψ∣2. The quantum probability oscillates rapidly, but its average follows the teal dashed curve, the classical probability density: a classical oscillator moves fastest through the centre and slowest near the turning points, so it spends most of its time near the edges,
ρcl(x)=πa2−x21,a=amplitude.
At high quantum number the two agree, as Bohr’s correspondence principle demands. Quantum effects matter when the level spacing is comparable to the energy available, and that brings temperature in.
Temperature populates the levels
At temperature T a system in contact with its surroundings occupies level n with a probability given by the Boltzmann distribution, derived in the chapter on Boltzmann and Maxwell:
Slide the temperature in the lab. When kBT≪ℏω almost everything sits in the ground state, and the oscillator is frozen: it cannot absorb heat, and its thermal energy is pinned at the zero-point value. When kBT≫ℏω many levels are populated, and the mean energy approaches the classical value kBT (for the box, kBT/2), as the statistics row shows.
The numbers for real molecules are revealing. A C–H stretch vibrates at about 3000 cm⁻¹, so ℏω/kBT≈14 at room temperature and the ground state holds 99.9999 % of the molecules: that vibration is completely quantum. A soft torsion or lattice mode at 200 cm⁻¹ has ℏω/kBT≈1, and is close to classical. Einstein used exactly this freezing-out to explain in 1907 why the heat capacity of solids falls at low temperature.
Is classical molecular dynamics allowed?
Classical MD treats nuclei as points obeying Newton’s laws, so it gives each vibration kBT of energy whether or not it should. A useful yardstick is the thermal de Broglie wavelength, the typical quantum blur of a particle at temperature T:
The verdict is that classical dynamics of nuclei is accurate for heavy atoms and for structure, diffusion and most thermodynamics at room temperature. It fails for light atoms (hydrogen, lithium), for high-frequency vibrations, for low temperatures and for heat capacities. The remedies are to constrain stiff bonds (as most biomolecular force fields do with bonds to hydrogen), to apply quantum corrections afterwards, or to use path-integral MD, which represents each quantum nucleus as a ring of classical beads.
Check yourself
You halve the length of a box. What happens to its energy levels?
En∝1/L2, so halving L multiplies every level by 4. This is why small quantum dots emit bluer light.
What is the lowest energy of a quantum harmonic oscillator?
The zero-point energy 21ℏω survives even at absolute zero.
A vibration has ℏω=10kBT. Which statement is right?
The first excited level is populated with relative weight e−10≈5×10−5; classical mechanics would wrongly assign it kBT.
For which system is classical MD of the nuclei most questionable at room temperature?
Hydrogen is light, so its thermal wavelength is about an ångström and tunnelling and zero-point energy matter. Path-integral methods are used for such problems.
References and further reading
D. J. Griffiths and D. F. Schroeter, Introduction to Quantum Mechanics, 3rd ed., Cambridge University Press (2018), chapter 2 (infinite square well, harmonic oscillator).
P. Atkins and R. Friedman, Molecular Quantum Mechanics, 5th ed., Oxford University Press (2011), chapters 2–3.
D. V. Schroeder, An Introduction to Thermal Physics, Addison-Wesley (2000), chapter 6 (Boltzmann statistics, equipartition and its failure).
A. Einstein, “Die Plancksche Theorie der Strahlung und die Theorie der spezifischen Wärme”, Annalen der Physik22, 180 (1907).
L. de Broglie, Recherches sur la théorie des quanta, thesis, Paris (1924); Annales de Physique3, 22 (1925).
M. E. Tuckerman, Statistical Mechanics: Theory and Molecular Simulation, 2nd ed., Oxford University Press (2023), chapter on quantum statistical mechanics and path integrals.
T. E. Markland and M. Ceriotti, “Nuclear quantum effects enter the mainstream”, Nature Reviews Chemistry2, 0109 (2018).
Statistical mechanics
Entropy and temperature, the Boltzmann distribution, ensembles and free energy, fluctuations, phase transitions and liquid structure.
3Entropy and temperature
Statistical mechanics from scratch: microstates and macrostates, counting them in an Einstein solid, why energy flows from hot to cold, entropy as S = k ln Ω, and temperature defined as the rate at which entropy grows with energy.
A glass of water contains about 1025 molecules. Following every one is hopeless, and also unnecessary: we want the temperature, the pressure, the heat capacity, whether ice melts. Statistical mechanics connects the microscopic world of quantum levels and phase-space trajectories to those few macroscopic numbers. The whole subject rests on a single idea, which this chapter makes concrete by counting.
Microstates and macrostates
A microstate is a complete specification of the system: which quantum level every particle occupies, or every position and momentum. A macrostate is what we measure: total energy, volume, number of particles. One macrostate corresponds to an enormous number of microstates, written Ω (the multiplicity).
The single assumption of statistical mechanics, the fundamental postulate, is that an isolated system in equilibrium is equally likely to be found in any of its accessible microstates. Everything else, including the second law of thermodynamics, follows by counting.
Counting energy in a solid
Einstein’s model of a solid treats each atom’s vibration as quantum harmonic oscillators with the same frequency, so energy comes in identical quanta ε=ℏω. A microstate says how many quanta each oscillator holds. With N oscillators and q quanta, the number of microstates is the number of ways to drop q identical balls into N boxes:
The ten microstates of the example are easy to list: (3,0,0) in three arrangements, (2,1,0) in six, and (1,1,1) in one. Multiplicities grow at a ferocious rate: 100 oscillators sharing 100 quanta already have about 5×1058 microstates.
Two solids in contact
Now put two solids, A and B, in thermal contact so that quanta can hop between them while the total q stays fixed. A macrostate is now “how many quanta are in A”, and since every microstate of the whole is equally likely, the probability of a macrostate is proportional to its multiplicity,
P(qA)∝ΩA(NA,qA)ΩB(NB,q−qA).
Two Einstein solids sharing energy
Loading the interactive figure…
Left: the probability of every way of splitting the quanta, computed exactly by counting; the orange line marks the current state. Right: the oscillators (blue borders belong to solid A, teal to solid B) and the history of q_A while quanta hop at random. Start with all the energy in A and let it go.
Press the button and watch. Every hop moves one quantum from a random oscillator to another random oscillator, and nothing in the rule prefers either solid. Yet the energy flows out of A until A’s share fluctuates around the peak of the probability curve, and it never comes back. For the default settings (60 and 40 oscillators, 100 quanta) the peak is at qA=60 with a spread of about ±7, while the probability of finding all 100 quanta back in A is about 5×10−15.
That is the second law of thermodynamics, and nothing more: energy flows to the macrostate with overwhelmingly more microstates, simply because there are overwhelmingly more ways to be there. Increase the sizes in the lab and the peak becomes narrower in relative terms, its width falling as 1/N. For 1023 oscillators the fluctuations are invisible and the macrostate behaves as if it were exact.
Entropy
Multiplicities multiply when systems are combined, Ω=ΩAΩB. It is more convenient to work with a quantity that adds, so Boltzmann defined the entropy as the logarithm of the multiplicity:
This equation is carved on Boltzmann’s tombstone in Vienna. Entropy is not a measure of “disorder” in any vague sense: it is the logarithm of a count.
Temperature
What decides where the peak lies? At the maximum of lnΩA+lnΩB, moving one quantum from B to A leaves the total unchanged, so
∂UA∂lnΩA=∂UB∂lnΩB.
The two solids are in equilibrium when this quantity is the same for both. That shared quantity is what a thermometer measures, and it defines temperature:
The lab prints the temperature of each solid, computed from the exact counts. Start with all energy in A: A is hot and B is cold. As quanta flow, the two temperatures move towards each other and meet where the probability peaks. Energy flows from hot to cold because the cold body gains more entropy per quantum than the hot body loses; the total entropy rises until it can rise no further.
From counting to thermodynamics
Everything in classical thermodynamics follows from S(U,V,N). Differentiating with respect to volume and particle number gives pressure and chemical potential,
dS=T1dU+TPdV−TμdN,
which is the thermodynamic identity dU=TdS−PdV+μdN. This isolated-system picture, fixed N, V and E, is the microcanonical ensemble, and it is exactly what an MD simulation without a thermostat samples (the NVE ensemble). For classical particles, Ω becomes the volume of the shell of phase space with energy E, measured in units of h3N.
Check yourself
How many microstates do 2 oscillators sharing 3 quanta have?
(33+2−1)=(34)=4: (3,0), (2,1), (1,2), (0,3).
In the lab, why does energy not flow back into solid A?
The dynamics is unbiased; the asymmetry is entirely in the counting.
Two systems are in contact. System 1 gains more entropy per joule than system 2 loses. Which way does heat flow?
Total entropy grows if energy moves into system 1, which therefore has the larger ∂S/∂U, that is the lower temperature. Heat flows from hot to cold.
What happens to the relative width of the probability peak as the solids get larger?
This is why thermodynamics works for macroscopic matter: fluctuations around the most probable macrostate become negligible.
References and further reading
D. V. Schroeder, An Introduction to Thermal Physics, Addison-Wesley (2000), chapters 2–3. The two-solid example here follows his treatment.
T. A. Moore and D. V. Schroeder, “A different approach to introducing statistical mechanics”, American Journal of Physics65, 26 (1997).
A. Einstein, “Die Plancksche Theorie der Strahlung und die Theorie der spezifischen Wärme”, Annalen der Physik22, 180 (1907).
L. Boltzmann, “Über die Beziehung zwischen dem zweiten Hauptsatze der mechanischen Wärmetheorie und der Wahrscheinlichkeitsrechnung respektive den Sätzen über das Wärmegleichgewicht”, Wiener Berichte76, 373 (1877).
F. Reif, Fundamentals of Statistical and Thermal Physics, McGraw-Hill (1965), chapters 2–3.
M. E. Tuckerman, Statistical Mechanics: Theory and Molecular Simulation, 2nd ed., Oxford University Press (2023), chapter 3 (the microcanonical ensemble).
4The Boltzmann distribution
From counting microstates to the most useful formula in statistical mechanics: the Boltzmann factor and the partition function, the Maxwell–Boltzmann distribution of speeds, equipartition of energy, and pressure from molecular collisions, all watched emerging in a simulated gas.
The previous chapter treated an isolated system: fixed energy, every microstate equally likely. Real samples, and most simulations, are instead in contact with surroundings at a fixed temperature, which can lend and borrow energy. What is the probability of finding a small system in a particular microstate then? The answer, the Boltzmann distribution, is used in every corner of chemistry and materials science.
Deriving the Boltzmann factor
Let a small system share energy with a huge reservoir, with total energy Etot fixed. When the system is in a particular microstate s with energy Es, the reservoir has energy Etot−Es, and the combined system is still isolated, so every joint microstate is equally likely. The probability of s is therefore proportional to the number of reservoir microstates compatible with it:
P(s)∝ΩR(Etot−Es)=eSR(Etot−Es)/kB.
Because the reservoir is huge, Es is a tiny change for it, and a first-order Taylor expansion is exact in the limit: SR(Etot−Es)≈SR(Etot)−Es∂SR/∂E=SR(Etot)−Es/T. The constant first term cancels on normalising, which leaves one of the great results of physics:
This is the canonical ensemble (fixed N, V, T), the ensemble a thermostatted MD run samples (NVT). Its consequences are everywhere: vibrational populations, the Arrhenius law k∝e−Ea/kBT for reaction rates, vacancy concentrations in crystals, the exponential thinning of the atmosphere with height.
The partition function knows everything
Z looks like a mere normalising constant, but all of thermodynamics can be extracted from it by differentiation. With β=1/kBT:
For a classical particle the sum over states becomes an integral over phase space, Z=h3NN!1∫e−H(r,p)/kBTdrdp. Because H=K(p)+V(r), the integral splits into a momentum part, which can always be done exactly, and a configurational part, which is the hard part that MD and Monte Carlo exist to sample.
The speeds of molecules
The momentum part gives a striking prediction. Each velocity component has a Boltzmann weight e−mvx2/2kBT, a Gaussian. Combining the components and counting how many velocity vectors have the same speed (a circle of circumference 2πv in 2D, a sphere of area 4πv2 in 3D) gives the Maxwell–Boltzmann distribution of speeds:
Maxwell derived this in 1860 from symmetry arguments alone, before anyone could measure molecular speeds. The lab lets you watch it happen.
A gas of hard disks finds its own distribution
Loading the interactive figure…
Left: 160 disks in a box, coloured by speed, colliding elastically. Right: a histogram of their speeds against the 2D Maxwell–Boltzmann curve for the current temperature. Every particle starts with exactly the same speed; collisions alone produce the distribution. Tick “two species” to watch heavy and light particles share energy.
Restart and look at the histogram. At first every particle has the same speed, a single spike. Within a few hundred collisions the spike spreads into exactly the Maxwell–Boltzmann shape, though nothing in the program knows that curve: collisions conserve energy and momentum, and the distribution is simply the one with the most microstates. This is the second law happening in front of you. Boltzmann’s H-theorem (1872) proved that collisions drive any initial distribution towards this one.
Equipartition
Now tick “two species”. The orange particles are four times heavier but start with the same speed, so each carries four times the kinetic energy of a light particle. Watch the readout of mean kinetic energy: within a short time the two species have the same average kinetic energy, and the heavy particles move half as fast. This is the equipartition theorem:
Equipartition is how MD codes measure temperature. They compute the instantaneous kinetic temperature T=NdfkB2⟨K⟩, with Ndf the number of degrees of freedom (about 3N, less any constraints), and a thermostat nudges velocities to keep it near the target. It also explains the classical-MD error discussed earlier: equipartition gives every vibration kBT, even those that quantum mechanics would freeze.
Pressure from collisions
Pressure is the momentum delivered to the walls per unit time per unit area. A particle bouncing off a wall reverses its normal velocity and delivers momentum 2m∣vx∣. Averaging over the Maxwell–Boltzmann distribution gives the ideal gas law:
The lab measures pressure by adding up the momentum transferred to the walls. Compare it with the ideal-gas value: the measured pressure is somewhat higher, because the disks have a finite size and the free area is smaller than the box. That is the excluded-volume correction in van der Waals’s equation, and the starting point of the theory of real gases and liquids. In MD, pressure is computed from the virial, PV=NkBT+d1⟨∑iri⋅Fi⟩ in d dimensions, which adds the interparticle forces to the kinetic term (the MD chapter).
Check yourself
State A lies 2kBT above state B. What is the ratio of their probabilities PA/PB?
The Z cancels in the ratio: PA/PB=e−(EA−EB)/kBT=e−2.
Why is the most probable speed in a 3D gas not zero, even though zero speed has the largest Boltzmann factor?
The density of velocity vectors with speed v grows as v2 (as v in 2D), so the distribution peaks at a finite speed.
Helium (4 u) and xenon (131 u) are mixed at the same temperature. Which statement is true?
Equipartition fixes ⟨21mv2⟩; speeds scale as 1/m, and 131/4≈5.7.
How does an MD code compute the instantaneous temperature?
Equipartition links the average kinetic energy to T, with 21kBT per degree of freedom.
References and further reading
D. V. Schroeder, An Introduction to Thermal Physics, Addison-Wesley (2000), chapter 6 (Boltzmann factor, partition function, equipartition, the Maxwell speed distribution).
J. C. Maxwell, “Illustrations of the dynamical theory of gases”, Philosophical Magazine19, 19 (1860).
L. Boltzmann, “Weitere Studien über das Wärmegleichgewicht unter Gasmolekülen”, Wiener Berichte66, 275 (1872).
D. Chandler, Introduction to Modern Statistical Mechanics, Oxford University Press (1987), chapter 3.
D. Frenkel and B. Smit, Understanding Molecular Simulation, 3rd ed., Academic Press (2023), chapter 2 (statistical mechanics for simulation: temperature and pressure estimators).
M. P. Allen and D. J. Tildesley, Computer Simulation of Liquids, 2nd ed., Oxford University Press (2017), chapter 2.
5Ensembles and free energy
The canonical ensemble in depth: the partition function as a sum of Boltzmann weights and the generator of all thermodynamics; energy, entropy, heat capacity and the Gibbs entropy formula; free energy as the competition between energy and entropy; free-energy profiles and the potential of mean force; the classical partition function, the ideal gas and the Sackur–Tetrode entropy; and the isothermal–isobaric and grand canonical ensembles.
An experiment never controls the microscopic state of a sample. It controls a few macroscopic quantities, such as the temperature, the pressure or the number of molecules, and the sample explores all the microstates compatible with those constraints. Statistical mechanics describes this exploration with an ensemble: an imagined collection of infinitely many copies of the system, each in a different microstate, with the copies distributed according to the probability of each microstate under the given conditions. The average of any quantity over the ensemble is what an experiment measures.
The chapter on entropy used the microcanonical ensemble, which describes an isolated system with fixed number of particles N, volume V and energy E, and in which every accessible microstate is equally likely. The chapter on the Boltzmann distribution derived the canonical ensemble for a system at fixed N, V and temperature T, in contact with a heat bath, and showed that a microstate of energy Es occurs with probability proportional to e−Es/kBT. This chapter develops the canonical ensemble fully, because it is the ensemble of most experiments and of most simulations, and then introduces the ensembles at constant pressure and at constant chemical potential.
Different ensembles describe different experimental conditions, but for large systems they give the same thermodynamics, because the fluctuations that distinguish them are tiny compared with the averages; this is called the equivalence of ensembles. The choice is therefore a matter of convenience: one picks the ensemble in which the calculation is easiest or the simulation most natural.
The partition function
In the canonical ensemble the probability of microstate s is
The partition functionZ looks like a mere normalising constant, but it is the central object of statistical mechanics. Its name is apt: it describes how the system’s probability is partitioned among its states. At low temperature only the lowest states have appreciable weight and Z is close to the degeneracy of the ground state. As the temperature rises, more states acquire weight and Z grows; roughly, Z counts the number of states the system can effectively reach at temperature T.
The figure below makes this concrete. Each energy level contributes a weight gie−βEi, drawn as a gold bar; the weights add up to Z, and each level’s share of the total is its probability. Lower the temperature and the weights of the excited levels collapse exponentially; raise it and they approach their degeneracies.
The partition function as a sum of Boltzmann weights
Loading the interactive figure…
Left: the energy levels, with dots for their degeneracy. Middle: each level’s Boltzmann weight. Right: the weights stacked into Z, showing each level’s probability. Bottom: the mean energy U, the entropy S and the heat capacity C as functions of temperature (each scaled to its maximum); the dashed line is the current temperature. With ‘your own levels’ you can drag the levels up and down.
Partition functions factorise in a way that makes them practical. If a system consists of independent parts, its energy is a sum of their energies, so each Boltzmann factor is a product and Z=z1z2⋯. A molecule’s partition function factorises approximately into translational, rotational, vibrational and electronic parts, z=ztranszrotzvibzelec, each computed separately; this is how thermodynamic tables of gases are calculated from spectroscopic data. For N identical, non-interacting molecules, Z=zN/N!, where the N! corrects for the fact that exchanging identical molecules does not produce a new microstate.
Thermodynamics from the partition function
Every thermodynamic quantity follows from lnZ by differentiation. The derivations are short, and they explain what each quantity means.
The mean energy formula follows because differentiating Z=∑e−βEs with respect to β brings down a factor −Es in each term, so −∂lnZ/∂β=∑Ese−βEs/Z=⟨E⟩. Differentiating again gives the variance of the energy, which is why the heat capacity equals the energy fluctuations divided by kBT2: a system can absorb heat only if it has states at nearby energies to move into, and the same states allow its energy to fluctuate. This fluctuation formula is how heat capacities are computed from simulations, and the chapter on fluctuations develops it.
The entropy formula S=−kB∑pslnps, the Gibbs entropy, generalises Boltzmann’s S=kBlnΩ. If all Ω accessible states are equally likely, each ps=1/Ω and the sum reduces to kBlnΩ. If the probabilities are uneven, the entropy is lower, because the system is effectively confined to fewer states. The same expression, without kB, is Shannon’s measure of information, which is why entropy is often described as missing information about the microstate.
The figure’s bottom panel shows these quantities for each system. For the two-level system, the heat capacity rises from zero, peaks and falls again. This Schottky anomaly occurs because at low temperature the excited level is out of reach, and at high temperature both levels are already equally populated, so further heating changes nothing; only in between can the system absorb energy. The peak lies at kBT≈0.42Δ for a level spacing Δ, and such peaks are measured in magnetic materials and used to determine their energy levels. For the harmonic oscillator, the heat capacity rises from zero to the classical value kB, the freezing-out of vibrations described in the chapter on quantum energy levels.
Free energy: energy against entropy
The Helmholtz free energy F=U−TS is the quantity a system at constant temperature minimises. Its two terms pull in opposite directions. The energy term favours the states of lowest energy: atoms packed in a crystal, a protein in its folded form, a molecule in its deepest potential well. The entropy term, weighted by temperature, favours whatever has the most microstates: a gas filling its container, a disordered chain, a broad, shallow well rather than a narrow, deep one. Which wins depends on the temperature, and that competition is the origin of melting, boiling, unfolding and most other changes of state.
The cleanest way to see this is a system with two states, A and B. The probability of being in state A is the sum of the Boltzmann weights of all microstates belonging to A, so it is natural to define a partition function for each state, ZA and ZB, and a free energy for each, FA=−kBTlnZA. The ratio of probabilities then depends only on the free-energy difference:
The figure below samples a particle moving in a one-dimensional potential with two wells by the Metropolis Monte Carlo method (its own chapter). Well A is deep and narrow; well B is shallower but much broader. At low temperature the particle stays almost entirely in A, the state of lower energy. Raise the temperature and B gains, until above some temperature the particle spends more time in the shallow well than in the deep one. Nothing about the energies has changed. B wins because it offers more room: its larger entropy, multiplied by the higher temperature, outweighs its energy penalty. The readout decomposes the exact free-energy difference into its energy and entropy parts.
Energy against entropy in a two-well system
Loading the interactive figure…
Top: the potential energy (blue), and the free energy F(x) = −kT ln P(x) reconstructed from the sampled histogram (orange), with a violet bar showing the size of kT. Bottom: the histogram of positions visited and the exact Boltzmann density. Raise the temperature or widen well B and watch the population shift from A to B.
This is not a toy effect. Rubber contracts when heated because a stretched polymer chain has fewer conformations than a coiled one, so the entropic force pulling it back grows with temperature. Water and oil separate largely because water molecules next to an oily surface lose orientational freedom, an entropic penalty; this hydrophobic effect drives protein folding and the self-assembly of surfactants and nanoparticle ligands. And every first-order phase transition, from ice melting to a crystal changing its structure, is the point where the free energies of two phases cross.
Free-energy profiles and the potential of mean force
The same idea extends from two states to a continuous variable. Choose a collective variableξ that describes the progress of some process: the distance between two molecules, a dihedral angle, the number of atoms in a crystalline cluster. Its probability distribution P(ξ), obtained by summing the Boltzmann weights of all microstates with a given value of ξ, defines a free-energy profile:
In the two-well figure, the orange curve is exactly this: a histogram of where the particle has been, turned into a free energy. The difference between it and the blue potential-energy curve is entropy. Free-energy profiles are central to molecular simulation. The barrier height ΔF‡ of a profile along a reaction coordinate controls the rate of the process through a factor e−βΔF‡, and the depth of a minimum controls binding constants and solubilities. When the barrier is many kBT high, as in the figure at low temperature, an unbiased simulation almost never crosses it and the histogram cannot be measured on the far side; the readout warns when this happens. The chapter on free-energy methods describes umbrella sampling and metadynamics, which bias the simulation to overcome this.
The classical partition function and the ideal gas
For a classical system of N atoms, the sum over microstates becomes an integral over phase space, the 3N positions and 3N momenta:
Because the kinetic energy is a sum of squares of momenta, the momentum integrals are products of Gaussian integrals and can always be done exactly. All the difficulty, and all the interesting physics of interacting matter, lies in the remaining configurational integral over the potential energy. It is a 3N-dimensional integral that cannot be computed on a grid, which is why it is sampled by Monte Carlo or molecular dynamics.
For an ideal gas, U=0 and the configurational integral is simply VN, so Z=VN/(N!Λ3N). Everything follows from this one line. The pressure is P=kBT∂lnZ/∂V=NkBT/V, the ideal gas law. The entropy, using Stirling’s approximation lnN!≈NlnN−N, is the Sackur–Tetrode equation,
S=NkB[ln(NΛ3V)+25].
For argon at 298.15 K and 1 bar, the thermal wavelength is 0.16 Å, V/(NΛ3)≈107, and the formula gives a molar entropy of 154.8 J mol⁻¹ K⁻¹, which matches the value measured calorimetrically. That an absolute entropy can be calculated from Planck’s constant and the mass of an atom, and agree with experiment, was one of the early triumphs of quantum statistical mechanics: the factor h3N and the N! both matter.
Other ensembles
Experiments are more often done at constant pressure than at constant volume. In the isothermal–isobaric ensemble (NPT), the volume fluctuates as the system exchanges work with a barostat, a microstate with energy Es and volume V has weight e−β(Es+PV), and the corresponding free energy is the Gibbs free energyG=F+PV, minimised at constant temperature and pressure. Phase equilibria, reaction equilibria and solubilities at ordinary conditions are governed by G. Molecular dynamics simulations of liquids and solids are usually run in this ensemble, with a thermostat and a barostat (the chapter on thermostats).
In the grand canonical ensemble (μVT), the system exchanges particles as well as energy with a reservoir at fixed chemical potentialμ, the free-energy cost of adding one particle. A microstate with N particles and energy Es has weight e−β(Es−μN), and the grand potential Ω=−kBTlnΞ=−PV follows from the grand partition function Ξ. This is the natural ensemble for adsorption: grand canonical Monte Carlo simulations of gases in porous materials such as zeolites and metal–organic frameworks predict adsorption isotherms by letting molecules be inserted and deleted at a chemical potential fixed by the gas pressure.
The pattern is always the same. Each ensemble has a weight for each microstate, a partition function that normalises the weights, and a thermodynamic potential equal to −kBT times its logarithm. The potentials are related by Legendre transforms, F=U−TS, G=F+PV, Ω=F−μN, each swapping a controlled extensive variable for its conjugate intensive one, and each minimised at equilibrium under its own constraints.
Check yourself
A system has levels E = 0 (g = 1) and E = Δ (g = 3). What is Z at very high temperature?
As kT ≫ Δ every Boltzmann factor tends to 1, so Z tends to the total number of states, 1 + 3.
How is the heat capacity usually computed from a canonical simulation?
Differentiating ln Z twice links the heat capacity to energy fluctuations.
State B has higher energy than A but is found more often at 400 K. Why?
Populations follow free energy, not energy.
A histogram shows ξ = 1 visited 100 times more often than ξ = 2. What is F(2) − F(1)?
F(ξ) = −k_BT ln P(ξ), so the difference is k_BT ln(100).
Why can the momentum part of the classical partition function always be done exactly?
Each momentum component contributes a Gaussian integral, producing the thermal wavelength Λ.
References and further reading
D. Chandler, Introduction to Modern Statistical Mechanics, Oxford University Press (1987), chapters 3 and 6.
M. E. Tuckerman, Statistical Mechanics: Theory and Molecular Simulation, 2nd ed., Oxford University Press (2023), chapters 3–6 (microcanonical, canonical, isothermal–isobaric and grand canonical ensembles).
D. A. McQuarrie, Statistical Mechanics, University Science Books (2000), chapters 2–8.
T. L. Hill, An Introduction to Statistical Thermodynamics, Addison-Wesley (1960); Dover reprint (1986).
D. V. Schroeder, An Introduction to Thermal Physics, Addison-Wesley (2000), chapters 6–7, including the Schottky anomaly and the Sackur–Tetrode equation.
O. Sackur, “Die Anwendung der kinetischen Theorie der Gase auf chemische Probleme”, Annalen der Physik36, 958–980 (1911); H. Tetrode, “Die chemische Konstante der Gase und das elementare Wirkungsquantum”, Annalen der Physik38, 434–442 (1912).
D. Chandler, “Interfaces and the driving force of hydrophobic assembly”, Nature437, 640–647 (2005).
6Fluctuations and response
Why thermodynamic quantities fluctuate, how large the fluctuations are, and what they measure: energy fluctuations and the heat capacity, the 1/√N law and the thermodynamic limit, density fluctuations and compressibility, volume and enthalpy fluctuations at constant pressure, the fluctuation–dissipation theorem and linear response, and what all this means for simulations of small systems.
Thermodynamics treats the energy of a beaker of water in a thermostat, or the number of molecules in a cubic millimetre of air, as definite numbers. Statistical mechanics says they are not. A system in contact with a heat bath constantly exchanges energy with it, so its energy fluctuates about its average; a region of a gas constantly exchanges molecules with its surroundings, so the number inside it fluctuates too. For a macroscopic sample these fluctuations are far too small to notice, which is why thermodynamics works. For the systems studied in molecular simulation, a few thousand atoms, and for the nanoparticles, single molecules and small droplets of modern experiments, they are large enough to see and to matter.
Fluctuations are not merely noise. Their size is fixed by the same statistical mechanics that fixes the averages, and it turns out to be directly related to how the system responds when it is disturbed. The heat capacity, the compressibility and the magnetic susceptibility can all be written as the size of a spontaneous fluctuation. This is one of the most useful results in statistical physics, because it means that response functions can be computed from an equilibrium simulation simply by recording the fluctuations, without ever disturbing the system.
Energy fluctuations and the heat capacity
In the canonical ensemble, the mean energy is U=−∂lnZ/∂β, as the chapter on ensembles showed. Differentiating once more with respect to β gives the variance of the energy, and since ∂/∂β=−kBT2∂/∂T, the variance is proportional to the temperature derivative of the energy, which is the heat capacity:
The figure below samples the total energy of N independent two-level units, each with an excited level at energy Δ, in contact with a heat bath. Each unit is excited with probability p=1/(1+eΔ/kBT), so the number of excited units fluctuates from moment to moment. The readout computes the heat capacity from nothing but the variance of the sampled energies and compares it with the exact result. Change the temperature: the fluctuations, and the heat capacity, are largest at intermediate temperatures where the units are most uncertain about their state, the Schottky peak seen in the ensembles topic.
Fluctuations shrink as 1/√N, and measure the response
Loading the interactive figure…
Left: the system. Right: the distribution of the fluctuating quantity divided by its mean, on a fixed axis, with the Gaussian predicted by theory. Increase N from 10 to 10 000 and watch the distribution narrow; the readout recovers the heat capacity (or the compressibility) from the sampled variance alone.
The formula also explains why heat capacities are always positive: a variance cannot be negative. A system with a negative heat capacity would heat up when it lost energy, which cannot happen in a stable system in contact with a bath. (Isolated, self-gravitating systems such as stars can have negative heat capacities, and small isolated clusters near a melting transition can show them in the microcanonical ensemble, a reminder that the equivalence of ensembles holds only for large systems.)
The thermodynamic limit
How large are these fluctuations? For N independent units, the energies add, and so do the variances (the chapter on probability), so the mean grows as N and the standard deviation as N. The relative fluctuation therefore shrinks:
This holds well beyond independent units: whenever correlations between parts of a system extend over a finite distance, the system behaves like many independent blocks, and the same 1/N law applies. In the figure, increasing N by a factor of 100 narrows the distribution tenfold. For a mole of matter, N≈6×1023, the relative fluctuation is about 10−12, utterly negligible: this is the thermodynamic limit, in which averages become sharp and thermodynamics becomes exact. The exception is near a critical point, where correlations extend over macroscopic distances, the parts of the system cease to be independent, and fluctuations grow enormously; the chapter on phase transitions shows this.
For a simulation of 1000 atoms, by contrast, the relative energy fluctuation is a few per cent, which is easily visible in a plot of the energy against time. That is not a malfunction of the thermostat; it is the canonical ensemble behaving as it should.
Density fluctuations and compressibility
The same reasoning applies to other quantities. Consider a small region inside a fluid, open to the rest. Molecules wander in and out, so the number n inside fluctuates. In the grand canonical ensemble, where the region exchanges particles with a reservoir at fixed chemical potential, differentiating the grand partition function twice with respect to μ gives the variance of n, and thermodynamic identities relate it to the isothermal compressibilityκT=−V1(∂V/∂P)T:
Switch the figure to the gas. Molecules are scattered at random through a box, and the shaded sub-volume holds a fraction of them. The ratio of the variance to the mean of the count comes out close to 1, as the formula predicts for an ideal gas, reduced by the sub-volume fraction because the total number in the whole box is fixed. In a liquid, molecules repel each other at short range, so they cannot crowd into one region, the count fluctuates much less than for a gas, and ρkBTκT is small; for water at room temperature it is about 0.06. Liquids are nearly incompressible precisely because their density fluctuations are suppressed.
Density fluctuations are directly observable. They scatter light, X-rays and neutrons: the intensity scattered at small angles is proportional to ⟨(δn)2⟩/⟨n⟩, which is the structure factor S(q) at q→0 discussed in the chapter on liquids. Near the liquid–gas critical point the compressibility diverges, density fluctuations grow to the size of the wavelength of light, and an otherwise transparent fluid turns milky, the phenomenon of critical opalescence explained by Einstein and Smoluchowski in 1908–1910.
Fluctuations at constant pressure
In the isothermal–isobaric ensemble, the volume of the system is not fixed but fluctuates, and the corresponding formulas are the ones used in most molecular dynamics simulations, which run at constant temperature and pressure:
⟨(δV)2⟩=kBT⟨V⟩κT,⟨(δH)2⟩=kBT2CP,
where H=E+PV is the enthalpy. Recording the box volume and the enthalpy during a simulation therefore gives the compressibility and the constant-pressure heat capacity without any additional calculation. A further formula of the same kind gives the thermal expansion coefficient from the correlation between volume and enthalpy fluctuations. These estimators are widely used to validate force fields against experiment, and their accuracy depends on long simulations, because the variance of a fluctuation converges more slowly than the mean.
The fluctuations of a quantity depend on the ensemble even when its average does not. In a microcanonical (NVE) simulation the total energy does not fluctuate at all, while the kinetic and potential energies fluctuate against each other; in a canonical simulation the total energy fluctuates as above. A thermostat or barostat that gets the average temperature or pressure right but the fluctuations wrong produces the wrong ensemble and wrong response functions. The Berendsen thermostat is the classic example, discussed in the chapter on thermostats.
The fluctuation–dissipation theorem
The formulas above are special cases of a general principle. Suppose a small external field h is applied that couples to some quantity A of the system, adding −hA to the energy: a magnetic field coupling to the magnetisation, an electric field coupling to the dipole moment, a pressure coupling to the volume. The system responds by shifting the average of A. To first order in h, statistical mechanics gives
The proof is two lines: ⟨A⟩=∑sAse−β(Es−hAs)/Z, and differentiating with respect to h brings down βAs in each term, giving β(⟨A2⟩−⟨A⟩2). The dielectric constant of water in simulations is computed exactly this way, from the fluctuations of the total dipole moment of the box.
The dynamic version of this result is the fluctuation–dissipation theorem, formulated by Callen and Welton in 1951 and by Kubo in 1957. It states that the way a system relaxes back to equilibrium after a small disturbance is the same as the way its spontaneous fluctuations decay, a principle Onsager had stated in 1931 as the regression hypothesis. Quantitatively, transport coefficients, which measure dissipation, are integrals of equilibrium time-correlation functions, which measure fluctuations. The diffusion coefficient is the time integral of the velocity autocorrelation function, the viscosity is the integral of the autocorrelation of the stress, and the electrical conductivity is the integral of the autocorrelation of the current. These Green–Kubo relations are how transport coefficients are computed from equilibrium simulations, and the chapter on transport coefficients develops them. Einstein’s 1905 relation between the diffusion coefficient of a Brownian particle and the friction it feels, D=kBT/ζ, was the first example of the theorem: the same molecular collisions that make the particle jiggle also slow it down when it is pushed.
Consequences for simulations
Several practical lessons follow. Fluctuations in a small simulation are real and expected: a 1000-atom canonical simulation at 300 K shows temperature fluctuations of about 3 %, and a pressure that fluctuates by hundreds of bar is normal for a small box of liquid. Response functions computed from fluctuations need long runs, since a variance converges more slowly than a mean and correlated samples count less than they seem (the chapter on probability explains effective sample sizes). Fluctuation formulas are only valid if the simulation samples the correct ensemble, so the choice of thermostat and barostat matters. And finite-size effects are themselves a kind of fluctuation effect: quantities that depend on long-wavelength fluctuations, such as the compressibility near a critical point, converge slowly with system size and should be checked by repeating the calculation in a larger box.
Check yourself
In a canonical simulation the energy variance is 4 (kJ/mol)² at 300 K. What determines the heat capacity?
The canonical fluctuation formula relates the variance of the total energy to C_V.
System size grows from 1 000 to 100 000 atoms. The relative energy fluctuation…
Relative fluctuations scale as 1/√N; √100 = 10.
For an ideal gas, the number of molecules in a small open sub-volume follows…
ρk_BTκ_T = 1 for an ideal gas, so ⟨δn²⟩ = ⟨n⟩.
Why are liquids nearly incompressible, in the language of fluctuations?
Compressibility is proportional to the size of density fluctuations.
A thermostat reproduces the correct average temperature but suppresses energy fluctuations. What goes wrong?
Averages may be fine while variances, and hence response functions, are wrong.
References and further reading
D. Chandler, Introduction to Modern Statistical Mechanics, Oxford University Press (1987), chapters 3 and 8 (fluctuations, linear response).
M. P. Allen and D. J. Tildesley, Computer Simulation of Liquids, 2nd ed., Oxford University Press (2017), section 2.5 (fluctuations) and chapter 2 on estimators.
H. B. Callen and T. A. Welton, “Irreversibility and generalized noise”, Physical Review83, 34–40 (1951).
R. Kubo, “Statistical-mechanical theory of irreversible processes. I”, Journal of the Physical Society of Japan12, 570–586 (1957).
L. Onsager, “Reciprocal relations in irreversible processes. I”, Physical Review37, 405–426 (1931).
A. Einstein, “Über die von der molekularkinetischen Theorie der Wärme geforderte Bewegung von in ruhenden Flüssigkeiten suspendierten Teilchen”, Annalen der Physik17, 549–560 (1905).
A. Einstein, “Theorie der Opaleszenz von homogenen Flüssigkeiten und Flüssigkeitsgemischen in der Nähe des kritischen Zustandes”, Annalen der Physik33, 1275–1298 (1910).
7Phase transitions and the Ising model
How collective order appears: order parameters and the classification of transitions, the Ising model and its lattice-gas and alloy interpretations, Onsager's exact solution, Monte Carlo simulation of the model, mean-field theory solved graphically, Landau theory of continuous and first-order transitions, critical exponents, universality and finite-size effects in simulations.
Water freezes at 0 °C, iron loses its magnetism above 770 °C, and the copper and zinc atoms of β-brass, arranged in an ordered alternating pattern at room temperature, mix randomly on the same lattice above about 460 °C. These are phase transitions: changes in the collective organisation of matter that happen abruptly as a control parameter, usually temperature or pressure, passes a definite value. They are the most dramatic consequence of the competition between energy and entropy described in the chapter on free energy. Below the transition, the ordered arrangement has the lower free energy because its energy is lower; above it, the disordered arrangement wins because its entropy, multiplied by the temperature, outweighs the energy cost.
A phase transition is described by an order parameter, a quantity that is zero in the disordered phase and non-zero in the ordered one. For a magnet it is the magnetisation; for an alloy, the excess of one kind of atom on one sublattice; for the liquid–gas transition, the difference between the liquid and gas densities; for a nematic liquid crystal, the average alignment of the molecules. Transitions fall into two broad classes. In a first-order or discontinuous transition, such as melting or boiling, the order parameter jumps, the two phases coexist at the transition, a latent heat is absorbed, and the system can be superheated or supercooled. In a continuous or second-order transition, such as the loss of ferromagnetism at the Curie temperature, the order parameter falls smoothly to zero, there is no latent heat, but the heat capacity, the susceptibility and the size of fluctuations become very large near the critical point.
The Ising model
The simplest model that shows a phase transition was proposed by Wilhelm Lenz and solved in one dimension by his student Ernst Ising in 1925. Each site i of a lattice carries a spinsi that can point up (+1) or down (−1). Neighbouring spins prefer to align, and an external field h favours one direction:
Its simplicity is deceptive, because the same mathematics describes very different physical systems. Reading “up” as “site occupied by a molecule” and “down” as “empty site” turns the Ising model into a lattice gas, with J an attraction between neighbouring molecules and h related to the chemical potential; its transition is then the condensation of a gas into a liquid. Reading “up” and “down” as two kinds of atom turns it into a binary alloy, whose transition is ordering or phase separation. Lattice models of this kind, with J fitted to first-principles calculations through a cluster expansion, are used today to predict the ordering of real alloys and of ions in battery electrodes.
Ising found that the one-dimensional chain has no transition at any non-zero temperature: a single break in an aligned chain costs a fixed energy 2J but can be placed anywhere, so its entropy always wins. He wrongly concluded that the model was useless in higher dimensions too. In 1944 Lars Onsager solved the two-dimensional square-lattice model exactly, a celebrated feat of mathematical physics, and showed that it orders spontaneously below a critical temperature
kBTc=ln(1+2)2J≈2.269J.
The spontaneous magnetisation below Tc, published by Chen Ning Yang in 1952, is m=[1−sinh−4(2J/kBT)]1/8. These exact results make the 2D Ising model the standard test of approximate theories and of simulation methods.
Simulating the model
The model is easily simulated with the Metropolis Monte Carlo method (its own chapter explains why it samples the canonical ensemble). Repeatedly pick a spin, compute the energy change ΔE that flipping it would cause, which depends only on its four neighbours, and accept the flip with probability min(1,e−ΔE/kBT). One attempted flip per spin is called a sweep.
The two-dimensional Ising model
Loading the interactive figure…
Left: the lattice, blue spins up and orange spins down, with periodic boundaries. Right, top: the magnetisation per spin over time. Right, bottom: the average |m| you record at different temperatures against Onsager’s exact curve (gold); point colours mark the lattice size. The readouts give the susceptibility and heat capacity estimated from fluctuations.
Start at a temperature well below Tc, say kBT=1.5J, with random spins. The lattice does not order all at once. Small aligned domains of each sign form, and their boundaries move and smooth out, so that domains coarsen over time; eventually one sign usually takes over, although stripes spanning the periodic box can survive for a long time. Above Tc, at kBT=3J, the spins remain a fine-grained mixture and the magnetisation fluctuates around zero. Close to Tc, the picture is remarkable: clusters of every size, from single spins to the size of the lattice, coexist and fluctuate, and the magnetisation wanders widely. This is the critical state, in which the system has no characteristic length scale.
To rebuild the phase diagram, set a temperature, wait until the magnetisation has settled, and press Record. Points well below and well above Tc fall on Onsager’s curve. Near Tc they do not: a finite lattice cannot have a sharp transition, so the recorded ⟨∣m∣⟩ is rounded off and stays above zero slightly beyond Tc, and the rounding shrinks as the lattice grows. Recording the same temperatures on 32, 64 and 128 spin lattices shows this finite-size effect directly. Close to Tc the simulation also slows down dramatically, because large clusters take many sweeps to change, a phenomenon called critical slowing down. Cluster algorithms such as those of Swendsen and Wang or Wolff, which flip whole correlated clusters at once, were invented to overcome it.
The readouts show the susceptibility and heat capacity estimated from the fluctuations of the magnetisation and energy, using the formulas of the chapter on fluctuations. Both peak near Tc, where fluctuations are largest.
Mean-field theory
Onsager’s solution is a mathematical tour de force that does not generalise to three dimensions or to other models. A simple approximate theory that works in any dimension is mean-field theory, introduced by Pierre Weiss in 1907 for ferromagnets. Its idea is to replace the fluctuating neighbours of each spin by their average. Each spin then feels an effective field, the external field plus J times the sum of its z neighbours’ average values, heff=h+zJm. A single spin in a field heff has average value tanh(βheff), and since every spin is equivalent, this average must equal m itself:
The equation cannot be solved in closed form, but it can be solved by drawing. Plot the straight line y=m and the curve y=tanh((zJm+h)/kBT); the solutions are where they cross.
Mean-field theory solved graphically
Loading the interactive figure…
Blue: y = m. Orange: y = tanh((zJm + h)/kT). Their intersections are the self-consistent magnetisations; filled dots are stable, open dots unstable. Lower the temperature through zJ/k_B with h = 0 and watch two new solutions split off from m = 0.
At high temperature the tanh curve is shallow and crosses the line only at m=0: the disordered phase. As the temperature falls, the curve steepens, and when its slope at the origin, zJ/kBT, exceeds 1, it crosses the line at two more points, ±m0; the solution m=0 becomes unstable and the system orders spontaneously. Mean-field theory thus predicts a transition at kBTc=zJ, which for the square lattice is 4J, well above the exact 2.269J. It overestimates Tc because it ignores fluctuations, which disrupt order; it even predicts a transition in the one-dimensional chain, where there is none. It improves as the number of neighbours grows, and becomes exact when every spin interacts with every other.
Landau theory
Lev Landau generalised the mean-field idea in 1937 into a theory that applies to any transition, by writing the free energy as a function of the order parameter and expanding it in powers of m near the transition, keeping only terms allowed by the symmetry of the problem. For the Ising magnet, flipping every spin leaves the energy unchanged when h=0, so only even powers can appear:
The figure plots this free energy. For the continuous transition, as the temperature passes Tc the single minimum at m=0 flattens and splits into two symmetric minima that move apart continuously; a small field tilts the curve and selects one. The predicted magnetisation grows as (Tc−T)1/2 below the transition. Switch to the first-order form: now, over a range of temperatures, the free energy has three minima, one at m=0 and two at large ±m. The equilibrium state jumps from one to the other when their depths cross, which is the discontinuous transition, while the shallower minimum remains as a metastable state that the system can be trapped in. That is the origin of supercooling, superheating and hysteresis, and escaping a metastable minimum requires crossing a free-energy barrier, which is what nucleation of a new phase means.
Landau free-energy curves
Loading the interactive figure…
The free energy as a function of the order parameter. Teal: the global minimum (equilibrium). Orange: metastable minima. Compare how the minimum moves through the continuous transition with how it jumps in the first-order one.
Critical phenomena and universality
Near a continuous transition, many quantities follow power laws in the distance from the critical temperature, t=(T−Tc)/Tc, characterised by critical exponents: the order parameter vanishes as m∝(−t)β, the susceptibility diverges as χ∝∣t∣−γ, the heat capacity as C∝∣t∣−α, and the correlation lengthξ, the typical size of correlated regions, diverges as ξ∝∣t∣−ν. The divergence of ξ is the heart of the matter: at the critical point fluctuations are correlated over all length scales, which is what the simulation shows as clusters of every size.
exponent
mean field / Landau
2D Ising (exact)
3D Ising (numerical)
order parameter β
1/2
1/8
0.326
susceptibility γ
1
7/4
1.237
correlation length ν
1/2
1
0.630
Mean-field theory gets the exponents wrong in two and three dimensions because it neglects exactly these long-range fluctuations. The most striking discovery about critical exponents is universality: they do not depend on the details of a system, only on its dimension and the symmetry of its order parameter. The liquid–gas critical point of carbon dioxide, the critical point of a binary liquid mixture and the Curie point of a uniaxial magnet all have the exponents of the 3D Ising model, even though the forces involved are completely different. The explanation came from the renormalisation group developed by Kenneth Wilson in the early 1970s, for which he received the 1982 Nobel Prize in Physics: near a critical point, as the system is viewed on longer and longer length scales, microscopic details become irrelevant and only symmetry and dimension survive.
Phase transitions in simulations
Simulations of phase transitions must contend with the finite size of the simulated system. A box of N particles cannot show true singularities, so transitions are rounded and shifted, and the critical properties of the infinite system are obtained by finite-size scaling: repeating the simulation for several sizes and extrapolating using the known way in which quantities scale with L/ξ. A practical tool is the Binder cumulant of the order parameter, whose curves for different system sizes cross near Tc.
First-order transitions pose the opposite problem. The two phases are separated by a free-energy barrier that grows with system size, so a simulation started in one phase can remain there far beyond the true transition temperature: a simulated crystal heated at constant rate often melts well above its melting point, because there is no surface from which melting can start. Locating first-order transitions reliably therefore requires free-energy calculations that compare the two phases directly, coexistence simulations in which both phases share a box with an interface, or biased sampling methods that drive the system over the barrier, described in the subject on enhanced sampling.
Check yourself
Why does the one-dimensional Ising chain have no phase transition at T > 0?
Free energy per wall ≈ 2J − k_BT ln N becomes negative for large N at any T > 0, so walls proliferate and destroy order.
Mean-field theory predicts T_c = 4J/k_B for the square lattice; the exact value is 2.269J/k_B. Why the overestimate?
Neglecting fluctuations makes order look more robust than it is.
In a Landau free energy with three minima, the system is in the minimum at m = 0 while a deeper minimum exists at m = 0.9. The m = 0 state is…
It is a local minimum; escaping it requires nucleation over a free-energy barrier.
The liquid–gas critical point of CO₂ and the Curie point of a uniaxial magnet share critical exponents because…
Both belong to the 3D Ising universality class.
A simulated crystal heated steadily melts 20 % above its experimental melting point. The most likely reason is…
First-order transitions show hysteresis in simulations; use coexistence or free-energy methods to locate them.
References and further reading
E. Ising, “Beitrag zur Theorie des Ferromagnetismus”, Zeitschrift für Physik31, 253–258 (1925).
L. Onsager, “Crystal statistics. I. A two-dimensional model with an order-disorder transition”, Physical Review65, 117–149 (1944).
C. N. Yang, “The spontaneous magnetization of a two-dimensional Ising model”, Physical Review85, 808–816 (1952).
K. G. Wilson, “Renormalization group and critical phenomena. I”, Physical Review B4, 3174–3183 (1971).
N. Goldenfeld, Lectures on Phase Transitions and the Renormalization Group, Addison-Wesley (1992).
J. M. Yeomans, Statistical Mechanics of Phase Transitions, Oxford University Press (1992).
D. P. Landau and K. Binder, A Guide to Monte Carlo Simulations in Statistical Physics, 5th ed., Cambridge University Press (2021).
U. Wolff, “Collective Monte Carlo updating for spin systems”, Physical Review Letters62, 361–364 (1989).
8The structure of liquids
How disordered matter is described statistically: the radial distribution function and what its peaks mean, coordination numbers, energy, pressure and compressibility from g(r), the potential of mean force and why it differs from the pair potential, the structure factor measured by X-ray and neutron scattering, the hard-sphere picture of liquids, and how g(r) is computed correctly from simulations.
A crystal is easy to describe: give the lattice and the contents of one unit cell, and every atomic position follows. A gas is easy too: the atoms are almost independent. Liquids, glasses, amorphous solids and dense fluids lie in between. They have no long-range order, yet they are far from random: each atom is surrounded by a well-defined first shell of neighbours at nearly fixed distance, a less sharply defined second shell, and so on, with order fading over a few molecular diameters. The theory of liquids, developed from the 1930s by John Kirkwood, Joseph Mayer, Jean-Pierre Hansen, John Barker, Douglas Henderson and many others, and tested at every stage by computer simulation, describes this statistical order with a few correlation functions. The most important is the radial distribution function.
The radial distribution function
The radial distribution functiong(r) measures how the density of particles around a given particle varies with distance, relative to the average density:
The figure runs a two-dimensional Lennard-Jones fluid by molecular dynamics and accumulates g(r) as it goes. At low density, g(r) shows a single weak peak just beyond the repulsive core, reflecting the attraction of neighbouring pairs, and is otherwise close to 1. In the liquid, it develops a strong first peak at about one particle diameter, a minimum, a second peak and weaker oscillations that decay within a few diameters. Compress further and the peaks sharpen and split as the system crystallises into a triangular lattice. The tagged atom (rose) and its first-shell neighbours (teal) show the shell that the first peak counts.
Structure of a Lennard-Jones fluid
Loading the interactive figure…
Left: the fluid, with a tagged atom (rose) and its first-shell neighbours (teal) inside the dashed circle at the first minimum of g(r). Right: g(r) (teal) and the running coordination number (violet), or, in the second view, the potential of mean force against the pair potential. Vary density and temperature to move between gas, liquid and solid.
Coordination numbers and thermodynamics from g(r)
Integrating ρg(r) over the first peak gives the coordination number, the average number of nearest neighbours,
n1=ρ∫0rming(r)4πr2dr,
with the integral stopped at the first minimum rmin. Simple liquids near their triple point have about 12 neighbours in three dimensions, close to the 12 of a close-packed crystal, which is why melting changes the density of simple substances by only around 10 %; water has only about 4.5 neighbours, the signature of its open, hydrogen-bonded network. In two dimensions, as in the figure, the dense liquid has close to 6 neighbours.
For particles interacting through a pair potential u(r), g(r) determines the thermodynamics. The average potential energy per particle and the pressure are
and the isothermal compressibility follows from the compressibility route, ρkBTκT=1+ρ∫0∞[g(r)−1]4πr2dr, which links g(r) to the density fluctuations of the chapter on fluctuations. Because these routes are exact only for the exact g(r), comparing them is a sensitive test of approximate theories such as the Percus–Yevick and hypernetted-chain integral equations.
The potential of mean force
The probability of finding two particles at distance r, relative to an ideal gas, defines a free energy as a function of their separation:
Switch the figure to the potential of mean force. At low density the orange curve follows the blue pair potential. At liquid density it develops extra minima at the second and third neighbour distances and a barrier between the first two: there is no direct interaction at those distances, but the surrounding particles make some separations more probable than others. This is the same idea as the free-energy profiles of the chapter on ensembles, applied to a distance. It is important in practice: the potential of mean force between two ions in water shows a contact minimum and a solvent-separated minimum, with a barrier between them corresponding to a water molecule entering or leaving the gap, and its depth determines ion pairing and the stability of colloids and nanoparticles in solution. Coarse-grained models are often built by matching potentials of mean force, by iterative Boltzmann inversion for example.
Scattering and the structure factor
g(r) is not only a simulation concept; it is measured. X-rays and neutrons scattered by a liquid produce an intensity pattern whose variation with the scattering vector q is the static structure factor, related to g(r) by a Fourier transform:
Comparing simulated and measured structure factors is one of the main tests of force fields and MLIPs for liquids, glasses and amorphous materials. For multicomponent systems there are partial structure factors and partial gαβ(r) for each pair of species, and X-ray and neutron experiments, which weight the species differently, together constrain them; for water, the oxygen–oxygen g(r) from X-ray diffraction is the standard benchmark.
Hard spheres and the van der Waals picture
The structure of simple dense liquids is dominated by repulsion. Simulations of hard spheres by Berni Alder and Thomas Wainwright (1957) and by William Wood and J. D. Jacobson showed that even particles with no attraction at all crystallise at high density, an entropy-driven transition, and that their liquid g(r) looks remarkably like that of real simple liquids. This led to the modern van der Waals picture of liquids, developed by John Weeks, David Chandler and Hans Andersen (1971) and by Barker and Henderson: the structure is fixed by packing of the repulsive cores, and the attraction mainly provides a uniform cohesive background that holds the liquid together. Perturbation theories built on this idea predict liquid thermodynamics accurately and underlie much of the theory of fluids.
Computing g(r) in a simulation
The recipe is simple, and the figure follows it: for every pair of particles compute the distance, applying the minimum-image convention in a periodic box; histogram the distances into bins of width Δr; average over many frames; and normalise each bin by the number of pairs an ideal gas would have in that shell, 21Nρ⋅4πr2Δr (counting each pair once) or Nρ⋅4πr2Δr (counting both orders). Distances beyond half the box length are unreliable, because shells there are cut off by the periodic boundary. Bins must be fine enough to resolve the first peak but coarse enough to collect statistics, and the result should be averaged over frames separated by more than the correlation time. Analysis libraries such as MDAnalysis, MDTraj and OVITO compute g(r), coordination numbers and structure factors directly from trajectories, as the chapter on trajectory analysis describes.
Check yourself
What is g(r) at very large distances in a liquid?
Far away, positions are uncorrelated and the local density equals the average.
The potential of mean force between two ions in water has two minima. What does the second represent?
The medium creates free-energy minima where there is no direct interaction minimum.
What does S(q → 0) measure?
S(0) = ρk_BTκ_T.
References and further reading
J.-P. Hansen and I. R. McDonald, Theory of Simple Liquids: with Applications to Soft Matter, 4th ed., Academic Press (2013), chapters 2–5.
J. G. Kirkwood, “Statistical mechanics of fluid mixtures”, Journal of Chemical Physics3, 300–313 (1935).
B. J. Alder and T. E. Wainwright, “Phase transition for a hard sphere system”, Journal of Chemical Physics27, 1208–1209 (1957).
J. D. Weeks, D. Chandler and H. C. Andersen, “Role of repulsive forces in determining the equilibrium structure of simple liquids”, Journal of Chemical Physics54, 5237–5247 (1971).
J. A. Barker and D. Henderson, “What is ’liquid’? Understanding the states of matter”, Reviews of Modern Physics48, 587–671 (1976).
D. Chandler, Introduction to Modern Statistical Mechanics, Oxford University Press (1987), chapter 7.
L. B. Skinner et al., “Benchmark oxygen–oxygen pair-distribution function of ambient water from x-ray diffraction measurements with a wide Q-range”, Journal of Chemical Physics138, 074506 (2013).