Disclaimer: I just found a possible solution - eventhough i don't really understand, whats wrong with my prior approach. Edit:
I just tried to calculate it from scratch and found the following:
$E = -J*s\sum_r s_r$ and the new energy $E_n = -J*s_n \sum_r s_r$ where $s_n = -s$.
So the difference is:
$E_n - E = -J*s_n \sum_r s_r - -J*s\sum_r s_r = (-J\sum_r s_r)(s_n -s) = (-J\sum_r s_r)(-s -s) = (-J\sum_r s_r)(-2s)$.
So there's a factor 2 instead of a factor 4 in the energy difference.
My prior thought was:
If i change the spin from -1 to 1 from a point surrounded by +1 spins the energy of that point changes from +4J to -4J and all the surrounding points energy get reduced by 2, which adds up to the total difference $\delta E = (-4J-4J)+4*(-2J) = -16J
Why is that wrong?
The old problem, somewhat solved. Question- name still applies.
I'm currently writing a simulation of the 2D Ising model and there's something strange with my program.
I calculate my energy difference before a spinflip (Metropolis Hastings algorithm) with
dE = -4*s*S
s is the spin value of the (soon to be flipped) lattice site and
S is the sum of the nearest neighbours.
Usually there would be a coupling constant--I assumed it's just 1--and there is no field.
Then I calculate the probability with:
Math.exp(-dE* Beta) //Beta == 1/T
Here are the calculated acceptance prbpabilities, the first value is the temperature ($kT/J = kT$), the second value is the energy difference (if it's zero or below zero the probability is 100% so i didn't include those). The third value is the probability.
0.5 16.0 1.2664165549094176E-14 0.5 8.0 1.1253517471925912E-7 1.0 16.0 1.1253517471925912E-7 1.0 8.0 3.3546262790251185E-4 2.0 16.0 3.3546262790251185E-4 2.0 8.0 0.01831563888873418 2.2669 16.0 8.604140030289146E-4 2.2669 8.0 0.029332814440979144 3.0 16.0 0.004827949226449516 3.0 8.0 0.06948344570075318 4.0 16.0 0.01831563888873418 4.0 8.0 0.1353352832366127
This is a screen shot of the simulation at $T=T_c = 2.2669$ which differs from what I expect: http://i.stack.imgur.com/Dmpi3.png
Can someone confirm my probabilities or suggest what is wrong with them?