The *Ising Model* is a model of a permanent magnet. It is named after Ernst Ising, who solved the one-dimensional version exactly as part of his 1924 thesis. The *Ising Model* is interesting due to the two- and three-dimensional versions exhibiting a **phase transition** at a critical temperature, above which the model no longer exhibits permanent magnetism. This is an example of short-range local interactions giving rise to extended long-range behavior, which can be a counter-intuitive and unexpected outcome. It should also be noted that the *Ising Model* is a special case of the more general *Heisenberg Model*, which is a magnetic model that is still in use to this day.

Only a specific version of the two-dimensional *Ising Model* can be solved exactly, and the three-dimensional version cannot be solved exactly in any form. Solving the Ising model is a statistical problem, and so its results can be numerically calculated using the Monte Carlo method to run simulations. The Monte Carlo method for simulating the two-dimensional Ising model is a classic problem in statistical mechanics and magnetic modeling, and the simulation itself is intriguing to watch when converted into an animation. Furthermore, Ising-like models have been used outside of the field of physics to explain complex behaviorial phenomena, including rational herding, segregation, and how languages change over time. There has been great utility in studying this seemingly simple model, and it continues to play an important role in simulated-based science.

Iron is a classic and familiar example of a permanent magnet. Permanent magnets are different from other kinds of magnets in that they generate a magnetic field via their internal structure. However, this type of magnetism cannot be sustained under all conditions. For example, above 1418 degrees Fahrenheit (the **critical temperature**) iron is no longer magnetic. And, it turns out, the demagnetization process that’s induced by heating a material is quite complicated, but yet can be modeled in a straightforward way. **This is the context for the Ising Model: we want to model what happens to a permanent magnet as you increase the temperature and it starts to demagnetize.**

It may sound overly simplistic, but a reasonable model for a permanent magnet is as a grid of arrows that either point up or down. A grid of all *up* arrows is called **ferromagnetism** and is a model of what happens with iron at lower temperatures:

The subsections in How the Simulation Works explain some of the details behind **why** the arrows would prefer to all point in the same direction.

Now, if we “turn on” the temperature, some of these arrows will start to flip their direction from up to down. Above the **critical temperature**, you will find that, on average, 50% of the arrows will point up and the other 50% will point down, much like in this image:

To take this a little further, imagine that you assign a value of \(+1\) to each up arrow and a value of \(-1\) to each down arrow. You then add the number of \(+1\)s and \(-1\)s together, which will give you the total magnetization. If the sum is 0 on average, then we have a paramagnet. If instead the sum is non-zero, then we have a ferromagnet.

For our purposes, instead of using arrows, we will replace the blue up arrows with a light yellow square and wthe orange down arrows with a dark blue square.

The simulation environment is bit like an over-sized checkerboard, in that it’s a two-dimensional square grid with \(n\) rows and \(n\) columns. For the purposes of this simulation, we set \(n=100\), meaning that there are 10,000 squares on the grid. To set things up, we first will populate the grid with two different colors of squares: **blue** and **yellow**. We do this by moving to each grid square and flipping a coin. If we get “heads”, then we color the square **yellow**, else if we get “tails” we color the square **blue**. We repeat this process until we’ve colored every grid square either **yellow** or **blue**.

If you’ve ever taken a physics class, you’ve likely encountered the concept of **energy**, which is defined as the capacity for doing work. Energy comes in several forms, including potential, kinetic, electric, and thermal energy. For this simulation, we are dealing with two kinds of energy, electric energy and thermal energy.

We call the full collection of yellow and blue squares the **system**. Although you might not know it simply by looking at the model itself, the squares themselves are meant to represent a lattice of atoms with electrons in their orbitals. The electrons can interact via the Coulomb interaction, meaning there is electrical energy in the system, and they must also obey the laws of quantum mechanics. In certain situations, these interactions lead to **magnetism** and **long-range magnetic ordering**, meaning that you have a permanent magnet, much like the magnets you might hang on your refrigerator. Thankfully, it is not necessary to know quantum mechanics or the details of magnetism in order to implement or interpret the Ising Model.

We can compute a total energy for the system as follows:

Start with a grid square and look at its color, if it’s yellow the square’s value is \(+1\), while if it’s blue the square’s value is \(-1\)

Inspect the square’s four neighbors in the north, south, east, and west directions, note the color of each, and then convert that into a \(+1\) or \(-1\) value just as in step 1

Multiply each of the four neighbor values by the central square’s value

Sum up the four products to produce a single value, then take the negative of this value (for example, a \(2\) will become \(-2\)) and save the result, which should be a value between \(-4\) and \(4\)

Repeat steps 1–4 for all remaining squares in the grid

After checking every square, sum together

**all**of the logged numbers from step 4 to produce a single number, then divide by 2 (this is because of double counting, you only want to count each pair of squares once when computing the total energy, but this procedure will count every pair twice)

The number that you compute at the end of step 6 is the system’s total energy. To further illustrate, imagine we have a yellow square with one blue neighbor and three yellow neighbors. If we apply steps 1–4 to this scenario, we then compute the single square’s energy as \(-(1 \times -1) - (1 \times 1) - (1 \times 1) - (1 \times 1) = -2\).

The role of thermal energy is described in the next section.

In addition to initializing the grid, we also need to set the *Temperature* parameter, which by default is set to \(T = 1\). If you are wondering why the temperature isn’t specified in units of degrees Fahrenheit, Celsius, or Kelvin, that’s because this simulation was implemented using “unit-less” parameters, which are convenient from a modeling and simulation perspective. What does temperature do in the context of the Ising Model? It introduces a non-zero probability that the system will transition from a state of lower energy, as computed in the previous section, to a state of higher energy. In order to compute this probability, we first look at how the energy of the system changes if we flip a yellow square to a blue square, or flip a blue square to yellow. We label the change in energy due to this test flip as \(\Delta{}E\). Then, if \(\Delta{}E\) is positive, meaning that the flip will *increase* the total energy, we calculate the probability of this transition occuring using the formula: \[\text{Probability}=e^{\Delta{}E/T}\] Below we outline how this probability factors into the simulation’s algorithm.

One step in the simulation proceeds as follows:

Select a square — color is not important — at random

Perform a test flip where the square changes color from yellow to blue or blue to yellow, and calculate how much this changes the total energy of the system

If the energy

*decreases*after the test flip, then accept the flip and the time step is over, otherwise continue to step 4If the energy

*increases*after the test flip, compute the probability \(e^{\Delta{}E/T}\)Generate a random number between 0 and 1

If the random number from step 5 is

*smaller*than the probability in step 4, then accept the flip, if not then reject the flip

Steps 1–6 are then repeated multiple times until the simulation is stopped by pressing the `Pause`

button or closing the web browser. This particular algorithm is known as the Metropolis-Hastings algorithm.

An implementation of *Ising Model* is below. Use the slider to adjust the temperature of the simulation, which can be varied in real-time as the simulation runs. **However, it is recommended that you don’t continuously move the temperature slider around**. Instead, select a temperature and let things run for a while. If you wish to reset the simulation, press the `Reset`

button.

How does moving the temperature slider affect how easy it is for colors of the same color to clump together?

Does the simulation ever reach a point where every grid cell is the same color? If so, can you destroy the same color state by ramping up the temperature slider? About how high does the simulation’s temperature need to be before something like this occurs?

Can the “domain walls” that separate blue regions from yellow regions ever grow or shrink significantly over time?