grzegorz pawlik - if.pwr.edu.plgrpawlik/listyz/bda.pdf · g. pawlik 7. 1.1. drunkard (sailor)...
TRANSCRIPT
Grzegorz Pawlik
The teaching material in this compilation is destined for the students of thespecialization Big Data Analytics attending the course Statistical Physics(computer lab) at Wroclaw University of Science and Technology.
Basic literature:
1. K. Binder, D.W. Heermann, Monte Carlo Simulations in StatisticalPhysics. An introduction, 3rd ed. (Springer: Berlin, 1997)
2. D. Frenkel and B. Smit, Understanding Molecular Simulation: FromAlgorithms to Applications (Academic Press, New York, 2002)
3. D. P. Landau, K. Binder, A Guide to Monte Carlo Simulations inStatistical Physics (Cambridge University Press, Cambridge 2000)
G. Pawlik 1
Contents
0.1 Basic programming constructions . . . . . . . . . . . . . . . . 30.1.1 DO loop . . . . . . . . . . . . . . . . . . . . . . . . . . 30.1.2 IF statement . . . . . . . . . . . . . . . . . . . . . . . 4
1 Simple Models of Diffusion 51.1 Drunkard (sailor) random walk in 1D . . . . . . . . . . . . . . 61.2 Lattice model of diffusion in 2D. Dependence of diffusion co-
efficient on density . . . . . . . . . . . . . . . . . . . . . . . . 10
2 Simple Models of a Phase Transition 152.1 Importance sampling . . . . . . . . . . . . . . . . . . . . . . . 162.2 Ising Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.2.1 The Model . . . . . . . . . . . . . . . . . . . . . . . . . 172.2.2 Metropolis Monte Carlo simulation of the Ising model . 182.2.3 Calculation of averaged values . . . . . . . . . . . . . . 19
2.3 Phase transition between ordered NLC and isotropic liquid . . 242.3.1 Order parameter for a 2D nematic . . . . . . . . . . . . 242.3.2 The model of NLC system and simulation . . . . . . . 24
2
0.1. BASIC PROGRAMMING CONSTRUCTIONS
0.1 Basic programming constructions
0.1.1 DO loop
A DO loop allows a block of statements to be executed repeatedly.
DO loop-control-variable=initial-value,final-value,step-size
statement1
statement2
...
statementn
ENDDO
Example:Program sum calculates the sum s of terms sin(n2) for n = 1, . . . , 10:
s =
n=10∑
n=1
sin(n2)
Figure 1: Sample code in Fortran.
G. Pawlik 3
0.1. BASIC PROGRAMMING CONSTRUCTIONS
0.1.2 IF statement
IF statements allow a program to follow different paths depending on prede-fined criteria.
IF (logical-expression1) THEN
statement1
ELSE IF (logical-expression2) THEN
statement2
ELSE
statement3
END IF
G. Pawlik 4
Chapter 1
Simple Models of Diffusion
5
1.1. DRUNKARD (SAILOR) RANDOM WALK IN 1D
1.1 Drunkard (sailor) random walk in 1D
There is a drunkard coming out of the pub and wants to go home, but he iscompletely drunk so that he has no control over his single step.
x-1 0 1
Figure 1.1: Model of random walk in 1D.
Random walk:
• he starts at position x = 0
• makes steps with step length 1 to the left or to the right
• he loses all memory between any single steps (uncorrelated steps)
This concept was introduced into science by Karl Pearson in a letter to Nature in1905.
G. Pawlik 6
1.1. DRUNKARD (SAILOR) RANDOM WALK IN 1D
Algorithm for a single step:
• on each step, we move one unit left or right, chosen at random:generate a random number R from the uniform distribution on the interval(0, 1).
⊲ if 0 ≤ R < 0.5 we move to the left: x = x− 1
⊲ if 0.5 < R ≤ 1 we move to the right: x = x+ 1
After N steps the position of the drunkard is x = xN .
0 20 40 60 80 100-15
-10
-5
0
5
10
15
x
steps
Figure 1.2: Position of drunkard during simulation.
G. Pawlik 7
1.1. DRUNKARD (SAILOR) RANDOM WALK IN 1D
We repeat the procedure of N steps for K drunkards(before starting we set x = 0)
-30 -20 -10 0 10 20 300
20
num
ber o
f dru
nkar
ds
xN
N=100K=300
-30 -20 -10 0 10 20 300
500
1000
1500
2000
2500
3000
num
ber o
f dru
nkar
ds
xN
N=100K=30 000
Figure 1.3: Histograms of positions xN after N = 100 steps for K = 300(top) and K = 30 000 (bottom).
G. Pawlik 8
1.1. DRUNKARD (SAILOR) RANDOM WALK IN 1D
Theoretical prediction for the standard deviation and the variance of xN :
σ(xN ) ≡√
V (xN ) =√
〈x2N 〉 − 〈xN 〉2 =√N
-90 -60 -30 0 30 60 900
500
1000
1500
2000
2500
num
ber o
f dru
nkar
ds
xN
N=100, K=30 000 N=1000. K=30 000
s(xN)
Figure 1.4: Histograms of positions xN after N = 100 steps (green) andN = 1000 (red) for K = 30 000.
Diffusion 1D – exercises
• Calculate σ(xN ) for the chosen number of steps Nand the number of repetitions K.
• Repeat the same analysis for various values of number of steps N . Make theplot of σ(xN )(N). Compare results with theoretical predictions. Draw theconclusions.
G. Pawlik 9
1.2. LATTICE MODEL OF DIFFUSION IN 2D. DEPENDENCE OFDIFFUSION COEFFICIENT ON DENSITY
1.2 Lattice model of diffusion in 2D. Depen-
dence of diffusion coefficient on density
Random walk in 2D (Fig. 1.5 left):
• on each step, we move one unit up, down, left, or right, chosen at random:generate a random number R between 0 and 1
⊲ calculate a = int(4 ·R)
⊲ if a = 0 we move to the right: x = x+ 1
⊲ if a = 1 we move to the left: x = x− 1
⊲ if a = 2 we move up: y = y + 1
⊲ if a = 3 we move down: y = y − 1
PBC
a=0a=1
a=2
a=3
Figure 1.5: Lattice model of diffusion with PBC in 2D. Atoms are locatedon L× L lattice sites.
G. Pawlik 10
1.2. LATTICE MODEL OF DIFFUSION IN 2D. DEPENDENCE OFDIFFUSION COEFFICIENT ON DENSITY
Periodic Boundary Conditions (PBC)
• simaulation of a large (infinite) system by using a small part called a unit
cell.
• table of nearest neighbours (TNN) for size of the system L× L:
DO I=1,L
IN(I)=I+1
IP(I)=I-1
ENDDO
IN(L)=1
IP(1)=L
• atom movement using TNN:
⊲ calculate a = int(4 ·R)
⊲ if a = 0 we move to the right: x = IN(x)
⊲ if a = 1 we move to the left: x = IP(x)
⊲ if a = 2 we move up: y = IN(y)
⊲ if a = 3 we move down: y = IP(y)
• the sqare of the dispacement of atom for PBC:
⊲ ∆x = +1− 1− 1 + 1 + ...
⊲ ∆y = −1− 1− 1 + 1 + ...
⊲ (∆R)2 = (∆x)2 + (∆y)2
Simulation for n atoms in the system
• density: C = n/L2 (n – number of atoms)
• random initial positions of n atoms (Fig. 1.7):
⊲ calculate trial coordinates of new atom:xt = int(R · L+ 1)yt = int(R · L+ 1)
⊲ If position (x, y) is empty then place new atom in the system
⊲ repeat above steps if number of atoms in the system < n
G. Pawlik 11
1.2. LATTICE MODEL OF DIFFUSION IN 2D. DEPENDENCE OFDIFFUSION COEFFICIENT ON DENSITY
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80
10
20
30
40
50
60
70
80y
x
Figure 1.6: Trajectory of single walker with PBC in 2D (L = 80, number ofsteps N = 2 000).
• algorithm for a single step
⊲ A(x, y) = 1 – occupied place (x, y)A(x, y) = 0 – free place (x, y)
⊲ 1. choose a random direction of movement and generate new position(xnew, ynew)
2. check destination place:
∗ if occupied: A(xnew, ynew)=1 – stay in initial place
∗ if free: A(xnew, ynew) = 0 – movement into new place:A(xnew, ynew) = 1,A(x, y) = 0
G. Pawlik 12
1.2. LATTICE MODEL OF DIFFUSION IN 2D. DEPENDENCE OFDIFFUSION COEFFICIENT ON DENSITY
y
x 1 20
1
20
Figure 1.7: Random positions of n = 200 atoms in the system with sizeL = 20 (density C = 200/400 = 0.5).
Diffusion coefficient
• D = limt→∞(∆R)2
2 d t , (d – dimension of space, t – time)
• in simulation:
D ≈ 〈(∆R)2〉2 d MCS
〈...〉 – averaging over atoms and many independent realizations (MCS de-notes Monte Carlo steps)
G. Pawlik 13
1.2. LATTICE MODEL OF DIFFUSION IN 2D. DEPENDENCE OFDIFFUSION COEFFICIENT ON DENSITY
0 10 20 30 40 500,00
0,05
0,10
0,15
0,20
0,25
C=0.1 C=0.5
D
MCS
Figure 1.8: Diffusion coefficient calculated during simulation for system sizeL = 20 and number of independent realizations K = 10.
Diffusion 2D – exercises:
• Calculate the diffusion coefficient for different values of the concentration.To this end make a plot of D against MC ”time” and look for the plateau.
• Make the plot of D against concentration C.
G. Pawlik 14
Chapter 2
Simple Models of a PhaseTransition
15
2.1. IMPORTANCE SAMPLING
2.1 Importance sampling
• The Boltzmann distribution law states that the average of any physicalproperty (with the property value X) for a system at temperature T isgiven by:
〈X〉 =∑
aXae− Ua
kBT
∑
a e− Ua
kBT
,
where the sum is over the states a available to the system.
• The algorithm of Metropolis is an important sampling technique. It gener-ates a Markov chain of system states whose limiting relative frequencies areequal to their Boltzmann probabilities.
• In this approach the above sum is over those states only instead of over allstates available to the system.
• In the Metropolis importance sampling Monte Carlo scheme one has to:
1. start from an arbitrary initial configuration a;
2. generate a trial configuration a′;
3. calculate the energy difference Ua′−Ua between trial andinitial configuration;
4. if Ua′ − Ua < 0 then the trial configuration is attachedto the Markov chain of configurations and the algorithmreturns to step (2);
5. calculate probability w = exp[−(Ua′ − Ua)/kBT ] andsample a random number R from the uniform distribu-tion on the interval (0, 1);
6. if R ≤ w then the trial configuration (a′) is attached tothe Markov chain of configurations and the algorithmreturns to step (2);
7. if (6) is not satisfied then the old configuration (a) isattached to the Markov chain of configurations and thealgorithm goes back to step (2);
G. Pawlik 16
2.2. ISING MODEL
2.2 Ising Model
2.2.1 The Model
This model of ferromagnetism was developed by Wilhelm Lenz (1924).
We consider a 2D square lattice lattice of magnetic moments:
• On each lattice site, the local magnetic moment is represented by a ”spin”(drawn as an arrow in Fig. 2.1).
• The spin has just two possible states, either pointing up (↑, s = +1) orpointing down (↓, s = +1).
• The energy for the Ising model is related to the interaction between neigh-boring spins
L
L
1
1 i
j
s=+1
s=-1
Figure 2.1: 2D Ising model.
The total energy for the system (the hamiltonian):
U = −J∑
〈i,j〉
si sj
where 〈i, j〉 represent nearest-neighbor pairs, J denotes a positive coefficient givingthe interaction strength
G. Pawlik 17
2.2. ISING MODEL
2.2.2 Metropolis Monte Carlo simulation of the Isingmodel
• Generate an initial configuration (e.g. uniform or random).
• For a chosen spin s(i, j) generate a trial configuration with the oppositedirection of this spin (Fig. 2.2).
s(i,j)
s(i,j-1)
s(i-1,j) s(i+1,j)
s(i,j+1)
old configuration trial configuration
Figure 2.2: Trial configuration for single spin.
• Calculate the energy difference:
∆U = −J (−s(i, j))[s(i + 1, j) + s(i− 1, j) + s(i, j + 1) + s(i, j − 1)]
−{−J s(i, j)[s(i + 1, j) + s(i− 1, j) + s(i, j + 1) + s(i, j − 1)]}= 2J s(i, j)[s(i + 1, j) + s(i− 1, j) + s(i, j + 1) + s(i, j − 1)].
With PBC and the table of nearest neighbors (TNN) (see Section 1.2):
∆U = 2J s(i, j)[s(IN(i), j) + s(IP(i), j) + s(i, IN(j)) + s(i, IP(j))]
For example in Fig. 2.2: ∆U = 2 · J · 1 · (1− 1 + 1 + 1) = 4J .
• Calculate probability w = exp[−∆U/kBT ]. Using the reduced temperatureT ∗ = TkB/J for example in Fig. 2.2: w = exp(−4/T ∗). So probability wdepends on T ∗ (Fig. 2.3):
⊲ for ∆U = 6 and T ∗ = 1 probability of acceptance w ≃ 0.018
⊲ for ∆U = 6 and T ∗ = 4 probability of acceptance w ≃ 0.368
• Based on the probability w accept or reject the trial configuration.
• Repeat the above procedure for another spin. One MC step (MCS) corre-sponds to a sweep of trial reorientation over all the spins in the system.
G. Pawlik 18
2.2. ISING MODEL
-1 0 1 2 3 4 5 6 7 80
1
2
3
DU
w =
exp
(-DU
/T*)
T*=4
T*=1
R > w rejection
R < w acceptance
Figure 2.3: Metropolis condition for ∆U = 4 and T ∗ = 4.
2.2.3 Calculation of averaged values
• Because the initial configuration is arbitrary, configurations obtained duringsome number of MCS (K0) are not characteristic of equilibrium.
• The first K0 configurations are omitted from the calculation of averagedvalues.
• For the calculation of averaged values of chosen physical properties, each1000th MCS configuration from K −K0 equilibrium configurations is takeninto account. Example: for K = 230 000MCS and K0 = 30 000MCS –k = (K −K0)/1000 = 200 equilibrium configurations are analyzed.
G. Pawlik 19
2.2. ISING MODEL
Thermodynamic quantities:
• Average spin in a single configuration:
m =1
N
N∑
i=1
si
• Susceptibility:
χ =N
kBT
(
〈m2〉 − 〈m〉2)
• Heat capacity:
C =1
NkBT 2
(
〈U2〉 − 〈U〉2)
• Binder’s cumulant:
UL = 1− 〈M4〉L3〈M2〉2L
,
M =
N∑
i=1
si
Example: size and temperature dependence of magnetization:
• ”Irregular” behaviour of instantaneous magnetization: flips between statesm = +1 and m = −1 (Fig. 2.4) at low temperature (below Tc).
• Magnetization averaged over k equilibrium configurations (with the modulusof m):
〈m〉 = 1
k
k∑
i=1
|mi|
In Fig. 2.5 the dependence of 〈m〉 on T ∗ is presented.
• Finite size scaling:mLβ/ν = f(t L1/ν),
where t = T−Tc
Tc.
Critical exponents: ξ ∝ |t|−ν , 〈m〉 ∝ |t|β, ξ denotes the correlation length.For 2D Ising model: ν = 1, β = 1/8.
G. Pawlik 20
2.2. ISING MODEL
0 1x107 2x107 3x107 4x107 5x107
-1.0
-0.5
0.0
0.5
1.0
m
MCS
Figure 2.4: Magnetization (average spin) in a single configuration duringsimulation for size L = 10 and T ∗ = 1.7.
1.5 2.0 2.5 3.00.0
0.2
0.4
0.6
0.8
1.0
L=100 L=40 L=10
m
T*
Figure 2.5: Magnetization averaged over equilibrium configurations for dif-ferent size of the system: L = 10, L = 40 and L = 100.
G. Pawlik 21
2.2. ISING MODEL
Configurations of spins
5 10 15 20
5
10
15
20
5 10 15 20
5
10
15
20
5 10 15 20
5
10
15
20
20 40 60 80 100
20
40
60
80
100
20 40 60 80 100
20
40
60
80
100
20 40 60 80 100
20
40
60
80
100
Figure 2.6: Configuratons of spins for size of the system L = 20 (left panel)and and L = 100 (right panel) for T < Tc (T ∗ = 1)(top),T ≃ Tc (T ∗ =2.26)(middle) and T > Tc (T
∗ = 5)(bottom).
G. Pawlik 22
2.2. ISING MODEL
2D Ising model – exercises:
1. Explore the behaviour of the system (analysis of configurations) at hightemperature (above Tc), at low temperature (below Tc) and for T ∗ ≃ Tc.
2. Observe flips between states m = +1 andm = −1 at low temperature (belowTc).
3. Calculate the temperature dependence of the mean value of magnetization,energy, susceptibility and specific heat for a few values of the linear size ofthe system (for example: L = 10, 50, 100).
4. Calculate the temperature dependence of the mean value of Binder’s cu-mulant for a few values of linear size of the system (for example: L =10, 50, 100). Based on temperature dependence of Binder’s cumulant fordifferent sizes of the system determine the value of the critical temperature.
5. Demonstrate finite size scaling close to the critical point using theoreticalvalues of critical exponents β = 1/8, ν = 1 for the 2D Ising model.
G. Pawlik 23
2.3. PHASE TRANSITION BETWEEN ORDERED NLC ANDISOTROPIC LIQUID
2.3 Phase transition between ordered NLC
and isotropic liquid
2.3.1 Order parameter for a 2D nematic
The orientational the order in a 2D nematic liquid crystal (NLC) is representedby the second rank symmetric and traceless tensor:
Q̂ =
(
Qxx Qxy
Qxy −Qxx
)
.
In MC simulations order parameter can be inferred from the ensemble averageof the above tensor. A NLC particle orientation is described by a director n̂. Forthe director n̂ with components nx = cosφ and ny = sinφ (Fig. 2.7) the tensor Q̂can be written in the component notation:
Qαβ =1
N
N∑
i=1
(2ni,αni,β − δαβ), α, β = x, y
where ni,α denotes the αth component of the versor describing the orientation ofthe long axis of the ith NLC molecule, N denotes the number of molecules, andδαβ - the Kronecker delta function. The diagonalization of the ensemble averagedtensor Qαβ yields two eigenvalues +λ and −λ which sum up to zero.
The scalar order parameter S is the largest eigenvalue of Q̂: S = λ. S takesvalues between 0 for a completely disordered phase and 1 for a completely orderedphase.
2.3.2 The model of NLC system and simulation
• NLC molecules are placed in a 2D square lattice with size L × L. Eachmolecule can rotate and its orientation is described by the angle φ (Fig. 2.7(right)).
• Lebwohl-Lasher effective Hamiltonian:
H = −ξ∑
<~r,~r ′>
P2
(
cos β(~r, ~r ′))
ξ denotes the strength of NLC-NLC orientational interaction, P2 is thesecond-order Legendre polynomial. β(~r, ~r ′) denotes the relative angle be-tween two molecules located at points ~r, ~r ′ (Fig.2.8).
G. Pawlik 24
2.3. PHASE TRANSITION BETWEEN ORDERED NLC ANDISOTROPIC LIQUID
fx
y
1
L
1 L
Figure 2.7: Orientation of a LC molecule in 2D (left). Model of a nematicliquid crystal system with L× L particles (right).
• Nearest neighbor interactions are taken into account (< ~r,~r ′ > representnearest-neighbor pairs).
Figure 2.8: β(~r, ~r ′) denotes the relative angle between two molecules locatedat points ~r, ~r ′.
G. Pawlik 25
2.3. PHASE TRANSITION BETWEEN ORDERED NLC ANDISOTROPIC LIQUID
MC simulation
• Trial configuration (Fig. 2.9) in Metropolis algorithm:
φnew = φold + (R− 0.5)δφ
fold
x
y
Figure 2.9: Trial configuration for a single LC molecule.
• Orientation φ (φ in degrees) in the range (−90◦, 90◦):
⊲ if φnew > 90◦ then = φnew = φnew − 180◦
⊲ if φnew < −90◦ then = φnew = φnew + 180◦
• Reduced temperature T ∗ = T kBξ
• The relative angle between two molecules in the range (−180◦, 180◦).
G. Pawlik 26
2.3. PHASE TRANSITION BETWEEN ORDERED NLC ANDISOTROPIC LIQUID
• Configurations
Figure 2.10: Typical configurations for T ∗ < TC (top) and for T ∗ > Tc
(bottom).
NLC model – exercises:
• Calculate the temperature dependence of the scalar order parameter S.
• Estimate the temperature Tc of the transition nematic LC – isotropic liquid(assume S(Tc) ≈ 0.4).
G. Pawlik 27