Homework 08: Local Metropolis and Cluster algorithm for the Ising model
Don't hesitate to ask questions and make remarks on this page.


In this exercise, we study the local Metropolis algorithm and the Cluster algorithm for the two-dimensional Ising model.

A- Local algorithm

Implement the local Metropolis algorithm, as seen during the lecture:
def square_neighbors(L):
   N = L*L
   site_dic = {}
   x_y_dic = {}
   for j in range(N):
      row = j//L
      column = j-row*L
      site_dic[(row,column)] = j
      x_y_dic[j] = (row,column)
   for j in range(N):
      row,column = x_y_dic[j]
      right_nbr = site_dic[row,(column+1)%L]
      up_nbr = site_dic[(row+1)%L,column]
      left_nbr = site_dic[row,(column-1+L)%L]
      down_nbr = site_dic[(row-1+L)%L,column]
   nbr = tuple(nbr)
   return nbr,site_dic,x_y_dic
S=[choice([-1,1]) for k in range(N)]
for i_sweep in range(100):
   for iter in range(N):
      h=sum(S[nbr[k][j]] for j in range(4))
      if ran(0.,1.) < Upsilon: S[k] = -S[k]
  1. Change two lines in this algorithm so as to compute the internal energy and the specific heat (see SMAC p. 235).
  2. Check the implementation of this algorithm in the 6x6 lattice with periodic boundary conditions (compare with SMAC Table 5.3 page 236, which was obtained using exact enumerations): compare (on a graphics) your numerical evaluations of the internal energy and the specific heat to that provided in the table. Comment on the convergence in time. For a some well-chosen values of the temperatures (i.e. far and around Tc), determine the error of your evaluation using the bunching algorithm, and comment.

B- Cluster algorithm

Implement the Wolff cluster algorithm as seen during the lecture:
S=[choice([-1,1]) for k in range(N)]
p=1 - exp(-2*beta)
for iter in range(100):
   Pocket = [k]
   Cluster = [k]
   N_cluster = 1
   while Pocket != []:
      k =choice(Pocket)
      for l in nbr[k]:
         if S[l] == S[k] and l not in Cluster and ran(0,1) < p:
            N_cluster += 1
   for k in Cluster: S[k] = - S[k]
   print iter, N_cluster
  1. For large lattices, such as 32x32, determine numerically the mean cluster size flipped at each step of this algorithm as a function of temperature. Comment, especially, considering temperatures (i) well below the critical temperature, (ii) around the the critical temperature and (iii) well above the critical temperature. Explain the observed behaviour.

C- Comparison between local and cluster algorithm

Consider as an observable the mean value of the absolute magnetization

  1. Using the bunching algorithm (and displaying your results on a graphics), determine the error on the measure of this observable for the two algorithms at the inverse temperatures β = 0.2 and β = 0.4. (Try 14 bunching iterations for β = 0.2 and 16 bunching iterations for β = 0.4).
  2. Comment (in view of the critical slowing down).

[Print this page]