Computational Projects » 2-Dimensonal Ising Model Simulation

This is a simulation of the two-dimensional square lattice Ising model that I created for fun. The plot below (once you press start) has two frames. The large frame on the left is a 2-D grid of boxes that represent the individual spins of atoms. These spins are only allowed two values: up and down, signified by two different colors. The thin bar on the right shows the magnetization.

Each spin is coupled to its four nearest neighbors. The tendency is for all of the spins to align the same way. In fact, the lowest energy configurations are when all of the spins are up or down. In statistical physics, however, the energy is not fixed but is Boltzmann distributed. Below the Curie temperature (marked on the temperature slider), this leads to domains with the same spin – a ferromagnet. At higher temperatures the fluctuations are too great for domains to form. There is a phase change at the Curie temperature. You can also apply an external magnetic field. The spins in the system tend to align themselves with the field. This has the effect of enlarging the domains matching the field until the whole system is aligned. This is the effect of induced magnetism found in all ferromagnets.

The problem is solved with the Metropolis algorithm. A number of spins are chosen randomly as trials. The probabiliy that the spin will flip is given by the Boltzmann distribution and depends on the energy difference that would occur if flipped and the temperature. If the temperature is high, the probability of a flip is high, regardless of the energy difference. The simulation is done in Javascript using a web worker for the computation and HTML5 canvas for the display.

I also created a video demonstrating some of the neat features in this model.


Runtime Options
Temperature:
External Magnetic Field:
Color Palette:
Trials per Frame
Initial Options
Resolution:
Initial State:
1x
The source code is available for those interested. You are free to use or modify my code and ideas. I just ask that you give credit where credit is due by including a reference to me and a link to this website. Download Source Code