monte carlo simulations in statistical...

14

Upload: others

Post on 24-Feb-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Monte Carlo Simulations in Statistical Mechanicsmafija.fmf.uni-lj.si/seminar/files/2010_2011/montecarlo.pdf · In this section, some applications of Monte Carlo (MC) methods in statistical

University of Ljubljana

Faculty of Mathematics and Physics

Department of Physics

Seminar

Monte Carlo Simulations in Statistical

Mechanics

Author: �iga Osolin

Supervisor: dr. Gregor Ska£ej

May 20, 2011

Abstract

There are only a few physical systems where equilibrium properties can be cal-

culated analytically. For all other systems theory is tested by simulating the system

and match the computed properties with the ones gained from experiments. In

this seminar, the focus will be on Monte Carlo simulations, more speci�cally on the

Metropolis algorithm and some selected applications.

Page 2: Monte Carlo Simulations in Statistical Mechanicsmafija.fmf.uni-lj.si/seminar/files/2010_2011/montecarlo.pdf · In this section, some applications of Monte Carlo (MC) methods in statistical

1 Introduction

There are not many physical systems where properties can be calculated using analyt-ical techniques. When one is faced with such a system, numerical algorithms are used.This seminar will focus on the numerical solutions of equilibrium properties of statisticalmechanics systems. Usually, a speci�c theoretical model of particle interactions is beingtested. The numerical method is used to obtain some property dependance of the the-oretical model. These solutions can then be matched against data, obtained from thereal experiments. This way, the agreement between the theoretical model and the realexperiment is obtained, and the model can either be con�rmed or rejected1.

2 Statistical Mechanics

We start with a classical statistical mechanics system with constant number of particles(N), constant volume (V ) and constant temperature (T ), namely N, V, T or canonicalensemble. The partition function for such a system is

Z =

∫dpNdrNexp[−βH(pN , rN)]. (1)

Here, pN is the 3N -dimensional vector representing momenta of all particles and thecorresponding rN are positions of the particles. H is the Hamiltonian of the system,while β = (kBT )−1, where kB is the Boltzmann constant. Partition function acts as anormalizing constant for the system. We want to compute average value of A = A(rN)de�ned by

〈A〉 =1

Z

∫dpNdrNexp[−βH(pN , rN)]A(rN). (2)

We are interested in average behavior because it is the one measured in experiments.Evaluation of (2) is therefore the goal in the simulations [1].

2.1 Ergodicity

What is actually measured in experiments is the time average of some observable A. Onthe other hand, de�nition (2) is purely a statistical average over all possible states. Wecall it an ensemble average. In experiments, we usually start with one state and averageover time evolution of the system

A = limt→∞

∫ t

0

A(r(t))dt. (3)

In general, these two averages are not the same, however for most systems they are. If theare, we say that such system is ergodic, so A = 〈A〉. We will discuss only such systems[1]. Non-ergodic systems usually have a lot of metastable states, for example a spin-glassmodel [2].

1Or further re�ned.

1

Page 3: Monte Carlo Simulations in Statistical Mechanicsmafija.fmf.uni-lj.si/seminar/files/2010_2011/montecarlo.pdf · In this section, some applications of Monte Carlo (MC) methods in statistical

3 Monte Carlo Simulation

The name Monte Carlo (MC) refers to a set of numerical methods that extensively userandom numbers. It is be assumed that random numbers can be generated on a deter-ministic computer well. The following statement is generally true for almost all cases, formore information on random number generators, refer to [3].The MC simulation of a statistical system consists of calculating ensemble averages (2).Most of the time, the integration over dpN is carried out analytically but the integrationover particle positions usually requires numerical evaluation. We are faced with a di�cultmultidimensional integral. For instance, if we wanted to evaluate such integral for a reallysmall system of N = 100 particles with m = 5 points along all three axes, we would need10210 sample points. This is clearly too much. What is more, most of the sample pointswould give negligable contribution to the integral. Even if we carried out this numericalintegration, we would have big errors due to functions not being smooth at all [1].

