2D Ising model simulation using the Metropolis algorithm.

There is one thing which I don't understand. The difference in energy $\Delta E$ between the initial state and the new state is:

$\Delta E = 2Js\sum_rs_r$ (btw can someone confirm that pls) where J is constant, s-initial spin and sum are equal to the sum of spins of the nearest neighbours.

The new state is always accepted when $\Delta E<0$ or if $\Delta E>0$ accepted with probability $p=\exp(-\Delta E/k_bT)$.

The question is, what happens when $\Delta E = 0$?

  • $\begingroup$ If you apply either of the $\Delta E < 0$ and $\Delta E > 0$ rules to the $\Delta E = 0$ case, you get the same result (accept with probability $p=1$). $\endgroup$
    – Noiralef
    Commented Jan 28, 2017 at 11:29

1 Answer 1


The answer comes from the implementation. The simplest way to code this is to generalize the process of acceptance by always calculating the acceptance probability $p=\exp(-\Delta E / k_b T)$, which, all other quantities assumed constant:

  • is between 0 and 1 for $\Delta E > 0$
  • is larger than 1 for $\Delta E < 0$
  • is exactly 0 for $\Delta E = 0$

Then you pick a real number between 0 and 1 at random and if it's less than $p$, accept the spin flip. And here's the kicker - since you're picking a random float, the chance of hitting precisely 1 is basically zero. So it's not something that's going to impact your simulation either way.

This, at least, is how it was implemented in the amazing MOOC "Statistical Mechanics: Algorithms and Computations" on Coursera, so I'm basing the answer on that.

Your $\Delta E$ expression looks okay, by the way.

  • $\begingroup$ For ΔE = 0 p =1 and spin flip is always accepted? $\endgroup$
    – ad1v7
    Commented Jan 27, 2017 at 22:05
  • $\begingroup$ Yeah, because your random number for checking acceptance of the flip is always below zero. $\endgroup$ Commented Jan 27, 2017 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.