At a glance
A square grid of spins, each up or down, is the simplest model of a magnet. This sim lets you set the temperature, watch the grid rearrange under one local rule, and measure how aligned the whole grid is.
What you'll learn
- How one spin flip is decided from its energy cost and the temperature.
- How the average magnetisation ⟨|M|⟩ depends on T, and where it starts to rise.
- What the signed trace M and the plotted ⟨|M|⟩ each measure.
- How the grid size L changes what you measure near the transition.
What's on screen
- Spin up (+1): blue squares in the lattice. The title line above it gives L and T.
- Spin down (−1): amber squares.
- M trace (teal): the signed mean spin of the whole grid over the last 15 s, from −1 (all down) to +1 (all up).
- ⟨|M|⟩ plot (orange dots): one dot per ⏺ Record, with a bar for the sweep-to-sweep spread. Filled dots were measured on the current grid size, hollow ones on another.
- Exact curve and Tc lines (amber): Onsager's result for an infinite lattice, and where your grid's rise is expected. The Guided Inquiry reveals them after you have mapped the rise yourself.
The controls
Press ⌖ on a row to see where that control sits in the sim. In the Guided Inquiry some controls appear only at later cards; in Free Exploration they are all there.
| Control | What it changes | Range | |
|---|---|---|---|
| Temperature T | The temperature in units of J/kB. Half of the slider's travel covers 2.1–2.5, where the action is. Changing T during a Record discards that measurement. | 1.0–3.5 opens at 3.0 | |
| Grid size L | The number of spins on a side. Changing it starts a fresh random grid and keeps your T and sweep rate. | 32, 64 or 96 opens at 64 | |
| Sweeps per second | How fast the run is shown. One sweep is L² flip attempts, so this sets the viewing speed, not the physics. | 1–2000, log scale opens at 120 | |
| ⏺ Record | Waits 200 sweeps, then averages |M| over 400 more at the current T and L, and adds a dot. Between 2.15 and 2.45 it uses 600 and 1200. Press again to cancel. | button | |
| Measurements | Counts your recorded points, shows the last result, and holds the flag you drag along the bottom of the plot to mark where you think the rise begins. | panel | |
| The exact answer | The exact Tc and your grid's apparent Tc. In the Guided Inquiry it opens once six points on both sides of Tc and your flag are in. | panel | |
| ▶ Play / ⏸ Pause | Starts the sweeping, or freezes the grid so you can study a pattern. | top bar | |
| Speed | Multiplies the clock, and so stacks on the sweep rate. | 0.25×–4× opens at 1× | |
| ↻ Reset | A new random grid at T = 3.0, L = 64 and 120 sweeps/s, paused. | top bar |
Fixed: J = kB = 1, zero external field, periodic edges.
A flip is judged by its energy cost
A neighbouring pair contributes −J to the energy if its two spins match and +J if they differ. Each step picks one spin at random and proposes to flip it. The Metropolis rule accepts the flip with this probability:
- A flip that lowers or keeps the energy is always accepted.
- An uphill flip is accepted with probability e−ΔE/kBT. For ΔE = +4J that is 0.082 at T = 1.6 and 0.264 at T = 3.0, so heat is what buys disagreement.
- One sweep is L² attempts: Monte Carlo time, not seconds.
- This rule satisfies detailed balance, so a long run samples the equilibrium distribution at temperature T.
Below Tc the whole grid orders
Below one temperature, matching neighbours win often enough that agreement spreads across the whole grid. Onsager's exact solution for an infinite lattice gives that temperature and the size of the order:
These sliders move the sim too.
- M(T) is 0.98 at T = 1.6, and 0.91 at T = 2.0.
- An eighth root rises steeply: 1% below Tc it is already 0.69, and 0.1% below it is still 0.52.
- Cool gradually. A sudden quench can freeze the grid into two ordered stripes with domain walls, and the sim flags trapped stripes. Reheat and cool again.
Which direction wins is chance
With no external field, flipping every spin leaves the energy and every flip probability unchanged. Nothing in the rule prefers up, so the colour that takes over is decided by each run's random fluctuations, and both are equally likely.
- On a finite grid at zero field, the long-run average of the signed M is exactly zero: given enough time, a grid below Tc flips between its two ordered states.
- That waiting time grows exponentially with L. Well below Tc it is far longer than any session, so the trace stays at one sign.
- That is why the plot averages |M|. The signed average would cancel to zero and hide the order, while |M| counts up-order and down-order alike.
Near Tc the grid decides slowly
Close to Tc, ordered patches of every size coexist, and the grid needs very many sweeps before it forgets its present state. The signed M wanders slowly over a wide range instead of jittering about zero.
- Successive sweeps stay correlated, so 400 sweeps hold far fewer independent samples than they do at T = 1.6 or 3.0. Between 2.15 and 2.45, Record therefore takes three times as many: 600 to settle and 1200 to measure.
- The scatter between runs is large here. Repeated 64 × 64 records at T = 2.30, simulated with the sim's own rule, landed anywhere from about 0.1 to 0.6, while at T = 1.6 or 3.0 they repeat to within a few hundredths.
- That scatter is physics, not noise to be averaged away. The ± in the Record message is the sweep-to-sweep spread, not an error bar.
A finite grid blurs the transition
Onsager's curve is for an infinite lattice. An L × L grid cannot show a sharp drop, so its rise is rounded and sits slightly warm of Tc, and some ⟨|M|⟩ remains above it.
| grid | apparent Tc | ⟨|M|⟩ at T = 3.0 |
|---|---|---|
| 32 × 32 | 2.326 | ≈ 0.086 |
| 64 × 64 | 2.298 | ≈ 0.042 |
| 96 × 96 | 2.288 | ≈ 0.028 |
Exact Tc = 2.269. The last column is an average of repeated records; a single record scatters by about a third.
- The tail above Tc falls roughly as 1/L. It is shown, never subtracted.
- A larger grid gets closer to the exact curve, but near Tc it also needs longer runs.
Where it matters
- One idea, many materials. The order parameter changes name, not role: magnetisation in a magnet, the liquid–vapour density difference in a fluid. Each vanishes at its critical point, and systems that share a dimension and a symmetry share exponents. This is called universality.
- Real fluids and layered magnets. CO₂ has its liquid–vapour critical point at 304 K and 73.8 bar, in the three-dimensional Ising class (β ≈ 0.326, not this grid's 1/8). Layered magnets such as Rb₂CoF₄ behave as two-dimensional Ising systems, with a measured β close to 1/8.
- Simulation practice. Metropolis sampling is a standard tool in statistical physics. The slow decisions and finite-size shifts you measured here are the everyday obstacles near any critical point.
Go deeper: how the exponent sets the shape
- Mean-field theory puts the transition at T = 4J/kB (four neighbours), far above the exact 2.269, and gives β = 1/2.
- Onsager solved the 2D model in 1944. Above two dimensions the exponents come from the renormalisation group and numerics.
Summary
Key points
- A flip costs ΔE = 2J si Σ sj. Downhill is always taken, uphill with probability e−ΔE/kBT.
- Below Tc, ⟨|M|⟩ rises steeply as (1 − T/Tc)1/8.
- Near Tc the grid decides slowly, so records scatter.
- A finite L rounds the transition, shifts it warm by about Tc·0.8/L, and leaves a tail that falls as 1/L.
Common mix-ups
- "Order needs something that favours up." The field is zero and the rule is symmetric. Below Tc, agreeing wins in either direction.
- "It should settle half up, half down." A wall of mismatched neighbours costs energy. A hasty quench can still freeze into stripes.
- "The transition on screen is sharp, and ⟨|M|⟩ is zero above it." On a finite grid the rise is rounded, and a tail remains above Tc, about 0.04 on 64 × 64 at T = 3.0.
Things to try on your own
- Cool slowly from 3.0 and Record at six or more temperatures, then compare your dots with the exact curve.
- Record three times at T = 2.30, then three times at T = 1.6, and compare the spreads.
- Record at T = 2.5 on L = 32, 64 and 96 and compare how large the tail above Tc is on each.