← Back to Research

Research entry

Ising Model Simulation in Rust + WebAssembly

Active · March 2026

A publication-grade Monte Carlo simulation engine for classical spin models, achieving 0.01% accuracy on the 3D critical temperature. Supports three universality classes, GPU acceleration via CUDA, and finite-size scaling analysis — targeting Physical Review E.

Physics Rust WebAssembly Monte Carlo Computational Physics CUDA GPU

View external resource →

Live Demo

Try the interactive 3D Ising model simulation running entirely in your browser via WebAssembly:


Key Results

The simulator recovers known exact solutions and experimental values with high precision:

QuantityMeasuredReferenceError
3D cubic T_c4.512(4) J/k_B4.5115 (Hasenbusch 2010)0.01%
2D square T_c2.269 J/k_B2.2692 (Onsager exact)< 0.02%
gamma/nu1.933(30)1.964 (theory)1.6%
beta/nu0.492(26)0.518 (theory)5.0%
nu0.667(37)0.630 (theory)5.9%
Fe Curie temp1043 K1043 K (experiment)< 1%
Ni Curie temp~631 K~627 K (experiment)~1%
KZ exponent kappa0.258(15)0.279 (theory)7.4%

The hyperscaling relation 2(beta/nu) + gamma/nu = d is satisfied to within 2.7%.


Finite-Size Scaling

The core analysis technique is finite-size scaling (FSS) on 3D simple-cubic lattices from L=8 to L=48, using the Wolff cluster algorithm.

Binder Cumulant Crossing

The Binder cumulant U_4 is a dimensionless ratio that crosses at the same point for all lattice sizes, pinning the critical temperature independently of any exponent assumptions.

Binder cumulant crossings pinning the critical temperature at T_c = 4.512(4)

Histogram Reweighting

Ferrenberg-Swendsen histogram reweighting extrapolates from 41 simulated temperatures to a fine 200-point grid near T_c, giving much sharper resolution than raw data alone.

Histogram-reweighted observables near the critical point

Peak Scaling

The heights of thermodynamic peaks follow power laws in system size. Log-log fits extract the critical exponent ratios gamma/nu and beta/nu.

Log-log peak scaling for extracting critical exponents

Scaling Collapse

When axes are rescaled using the extracted exponents, data from all lattice sizes collapse onto a single universal curve — the hallmark of a continuous phase transition.

All system sizes collapse onto one universal curve


Three Universality Classes on GPU

The same engine supports three spin symmetries, each belonging to a distinct universality class. GPU-accelerated runs on an RTX 2060 produce finite-size scaling results for all three:

Ising (Z_2 discrete symmetry)

Ising scaling collapse from GPU data

Heisenberg (O(3) continuous symmetry)

Heisenberg scaling collapse from GPU data

XY (O(2) planar symmetry)

XY scaling collapse from GPU data

Each model recovers the expected critical exponents for its universality class, confirming that the GPU implementation is correct across all three symmetries.


Algorithms and Performance

Wolff Cluster Algorithm

The Wolff algorithm grows correlated spin clusters from a random seed and flips the entire cluster in one step. Near T_c, it achieves a dynamic exponent z_W of roughly 0.3, compared to z of roughly 2.17 for single-spin Metropolis — approximately 7x faster decorrelation at the critical point.

GPU Checkerboard Metropolis

The lattice is coloured like a chessboard so that all same-colour spins can update simultaneously without neighbour conflicts. On an RTX 2060 this enables over 10,000 simultaneous spin updates, providing an estimated 50-200x speedup over CPU single-core Metropolis.

GPU Parallel Tempering

Replica exchange Monte Carlo runs multiple copies of the system at different temperatures on the GPU, swapping configurations between adjacent replicas to improve sampling efficiency — especially near the critical point where autocorrelation times diverge.


Non-Equilibrium Physics

Kibble-Zurek Mechanism

When the system is cooled through T_c at a finite rate, it cannot keep up with the changing equilibrium. Topological defects (domain walls) freeze in, with density following a power law in the quench timescale.

The measured exponent kappa = 0.258(15) at L=80 agrees well with the theoretical prediction kappa = nu/(1 + nu*z) = 0.279.

Kibble-Zurek power-law fit: defect density vs quench time

Domain Coarsening (Allen-Cahn)

After a sudden quench below T_c, domains of aligned spins grow over time. The domain wall density decays as rho(t) ~ t^(-1/2), consistent with Allen-Cahn theory for non-conserved order parameter dynamics.

Domain wall density decays as t^(-1/2)


Materials Science: From Simulation to Experiment

By fitting the exchange coupling constant J to reproduce experimental Curie temperatures, the simulator bridges lattice models to real magnetic materials:

MaterialLatticeJ_fitPredicted T_cExperimental T_c
Iron (Fe)BCC14.3 meV1043 K1043 K
Nickel (Ni)FCC5.6 meV~631 K~627 K

Supporting arbitrary graph topologies (BCC, FCC, bond-diluted, custom edge lists) makes this possible without changing the core simulation engine.

Bond Dilution

Randomly removing bonds weakens the magnetic coupling. The critical temperature decreases approximately linearly with dilution fraction, consistent with the Harris criterion.

Critical temperature vs bond dilution fraction


Validation

The simulator is validated against exact analytical solutions and consistency checks:

  • Onsager exact solution — 2D Monte Carlo matches the exact analytical result to within 0.02%
  • Exact enumeration — full brute-force calculation on a 4x4 lattice matches Monte Carlo averages
  • Fluctuation-dissipation theorem — heat capacity from energy fluctuations agrees with the direct numerical derivative
  • Autocorrelation scaling — autocorrelation times grow with system size as expected
  • Known limits — fully ordered at T=0, fully disordered at T → infinity

Monte Carlo results match Onsager's exact 2D solution


Engineering and Reproducibility

This is not just a simulation — it is a reproducible research platform:

  • 87 tests (74 unit + 13 integration) across the full codebase
  • CI/CD via GitHub Actions: format, build, test, clippy, cargo-deny on Ubuntu/Windows/macOS
  • Versioned result packs with checksums, manifests, and full parameter provenance
  • Scripted reproductionreproduce_validation.py, reproduce_classical_baseline.py, reproduce_dilution.py, reproduce_kz.py
  • Graph-agnostic architectureneighbours: Vec<Vec<usize>> works for any topology
  • WASM compilation for the interactive browser demo via wasm-bindgen

The entire codebase is roughly 5,000 lines of Rust across 46 source files, with optional CUDA support gated behind a feature flag.


Publication Status

A manuscript is in preparation targeting Physical Review E, covering:

  • Finite-size scaling validation on the 3D cubic Ising model
  • GPU-accelerated Monte Carlo for three universality classes
  • Exchange coupling fitting for BCC iron and FCC nickel
  • Bond dilution and the Harris criterion
  • Kibble-Zurek defect scaling

Research Roadmap

PhaseFocusTimeline
1. Benchmark PlatformLock down correctness, finish L≤192 GPU analysisCurrent
2. Anisotropy CrossoverHeisenberg-to-Ising crossover via uniaxial anisotropyNext
3. Materials-InspiredBCC/FCC Heisenberg with fitted couplings, competing interactionsFuture
4. Quantum BridgeTransverse-field Ising model as first quantum-critical benchmarkLong-term

Sources