Metropolis algorithm for the Ising model

The Metropolis algorithm can be summarized in the context of the simulation of a system of Ising spins as follows:
  1. Establish an initial microstate: a random initial configuration of spins.

  2. Make a random trial change in the microstate: choose a spin at random and flip it, si -> -si.

  3. Compute DE = Etrial - Eold, the change in the energy of the system due to the trial change.

  4. If DE <= 0, accept the new microstate and go to step 8.

  5. If DE > 0, compute the Boltzmann weighting factor w = exp[-(DE)/kT].

  6. Generate a random number r in the unit interval.

  7. If r <= w, accept the new microstate; otherwise retain the previous microstate.

  8. Determine the value of the desired physical quantities.

  9. Repeat steps (2) through (8) to obtain a sufficient number of microstates.

  10. Periodically compute averages over microstates.

Steps 2 through 7 give the conditional probability that the system is in microstate {sj} given that it was in microstate {si}.

 

This description of the algorithm is attributed to Harvey Gould.