Docsity

Random Walk and Ising Model: Fortran Code and Explanation, Study notes of Physics

Toggle sidebar
bg1
Random walk declarations
! Program to perform a random walk in two dimensions
! repeats for many realizations and accumulates r**2 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**2
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Random Walk and Ising Model: Fortran Code and Explanation and more Study notes Physics in PDF only on Docsity!

Random walk declarations

! 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

Random number generator

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

F

i , x

= m

i

dv

i , x

dt

! 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

x

i

( n + 1 ) = 2 x

i

( n ) " x

i

( n " 1 ) +

F

i , x

m

i

# t

2 This works out to give the Verlet algorithm,

Lennard-Jones potential for noble gas ! V (^) ( r ) = 4 "

r $ % & ' ( ) 12

r $ % & ' ( ) 6

,

  • . / 0

Radial distribution function ! g ( r ) =

" N

r $ r

( (^) ij ) i % j &

  • ρ is the density N/Ω
  • Dirac-delta defined numerically (not infinitely sharp)
  • In an ideal gas, g(r) =
  • In a liquid, g(r) =1 at long ranges, short range structure
  • In a crystal, g( r) has sharp peaks, long-range order