3.1 Metropolis Algorithm

In the previous section, it was shown that it is in general impossible to evaluate thepartition function Z. We are however not interested in the value of Z, we are interestedin ratio of two integrals

〈A〉 =

∫drNA(rN)exp[−βU(rN)]∫

drNexp[−βU(rN)]. (4)

Here, U(rN) is the non-momentum part of Hamiltonian, H = T (pN) + U(rN), where Tdenotes the kinetic energy. In the canonical ensemble, the probability density to visit rN

isκ(rN) = Z−1exp[−βU(rN)]. (5)

We now wish to sample points based on this distribution without computing Z. 〈A〉 canthen be computed simply as

〈A〉 =1

K

K∑i=1

A(rNi), (6)

where rNi is a sample from the probability density (5).To sample points in such a manner, we start with the con�guration rN , called o (old).The selected state must have a nonvanishing Boltzmann factor exp(−βU(o)), that meansit must be probable. A new con�guration n is generated from o by some small randomdisplacement ∆ to o. The decision whether to accept the move or reject it dependson Boltzmann factors of both states. It must be done in such a way that on averagecon�gurations are sampled from the desired canonical distribution.There are many ways to achieve the described sampling, the most famous one is theMetropolis scheme described below. Let us start withM simulations at once, whereM isbigger than the number of all con�gurations. Let m(i) denote the number of simulationsin state i. We wish that on average m(i) is propotional to κ(i). Let π(o → n) denotethe probability of transition from state o to n. Once we are in equilibrium, we must notdestroy it. This means that the average number of moves leaving o must be the same

2

Page 4: Monte Carlo Simulations in Statistical Mechanicsmafija.fmf.uni-lj.si/seminar/files/2010_2011/montecarlo.pdf · In this section, some applications of Monte Carlo (MC) methods in statistical

as the number of moves from all other states in o. We can impose an even strongercondition, namely that the number of o→ n moves is exactly the same as the number ofn→ o, which gives

κ(o)π(o→ n) = κ(n)π(n→ o). (7)

This is called the detailed balance condition. We can further divide the probability oftransition π to

π(o→ n) = α(o→ n) · acc(o→ n) (8)

Here, α is the probability of proposing o → n move and acc is acceptance probability.For the Metropolis scheme, we usually take α symetric α(o → n) = α(n → o) to avoidany bias in the sampling scheme. We can rewrite the equation (7) as

κ(o)acc(o→ n) = κ(n)acc(n→ o), (9)

acc(o→ n)

acc(n→ o)= exp[−β(U(n)− U(o))]. (10)

There are many ways to satisfy this condition, Metropolis choice is

acc(o→ n) =κ(o)

κ(n), κ(n) < κ(o), (11)

acc(o→ n) = 1, κ(n) > κ(o). (12)

To summarize, the Metropolis scheme is quite simple. From the old state o choose adisplacement of one or more coordinates (more about that later) to create a new state n.The displacement should be chosen in a symetric way, so that the reverse displacementfrom state n to o is equally likely. Then, we evaluate κ in both states. If it is lower innew state, accept it, otherwise accept it with probability κ(o)/κ(n). Using this samplestates, average values 〈A〉 can be computed using (6) [1].

3.1.1 Boundary conditions

Even with the Metropolis scheme, it is not possible to simulate really large systems.We can hope to simulate systems with N = 1000 particles, or maybe 105, but nevermacroscopic system with 1020. While in systems with many particles i.e., bulk systems,boundaries become unimportant, simulations run in conditions when the boundary isimportant. In a 3-dimensional system where the particles are arranged in cubic lattice,∝ N

23 particles are on the boundary. One side of the cube contains L = 3

√N particles.

The number of particles inside is therefore (L − 2)3, so the number of particles on thesurface is

Nsurf = L3 − (L− 2)3 = 6L2 − 12L+ 8 � 6L2 � 6N23 (13)

