Monte Carlo Methods in Statistical Mechanics Aziz Abdellahi CEDER group Materials Basics Lecture :...

12
Monte Carlo Methods in Statistical Mechanics Aziz Abdellahi CEDER group Materials Basics Lecture : 08/18/2011 1

Transcript of Monte Carlo Methods in Statistical Mechanics Aziz Abdellahi CEDER group Materials Basics Lecture :...

Page 1: Monte Carlo Methods in Statistical Mechanics Aziz Abdellahi CEDER group Materials Basics Lecture : 08/18/2011 1.

Monte Carlo Methods in Statistical Mechanics

Aziz AbdellahiCEDER group

Materials Basics Lecture : 08/18/2011

1

Page 2: Monte Carlo Methods in Statistical Mechanics Aziz Abdellahi CEDER group Materials Basics Lecture : 08/18/2011 1.

What is Monte Carlo ?

Famous for its casinos !

Monte Carlo is an administrative area of the principality of Monaco.

Monte Carlo is a (large) class of numerical methods used to solve integrals and differential equations using sampling and probabilistic criteria.

2

Page 3: Monte Carlo Methods in Statistical Mechanics Aziz Abdellahi CEDER group Materials Basics Lecture : 08/18/2011 1.

π ≈4 *N _ inside_ circle

N _ total

The simplest Monte Carlo methodFinding the value of π (“shooting darts”)

π/4 is equal to the area of a circle of diameter 1.

1

1

Details of the Method

Randomly select a large number of points inside the square

Integral solved with Monte Carlo€

π4

= dx dy∫x 2+ y 2 <1

(Exact when N_total ∞)

3

Page 4: Monte Carlo Methods in Statistical Mechanics Aziz Abdellahi CEDER group Materials Basics Lecture : 08/18/2011 1.

MC : Common features and applicationsCommon features in Monte Carlo methods

Uses random numbers and selection criteria

Monte Carlo in Statistical Mechanics : Calculating thermodynamic properties of a material from its first-principles Hamiltonian

Requires the repetition of a large number of events

Monte Carlo method that will be discussed in this talk

Example of results obtained from MC : LixFePO4 (Li-ion battery cathode)

Only consider configurational degrees of freedom (Li-Vacancy)

The energies of all Li-Vacancy configurations are known (Hamiltonian) 4

Page 5: Monte Carlo Methods in Statistical Mechanics Aziz Abdellahi CEDER group Materials Basics Lecture : 08/18/2011 1.

Useful battery properties that can be obtained from Monte Carlo

Phase diagram, Voltage profiles

Results obtained from Monte Carlo

These properties are deduced from the μ(x,T) relation [or alternatively x(μ,T)]

Results obtained in the Ceder group (using Monte Carlo)LixFePO4 phase diagram Voltage profile (room temperature)

5

Page 6: Monte Carlo Methods in Statistical Mechanics Aziz Abdellahi CEDER group Materials Basics Lecture : 08/18/2011 1.

How to calculate the partition function ?Key physical quantity : The partition function

Finding a numerical approximation to the partition function

Monte Carlo strategy : Calculate thermodynamic properties by sampling configurations according to their Boltzmann probability

{j} : Set of all possible Li-Vacancy configurationsEj : Energy of configuration j

Nj : Number of Li in configuration j

Q T,μ( ) = exp −1

kBTE j − μN j[ ]

⎝ ⎜

⎠ ⎟

j

All thermodynamic properties can be computed from the partition function

x μ,T( ) =1

Q

N j

NLi_ sites

exp −1

kBTE j − μN j[ ]

⎝ ⎜

⎠ ⎟

j

E μ ,T( ) =1

QEj exp −

1

kBTEj −μN j[ ]

⎝ ⎜

⎠ ⎟

j∑ Etc.

Control parameters

The partition function cannot be calculated directly because the number of configurations scales exponentially with the system size (2N_sites possible configurations … too hard even for modern computers !).

6

Page 7: Monte Carlo Methods in Statistical Mechanics Aziz Abdellahi CEDER group Materials Basics Lecture : 08/18/2011 1.

