









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The fortran code for performing a random walk in two dimensions and running the monte carlo simulation of the 2-d ising model. The code includes declarations, subroutines, and explanations of the overall outline of the program. It also discusses the physical meaning of the results, such as magnetization, energy, heat capacity, and susceptibility.
Typology: Study notes
1 / 16
This page cannot be seen from the preview
Don't miss anything!










! Program to perform a random walk in two dimensions ! repeats for many realizations and accumulates r2 statistics IMPLICIT NONE INTEGER, PARAMETER :: Prec14=SELECTED_REAL_KIND(14) INTEGER :: i,j,is,ne,nt REAL(KIND=Prec14) :: rnd,rnds,r2,t INTEGER, PARAMETER :: ntmax=100! maximum number of time steps INTEGER, PARAMETER :: nemax=100000! number of walks in ensemble REAL(KIND=Prec14), DIMENSION(ntmax) :: r2a! accumulated average of r
! initialize random number generator call RANDOM_SEED
call RANDOM_NUMBER(rnd) call RANDOM_NUMBER(rnds) One random number (rnds) can be used to decide on +/- Step Other random number (rnd) can be used to decide whether we move walker in x or y direction
log Declarations, Monte Carlo 2-D Ising model IMPLICIT NONE INTEGER, PARAMETER :: Prec14=SELECTED_REAL_KIND(14) INTEGER , PARAMETER :: mcmax=5.0d8,mcmin=mcmax/ INTEGER, PARAMETER :: nn= INTEGER, PARAMETER :: nx=nn,ny=nn INTEGER :: ix,iy INTEGER :: mc,kt,ktot REAL(KIND=Prec14) :: l1,en,en0,K,mag,lav,mav,rnd,prob,mav2,lav REAL(KIND=Prec14), DIMENSION(nx,ny) :: S REAL(KIND=Prec14), PARAMETER :: ksteps= 100 REAL(KIND=Prec14), PARAMETER :: kmax=0.50d0,kmin=0.30d REAL(KIND=Prec14), PARAMETER :: dk=(kmax-kmin)/ksteps
l1=0.0d do ix=1,nx do iy=1,ny call cluster(ix,iy,nx,ny,S,K,en) l1=l1+0.5d0*en enddo enddo Initial energy
subroutine cluster(ix,iy,nx,ny,S,K,en) INTEGER, PARAMETER :: Prec14=SELECTED_REAL_KIND(14) INTEGER :: ix,iy,nx,ny,l,m,n REAL(KIND=Prec14), DIMENSION(nx,ny) :: S REAL(KIND=Prec14) :: K,en ! compute interaction of spin ix,iy with its neighbors en=0.0d do n=0, l=ix-1+n* m=iy ! implement the pbc if(l.lt.1) l=nx if(l.gt.nx) l= en=en-KS(ix,iy)S(l,m) enddo do n=0, l=ix m=iy-1+n* ! implement the pbc if(m.lt.1) m=ny if(m.gt.ny) m= en=en-KS(ix,iy)S(l,m) enddo return end Cluster subroutine
Heat capacity -- discontinuity at T=T C C 1/K
Susceptibility -- diverges at T=T c χ 1/K
Integrating equations of motion
i , x
i
i , x
! F i , y = m i dv i , y dt ! F i , z = m i dv i , z dt ! dv i , x dt = d 2 x i dt 2 " x i ( n + 1 ) # 2 x i ( n ) + x i ( n # 1 ) $ t 2
i
i
i
i , x
i
2 This works out to give the Verlet algorithm,
Lennard-Jones potential for noble gas ! V (^) ( r ) = 4 "
r $ % & ' ( ) 12
r $ % & ' ( ) 6
,
Radial distribution function ! g ( r ) =
( (^) ij ) i % j &