Examples#
Runnable demonstrations of the central results in each
physicskit.statphys chapter: lattice phase transitions, molecular
dynamics, random walks, and self-organized criticality.
See also the narrative tutorial:
Each script in this gallery is self-contained and can be run directly with
python examples/statphys/<section>/<script>.py. Every script also carries
an RST module docstring as its title/description and uses # %% markers to
split narrative text from code, which is exactly what Sphinx-Gallery renders
into the pages below – the script is the source of truth for what you see,
not a copy of it.
Sections#
ising – the 2D Ising model: Onsager’s exact phase transition, finite-size scaling to extract critical exponents, and critical slowing down (Metropolis versus the Swendsen-Wang and Wolff cluster algorithms).
wang_landau – flat-histogram sampling of the density of states.
path_integral – path-integral Monte Carlo of a quantum particle in a well.
xy_model – the Kosterlitz-Thouless transition via vortex-antivortex unbinding.
potts_model – first- versus second-order transitions in the q-state Potts model.
spin_glass – frustration and the Edwards-Anderson order parameter.
percolation – percolation as a purely geometric phase transition.
renormalization – Kadanoff block-spin renormalization group flow.
quantum_statistics – Bose-Einstein and Fermi-Dirac distributions and Bose-Einstein condensation.
molecular_dynamics – Boltzmann’s H-theorem: relaxation to the Maxwell-Boltzmann distribution.
random_walk – diffusion, the Einstein relation, and the central limit theorem.
stochastic_processes – Langevin and Fokker-Planck dynamics: the Einstein relation \(D = \mu k_BT\) from drift and spread, the fluctuation-dissipation balance in a trap, a double-well density relaxing to Boltzmann, the Ornstein-Uhlenbeck process, and the strong convergence of the Euler-Maruyama and Milstein schemes.
ehrenfest_urn – the Ehrenfest urn: reversibility, recurrence, and the arrow of time.
sandpile – self-organized criticality in the Bak-Tang-Wiesenfeld sandpile.
interactive – interactive Plotly dashboards.
Ehrenfest urn#
Reversible microscopic dynamics and the emergence of an arrow of time.
The Ehrenfest urn: reversibility, recurrence, and the arrow of time
Interactive Plotly visualizations#
Pan/zoom/hover-enabled counterparts of the static Matplotlib plots.
Ising model#
The 2D ferromagnetic Ising model: Gibbs’s canonical ensemble summed exactly, the Metropolis algorithm, Onsager’s exactly solved second-order phase transition, and the Swendsen-Wang and Wolff cluster algorithms.
The Wolff cluster algorithm: beating critical slowing down
Finite-size scaling: extracting critical exponents
Gibbs’s canonical ensemble: response from fluctuations
Onsager’s exact solution: the 2D Ising phase transition
The Metropolis algorithm: sampling Boltzmann without the partition function
The Swendsen-Wang algorithm: flipping every Fortuin-Kasteleyn cluster at once
Interface growth#
The Kardar-Parisi-Zhang universality class via Restricted Solid-On-Solid growth.
Universal interface roughening: the Kardar-Parisi-Zhang universality class
Landau mean-field theory#
Order parameters, broken symmetry, and critical exponents from a free-energy expansion alone.
Landau mean-field theory: order parameters from symmetry alone
Molecular dynamics#
Maxwell’s velocity distribution, Alder and Wainwright’s molecular dynamics with the Lennard-Jones gas and Velocity Verlet integration, and Boltzmann’s H-theorem.
Alder and Wainwright: molecular dynamics simulation
Boltzmann’s H-theorem: relaxation to the Maxwell-Boltzmann distribution
Nonequilibrium work relations#
Jarzynski’s equality: exact equilibrium free energies from irreversible work measurements.
Jarzynski’s equality: exact free energies from irreversible work
Path-integral Monte Carlo#
Quantum statistical mechanics by Monte Carlo: Feynman’s imaginary-time path integral as a classical ring polymer.
Path-integral Monte Carlo: a quantum particle as a classical ring polymer
Percolation#
Site and bond percolation: a purely geometric critical phenomenon.
Potts model#
The q-state generalization of the Ising model, contrasting continuous and discontinuous transitions.
First- versus second-order transitions in the q-state Potts model
Quantum statistics#
Bose-Einstein and Fermi-Dirac occupation, and Bose-Einstein condensation.
Quantum statistics: Bose-Einstein, Fermi-Dirac, and condensation
Random walks#
Diffusion, the Einstein relation, the central limit theorem, and the Langevin equation.
Diffusion, the Einstein relation, and the central limit theorem
The Langevin equation: Brownian motion one trajectory at a time
Renormalization group#
Kadanoff block-spin coarse-graining and RG fixed points.
Self-organized criticality#
The Bak-Tang-Wiesenfeld sandpile: power laws without fine-tuning.
Self-organized criticality: the Bak-Tang-Wiesenfeld sandpile
Spin glasses#
The Edwards-Anderson Ising spin glass: quenched disorder and frustration.
Spin glasses: frustration and the Edwards-Anderson order parameter
The Sherrington-Kirkpatrick model and Parisi’s replica overlap
Stochastic processes#
Brownian motion and the Einstein relation, Langevin dynamics and the fluctuation-dissipation balance, the Fokker-Planck equation for the probability density, the Ornstein-Uhlenbeck process, and the Euler-Maruyama and Milstein schemes that integrate Itô stochastic differential equations.
Einstein’s Brownian motion: diffusion equals mobility times temperature
The Fokker-Planck equation: from noisy trajectories to a deterministic density
Itô’s stochastic calculus: the Euler-Maruyama and Milstein schemes
The Langevin equation: friction and noise must balance
The Ornstein-Uhlenbeck process: Gaussian noise with a memory
Wang-Landau sampling#
Flat-histogram Monte Carlo: estimating the density of states directly, then reading off the thermodynamics at every temperature.
Wang-Landau sampling of the Ising density of states
XY model#
The 2D classical XY model and the topological Kosterlitz-Thouless transition: the vortex energy-entropy argument and vortex unbinding.
Kosterlitz and Thouless: the vortex energy-entropy argument
The Kosterlitz-Thouless transition: vortex-antivortex unbinding
Partition function zeros#
The Lee-Yang circle theorem: phase transitions from the complex-fugacity structure of Z.
The Lee-Yang circle theorem: partition function zeros in the complex plane