Change two lines in this algorithm so as to compute the internal energy and the specific heat (see SMAC p. 235).

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:

L=32
N=L*L
S=[choice([-1,1])for k inrange(N)]
beta=
p=1 - exp(-2*beta)
nbr,site_dic,x_y_dic=square_neighbors(L)foriterinrange(100):
k=randint(0,N-1)
Pocket =[k]
Cluster =[k]
N_cluster =1while Pocket !=[]:
k =choice(Pocket)for l in nbr[k]:
if S[l]== S[k]and l notin Cluster and ran(0,1)< p:
N_cluster +=1
Pocket.append(l)
Cluster.append(l)
Pocket.remove(k)for k in Cluster: S[k]= - S[k]printiter, N_cluster

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

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).

Homework 08: Local Metropolis and Cluster algorithm for the Ising model## Table of Contents

Don't hesitate to ask questions and make remarks onthis page.## Introduction

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:i.e.far and aroundTc), 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:

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β= 0.2 andβ= 0.4. (Try 14 bunching iterations forβ= 0.2 and 16 bunching iterations forβ= 0.4).[Print this page]