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 spins, each taking the value (spin-up or spin-down). Spins interact with their nearest neighbours, and the system uses periodic boundary conditions ().
Energy
The Hamiltonian (total energy) is:
- : ferromagnetic (aligned spins are favoured, lowering energy)
- : antiferromagnetic (anti-aligned spins are favoured)
Magnetisation
The magnetisation per spin measures the average alignment:
is fully aligned up, is fully aligned down, is disordered.
Analytical Results (1D)
In one dimension, there is no phase transition at finite temperature. The analytical energy per spin is:
(setting for simplicity).
Metropolis Algorithm
The Metropolis Monte Carlo algorithm samples spin configurations at temperature :
- Pick a random spin
- Compute the energy change if is flipped
- Accept the flip with probability
The acceptance probability as a standalone function is:
Your Task
Implement four functions:
ising_energy(spins, J=1.0)— compute total energy with periodic boundary conditionsising_magnetization(spins)— compute magnetisation per spinising_energy_analytical(T_K, J=1.0)— return analytical energy per spin ()metropolis_acceptance(delta_E, T_K)— return the Metropolis acceptance probability