Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

1

ACM 216: Lecture Agenda: Markov Chain Monte Carlo


1D Ising model Swendsen Wang algorithm

One dimensional Ising model


State space is {1, 1}d Distribution at temperature T T (I) exp 1 T
d1

Ii Ii+1
i=1

Swendsen Wang algorithm


Auxiliary bond variables bij {0, 1} Joint distributions (I; b) =
ij:Ii =Ij

[I(bij = 0)+I(bij = 1)(e2/T 1)]


ij:Ii =Ij

[I(bij = 0)]

Algorithm: repeat the following step until convergence 1. Sample from (b|I): for a given spin conguration I, sample the bond variable by giving every edge with Ii = Ij the value 1 w.p. 1 e2/T and 0 w.p. e2/T , and 0 otherwise. 2. Sample from (I|b): form clusters by connecting neighboring sites with bond value 1. Assign to each cluster the value 1 w.p. 1/2 independently of the others.

Implementation
% Swendsen and Wang algorithm for the 1D Ising model % pi(I) propto exp(beta sum_{i} I_{i} I_{i+1} d = 50; T = .46; beta = 1/T; iter = 100; I = ones(1, d); % initial configuration % I = 2*(rand(1,d)>.5)-1; for i=1:iter % sample bonds given spin configuration b = zeros(1,d-1); for i = 1:d-1, if I(i) == I(i+1) b(i) = (rand(1) > exp(-2*beta)); end end

% sample spin configuration given bonds clusters = FindClusters(b); nclusters = length(clusters); for k = 1:nclusters -1, I(clusters(k):clusters(k+1)-1) = 2*(rand(1) > .5) - 1; end I(clusters(nclusters):d) = 2*(rand(1) > .5) - 1; end

%-------------------------------------------------------------function clusters = FindClusters(bonds) % Find the left point of all clusters id = 1:length(bonds); clusters = [1, id(bonds == 0)+1];

Magnetization after 100 steps


Initial state: all the spins are up Magnetization histogram M =
300

d i=1

Ii
Swendsen Wang algorithm, 100 iterations, all spins +1 initially, T = .4 180

Swendsen Wang algorithm, 100 iterations, all spins +1 initially, T = .1

160 250 140

200

120

100 150 80

100

60

40 50 20

!45

!35

!25

!15

!5

15

25

35

45

!45

!35

!25

!15

!5

15

25

35

45

T = .1

T = .46

Magnetization after 100 steps


Initial state: spins are i.i.d. 1 Magnetization histogram M =
300

d i=1

Ii
Swendsen Wang algorithm, 100 iterations, random spins initially, T = .4 160

Swendsen Wang algorithm, 100 iterations, random spins initially, T = .1

140 250 120 200 100

150

80

60 100 40 50 20

!45

!35

!25

!15

!5

15

25

35

45

!45

!35

!25

!15

!5

15

25

35

45

T = .1

T = .46

You might also like