🧲 Heisenberg Spin Model — Quantum Magnetism
Metropolis Monte Carlo simulation of the classical Heisenberg model: 3D unit spins on a 2D lattice order into visible magnetic domains as temperature drops.
How it Works
Each site on the lattice holds a classical spin: a unit vector (Sx, Sy, Sz) that can point anywhere on a sphere, not just "up" or "down" as in the simpler Ising model. Neighboring spins interact through the exchange energy E = -J·Σ Sᵢ·Sⱼ, summed over nearest-neighbor pairs with periodic boundary conditions (the lattice wraps at the edges). Positive J favors parallel alignment (ferromagnetic); negative J favors anti-parallel alignment (antiferromagnetic).
The simulation uses the Metropolis Monte Carlo algorithm: each animation frame performs a full sweep (one attempted update per site on average). For every attempt, a site is picked at random, a new random unit-vector orientation is proposed, and the resulting energy change ΔE is computed from its four lattice neighbors. Moves that lower the energy are always accepted; moves that raise it are accepted with probability exp(-ΔE / kBT). Over many sweeps this drives the lattice toward thermal equilibrium at the chosen temperature T, visibly reorganizing into large colorful ordered domains at low T and dissolving into noise-like disorder at high T.
Metropolis acceptance: P = min(1, exp(-ΔE / kBT))
Magnetization: |M| = |(1/N)·Σᵢ Sᵢ|, 0 ≤ |M| ≤ 1
Color mapping: hue = atan2(Sy, Sx), lightness ∝ Sz
Frequently Asked Questions
What is the Heisenberg spin model?
The classical Heisenberg model represents each magnetic moment as a continuous 3D unit vector rather than a fixed direction. Neighboring spins interact through an exchange energy E = -J·Sᵢ·Sⱼ, and the system evolves toward the orientation pattern that minimizes total energy at a given temperature.
How does the Heisenberg model differ from the Ising model?
The Ising model restricts each spin to two discrete states, up or down. The Heisenberg model allows spins to point in any direction on the unit sphere, giving continuous rotational freedom — a more realistic description of many real magnetic materials.
What does the Metropolis Monte Carlo algorithm do?
At each step, a random site is chosen and a new random spin orientation is proposed. If it lowers the energy it is always accepted; if it raises the energy it is accepted with probability exp(-ΔE / kBT). This samples the Boltzmann distribution so the lattice reflects thermal equilibrium at temperature T.
Why is the acceptance probability exp(-ΔE/kBT)?
This is the Boltzmann factor from statistical mechanics: the relative probability of a state with energy E is proportional to exp(-E/kBT). Using it as the acceptance rule guarantees detailed balance, so simulated configurations converge to the correct thermal ensemble.
What does the magnetization |M| measure?
The magnetization is the vector average of all spins, M = (1/N)·Σ Sᵢ. Its magnitude ranges from 0 (random orientations, no net moment) to 1 (all spins perfectly aligned) — the simplest order parameter for magnetic ordering.
Why doesn't the 2D Heisenberg model have a true phase transition at finite temperature?
The Mermin-Wagner theorem shows continuous symmetries cannot be spontaneously broken in 1D or 2D short-range systems at any T > 0 — long-wavelength spin-wave fluctuations destroy true long-range order. The lattice still shows strong short-range correlations and large ordered domains at low T; related planar (XY-like) models show a topological Berezinskii-Kosterlitz-Thouless (BKT) crossover instead of a conventional transition.
What does the coupling constant J represent?
J is the exchange interaction strength between neighboring moments, arising quantum mechanically from electron wavefunction overlap and the Pauli exclusion principle. Positive J (ferromagnetic) favors parallel spins; negative J (antiferromagnetic) favors a checkerboard-like anti-parallel pattern at low T.
What does the external field control do?
Enabling the field adds a Zeeman term -h·Sᵢz to each spin's energy, favoring alignment along z. This mimics an applied magnetic field Bz; even a modest field pulls the lattice toward net out-of-plane magnetization, visible as the canvas becoming uniformly brighter or darker.
Where is the classical Heisenberg model used in real research?
It is a standard testbed for ferromagnets, antiferromagnets, and frustrated magnets, and underlies simulations used in spintronics device design, magnetic recording media research, and quantum magnetism studies where classical Monte Carlo guides quantum many-body calculations.
What is a Monte Carlo sweep?
One sweep attempts one Metropolis update per lattice site on average (N×N attempts for an N×N lattice). Many sweeps let the configuration relax from a random start toward equilibrium; acceptance rate and magnetization typically stabilize after a few dozen sweeps.
About this simulation
This simulator runs a live Metropolis Monte Carlo simulation of the classical Heisenberg model, where every lattice site holds a free-rotating 3D spin instead of a simple up/down bit. Each frame performs a full lattice sweep of proposed spin flips, accepted or rejected according to the Boltzmann rule, so you watch a genuine thermal relaxation process rather than a pre-baked animation. At low temperature, the colorful hue-and-brightness texture organizes itself into broad ordered domains; crank the temperature up and the same lattice dissolves into shimmering, uncorrelated noise — a vivid, interactive picture of how magnetic order competes with thermal disorder.
🔬 What it shows
A 2D lattice of classical 3D spins evolving under Metropolis Monte Carlo dynamics, colored by hue (in-plane angle) and brightness (out-of-plane component Sz), alongside a live chart of the magnetization |M| over recent sweeps so you can watch the system settle or fluctuate in real time.
🎮 How to use
Drag the temperature slider to cross the ordering crossover, flip the sign of J to switch between ferromagnetic and antiferromagnetic coupling, change the lattice size for finer or coarser detail, and toggle the external field to see the spins pulled toward alignment along z.
💡 Did you know?
Unlike the 3D Heisenberg model, this 2D version has no true long-range magnetic order at any nonzero temperature (Mermin-Wagner theorem) — yet it still shows striking short-range order and slow, glassy-looking domain dynamics at low T, physics closely related to the Berezinskii-Kosterlitz-Thouless crossover in planar spin systems.
Frequently asked questions
Why does the lattice look like colorful static at high temperature?
At high T, thermal fluctuations dominate the exchange coupling J, so the Metropolis algorithm accepts almost any proposed reorientation. Each spin ends up pointing in an essentially random direction uncorrelated with its neighbors, which the hue/brightness color map renders as noisy, uncorrelated speckle.
Why do large colored domains appear at low temperature?
At low T, the exchange energy dominates and misaligned neighbors cost too much energy for the Metropolis rule to accept easily. Spins align with their neighbors in patches that grow and merge over successive sweeps, producing the broad, smoothly-varying colored regions you see.
What happens if I set J negative?
Negative J makes antiparallel neighboring spins energetically favorable instead of parallel ones. At low temperature the lattice develops a checkerboard-like antiferromagnetic pattern of alternating orientations rather than uniform ferromagnetic domains.
Why does the |M| chart still fluctuate even at low T?
Because this is a finite lattice with genuine thermal noise, the magnetization never perfectly settles — it fluctuates around an equilibrium value whose size depends on temperature and lattice size. Larger lattices at low T show smaller relative fluctuations, closer to the idealized thermodynamic limit.
What does the acceptance rate stat tell me?
The acceptance rate is the fraction of proposed spin reorientations accepted during the last sweep. It is typically high at high temperature (almost any move is accepted) and lower at low temperature (only moves that barely raise the energy, or lower it, tend to succeed), making it a quick diagnostic of how "hot" or "frozen" the system currently is.
Why use unit vectors instead of angles?
Representing each spin as a 3D unit vector (Sx, Sy, Sz) makes the dot product Sᵢ·Sⱼ — and therefore the exchange energy — a simple, numerically stable calculation, and lets the model naturally include out-of-plane tilting (captured here as brightness) alongside in-plane rotation (captured as hue), which a single in-plane angle could not represent.
Metropolis Monte Carlo simulation of the classical Heisenberg model: 3D unit spins on a 2D lattice order into visible magnetic domains as temperature drops.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install