For 1000 particles in the cubic lattice, around 50% of them are on surface. Therefore, wewish to use a boundary condition that will mimic really large systems. A natural choice isa periodic boundary condition (PBC). The volume is treated as a cell of in�nite periodiclattice of identical cells. In this way, particles on the surface are avoided, but we can getsome sort of correlation because all cells are identical. The longest wavelength that canexist in such a system is of order of the size of the cell. Some phenomena, for example aphase transition, require long wavelengths to appear in the system. One must be carefulwhen simulating them with PBC.

3

Page 5: Monte Carlo Simulations in Statistical Mechanicsmafija.fmf.uni-lj.si/seminar/files/2010_2011/montecarlo.pdf · In this section, some applications of Monte Carlo (MC) methods in statistical

4 Examples

In this section, some applications of Monte Carlo (MC) methods in statistical physics willbe presented. When �rst computers sprung to life around 1950s, method was used forcalculations required to build nuclear weapons and for code breaking. First public articlewas published by Metropolis, introducing the Metropolis sampling to calculate equationof state of hard sphere system [4]. In statistical physics it has been used to study fero-magnets and antiferomagnets [5, 6], intranuclear cascades [7], properties of liquids [8, 9],and much more.The method is not bound only to statistical physics; it has been widely used in any prob-lem that needs multidimensional integration (radioactive decay ) [3], error estimations [3],stohastic simulations [3], computer graphics [10] etc. A variant, called simulated anealingis also used for e�cient global minimization [3].

4.1 Ising Model

The Ising model aproximatelly describes interactions of spins in feromagnets and antif-eromagnets. This is the simplest model that can reproduce a phase transition. Someproblems, for example a problem of linear mixtures in chemistry, translate to this prob-lem.Ising has proved that the one dimensional model does not exhibit phase change. Sinceexact solutions for two dimensional systems is known, it can be compared to the simula-tion results. No one succeded to solve the Ising model analytically in three dimensions[11].The model consists of N objects with spin Si = ±1

2, arranged on a lattice. The Ising

Hamiltionian only includes nearest neighbour interactions and can be written as

H = −J∑<i,j>

SiSj, (14)

where J is the interaction energy and∑

<i,j> denotes a sum over nearest neighbours i, j.For J > 0, parallel spin alignment is preferred (both up or both down), simulating aferomagnet. If J < 0, than the model may represent antiferomagnets. [11]In the model implementation, we will deal with a square lattice for simpli�cation. TheMetropolis simulation of the Ising model starts from a selected spin con�guration; forexample random or aligned. The trial move for sampling can be as simple as a �ip of arandom spin. After the �ip is made, the energy change ∆E between new and old statedis evaluated. The energy change calculation can be made fast by noticing that we onlychanged energies of chosen spin and its neighbours. If the energy change is negative,we accept the state, otherwise we accept it with probability exp[−β∆E]. In order tosimulate system as if it were bigger, we use PBC. Because interactions are short range(only neighbours), we are not too worried about correlations.Above, a basic simulation has been presented. Di�erent observables can now be mon-itored, such as energy or magnetisation at di�erent temperatures. When we start thesimulation, we must �rst relax it to a more likely state. In this state the energy will os-cilate around an equilibrium value, as shown in Figure 1. After that, we can sample ourobservables to obtain their estimates. To avoid correlations, we take every K-th sampleto calculate our observable averages.

4

Page 6: Monte Carlo Simulations in Statistical Mechanicsmafija.fmf.uni-lj.si/seminar/files/2010_2011/montecarlo.pdf · In this section, some applications of Monte Carlo (MC) methods in statistical

Figure 1: Initial relaxation and oscilations of the magnetisation in the Ising model fortemperature above (green) and below (red) phase transition [12].

We �rst want to observe a phase transition in the system, therefore it is necessary toexamine the behaviour of the order parameter, i.e., the magnetisation. It is de�ned as

M =∑i

Si. (15)

