Professional Documents
Culture Documents
(To Minh) SwendsenWang
(To Minh) SwendsenWang
Ii Ii+1
i=1
[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];
d i=1
Ii
Swendsen Wang algorithm, 100 iterations, all spins +1 initially, T = .4 180
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
d i=1
Ii
Swendsen Wang algorithm, 100 iterations, random spins initially, T = .4 160
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