Ising Magnet Simulator

Each arrow is a magnetic moment (a “spin”) that can only point up or down. Neighboring spins interact through the exchange constant J, temperature T jostles them randomly, and an applied field H pulls them toward one direction. Move the sliders and watch order appear or melt, then use the M vs T and M vs H tabs to measure magnetization curves.

↑ spin up (+1) ↓ spin down (−1) One 20 × 20 slice of a 20 × 20 × 20 cube
m
0.000
−3 antiferro0ferro +3
0.111050
−5 down0up +5
slowfast

The magnetization fluctuates as spins flip. Deep in the ordered or disordered state it is steady; near the transition temperature the fluctuations become large and slow — a hallmark of a phase transition.

Things to try
  1. Find the Curie temperature. With a ferromagnet (J = 1) at zero field, start hot and slowly lower T. Below about T ≈ 4.5 domains of aligned spins appear, compete and grow. Run M vs T to watch |m| switch on as the temperature passes TC.
  2. A field smears out the transition. Run M vs T at H = 0, then again at H = 0.5 and 2 (earlier runs stay on the plot). With a field there is no sharp onset — the field already picks a direction at all temperatures.
  3. Hysteresis. At T = 2 a ferromagnet “remembers” its direction: run M vs H and the magnetization only reverses once the field is strong enough to nucleate reversed domains. Repeat at T = 3.5 and 6 — the loop shrinks and vanishes above TC.
  4. The ideal paramagnet. Set J = 0 so that spins ignore each other. M vs H now follows the dotted curve m = tanh(H/T) — linear at small field (Curie’s law, m ≈ H/T) and saturating at large field. Compare to J = 1 at the same T: interactions make the magnet far easier to polarize.
  5. The antiferromagnet. With J = −1 neighbors prefer to point opposite, and cooling below the Néel temperature gives a checkerboard with almost no net magnetization. In a field of H = 2, run M vs T: m rises on cooling, peaks near the Néel temperature TN ≈ 4.5, then falls as the checkerboard locks in — the cusp that identifies an antiferromagnet in a magnetometer measurement. Compare it with the dotted non-interacting curve.
  6. Spin-flip transition. An antiferromagnet resists a field until the field energy beats the exchange: with J = −0.5 at low T, M vs H shows a plateau at m ≈ 0, then a steep rise to saturation around |H| = 6|J| = 3, where the field energy of a flipped spin equals its exchange energy.
How the simulation works

Spins si = ±1 sit on a simple-cubic lattice of 20 × 20 × 20 = 8000 sites, with periodic boundaries (the cube wraps around on itself). The energy of a configuration is

E = −J ∑⟨ij⟩ si sj − H ∑i si

where the first sum runs over the six nearest-neighbor pairs of each site. J > 0 favors parallel neighbors (ferromagnet), J < 0 favors antiparallel neighbors (antiferromagnet), and H favors spins pointing along the field. Energies, temperature and field share the same units (kB = 1, and H stands for the Zeeman energy μH).

Temperature enters through the Metropolis Monte Carlo algorithm. Repeatedly: pick a random spin and compute the energy cost of flipping it,

ΔE = 2si ( J ∑j sj + H )

If ΔE ≤ 0 the flip is accepted; otherwise it is accepted with probability e−ΔE/T. One MC sweep is 8000 attempts, so every spin gets about one chance to flip. Repeating this samples the Boltzmann distribution at temperature T.

For this lattice the exact transition temperature is TC ≈ 4.51|J| (mean-field theory overestimates it as 6|J|). The finite 203 cube rounds off the transition slightly, and short runs at low T can get stuck in metastable domain states — just like real magnets.