In the demonstration below, we simulate a 10-state
(Q = 10) Potts model.
For Ising model, set Q = 2.
Download: Java source code.
The principles of Monte Carlo simulations are best illustrated on the two-dimensional Ising/Potts model.
The system is set up on a L×L lattice.
Each site has a spin,
and each spin
si
at site
i
can assume one of the two values 1 or −1.
Each spin can only interact with the four neighbors.
The Hamiltonian (energy function)
H
is defined as
The code is2.c,
gives a minimalist example for a simulation of 2D Ising model.
It outputs energy and heat capacity.
Exact value for the internal energy and heat capacity are
Eav = −1133.866661, C = 907.072, respectively,
computed from is2exact.c.
The above Monte Carlo simulation requires many random numbers for selecting spins and for deciding whether or not to accept a move. Here are some commonly-used options.
rand()
function
from the standard C library <stdlib.h>
in any Monte Carlo simulation,
usually it yields terribly wrong results (due to a short period of self-repetition),
see is2rand.c.
Below we demonstrate a generalization of the Ising model, called Potts model. Here the spin on each site can now assume Q, instead of two, different values (shown by different colors).
The Hamiltonian becomes:
The model is demonstrated at the beginning of the web page.