Classical models of statistical physics and complex systems implemented in Julia: equilibrium phase transitions, out-of-equilibrium collective motion, synchronization, and stochastic processes — with Monte Carlo, ensemble averaging, and finite-size critical analysis.
Developed for the graduate course Física Estadística Computacional (MSc in Physics). Author: José Ake · github.com/ak3sit0
| Module | Model | Method | Key result |
|---|---|---|---|
spin-models/ising |
2D Ising | Metropolis and Wolff Monte Carlo, Binder cumulant | Ferro–para transition; recovers Onsager's exact Tc = 2/ln(1+√2) ≈ 2.269 |
spin-models/xy |
2D XY | Metropolis, spatial correlations G(r) | Quasi-long-range order (algebraic vs. exponential decay) |
vicsek |
Vicsek | Self-propulsion, threaded ensembles | Order–disorder transition (out of equilibrium), φ(η) |
kuramoto |
Kuramoto | Coupled phase oscillators | Spontaneous synchronization, order parameter r(K) |
random-walks |
Brownian, Ornstein–Uhlenbeck, Run-and-Tumble, resetting | Langevin dynamics, MSD | Diffusion, persistence, stochastic resetting |
The 2D Ising critical point is found via the Binder cumulant crossing across lattice
sizes (finite-size scaling), recovering the exact Onsager value Tc = 2/ln(1+√2) ≈ 2.2692.
Also computed: magnetization, specific heat, and spatial correlations.
Self-propelled particles exhibit a sharp phase transition from ordered (aligned flocking) to disordered (random motion) as noise increases.
| Low Noise (Ordered) | High Noise (Disordered) | Order Parameter φ(η) |
|---|---|---|
![]() |
![]() |
![]() |
Ising at Tc |
XY (low T) | Vicsek (ordered) |
|---|---|---|
![]() |
![]() |
![]() |
vicsek/SimulationUtils.jl— a reusable module: metaprogramming (@pbc, a zero-overhead@debug,@timed) and a higher-orderparallel_ensemblethat runs realizations across threads with an independent RNG per thread, keeping results reproducible.- Observables are estimated by averaging over independent realizations with reported SEM.
Requires Julia 1.9+. Dependencies are pinned in Project.toml:
using Pkg
Pkg.activate(".")
Pkg.instantiate()Notebooks run with IJulia (or VS Code + the Julia extension). For threading:
export JULIA_NUM_THREADS=8.
Each model is available as a reusable Julia module in src/:
using Pkg
Pkg.activate(".")
# Load a model
using Ising
# Create and simulate
model = Ising.IsingModel(L=20, T=2.269)
Ising.equilibrate!(model, 1000)
M = Ising.compute_magnetization(model)Available modules: Ising, XY, Vicsek, Kuramoto, RandomWalks, SimulationUtils.
Physics-based tests validate key properties (e.g., Onsager critical temperature, MSD exponents):
julia --project -e 'using Pkg; Pkg.test()'Tests run automatically on every push via GitHub Actions (see .github/workflows/test.yml).
statistical-physics-computational/
├── spin-models/ ising/ · xy/
├── vicsek/ vicsek.ipynb · SimulationUtils.jl
├── kuramoto/ kuramoto.ipynb
├── random-walks/ brownian, ou, run-and-tumble, resetting notebooks
├── assets/ GIFs and animations
└── Project.toml reproducible environment
Onsager (1944), Crystal Statistics I; Landau & Binder, A Guide to Monte Carlo Simulations in Statistical Physics; Vicsek et al. (1995); Kuramoto (1975). Per-model references live in each module's README.
Code under the MIT license. © 2026 José Ake.






