2
$\begingroup$

In most of the Monte-Carlo-Algorithms I studied, I found, at the place where they compute the energy, always a line of code, where they divided by four.

For example, this code-snippet is taken from here

def Energy(Q):
        starting_energy=0
        for i in range(len(Q)):
            for j in range(len(Q)):
                g=Q[i,j]
                n_y=Q[(i+1)%num,j]+Q[i,(j+1)%num]+Q[(i-1)%num,j]+Q[i,(j-1)%num]
                starting_energy+=g*-n_y
        return starting_energy/4

Another example can be found here

def calcEnergy(config):
    '''Energy of a given configuration'''
    energy = 0
    for i in range(len(config)):
        for j in range(len(config)):
            S = config[i,j]
            nb = config[(i+1)%N, j] + config[i,(j+1)%N] + config[(i-1)%N, j] + config[i,(j-1)%N]
            energy += -nb*S
    return energy/4.

From my understanding, we want to compute the energy of a spin-configuration that includes the spin we are currently looking at plus its closest neighbors. So in sum that would make 5 ising-spins we are computing in this function.

So why is it correct to return return energy/4 instead of return energy/5?

$\endgroup$

1 Answer 1

2
$\begingroup$

The energy expression is not a sum over spins, it is a sum over spin pairs, each pair counted once. But as expressed in

nb = config[(i+1)%N, j] + config[i,(j+1)%N] + config[(i-1)%N, j] + config[i,(j-1)%N

each (non-zero coupling) spin pair is counted 4 times. Hence the need to quarter the final result.

$\endgroup$
1
  • $\begingroup$ Thank you very much. I didn't understand that it is actually spin pairs one is looking at. $\endgroup$
    – MLK
    Commented Jun 6, 2020 at 16:38

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.