A high-performance C++ Monte Carlo simulation engine modeling out-of-equilibrium critical phenomena and domain wall dynamics in disordered ferromagnetic lattices.
This project simulates the thermodynamic and dynamic phase transitions of a 2D Ising ferromagnet. The underlying engine utilizes the Metropolis-Hastings algorithm, heavily optimized for CPU cache efficiency using 1D flat-array memory mapping.
The project is divided into two phases:
- Equilibrium Validation: Replicating exact thermodynamic critical exponents via finite-size scaling.
- Out-of-Equilibrium Dynamics (Novel Contribution): Introducing a time-dependent oscillating magnetic field and quenched lattice defects to mathematically map how non-magnetic impurities pin domain walls and collapse dynamic limit cycles.
This engine was initially built to re-create the baseline thermodynamic results outlined in the paper Introduction to Monte Carlo methods for an Ising Model of a Ferromagnet by Jacques Kotze: https://arxiv.org/pdf/0803.0217
After successfully re-creating Jindal's static phase transition models, I expanded the underlying Hamiltonian to push the system out of equilibrium:
- Language: C++11 (Simulation Engine), Python 3 (Data Visualization)
- Optimization: 1D flat-array grid mapping to prevent CPU cache misses during sequential Metropolis sweeps.
-
Dynamic Probabilities: Real-time Boltzmann weight calculations (
$e^{-\Delta E / T}$ ) integrated with a "fast-fail" condition that skips calculations on impurity coordinates, preserving massive execution speed. -
RNG:
std::mt19937(Mersenne Twister) to ensure rigorous statistical sampling without pattern artifacts.
Before introducing chaos, the engine was validated against Lars Onsager's exact analytical solutions for the 2D Ising model. By calculating the maximum magnetic susceptibility across different grid sizes (
Figure 1: Log-Log plot of Maximum Susceptibility vs. Lattice Size. The calculated slope of 1.7519 perfectly mirrors the theoretical exact limit of
$\gamma/\nu = 1.75$ , proving the statistical rigor of the underlying Metropolis engine.
By exposing the lattice to an oscillating magnetic field H(t) = H0 * sin(wt), the system is forced into a hysteresis limit cycle. The Dynamic Order Parameter (
Figure 2: Dynamic Phase Boundary for a lattice with 10% quenched defects. The bright region represents the dynamically ordered phase (
$|Q| > 0$ , asymmetric limit cycle), while the dark region represents the chaotic, disordered phase ($|Q| \approx 0$ ).
To study how non-magnetic impurities alter physical strength, the parameter space was scanned across multiple defect concentrations (0% to 30%).
Figure 3: Dynamic phase boundaries mapped across varying impurity concentrations. As defect density increases, the absolute-zero coercive limit drops and the dynamically ordered parameter space collapses. This computationally proves that quenched impurities act as localized pinning centers, snagging expanding domain walls and structurally "softening" the ferromagnet.
1. Compile the C++ Engine
g++ -O3 -std=c++11 src/main.cpp src/IsingLattice.cpp src/MonteCarlo.cpp -o ising_sim

