Magnet Phase Transition LabBeta

Tune the temperature and watch magnetic domains form and melt

This tool is a beta version still being stabilized. Please let us know if a result looks off.

Brush

Loading the simulation engine (WebAssembly)…

Over time
  • Magnetization M
  • Energy E
  • Onsager exact |M|

Each cell is a tiny magnet pointing up (↑) or down (↓). Neighbors that agree lower the energy, and heat flips spins at random. Cool below the critical temperature Tc ≈ 2.269 and large same-direction domains form; heat above it and they break apart. Near Tc you see domains of every size at once. Drag on the canvas to paint spins yourself. The Wolff method reaches equilibrium much faster near Tc.

About Magnet Phase Transition Lab

Each cell of a square lattice holds a spin that can only point up (+1) or down (−1). Two neighbouring spins that agree lower the energy by 1; two that disagree raise it by 1. An external field h gives an extra advantage of h to spins pointing its way. That is the whole rulebook, yet as you cool the lattice there is a sharp temperature below which the whole grid lines up. It is the barest possible model of iron becoming a magnet below its Curie point.

Temperature T is measured in units where the coupling J and Boltzmann's constant k are both 1. The edges wrap around (periodic boundaries), so the lattice has no edges, like the surface of a doughnut. You can choose 128², 256² or 512² spins; the default is 256².

Onsager's exact critical temperature

In 1944 Lars Onsager solved the zero-field 2D Ising model exactly. On the square lattice the transition happens where sinh(2J/kTc) = 1, which gives Tc = 2/ln(1+√2) ≈ 2.269. That is the tick mark on the temperature slider and the value the go-to-Tc button sets. At this temperature the specific heat diverges logarithmically and the energy per spin is exactly −√2 ≈ −1.414.

Below Tc the spontaneous magnetisation is M = [1 − sinh⁻⁴(2/T)]^(1/8), a result Onsager announced and C. N. Yang proved in 1952. The pair of dashed Onsager lines on the graph sit at +M and −M from this formula. The exponent 1/8 means magnetisation appears very steeply just below Tc. Mean-field theory predicts 1/2, which is wrong in two dimensions.

Experiment 1: domains growing after a quench

Reset to random and set T = 1.5. A random lattice is the infinite-temperature state, so this is a sudden quench. Small patches appear, then small domains are swallowed by large ones and the boundaries shorten. Theory says |M| ≈ 0.987, yet the readout sits near zero for a while because up and down domains of similar size are competing. With periodic boundaries you sometimes get two stripes spanning the lattice that last a very long time. A straight boundary has no curvature pulling it in, so nothing drives it away.

Switch to Wolff clusters in the same situation and big chunks flip in one move, so the lattice orders quickly. Both algorithms sample the same equilibrium; they differ only in how fast they reach it.

Experiment 2: patches of every size at Tc

Press go-to-Tc. At T = 2.269 domains of all sizes are visible at once. The correlation length diverges at the critical point, leaving a fractal-looking pattern with no characteristic scale. Metropolis has to flip large domains one spin at a time, so the picture changes very slowly; this is critical slowing down. Wolff's method bonds aligned neighbours with probability 1 − e^(−2/T) and flips the whole cluster. At Tc that probability is exactly 2 − √2 ≈ 0.586. Wolff's 1989 paper reported that the method almost eliminates critical slowing down for the 2D Ising model.

Grow the lattice from 128 to 512 and |M| at Tc gets a little smaller. Finite-size scaling says the critical magnetisation goes as L^(−1/8), so a lattice four times wider shows about 4^(1/8) ≈ 1.19 times less. On an infinite lattice it would be zero.

Experiment 3: a field, and a state that refuses to flip

Start with all up, set T = 1.5 and h = −0.3. Every spin now opposes the field, so flipping is favourable overall, but under Metropolis the lattice holds out for a long time. Flipping one spin inside the up region breaks four bonds (cost 8) and gains only 0.6 from the field; the acceptance probability is exp(−7.4/1.5) ≈ 0.007. Only when a down seed happens to grow large enough does the down phase spread. It is the same mechanism as supercooled water waiting for a nucleus before it freezes.

Paint a large down disk with the brush and the transition starts at once. Paint a small one and it shrinks away, because its boundary costs more than its interior gains. The size that survives is the critical nucleus.

What the graph is and isn't telling you

The magnetisation plotted is signed. Below Tc a finite lattice can wander between +M and −M, especially with Wolff updates, which is why the Onsager lines are drawn at both +M and −M. Above Tc the theory says zero, but a finite lattice shows small fluctuations of order 1/L in magnitude, larger on the 128² grid than on 512².

Worked examples

Onsager's magnetisation by hand

Input
T = 2.0, h = 0
Output
sinh(1) = 1.1752 → sinh⁻⁴ = 0.524 → M = (0.476)^(1/8) ≈ 0.911

At T = 2.2 the same formula gives 0.784, and at T = 1.5 it gives 0.987. Even 0.07 below Tc the magnetisation is still 0.78; that is what an exponent of 1/8 looks like.

Odds of flipping one spin at Tc

Input
T = 2.269, all four neighbours aligned, h = 0
Output
ΔE = 8, acceptance exp(−8/2.269) ≈ 0.029

With three neighbours aligned ΔE = 4 and the chance is 0.171; with two aligned ΔE = 0 and the flip always happens. That is why activity concentrates on domain boundaries while domain interiors barely change.

Wolff bond probability

Input
T = Tc = 2/ln(1+√2)
Output
1 − e^(−2/Tc) = 1 − 1/(1+√2) = 2 − √2 ≈ 0.586

Since e^(2/Tc) = 1 + √2 exactly, the bond probability at the critical point is a clean algebraic number.

How to use it

  1. Pick a starting state: random, all up, all down or half and half.
  2. Move T and h and watch magnetisation and energy on the graph.
  3. Switch the update method between Metropolis and Wolff and compare speed.
  4. Paint spins with the brush to test nucleation and domain walls.

Frequently asked questions

I'm below Tc but the magnetisation stays near zero.

After a quench from random, up and down domains coarsen slowly, and stripes spanning the lattice can last a long time. Switch to Wolff or wait longer and one direction wins.

Why is there no phase transition in 1D?

In a chain, one domain wall costs a fixed energy but can sit in as many places as the chain is long, so entropy wins at any temperature above zero. In 2D a wall costs energy proportional to its length, and order survives at low temperature.

Is the 3D critical temperature known exactly?

No. The 3D Ising model has no known exact solution; its critical temperature is known only from high-precision numerical work.

How is the phase label chosen?

From T/Tc alone, not from the lattice, which is why it reads "Theoretical phase". Below 0.95 it says ferromagnetic, above 1.05 paramagnetic, and in between near critical. A freshly quenched lattice can be labelled ferromagnetic while mixed domains keep M near zero, so check the M readout and graph to see whether it has actually ordered.

Notes

The theory curve is for an infinite lattice. On a finite lattice the transition is rounded near Tc, and |M| fluctuates slightly above zero even above Tc.

There is no exact solution with a nonzero field, so the theory lines are hidden when h ≠ 0.

Sources

Last reviewed:

Privacy and how data is handled