HomeArticlesStatistical Mechanics

The Ising Model: How a Lattice of Coins Learns to Agree

A 2D grid of up/down spins, Metropolis Monte Carlo, and a critical temperature Tc ≈ 2.269 J/k where order emerges out of pure thermal noise.

mysimulator teamUpdated June 2026≈ 9 min read▶ Open the simulation

A grid of spins that just want to agree with their neighbours

The Ising model, introduced by Wilhelm Lenz and solved in one dimension by his student Ernst Ising in 1925, is the simplest possible caricature of a magnet. Place a spin s = ±1 on every site of a square lattice. Each spin only cares about its four nearest neighbours, and the energy of the whole configuration is:

H = −J ∑<i,j> s_i s_j  −  h ∑_i s_i

J > 0   ferromagnetic coupling (aligned neighbours lower the energy)
<i,j>   sum over nearest-neighbour pairs only
h       external field (0 in the classic phase-transition demo)

That is the entire model: no long-range forces, no quantum mechanics, just a local rule that neighbouring spins prefer to point the same way. Everything interesting — a sharp phase transition, universal critical exponents, an exactly solvable free energy — falls out of that one local rule once you add temperature.

live demo · spin lattice ordering as temperature drops through Tc● LIVE

Sampling with the Metropolis algorithm

At temperature T, the probability of any configuration is given by the Boltzmann weight exp(−H/kT), and computing exact averages over 2^(N²) configurations is hopeless for any real lattice size. The Metropolis algorithm (1953) instead builds a Markov chain that visits configurations with exactly the right long-run frequency:

repeat:
  pick a random site i
  ΔE = energy change if s_i were flipped
  if ΔE <= 0:            accept the flip (it lowers the energy)
  else:                    accept with probability exp(−ΔE / kT)
  (otherwise leave s_i unchanged)

Accepting some energy-raising moves is the whole point: it is what lets the chain climb out of local minima and sample the full thermal distribution rather than just collapsing to the ground state. Sweep every site in the lattice once and you have completed one Monte Carlo step; run enough steps and time-averages of the magnetisation, energy and other observables converge to their equilibrium values at that temperature.

The critical temperature and the exact Onsager solution

In two dimensions the model has a genuine phase transition at a nonzero temperature — unlike the 1D chain, which never orders at any T > 0. Above the critical temperature Tc, thermal agitation wins and the average magnetisation is zero: spins point up and down in roughly equal, disorganised measure. Below Tc, the coupling wins and the lattice spontaneously picks one direction, developing a nonzero net magnetisation with no external field forcing it to. Lars Onsager solved the 2D square-lattice model exactly in 1944 and found:

kTc / J = 2 / ln(1 + √2)  ≈  2.269

Spontaneous magnetisation for T < Tc:
  M(T) = [1 − sinh⁻⁴(2J/kT)]^(1/8)

Onsager's result remains one of the few exactly solved nontrivial phase transitions in statistical mechanics, and it gives simulations like this one a precise target to check against: run the Metropolis chain at many temperatures, plot the average |M| against T, and it should trace Onsager's curve, flattening to zero right at Tc.

Critical exponents and universality

Near Tc, several quantities diverge or vanish as power laws of the reduced temperature t = (T−Tc)/Tc: magnetisation M ∼ |t|^β (β = 1/8), susceptibility χ ∼ |t|^−γ (γ = 7/4), specific heat C ∼ ln|t| (a logarithmic, not power-law, divergence for this model), and the correlation length ξ ∼ |t|^−ν (ν = 1). What makes these numbers famous is universality: wildly different physical systems — real uniaxial ferromagnets, certain binary fluid mixtures near their critical mixing point, some liquid-gas critical points — share exactly the same exponents as the 2D Ising model, because near a continuous phase transition only the dimensionality and symmetry of the order parameter matter, not the microscopic details of the interaction.

Frequently asked questions

What does 'spontaneous magnetisation' actually mean here?

It means that below Tc, even with zero external magnetic field, the spins collectively favour one alignment over the other purely because neighbours prefer to match. Above Tc thermal noise wins and the average magnetisation is zero; below Tc the coupling wins and a nonzero net magnetisation appears on its own, without any field forcing it.

Why does the Metropolis algorithm sometimes accept a flip that increases the energy?

Because the system needs to sample the full thermal (Boltzmann) distribution, not just slide downhill to the lowest-energy state. Accepting uphill moves with probability exp(-ΔE/kT) is exactly what makes the long-run visit frequency of each configuration match its Boltzmann weight; without it the simulation would just be an energy-minimiser and could never reproduce finite-temperature behaviour like the critical point.

Why does the simulation slow down so much near Tc?

It is called critical slowing down. Near the critical temperature, correlated regions of aligned spins grow to the size of the whole lattice, and single-spin-flip Metropolis moves need very many steps to reorganise a large correlated patch. The correlation time diverges as you approach Tc, which is why serious studies switch to cluster algorithms like Wolff or Swendsen-Wang near the transition.

Try it live

Everything above runs in your browser — open Ising Model — Phase Transition and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.

▶ Open Ising Model — Phase Transition simulation

What did you find?

Add reproduction steps (optional)