Interactive real-time simulation of the 2D Ising model with OpenGl, using the FLTK library (https://www.fltk.org) for the graphical interface.
Let's consider a 2D NxN spin lattice, where each spin can assume the values
-uniform interaction term
-uniform external magnetic field
is then:
where
For the 2D case we have 4 nearest neighbours, let's call them up (U), down (D), left(L) and (R) right. Then the Hamiltonian at a local site
For simplicity we set |J| = 1 and re-parameterize the external magnetic field
So a single spin flip at the site
Since
In the Metropolis-Hastings algorithm we are accepting the spin flip with acceptance rate
The value of the critical temperature from Onsager's exact solution for the 2D model is
For our simulation, instead of the absolute temperature
completely removing the model's dependence on
To summarize, the model depends on two external variables,
In the program you can choose the initial distribution of the spins (random, all up, all down) and the value of J:
(J=1 -> ferromagnetic, J=-1 -> antiferromagnetic)