This is a numerical simulation of the ising-model in two dimensions, using the metropolis algorithm.
The cells of the grid represent coupled elementar magnets of a ferromagnetic solid. In a cubic grid with dimension d and grid length a, we number grid points k = 1, ..., N with N = ad. If sk = ±1 is the index of the third spin component, then a physical state of the ising-model is defined by (s1, s2, ..., sN). There are 2N possible states, and the energy of the state i in the ising-model is Ei = -(ε/2)ΣNk=0Σj in U(k)sk sj with the coupling constant ε > 0 and the nearest neighbours U(k) of grid point k. The canonical probability for the state i at Temperature T is pi = exp(-Ei/kT)/Z with the partition function Z := Σj exp(-Ej/kT). Spontaneous phase-transitions occur at low temperatures. With the definiton T' := kT/ε the critical temperature is T' = 2.27 (solution by L. Onsager, 1944).