A quick explanation of the demonstration, for anyone who just wants to play around:
The above plot shows a spacetime view of the Ising Model in one dimension. I want you to understand what this plot is, what it represents, and how it was written, so it's a bit more than a "wow" picture to you.
Each pixel is a site. Each site can have one of two states, \([-1, +1]\). Each site interacts with its nearest neighbors and prefers to have the same spin as them. At each time step of the simulation (time increasing upwards), exactly one site is chosen for a potential random flip to the opposite state.
- \(T\) is the temperature of the system. The higher the temperature is, the more energetically the system is going to fluctuate. At high temperatures the picture will look like static noise.
- \(J\) is the strength of the interaction between the sites. At high \(J\) they will more aggressively want to be in the same state; at negative \(J\) they will want to be in different states. At \(J=0\) sites do not care about their neighbors at all.
- \(h\) is a constant, external field. Sites will want to become more strongly aligned with this field the larger it is, or more strongly anti-aligned the more negative it is. By default \(h=0\), and its effects are not present.
- Nx is the number of sites in the horizontal direction. If you consider the sites to be particles, a larger Nx simply means more particles, evenly spaced, will be present in the simulation.
One-Dimensional Ising Model
The traditional Ising model is a way of representing a system of sites, and there's no need to be too specific about what those sites are. Each site might represent a particle, an atom, a molecule, or a person, depending on what the simulation is being used for. The important point is that each pixel of the image is a site of the same kind as its neighbors.
Each site has only two orientations, called "states" in academic language. These states could be "up and down", or "present and not present", or "carnivore and vegetarian", as long as it is a binary option. I'll lean on "up and down" states for my discussion, and consider each site an atom (but I reserve the right to become lazy and say "particle" instead).
In the Ising model, each site interacts only with its nearest neighbors. In 1D, that means each state only interacts with its two immediate neighbors, in 2D with its four immediate neighbors, etc. The usual formulation is to consider states that prefer to be aligned with their neighbors; that is, a state that has neighbors that are "up" will prefer to be "up" as well.
The hamiltonian for the system takes the simple form below: The sum over index i and j sums each lattice site and care must be taken not to overcount. The factor of 1/2 in front of the first term takes into account the double counting of pairs from the sum of i and j over all sites. If the coupling constant \(J\) is a constant, its indices can be dropped. There may also be an external field of some sort (magnetic, electric, etc) that interacts with the sites in some way. I've represented that abstractly as \(\mathbf{h}\) here. Many treatments ignore the external field and the simulation on this page defaults to turning it off (\(\mathbf{h}=0\)).More details...
Ising Hamiltonian
The main bit of "simulation" here is this: assume that these sites are all interacting with their nearest neighbors, but also that they are in contact with some heat source that exchanges energy with the system so as to keep it at constant temperature \(T\). Because the temperature stays the same but energy is allowed to transfer between the sites and the heat bath, the energy of the Ising system fluctuates in time.
Random fluctuations are represented in the simulation by randomly choosing any one site of the system, and deciding whether or not to flip the state of that site. The decision is done using some insight from statistical physics, but essentially it comes down to this: if flipping the site would lower the energy of the total system, accept the flip and move on. If flipping the site would raise the energy of the total system, calculate the probabilistic likelihood of that fluctuation, and accept or deny the flip with that likelihood. The higher the energy would raise, the less likely the acceptance likelihood.
The Boltzmann distribution relates the probability of finding a system in a particular state to the energy of that state and its temperature. For a given temperature, a lower energy configuration will be more likely. In the Ising model this is used to decide whether or not to accept a random spin flip. The energy \(E\) is the total energy of the entire system's configuration; each site and its energy from interacting with each of its nearest neighbors would need to be calculated and summed to fully compute the Boltzmann distribution. The fix is that, since only one site is flipping at each step, the change in the energy between steps will only depend on the difference in the energy at that site. Imagine the Boltzmann distribution expressed as a sum over all sites i, and subtracting the energy at all sites after flipping site n. Each pair of unflipped sites will have the same energy, and the difference will cancel. Remember the criteria on which the spin flip is to be accepted or rejected? If the energy decreases, the flip is accepted: decreasing energy means \(\Delta E\) is negative, which means the Boltzmann factor is greater than or equal to one. Increasing energy means a positive \(\Delta E\), and a Boltzmann factor smaller than one. This is mathematically summarized below: This completes the mathematical basics needed to actually code the Ising model. If the energy stays the same or decreases, accept the step. If the energy increases, compute the Boltzmann factor. This will be some number on \([0,1)\). Compute a uniform random number \(U\) on this interval, and compare the two. If \(U \leq \exp\left(-\Delta E / k_B T\right) \), accept the flip.
More details...
Boltzmann distribution
The result is a simple model of not too many lines of code that has surpisingly deep effects encoded in it. The main attraction of the Ising model is the presence of phase transitions in systems. At a certain temperature, the system will exhibit long-range correlations between sites. In words: at a high temperature in this randomly fluctuating system, you wouldn't expect that knowing the spin of one site in the system would tell you anything about the spin of a site far away in the system. In certain cases, and when the temperature is low enough, that assumption breaks down, and distant sites do become correlated. This is surprising behavior from a model that is both simple and random, which has led to nearly a century of interest in the problem.
Phase transitions as described above do not occur in the one-dimensional Ising model. To observe them, an at least two-dimensional system is necessary. Since this page is a demonstration of the 1D Ising model, I'll leave the discussion here and hopefully finish a 2D example in the near future.
07.31.2026