About
Interactive browser-based simulation of the 2D Ising model — a statistical mechanics system that demonstrates magnetic phase transitions. Runs entirely in the browser; no server required.
What it does
- Simulates ±1 spins on an N×N square lattice using the Metropolis Monte Carlo algorithm
- Visualizes the ferromagnetic phase transition at critical temperature Tc ≈ 2.269
- Tracks four observables in real time: magnetization |M|, energy E/N², susceptibility χ, specific heat C
- Accepts three tunable parameters: temperature T, coupling constant J, external field h
- Renders the spin lattice as a color-coded canvas and plots four live SVG charts
How to use
- Set temperature T — below Tc ≈ 2.269 produces ordered spin alignment; above produces disorder
- Adjust coupling J (positive = ferromagnetic, negative = antiferromagnetic) and field h
- Choose lattice size N — smaller grids run faster; larger grids show finer structure
- Click Run to start the simulation
- Watch the spin grid and four charts update live as sweeps complete
- Click Stop to pause, or Reset to clear data and restart
Input / Output
| Parameter | Range | Notes |
| Temperature T | 0.1 – 6.0 | Critical point at Tc ≈ 2.269 |
| Coupling J | −2.0 – 2.0 | + = ferromagnetic, − = antiferromagnetic |
| Field h | −2.0 – 2.0 | External magnetic bias |
| Lattice size N | 20 – 100 | N×N spins total |
Outputs: spin grid (orange = up, blue = down), live charts for |M|, E/N², χ, and C.
How it works
- Initializes N×N lattice with random ±1 spins and periodic (toroidal) boundary conditions
- Each Monte Carlo sweep visits every spin; proposes a flip, accepts if ΔE ≤ 0 or with probability exp(−ΔE/kT)
- Uses a checkerboard update order for correct Metropolis dynamics
- Magnetization and energy computed directly from the spin state each recorded step
- Susceptibility χ and specific heat C derived from variance of running averages
- Canvas renders spin states as ImageData pixels; charts are plain SVG path elements — no external libraries