The simulation can be started at low temperatures. The fastest relaxation is obtainedif we start from the aligned spin con�guration, though any other con�guration wouldalso work. We perform Metropolis algorithm and sample magnetisation M every K-thsample. When we have enough samples for a given temperature, we slowly increase itand perform the same computations at higher temperatures. At TC = (2.3 ± 0.1)J/kB,we see a phase transition (shown in Figure 2) that was also predicted by Lars Onsager.Analytic value from his article is Tc = 2.269185J/kB [13]. We can also estimate thecritical coe�cient βc for magnetisation by �tting

M ∝ |T − TC |βc . (16)

The exact value is also analytically computed and equals 1/8. The numerical simulationfor the critical coe�cient were not made since it requires a very long computation.

Furthermore, susceptibility χ per spin can also be calculated. Via the �uctuationdissipation theorem (FDT), it can be calculated as

χ =〈M2〉 − 〈M〉2

NkBT. (17)

If properties of Ising model in an external �eld need to be calculated, spin-external �eldinteraction −H0

∑i Si must be added to the energy of the system (14). Note that for

feromagnetics, relation between magnetisation and external �eld H0 is not linear so χwill also change with H0.We can also compute speci�c heat per spin c via DFT

c =〈E2〉 − 〈E〉2

NkBT 2. (18)

5

Page 7: Monte Carlo Simulations in Statistical Mechanicsmafija.fmf.uni-lj.si/seminar/files/2010_2011/montecarlo.pdf · In this section, some applications of Monte Carlo (MC) methods in statistical

Figure 2: Ising model: Magnetisation vs. temperature for di�erent system sizes L. Itcan be seen that the phase transition is better aproximated with more particles even ifwe use PBC. We can see that the phase transition consists of longer wavelengths thanthe ones used in the computer simulation, therefore we get error [12].

6

Page 8: Monte Carlo Simulations in Statistical Mechanicsmafija.fmf.uni-lj.si/seminar/files/2010_2011/montecarlo.pdf · In this section, some applications of Monte Carlo (MC) methods in statistical

Figure 3: Ising model: Susceptibility χ dependence on temperature at H0 = 0 (top) andheat capacity dependence on temperature (bottom) for di�erent system sizes L [12].

7

Page 9: Monte Carlo Simulations in Statistical Mechanicsmafija.fmf.uni-lj.si/seminar/files/2010_2011/montecarlo.pdf · In this section, some applications of Monte Carlo (MC) methods in statistical

4.2 Lennard Jones

From a discrete Ising model we turn to continious models, one of the simplest beingN particles interacting via the Lennard-Jones potential. This potential is useful forsimulations of noble gasses, such as argon, and is given by

U(r) = −ε[(rm

r

)12− 2(rmr

)6]. (19)

In this model, r is distance between particles and ε is the depth of the energy well whoseminimum is located at r = rm. The term representing attractive interaction is Van derWaals interaction. The repulsive term is approximated using 12-th power for e�cientnumerical evaluation, it is simply the the square of the attractive term [9].

8

Page 10: Monte Carlo Simulations in Statistical Mechanicsmafija.fmf.uni-lj.si/seminar/files/2010_2011/montecarlo.pdf · In this section, some applications of Monte Carlo (MC) methods in statistical

Figure 4: Lennard-Jones potential [14].

We want to calculate the equation of state for such a system. We simulate particles ina cubic box with side L. Periodic boundary conditions are used. One of the possible waysis to truncate the interaction at rc = L

2. In this way, we actually perform simulations

in cube with edge L around a given particle. We can use rc as large as L, but biggertruncation would result in interactions of particle with itself. Because of the truncatedinteraction, we are e�ectively ignoring particles at r > rc. These interactions are usuallynegligible, however near phase phenomena, they become important. This is why it isharder to simulate systems near phase transitions and more elegant methods need to beused there [9, 8]. A second consequence of the truncation is that potencial is discontinuousat rc. This can result in big errors if forces need to be calculated, for example when thepressure calculation is needed.2 We usually correct this by substracting U(rc) from (19),thus making potencial go to 0 at r = rc and staying zero for all r ≥ rc.

2In the molecular dynamics, this is even more essential since the simulation is based on the forces.

9

