monte carlo simulation methods
TRANSCRIPT
Monte Carlo Methods:- Markov Chain Random movements, one follow another- Importance sampling To sample many points in the region where the Boltzmann factor is
large and few elsewhere- Ergodicity (ensemble average) Such an average over all possible quantum states of a system - Detailed Balance
??
Metropolis Method:
]/)(exp[y probabilith accept wit :accept:
TKEEEEEE
Bonon
on
In terms of words:
- Canonical ensemble: N,V,T constant
- Metropolis method: To generate a new configuration with probabilities
Monte Carlo simulation in the canonical ensemble
0. Generate the initial configuration (random or c(2×2))
Beginning of the MC cycle
1. Calculate Eold 2. Randomly select a particle3. Random displacement (or rotation)4. Calculate Enew5. Accept the move with probability (Metropolis method) En<Eo accept (the move) En>Eo accept with probability exp[-(En-Eo)/kT] (Periodic boundary conditions)
End of MC cycle
In terms of diagram:
Monte Carlo simulation in the canonical ensemble
Monte Carlo simulation in the canonical ensembleChoice of the parameters
Initial configuration
do
en1=EN
typ=1call rand_pos(mat,typ,xrp,yrp)x1=xrp, y1=yrp
typ=0call rand_pos(mat,typ,xrp,yrp)x2=xrp, y2=yrp
mat(x1,y1)=0mat(x2,y2)=1
mat(x1,y1)=1mat(x2,y2)=0
call tot_EN(mat,EN,ei0,ei1)en2=EN
metropolis conditionsacceptance: save new values+ add MC stepRejection: add MC step
If (count.eq.mcs+1) thenexitend ifend do
Monte Carlo simulation in the canonical ensembleChoice of the parameters
Initial configuration
do
en1=EN
typ=1call rand_pos(mat,typ,xrp,yrp)x1=xrp, y1=yrp
typ=0call rand_pos(mat,typ,xrp,yrp)x2=xrp, y2=yrp
mat(x1,y1)=0mat(x2,y2)=1
mat(x1,y1)=1mat(x2,y2)=0
call tot_EN(mat,EN,ei0,ei1)en2=EN
metropolis conditionsacceptance: save new values+ add MC stepRejection: add MC step
If (count.eq.mcs+1) thenexitend ifend do
real, parameter:: k=8,617339E-5real *8:: enT,enT2
print *,”temperature:”read(*,*) T
print *,”MC steps:”read(*,*) mcs
print *,”starting configuration, R or C:”read(*,*) ststart=0select case (st)case ( “c”, “C”)start=1end select
Monte Carlo simulation in the canonical ensembleChoice of the parameters
Initial configuration
do
en1=EN
typ=1call rand_pos(mat,typ,xrp,yrp)x1=xrp, y1=yrp
typ=0call rand_pos(mat,typ,xrp,yrp)x2=xrp, y2=yrp
mat(x1,y1)=0mat(x2,y2)=1
mat(x1,y1)=1mat(x2,y2)=0
call tot_EN(mat,EN,ei0,ei1)en2=EN
metropolis conditionsacceptance: save new values+ add MC stepRejection: add MC step
If (count.eq.mcs+1) thenexitend ifend do
if (start.eq.1) thendo v=1,10
if (mod(v,2).eq.0) thenmat (u*2,v)=0elsemat (u*2-1,v)=0end if, end if, end do
elsedoxr= int (rand()*10)+1yr= int (rand()*10)+1if (mat(xr,yr).eq.1) thenmat(xr,yr)= 0
do u=1,5
nb=nb+1end iftt= int (10*10*(1-cov))if (tt.eq.nb) thenexitend if, end do, end if
%% Start c(2×2) %%
%% Start random %%
Monte Carlo simulation in the canonical ensembleChoice of the parameters
Initial configuration
do
en1=EN
typ=1call rand_pos(mat,typ,xrp,yrp)x1=xrp, y1=yrp
typ=0call rand_pos(mat,typ,xrp,yrp)x2=xrp, y2=yrp
mat(x1,y1)=0mat(x2,y2)=1
mat(x1,y1)=1mat(x2,y2)=0
call tot_EN(mat,EN,ei0,ei1)en2=EN
metropolis conditionsacceptance: save new values+ add MC stepRejection: add MC step
If (count.eq.mcs+1) thenexitend ifend do
if (en2.lt.en1) then
mat(x2,y2)=1
enT=enT+en2enT2=enT2+en2*en2
count=count+1
else
if (exp(-(en2-en1)/(k*T)).gt.rand()) then
mat(x2,y2)=1mat(x1,y1)=0enT=enT+en2enT2=enT2+en2*en2
count=count+1
mat(x1,y1)=0
else
end if, end if
enT=enT+en1enT2=enT2+en1*en1EN=en1
count=count+1
EN=en2
EN=en2
%% Acceptance %%
%% probability %%
%% Rejection %%
Monte Carlo simulation in the canonical ensembleChoice of the parameters
Initial configuration
do
en1=EN
typ=1call rand_pos(mat,typ,xrp,yrp)x1=xrp, y1=yrp
typ=0call rand_pos(mat,typ,xrp,yrp)x2=xrp, y2=yrp
mat(x1,y1)=0mat(x2,y2)=1
mat(x1,y1)=1mat(x2,y2)=0
call tot_EN(mat,EN,ei0,ei1)en2=EN
metropolis conditionsacceptance: save new values+ add MC stepRejection: add MC step
If (count.eq.mcs+1) thenexitend ifend do
Subroutine Number of nearest neighbours
NNE=0
id=xn+1if (id.gt.10) then
end if
ig=xn-1if (ig.lt.1) thenig=ig+10end if
jh=yn-1if (jh.gt.10) thenjh=jh-10end if
jb=yn+1if (jb.lt.1) thenjb=jb+10end if
NNE=id + ig + jb + jh
%% periodic boundary conditions %%
id=id-10
Monte Carlo simulation in the canonical ensembleChoice of the parameters
Initial configuration
do
en1=EN
typ=1call rand_pos(mat,typ,xrp,yrp)x1=xrp, y1=yrp
typ=0call rand_pos(mat,typ,xrp,yrp)x2=xrp, y2=yrp
mat(x1,y1)=0mat(x2,y2)=1
mat(x1,y1)=1mat(x2,y2)=0
call tot_EN(mat,EN,ei0,ei1)en2=EN
metropolis conditionsacceptance: save new values+ add MC stepRejection: add MC step
If (count.eq.mcs+1) thenexitend ifend do
Subroutine Total energy of the system
EN=0
do ii=1,10do jj=1,10
if mat(ii,jj).eq.1) then
%% periodic boundary conditions %%
xn=iiyn=jj
call near_numb(mat,xn,yn,NNE)
EN=NNE*ei1+ei0
Monte Carlo simulation in the canonical ensembleChoice of the parameters
Initial configuration
do
en1=EN
typ=1call rand_pos(mat,typ,xrp,yrp)x1=xrp, y1=yrp
typ=0call rand_pos(mat,typ,xrp,yrp)x2=xrp, y2=yrp
mat(x1,y1)=0mat(x2,y2)=1
mat(x1,y1)=1mat(x2,y2)=0
call tot_EN(mat,EN,ei0,ei1)en2=EN
metropolis conditionsacceptance: save new values+ add MC stepRejection: add MC step
If (count.eq.mcs+1) thenexitend ifend do
Subroutine Random selection
do
xe= int(rand()*10)+1ye= int(rand()*10)+1
if (mat(xe,ye).eq.typ) then
xrp=xeyrp=ye
exit
end if, end do
Monte Carlo simulation in the canonical ensembleChoice of the parameters
Initial configuration
do
en1=EN
typ=1call rand_pos(mat,typ,xrp,yrp)x1=xrp, y1=yrp
typ=0call rand_pos(mat,typ,xrp,yrp)x2=xrp, y2=yrp
mat(x1,y1)=0mat(x2,y2)=1
mat(x1,y1)=1mat(x2,y2)=0
call tot_EN(mat,EN,ei0,ei1)en2=EN
metropolis conditionsacceptance: save new values+ add MC stepRejection: add MC step
If (count.eq.mcs+1) thenexitend ifend do
Subroutine Order parameter
matf=mat*2-1
do r = 1,10do q = 1,5
if (mod(r,2).eq.0) then
ma=ma+matf(2*q-1,r)mb=mb+matf(2*q,r)
else
ma=ma+matf(2*q,r)mb=mb+matf(2*q-1,r)
end if, end do, end do
Psi=sqrt((ma-mb)*(ma-mb)/100
Subroutine Heat capacity parameter
cv = ((enT2/mcs)-(enT*enT) / (mcs*mcs))) / (k*T*T)
Order-disorder transition Cv parameter
0
0.01
0.02
0.03
0.04
0.05
0.06
0.07
500 700 900 1100 1300 1500 1700 1900 2100 2300 2500
T(K)
Cv/N
0 (m
eV/K
)
Tc=1350K
Simulation: Simple cubic surface (100) plan- Θ=0.5ML
- Cell :10*10
- Start: random configuration
- Number of MC steps: 10 million
c(2×2)
Critical phase
Full disorder state
- Nearest neighbours interaction energy:
Eint= +0.1eV
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
500 700 900 1100 1300 1500 1700 1900 2100 2300 2500
T(K)
Order-disorder transition:Ψ parameter
Simulation: Simple cubic surface (100) plan- Θ=0.5ML
- Cell :10*10
- Start: random configuration
- Number of MC steps: 10 million
Tc=1350KC(2×2)
Critical phase
Full disorder state
- Nearest neighbours interaction energy:
Eint= +0.1eV
Ψ=F(T(K))