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.
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.
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
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,
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.