Page 11: Monte Carlo Simulations in Statistical Mechanicsmafija.fmf.uni-lj.si/seminar/files/2010_2011/montecarlo.pdf · In this section, some applications of Monte Carlo (MC) methods in statistical

Figure 5: Periodic boundary conditions in two dimensions [15].

4.2.1 Moves

We now discuss random moves. The simplest and usually most e�cient sampling moveis a random translation of a randomly chosen particle i,

xi → xi + δξ1,

yi → yi + δξ2,

zi → zi + δξ3.

Here, ξ1, ξ2, ξ3 are random numbers in range [−1, 1] and δ is the move amplitude. Notethat moves are symetric; with equal probability we get a move of the same particle in theopposite direction. The parameter δ should be chosen in such a way that the acceptanceratio is around 50%. If it is too large, the acceptance ratio will be too low becausewe will mostly generate high energy states (overlapping particles). If it is too low, thesimulation will proceed slowly. Adaptive step regulation is usually used to regulate δ insuch situations [1].

4.3 Equation of state

In the simulation, we can vary temperature (T ) and density (ρ = N/L3). Then, to obtainthe equation of state, pressure must be calculated given T and ρ. It can be calculatedusing the virial equation of state

p =ρ

β+vir

V, (20)

vir =1

3

∑i

∑j>i

~f(rij) · ~rij. (21)

10

Page 12: Monte Carlo Simulations in Statistical Mechanicsmafija.fmf.uni-lj.si/seminar/files/2010_2011/montecarlo.pdf · In this section, some applications of Monte Carlo (MC) methods in statistical

Figure 6: Results of Monte Carlo calculations of equation of state in the Lennard-Jonessystem. With �xed density and temperature, we calculate the pressure and the internalenergy. Last column is the ratio between the cuto� radius and potencial zero pointσ = rm

6√2 [16].

In this equation, ~f(rij) denotes the force between particles i and j, and ~rij is the inter-particle vector, moreover rij = |~rij|. We also need to account for pressure corrections dueto cuto� of interactions. It can be estimated with tail corrections

ptail =16

3πρ2[23r−9c − r−3c

](22)

We obtain this corrections by assuming that density of particles is homogeneous for r ≥ rcand integrating the potential. We get good agreement with experimental data for argonand Lennard-Jones model this way. [1].

4.3.1 Phase change

A vapor-liquid coexistence curve in the phase diagram can also be computed for theLennard-Jones system. Because simulation of the coexistence is nearly impossible withfew particles (PBC do not help here), we can get around the problem by performing alot of simulations outside the coexistence region. These data can then be �tted to ananalytic equation of state, using which we can determine coexistence curve.

4.3.2 Di�erent Ensambles

Metropolis algorithms can also be performed in other ensembles. I will give quick ideashow to simulate system in N, p, T ensamble. For more information about them, refer to[1].The isobaric-isothermal ensamble (N, p, T ) can be simulated by adding volume changeto the trial moves. Let us assume our system is simulated in cube of volume V = L3,

11

Page 13: Monte Carlo Simulations in Statistical Mechanicsmafija.fmf.uni-lj.si/seminar/files/2010_2011/montecarlo.pdf · In this section, some applications of Monte Carlo (MC) methods in statistical

where L is side of the cube. We introduce reduced coordinates si = ri/L, where ri arecomponents of vector rN , and write U(rN) = U(sN ;V ). Now we �rst choose whether toperform volume change or a coordinate change. The coordinate change is the same as forthe N, V, T ensemble. On the other hand, a volume change is accepted with the followingprobability:

acc(o, V → n, V ′) = min(1, exp[−β[U(sN , V ′)−U(sN , V ) +p(V ′−V )]− (N + 1)ln

V ′

V

]).

(23)This is e�ectively a Legendre transform U → U + pV . The last term in the exponentialis there because we introduced the reduced coordinates.

5 Monte Carlo vs. Molecular Dynamics

