← Back to Simulation

Ising Model Algorithms

Detailed descriptions of the Monte Carlo algorithms implemented in this simulation

Key Terms

Metropolis Algorithm

The Metropolis algorithm is a single-spin flip Monte Carlo method that follows the detailed balance condition. It's one of the most widely used algorithms for simulating the Ising model.

Implementation Details:

ΔE = 2J·s·(s_up + s_down + s_left + s_right) + 2h·s
P_accept = min(1, exp(-ΔE/T))

This algorithm efficiently samples the canonical ensemble and is particularly effective near equilibrium. The acceptance rate decreases at low temperatures but maintains detailed balance.

Glauber Dynamics

The Glauber algorithm is very similar to Metropolis, but uses a different acceptance probability that naturally satisfies detailed balance without requiring the min(1, ...) condition.

Implementation Details:

ΔE = 2J·s·(s_up + s_down + s_left + s_right) + 2h·s
P_accept = 1/(1+exp(ΔE/T))

Heat Bath Algorithm

The Heat Bath algorithm works by calculating the local field at site (i, j) from the nearest neighbors of each spin and the external field. This differs from other methods because we do not calculate ΔE to determine if a spin is flipped, rather we calculate the probability of it being +1 or -1 based on the local field.

Implementation Details:

local_field = J·(s_up + s_down + s_left + s_right) + h
P(s = +1) = 1 / (1 + exp(-2 * local_field / T))

Wolff Cluster Algorithm

The Wolff algorithm is a single cluster update method that can dramatically reduce critical slowing down near phase transitions. It constructs and flips an entire cluster of aligned spins. This algorithm is rejection-free, meaning that once a cluster is formed, it is always flipped.

Implementation Details:

P_add = 1 - exp(-2|J|/T) (add a site to the cluster)
P_ghost = 1 - exp(-2|h|/T) (couple a site to the ghost spin)
ghost_spin = 1 if h>=0 else -1
Note for Antiferromagnetism: This algorithm does not work out of the box for antiferromagnetic interactions (J<0). In order to handle this, we perform a gauge transformation by flipping one color of the checkerboard lattice before applying the Wolff algorithm. This effectively converts the antiferromagnetic problem into a ferromagnetic one, allowing the cluster algorithm to function correctly. At the end of every sweep, we flip the sublattice back to restore the original configuration. Learn more about checkerboard transformations here.
Note for External Field: In order to include the effect of an external magnetic field, we introduce a "ghost" spin that interacts with all spins in the lattice. Learn more about that here: Cluster representations and the Wolff algorithm in arbitrary external fields - Jaron Kent-Dobias, James P Sethna

Swendsen-Wang Algorithm

The Swendsen-Wang algorithm is another cluster algorithm that can efficiently update clusters of spins in a single move. The key difference between the Swendsen-Wang and Wolff algorithms is that Wolff only creates a single cluster which is always flipped with 100% certainty. Swendsen-Wang instead creates multiple clusters such that every site in the lattice is part of exactly one cluster, and then each cluster is flipped independently with a probability check. This means that for a lattice of N² sites, we can create anywhere from 1 to N² clusters, and none of them are guaranteed to be flipped.

Implementation Details:

Coming soon!
Note for Antiferromagnetism: This algorithm does not work out of the box for antiferromagnetic interactions (J<0). In order to handle this, we perform a gauge transformation by flipping one color of the checkerboard lattice before applying the Wolff algorithm. This effectively converts the antiferromagnetic problem into a ferromagnetic one, allowing the cluster algorithm to function correctly. At the end of every sweep, we flip the sublattice back to restore the original configuration. Learn more about checkerboard transformations here.
Note for External Field: In order to include the effect of an external magnetic field, we introduce a "ghost" spin that interacts with all spins in the lattice. Learn more about that here: Cluster representations and the Wolff algorithm in arbitrary external fields - Jaron Kent-Dobias, James P Sethna

Kawasaki Dynamics

The Kawasaki algorithm conserves the total magnetization by exchanging spins between neighboring sites rather than flipping individual spins. This is useful for studying systems with conserved quantities.

Implementation Details:

ΔE = E_after - E_before
P_accept = min(1, exp(-ΔE/T))
Note for ΔE Calculation: Normally when a site is flipped, 4 bonds are affected. In Kawasaki dynamics, since we exchange two spins, 6 bonds are affected (3 for each spin, the bond connecting the two sites is left unchanged). This must be accounted for in the ΔE calculation.

Comparison and Usage Guidelines

Performance Characteristics:

When to Use Each Algorithm:

Tip: In the simulation, you can switch between algorithms to see how they behave differently, especially near the critical temperature T_c ≈ 2.269 for the 2D Ising model.