2D Ising Model Simulator — Docs

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

  1. Set temperature T — below Tc ≈ 2.269 produces ordered spin alignment; above produces disorder
  2. Adjust coupling J (positive = ferromagnetic, negative = antiferromagnetic) and field h
  3. Choose lattice size N — smaller grids run faster; larger grids show finer structure
  4. Click Run to start the simulation
  5. Watch the spin grid and four charts update live as sweeps complete
  6. Click Stop to pause, or Reset to clear data and restart

Input / Output

ParameterRangeNotes
Temperature T0.1 – 6.0Critical point at Tc ≈ 2.269
Coupling J−2.0 – 2.0+ = ferromagnetic, − = antiferromagnetic
Field h−2.0 – 2.0External magnetic bias
Lattice size N20 – 100N×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