There is also an other very e�ective method for the calculation of equilibrium propertiescalled Molecular Dynamics (MD). The method essentially reproduced the time evolutionof the system, as it happens in experiments. We then calculate observables as a timeaverage. In ergodic system, this is equivalent to MC simulation where ensemble averagesare obtained. The main advantage of this method is that we actually see the real-timemotion and time scale of problems we are solving. For example, oscillations of boundparticles can be seen. The advantage of MC over MD is that it can usually be applied tomore problems (discrete problems, such as lattice problems), is easier to work with (nospecial energy conservation techniques needed, and no evaluation of forces and torques isneeded) and we may use non-physical moves to reach equilibrium faster. On CPU timeneeded to get certain property of the system, methods are equivalent.There is also a hybrid approach. It is sometimes hard to generate moves in MC, especiallycollective moves. An example of this is moving one big particle in a medium of a lot ofsmall particles. Generating move of only one particle will never allow the big particle tomove. If we move big particle, there will not be any space to move. Moving only onesmall particle will not make enough space for the big one to move since a lot of smallparticles surround it. In such situations, we can generate moves with MD, and thenaccept or reject them via MC algorithm. [1]

6 Conclusion

In this seminar, I have shown how Monte Carlo methods, speci�cally the Metropolisalgorithm, can be used to simulate statistical systems. Instead of more intuitive timeevolution of system (Molecular Dynamics), we perform ensemble sampling. If the ergodictheorem holds, these two methods give same results.The Metropolis algorithm is a general tool to generate samples from multidimensionaldistributions and this is why it is generally useful in many �elds of science.

12

Page 14: Monte Carlo Simulations in Statistical Mechanicsmafija.fmf.uni-lj.si/seminar/files/2010_2011/montecarlo.pdf · In this section, some applications of Monte Carlo (MC) methods in statistical

References

[1] D. Frenkel and B. Smit, Understanding Molecular Simulation: From Algorithms to

Applications. Academic Press, Inc., 1996. (Theoretical part of seminar is mostlybased on data aquired from this excellent guide to Monte Carlo simulations.).

[2] A. Crisanti, H. Horner, and H. J. Sommers, �The spherical p-spin interaction spin-glass model,� Zeitschrift für Physik B Condensed Matter, vol. 92, pp. 257�271, 1993.10.1007/BF01312184.

[3] W. H. Press, S. A. Teukolsky, W. T. Vatterling, and B. R. Flannery, NumericalRecipes: The Art of Scienti�c Computing. Cambridge University Press, third ed.,2007.

[4] N. Metropolis, A. W. Rosenbluth, M. N. Rosenbluth, and A. H. Teller, �Equationsof state calculates with fast machines,� 1953.

[5] J. Tobochnik and G. Chester, �Monte carlo study of planar spin model,� The PhysicalReview, 1979.

[6] J.D.Reger and A.P.Young, �Monte carlo simulations of spin-1/2 heissenberg antifer-romagnet on square lattice,� The Physical Review, 1988.

[7] N. Metropolis, R. Bivins, and M. Storm, �Monte carlo calculations of intranuclearcascades,� The Physical Review, 1957.

[8] A. M. Ferrenberg and R. H. Swendsen, �New monte carlo techniques for studyingphase transitions,� The Physical Review, 1988.

[9] J.-P. Hansen and L. Verlet, �Phase transitions of lennard-jones system,� The PhysicalReview, 1969.

[10] M. Colert, �An introduction to metropolis light transport,� 2000.

[11] L.E.Reichl, A modern course in Statistical Physics. John Wiley and Sons, INC.,1998.

[12] �Simple 2d ising model simulator.� http://www.triplespark.net/sim/isingmag/, April2011.

[13] L. Onsager, �Crystal statistics. i. a two-dimensional model with an order-disordertransition,� The Physical Review, 1943.

[14] �Lennard-jones potencial.� http://en.wikipedia.org/wiki/Lennard-Jones_potential,April 2011.

[15] �Computer simulation algorithms.� http://epress.anu.edu.au/sm/html/ch06.html,April 2011.

[16] J. K. Johnson, J. A. Zollweg, and K. E. Gubbins, �A lenard-jones equation of staterevisited,� Molecular Physics, 1992.

13