The Ising Model
Put a spin on every site of a square lattice, let each one be or , and have neighbours prefer to agree:
That is the whole model. It has no closed form for the magnetisation of a finite lattice, and its partition function is a sum over configurations — for the lattice below, terms, which is not a large number so much as a number with no physical meaning. Summing is over. From here on, we sample.
Why sampling is legitimate
Metropolis–Hastings does not compute and does not need to. It builds a random walk through configuration space whose stationary distribution is the Boltzmann one, by proposing a move and accepting it with probability
Every quantity in the previous modules was an exact sum weighted by ; every quantity here is an average over configurations that appear with frequency . Same weight, moved from the arithmetic into the sampling.
The catch is that consecutive configurations differ by one spin, so they are correlated, and an average over samples is worth fewer than independent ones. That is why the traces below take time to settle, and why the first thing to watch is whether they settle at all.
Changing anything starts a fresh chain — a Markov chain carries its temperature in every sample it has already taken, so there is nothing to reuse.
The one number we know exactly
Onsager solved the infinite square lattice in 1944, and the temperature at which it orders is
This is what makes the Ising model worth sampling rather than merely convenient. The sampler has something to be right about. Push the temperature below and should climb away from zero; push it above and should collapse toward it. Neither behaviour was put into the code — the sampler only ever sees for a single flip.
Three regimes, and the readout names which one you are in:
- — one domain wins. The energy per site heads for , every bond satisfied. Flipping a spin inside a domain costs , so almost nothing is accepted and the acceptance rate falls through the floor.
- — thermal noise beats the coupling. , the energy per site , and almost every proposal is accepted because barely matters.
- — domains on every scale, from single sites to the whole lattice, and they never stop reorganising.
Finite lattices lie, slightly
Onsager's is the infinite-lattice answer, and is not infinite. Two consequences worth expecting rather than being surprised by:
The transition is smeared. A true phase transition needs the thermodynamic limit; on a finite lattice every quantity is an analytic function of , so does not vanish sharply at but decays over a window whose width shrinks as grows. Try against and watch the crossover sharpen.
Below , is plotted rather than because on a finite lattice the whole system can and eventually will flip. Given long enough, at every temperature by symmetry — the two ground states are mirror images and nothing prefers either. What "ordered" really means is that the flipping time grows exponentially with , so the lattice is stuck in one of them for any run you will watch.
And near the sampler slows down. Correlated regions grow to the size of the lattice, single-spin flips take forever to rearrange them, and the error bars on anything measured there are much worse than the sample count suggests. This is critical slowing down, and it is the reason cluster algorithms exist.
What carried over
The acceptance rule here is the same expression the exact modules used as a weight, and the ensemble object is literally the same one: a temperature, plus a list of which extensive variables are free. Adding a magnetic field to this lattice would not require a new sampler, only a field in the ensemble — the acceptance already knows how to read one.