Monte Carlo or “Importance Sampling”Importance sampling : Sample states according to their actual probability

Consider the following random variable x :

Direct calculation of <x> :

x = 0* 0.1 +1* 0.8 + 2* 0.1 =1

Importance sampling : Randomly pick 10 values of x out of a giant hat containing 10% 0’s, 80% 1’s and 10% 2’s.

Possible outcome :

1 →0 →2 →1 →1 →1 →1 →2 →1 →1

x ≈1.1

The arithmetic average will not always be equal to the average. However, the two become equal in the limit of large “chains”.

Importance sampling : Sample states with the correct probability. Works well for very large systems that have heavy probability discrepancies.

7

Page 8: Monte Carlo Methods in Statistical Mechanics Aziz Abdellahi CEDER group Materials Basics Lecture : 08/18/2011 1.

Monte Carlo or “Importance Sampling”Monte Carlo : Methodology

Create a Markov chain of configurations, where each configuration is determined from the previous one using a certain probabilistic criteria

C1 C2 … CN_max

Choose the probabilistic criteria so that states are asympotically sampled with the equilibrium Boltzmann probability (that is the main difficulty !)

Start from an initial configuration C1

Limn→ ∞

= P Cn( ) =1

Qexp −

1

kBTEn − μNn[ ]

⎝ ⎜

⎠ ⎟

Calculate thermodynamic averages directly through arithmetic averages over the Markov Chain

En : Energy of configuration Cn

Nn : Number of Li in configuration Cn

x μ,T( ) ≈1

(NMax − M)

Nn

Number _Li_ sitesConfigurationsin MarkovChain

n≥M

∑ 8

Page 9: Monte Carlo Methods in Statistical Mechanics Aziz Abdellahi CEDER group Materials Basics Lecture : 08/18/2011 1.

Metropolis AlgorithmBuilding the chain : The Metropolis Algorithm

Start from an initial configuration C1 :

Change the occupation state of the first Li site :

Calculate Ei-μNi (Before the change) and Ef -μNf (After the change)

If Ef -μNf < Ei-μNi , accept the change

If Ef-μNf > Ei –μNi , accept the change with the probability :

Paccept = exp −1

kBTE f − μN f( ) − E i − μN i( )[ ]

⎝ ⎜

⎠ ⎟

Repeat for all other Li sites to get C2

(Ratio of Boltzmann probabilities…)

9

Page 10: Monte Carlo Methods in Statistical Mechanics Aziz Abdellahi CEDER group Materials Basics Lecture : 08/18/2011 1.

Metropolis algorithm (3)Why does the Metropolis algorithm work ?

The Metropolis algorithm generates a chain Markov consistent with Boltzmann probabilities sampling because the selection criteria has Boltzmann probabilities built into it.

It can be shown that all selection criteria that respect the condition of detailed balance produce correct sampling :

Pi→ j

Pj→ i

= exp −1

kBTE j − μN j( ) − E i − μN i( )[ ]

⎝ ⎜

⎠ ⎟ Probability of generating

configuration j from configuration i

Because the most probable configurations are sampled preferentially, good approximations of thermodynamic averages can be obtained by sampling a relatively small number of configurations

Pi→ j :

10

Page 11: Monte Carlo Methods in Statistical Mechanics Aziz Abdellahi CEDER group Materials Basics Lecture : 08/18/2011 1.

ConclusionMonte Carlo in Statistical Mechanics

Method to approximate thermodynamic properties using clever sampling

Other Monte Carlo methods in engineering

Good results can be obtained by sampling a relatively small number of configurations (relative to the total number of possible configurations) :

LixFePO4 voltage profile : 50 000 states sampled instead of 21728

Kinetic Monte Carlo (to calculate diffusivities)Quantum Monte Carlo (to solve the Schrodinger equation)Monte Carlo in nuclear engineering (to predict the evolution of the neutron population in a nuclear reactor)

11

Page 12: Monte Carlo Methods in Statistical Mechanics Aziz Abdellahi CEDER group Materials Basics Lecture : 08/18/2011 1.

Questions ?

12