Lesson 7 of 15

Ising Model

Ising Model

The Ising model is the workhorse of statistical mechanics — a minimal model of ferromagnetism that reveals deep truths about phase transitions and collective behaviour.

Setup

Consider a 1D chain of NN spins, each taking the value si{+1,1}s_i \in \{+1, -1\} (spin-up or spin-down). Spins interact with their nearest neighbours, and the system uses periodic boundary conditions (sNs0s_{N} \equiv s_0).

Energy

The Hamiltonian (total energy) is:

E=Ji=0N1sisi+1E = -J \sum_{i=0}^{N-1} s_i \, s_{i+1}

  • J>0J > 0: ferromagnetic (aligned spins are favoured, lowering energy)
  • J<0J < 0: antiferromagnetic (anti-aligned spins are favoured)

Magnetisation

The magnetisation per spin measures the average alignment:

M=1Ni=0N1siM = \frac{1}{N} \sum_{i=0}^{N-1} s_i

M=+1M = +1 is fully aligned up, M=1M = -1 is fully aligned down, M=0M = 0 is disordered.

Analytical Results (1D)

In one dimension, there is no phase transition at finite temperature. The analytical energy per spin is:

e=Jtanh ⁣(JkBT)\langle e \rangle = -J \tanh\!\left(\frac{J}{k_B T}\right)

(setting kB=1k_B = 1 for simplicity).

Metropolis Algorithm

The Metropolis Monte Carlo algorithm samples spin configurations at temperature TT:

  1. Pick a random spin sis_i
  2. Compute the energy change ΔE\Delta E if sis_i is flipped
  3. Accept the flip with probability min(1,eΔE/T)\min(1,\, e^{-\Delta E / T})

The acceptance probability as a standalone function is:

A(ΔE,T)={1if ΔE0eΔE/Tif ΔE>0A(\Delta E, T) = \begin{cases} 1 & \text{if } \Delta E \leq 0 \\ e^{-\Delta E / T} & \text{if } \Delta E > 0 \end{cases}

Your Task

Implement four functions:

  • ising_energy(spins, J=1.0) — compute total energy with periodic boundary conditions
  • ising_magnetization(spins) — compute magnetisation per spin
  • ising_energy_analytical(T_K, J=1.0) — return analytical energy per spin (kB=1k_B = 1)
  • metropolis_acceptance(delta_E, T_K) — return the Metropolis acceptance probability
Python runtime loading...
Loading...
Click "Run" to execute your code.