65
Evaluating Free Energy and Chemical Potential in Molecular Simulation Marshall T. McDonnell MSE 614 April 26, 2016

Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

  • Upload
    vukhanh

  • View
    216

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Evaluating Free Energy and Chemical Potential in Molecular Simulation

Marshall T. McDonnell

MSE 614

April 26, 2016

Page 2: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Outline● Free Energy

– Motivation

– Theory

– Free Energy Perturbation

– Thermodynamic Integration

● Chemical Potential

– Motivation

– Theory

– Free Energy Perturbation

– Particle Insertion

– Particle Deletion

Page 3: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Free Energies

Page 4: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Free Energy: Motivation● Why is Free Energy so important

– Gives you the comparison of relative stability between ≥2 systems

– Minimum in free energy for the conditions of interest => most stable

● This has a broad range of applications across multiple phenomena of interest. Examples of competing systems:

System

Liquid ↔ Vapor

Sold ↔ Liquid

Reactants ↔ Products

Folded ↔ Unfolded

Assembled ↔ Disordered

● Why is Free Energy so important

– Gives you the comparison of relative stability between ≥2 systems

– Minimum in free energy for the conditions of interest => most stable

● This has a broad range of applications across multiple phenomena of interest. Examples of competing systems:

● Why is Free Energy so important?

– Gives you the comparison of relative stability between ≥2 systems

– Minimum in free energy for the conditions of interest => most stable

● This has a broad range of applications across multiple phenomena of interest. Examples of competing systems:

Appliction / Calculation

Separation Processes

Conditions for Melting

Equilibrium Constants

Protein Folding

Self-Assembly

Page 5: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Un-Motivation: Why are calculation difficult?

● Need free energy difference between ≥2 systems in contact / same simulation => require good sampling of ≥2 with one (normally) being preferred.

● Barrier >> kBT => system to cannot sample regions that are separated by large barriers.

● Need free energy difference between ≥2 systems in contact / same simulation => require good sampling of ≥2 with one (normally) being preferred.

● Barrier >> kBT => system to cannot sample regions that are separated by large barriers.

Atta-Fynn, R., Bylaska, E. J., and de Jong, W. A., “Finite temperature free energy calculations in NWChem: Metadynamics and Umbrella Sampling-WHAM”, Environmental Molecular Sciences Laboratory, Pacific Northwest National Laboratory.

Page 6: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Helmholtz Free Energy (NVT Ensemble)

For partition funciton, , we have from statistical mechanics Q

A(N ,V ,T ) = U−TS=−k BT lnQ

=−k BT ln [∫ ...∫ d rN d pN e−β H ( pN , r N)

h3N N ! ]=−k BT ln [∫ ...∫ d rN e−βU ( r N

)

Λ3 N N ! ]

=−k BT ln [Z (N ,V ,T )

Λ3 N N ! ]

=−k BT ln [ Λ3N N ! ]−kB T ln [Z (N ,V ,T )]= A ig+Aex

β=1

k B T

Λ=√ h2

2 πm kB T

Where k B =

h =Λ =

Boltzmann's constant Planck's constant de Broglie wavelength

Z (N ,V ,T ) =

Aig =

Aex =

Configurational integral Ideal free energy Excess free energy

Page 7: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Free Energy Differences

Δ01 A ( N ,V ,T ) = Δ0

1 U−T Δ01 S

= A1−A0

=−k B T lnQ1−kB T ln Q0

=−k B T ln [Q1/Q0 ]

=−k B T ln [∫ ...∫ d rN d pN e−β H 1

h3N1 N1 !

h3N 0 N 0!

∫ ...∫ d rN d pN e−βH 0 ]

Instead, we calculate the change in free energy from State 0 (reference) to State 1 (target):

Z ( N ,V ,T ) = ∫ ...∫ d rN e−βU ( rN)

Cannot practically calculate absolute free energies due to configurational integral term:

If we assume equal # of particles between systems, we have:

Δ01 A (N ,V ,T ) = −kB T ln [

∫ ...∫ d rN d pN e−β H 1 (rN)

∫ ...∫ d rN d pN e−β H 0 (r

N)]

Page 8: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Free Energy Perturbation (FEP): Theory

Let us be very “sneaky” and use the following:

eβ H 0 e

−β H 0=1

Δ01 A (N ,V ,T ) = −kB T ln [∫ ...∫ d rN d pN e−β H 1 [eβ H 0 e−β H 0 ]

∫ ...∫ d rN d pN e−β H 0 ]

= −kB T ln [∫ ...∫ d rN d pN e−β( H 1−H 0 )e

−β H 0

∫ ...∫ d rN d pN e−β H 0 ]

Using this in the numerator of the integrand, we get:

Which is exactly the definition of an ensemble average for an observable, specifically:

Δ01 A ( N ,V ,T ) = −kB T ln ⟨e−β( H 1−H 0 )⟩0= −k BT ln ⟨e−β( Δ0

1 H )⟩0

Page 9: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Free Energy Perturbation (FEP): Theory

Δ01 A = −k B T ln ⟨e−β(H 1−H 0 ) ⟩0 = −k B T ln ⟨e−β(Δ 0

1 H )⟩0

This is the fundamental equation for FEP and a basis for many further extensions and developments in free energy calculation methods

This states we can obtain the change in free energy from State 0 (ref.) to State 1 (target) by sampling configurations only from the reference state!

As long as the masses do not change from State 0 ↔ State 1, we can integrate out the kinetic part of the Hamiltonians and cancel, leaving:

Δ01 A = −k B T ln ⟨e−β(Δ0

1U )⟩0

This gives us the convenience of applying a perturbation, , and sampling in the reference state.

But it does not overcome the sampling issues we discussed before.

Δ01U

Page 10: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Free Energy Perturbation (FEP): Coupling

We can link the two states by constructing intermediate states and couple them all together via a common parameter.

U ( λ ) = (1−λ)U0+λU 1 = U 0+λ Δ01 U

Δ01 A = ∑

i=0

n−1

Δλ=0λ=1 A = −k B T∑

i=0

n−1

ln ⟨e−β(U (λ i+1)−U ( λ i) ⟩λi

Figure from: Chipot, C. and Pohorille, A., Free Energy Calculations, Springer Series in Chemical Physics 86, (2007).

Page 11: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Free Energy Perturbation: Profile

Δ01 A = ∑

i=0

n−1

Δλ= 0λ=1 A = −k B T∑

i=0

n−1

ln ⟨e−β(U (λ i+1)−U ( λ i) ⟩λi

Figure from: Ponder, J.., “Introduction to Free Energy Calculations”, Lecture Series for Molecular Mechanics. Lecutre 18 & 19. website http://dasher.wustl.edu/chem478/

Page 12: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Free Energy Perturbation: Applications

Figure from: Chipot, C. and Pohorille, A., Free Energy Calculations, Springer Series in Chemical Physics 86, (2007).

Page 13: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Free Energy Perturbation: LAMMPS

Figure from: LAMMPS website. Plimpton, S. website: lammps.sandia.gov

Page 14: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Free Energy Perturbation: LAMMPS

Figure from: LAMMPS website. Plimpton, S. website: lammps.sandia.gov

Page 15: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Thermodynamic Integration (TI): Theory

Another technique that can be derived from Free Energy Perturbation is calculating the change in free energy via Thermodynamic Integration.

We take the derivative of the free energy with respect to the coupling:

( ∂ A (λ )∂ λ )

N , V , T=−k B T ∂

∂λlnQ ( N ,V ,T ,λ )

=−kB T

Q ( N ,V ,T ,λ )

∂Q ( N ,V ,T ,λ )∂λ

=∫ ...∫d rN d pN ∂H (λ )

∂ λe−β H (λ)

∫ ...∫d rN d pNe−β H (λ)

= ⟨∂ H (λ )

∂ λ⟩λ

A( N ,V ,T ,λ ) =−kB T ln [Q (N ,V ,T ,λ ) ] =−k B T ln [∫ ...∫ d rN

d pNe

−β H (λ )

h3N N ! ]

Page 16: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Thermodynamic Integration(TI): Theory

Now, we can get the change in free energy upon integration:

A(λ=1)−A (λ=0) = ∫λ=0

λ=1 (∂ A( λ )∂ λ )

N , V ,T∂λ

= ∫λ=0

λ=1⟨∂ H (λ)

∂ λ⟩λ∂λ

Thus, we can numerically integrate the above equation to get:

A(λ=1)−A (λ=0) = ∫λ=0

λ=1⟨∂ H (λ )

∂λ⟩λ∂λ

= ∑i=0

n−1

w i⟨H (λ i+ 1)−H (λi)

λ i+1−λ i⟩λi

Where the weights, , are a equally spaced points. w i

Page 17: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Thermodynamic Integration(TI): Profile

A(λ=1)−A (λ=0) = ∫λ=0

λ=1⟨∂ H (λ)

∂ λ⟩λ∂λ

Figure from: Ponder, J.., “Introduction to Free Energy Calculations”, Lecture Series for Molecular Mechanics. Lecutre 18 & 19. website http://dasher.wustl.edu/chem478/

Page 18: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Thermodynamic Integration(TI): Profile

Figure from: LAMMPS website. Plimpton, S. website: lammps.sandia.gov

Page 19: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Thermodynamic Integration(TI): Profile

Yet, we can also compute this with the FEP command as well

(very versatile). On the LAMMPS page:

Figure from: LAMMPS website. Plimpton, S. website: lammps.sandia.gov

Page 20: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

LAMMPS Note on FEP & TI

The compute fep or the compute ti will compute the perturbation at a fixed point in the trajectory (i.e. w/o moving the atomic coordinates). You still need to advance the coupling parameter as the simulation progresses.

Another note: You need to capture the average during a given “window” of the ith coupling parameter, thus you need to use the fix ave/time to compute these averages.

Figure from: LAMMPS website. Plimpton, S. website: lammps.sandia.gov

Page 21: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

LAMMPS Note on FEP & TI Fortunately, there are simulation examples in the LAMMPS distribution (as of 7Dec2015). These are in the directory

● $LAMMPS_HOME/examples/USER/fep/

There are three examples:

1) Methane in gas phase → methane in water => free energy of solvation

2) Methane in water → Perfluormethane in water => alchemical transformation

3) Ethane in water → Methanol in water => alchemical transformation

Also, there are data analysis tools that compute the free energy based on the output (i.e. they perform the numerical integrations, etc.). These are very “light” Python scripts (~10-20 lines each) so not too hard to follow or understand, even for a beginner in Python

● $LAMMPS_HOME/tools/fep/

Page 22: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Considerations for perturbative methods● There are some considerations / issues when using these

perturbative methods discussed (and most others):

– Must integrate along a reversible path – cannot “ruin” the ensemble's fixed variables. Remember, its a partial derivative only changing the coupling parameter.

– Consider the NVE ensemble. If one grew the coupling parameter to rapidly so that it was a non-adiabatic process, we no longer conserve energy. We end up in a state that does not correspond to any known ensemble.

– Must let the system come back to equilibrium after changing coupling parameter. Therefore, we must add equilibration periods after every change in the coupling parameter before we begin sampling the average again.

– Do to these considerations, FEP simulations can be very “expensive” and accuracy highly depends on the simulation setup.

Page 23: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potentials

Page 24: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Motivation ● How is Chemical Potential related to Free Energy?

– The chemical potential of species, , is given as the change in the free energy for the given ensemble with the change in the # of particles of that species.

μα = ( ∂G∂ Nα

)N , P , T

= ( ∂ A∂N α

)N ,V ,T

=(−T∂ S∂ Nα

)N , V , E

α

● Very important for processes that add or lose particles:

– Phase Equilibria - Which phase to I prefer? Vapor or liquid?

– Defects in Crystal Structures –

● Can I get in between you guys or find my own lattice site?(interstitial)

● What if I just didn't show up at all? (vacancies)

Page 25: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Un-Motivation

● Calculating free energy change is difficult enough. Now we are going to start adding and subtracting particles?

– Most of the ensembles we are familiar with conserve N, the # of particles in the system.

– Discrete changes in N creates discrete changes in the energy of the system.

– These types of changes are in the realm of non-equilibrium molecular dynamics.

– Chemical potential “fits” more naturally into Monte Carlo simulations since there are no dynamics that we want to conserve. Trial and error insertion or deletions are not such and issue / challenge.

– So... what do we do?

Page 26: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: FEP

● Actually, we have already talked about a technique that can work, the free energy perturbation method!

– The coupling parameter can couple the “creation” or “growth” of a particle in the simulation. Thus, State 0 (ref.) is the N particle system and State 1 (target) is the N+1 particle system

Figure from: Chipot, C. and Pohorille, A., Free Energy Calculations, Springer Series in Chemical Physics 86, (2007).

Page 27: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: FEP

Given a functional form for the potential energy, we can turn off the particles interactions initially. Thus, it resembles an ideal gas particle in the system (non-iteracting).

We then couple to the N+1 system by increasing the particle's interactions gradually along a reversible path.

This is sometimes known in the literature as the free energy of solvation because it gives you the change in the free energy to go from an ideal vapor phase to a solvated state by a given solvent (i.e. water, organic solvents, ionic solution, etc.)

An example would be for a Lennard-Jones fluid, we could grow the σ parameter, averaging or integrating along the path for λσ, starting from from λ=0 until we reached the full value of σ when λ=1.

Figure from: Chipot, C. and Pohorille, A., Free Energy Calculations, Springer Series in Chemical Physics 86, (2007).

Page 28: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: FEP

An example would be for a Lennard-Jones fluid, we could grow the σ parameter, averaging or integrating along the path for λσ, starting from from λ=0 until we reached the full value of σ when λ=1.

λ = 0

λ = 1

Figure from: Ponder, J.., “Introduction to Free Energy Calculations”, Lecture Series for Molecular Mechanics. Lecutre 18 & 19. website http://dasher.wustl.edu/chem478/

Page 29: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Considerations for FEP

Same issues apply as previously stated for using FEP to calculate chemical potentials:

● Must integrate along a reversible path

● Must let the system come back to equilibrium after changing coupling parameter.

● Can be very “expensive”

● Accuracy highly depends on the simulation setup.

Page 30: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: More “Elegant” Methods

A simple and elegant way to calculate the chemical potential using only the reference state is the particle insertion method, also known as the Widom method.

To derive this, we turn back to our previous statistical mechanics derivation:

Δ01 A ( N ,V ,T ) =−k B T lnQ 1−kB T lnQ0

=−k B T ln [Q1/Q0 ]

=−k B T ln [∫ ...∫ d rN d pN e−β H 1

h3N1 N1 !

h3N 0 N 0!

∫ ...∫ d rN d pN e−βH 0 ]Yet, now the transition from State 0 (reference) to State 1 (target) is the addition of a single particle.

Thus, in the equation above, we have N1=N +1N0=N

H 0=H ( N ,V ,T ) H 1=H (N +1,V ,T )

Page 31: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Insertion

A simple and elegant way to calculate the chemical potential using only the reference state is the particle insertion method, also known as the Widom method.

To derive this, we turn back to our previous statistical mechanics derivation:

Δ01 A ( N ,V ,T ) =−k B T lnQ 1−kB T lnQ0

=−k B T ln [Q1/Q0 ]

=−k B T ln [∫ ...∫ d rN d pN e−β H 1

h3N1 N1 !

h3N 0 N 0!

∫ ...∫ d rN d pN e−βH 0 ]Yet, now the transition from State 0 (reference) to State 1 (target) is the addition of a single particle.

Thus, in the equation above, we have N1=N +1N0=N

H 0=H ( N ,V ,T ) H 1=H (N +1,V ,T )

Page 32: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle InsertionΔ0

1 A

Δ N=

A (N +1,V ,T )−A ( N ,V ,T )

N+1−N

=−k B T ln [Q ( N+1,V ,T )

Q ( N ,V ,T ) ]=−k B T ln [∫ ...∫ d rN+ 1 d pN +1 e−βH (N +1, V ,T )

h3N +1 N +1 !h3N N !

∫ ...∫d rN d pNe−β H ( N ,V ,T ) ]=−k B T ln [∫ ...∫ d rN+ 1 e−βU ( N +1, V ,T )

Λ3 N +1 N +1!

Λ3N N !

∫ ...∫d rN e−β U ( N ,V ,T ) ]=−k B T ln [( 1

Λ3 N +1 )∫

...∫ d rN+ 1 e−βU ( N +1,V ,T )

∫ ...∫ d rN e−βU ( N ,V ,T ) ]=−k B T ln [( 1

Λ3 N +1 )]−kB T ln [∫ ...∫d rN +1 e−β U ( N +1,V , T )

∫ ...∫d rN e−β U ( N ,V ,T ) ]= μig+μex

Page 33: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Insertion

μex =−k B T ln [∫ ...∫ d rN+1 e−βU ( N +1, V ,T )

∫ ...∫ d rNe−βU ( N ,V , T ) ]=−k B T ln [∫d rN +1∫ ...∫ d rNe−βU ( N +1,V ,T ) +(βU ( N ,V ,T )−βU ( N ,V ,T ) )

∫ d rN e−βU (N ,V ,T ) ]=−k B T ln [∫d rN +1∫ ...∫ d rNe−β ( U ( N +1,V , T )−βU ( N ,V , T )) e−βU ( N , V , T )

∫ d rN e−βU ( N ,V ,T ) ]=−k B T ln [∫d rN +1∫ ...∫ d rNe−βΔU e−βU ( N ,V , T )

∫ d rN e−βU ( N ,V ,T ) ]=−k B T ln [∫d rN +1 ⟨e

−β ΔU⟩N ]

We can solve the ideal gas contribution analytically. Thus, for the excess term we have:

Page 34: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Insertion

μex =−k B T ln [∫ ...∫ d rN+1 e−βU ( N +1, V ,T )

∫ ...∫ d rNe−βU ( N ,V , T ) ]=−k B T ln [∫d rN +1∫ ...∫ d rNe−βU ( N +1,V ,T ) +(βU ( N ,V ,T )−βU ( N ,V ,T ) )

∫ d rN e−βU (N ,V ,T ) ]=−k B T ln [∫d rN +1∫ ...∫ d rNe−β ( U ( N +1,V , T )−βU ( N ,V , T )) e−βU ( N , V , T )

∫ d rN e−βU ( N ,V ,T ) ]=−k B T ln [∫d rN +1∫ ...∫ d rNe−βΔU e−βU ( N ,V , T )

∫ d rN e−βU ( N ,V ,T ) ]=−k B T ln [∫d rN +1 ⟨e

−β ΔU⟩N ]

We can solve the ideal gas contribution analytically. Thus, for the excess term we have:

Page 35: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Insertion

μex =−k B T ln [∫ ...∫ d rN+1 e−βU ( N +1, V ,T )

∫ ...∫ d rNe−βU ( N ,V , T ) ]=−k B T ln [∫d rN +1∫ ...∫ d rNe−βU ( N +1,V ,T ) +(βU ( N ,V ,T )−βU ( N ,V ,T ) )

∫ d rN e−βU (N ,V ,T ) ]=−k B T ln [∫d rN +1∫ ...∫ d rNe−β ( U ( N +1,V , T )−βU ( N ,V , T )) e−βU ( N , V , T )

∫ d rN e−βU ( N ,V ,T ) ]=−k B T ln [∫d rN +1∫ ...∫ d rNe−βΔU e−βU ( N ,V , T )

∫ d rN e−βU ( N ,V ,T ) ]=−k B T ln [∫d rN +1 ⟨e

−β ΔU⟩N ]

We can solve the ideal gas contribution analytically. Thus, for the excess term we have:

Page 36: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Insertion

μex =−k B T ln [∫d rN +1 ⟨e−β ΔU ⟩N ]

This last equation is central equation for calculating the excess chemical potential via the particle insertion / Widom method:

What does it say?

● For the integrand, we have a Boltzmann factor average of the difference in potential energy of State 1 (N+1) minus that of State 0 (N)

● This average is in the reference state, State 0, thus in a system with N particles

● The integration is over all the positions of the N+1th particle in the N-particle system

● Thus, we can use Monte Carlo sampling techniques equate the integral by brute force!

Page 37: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Insert in Action!

Particle Insertion in action! Pink particle is test insertion particle

Page 38: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: How well does it do?

Figure from: Fenkel, D. and Smit B. Understanding Molecular Simulation. Elsevies, Academic Press, 2002, 2nd edition.

Page 39: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Insertion

Particle Insertion has drawbacks which can be understood intuitively:

● Work well for low density systems; will not work for very dense systems (liquid) or crystals (solid)

● Must be able to insert a particle with a low Boltzmann factor to make any significant contribution to the integral

● For high density systems, have almost no chance of sampling this type of insertion via random insertions.

● Long-range corrections can have a large effect on the chemical potential. Straight forward to compute analytically.

● NOTE: Not an option / fix / compute in LAMMPS (as of 7Dec2015)

Page 40: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Insertion

If this isn't readily available in LAMMPS, why are you showing it!

● Unlike the FEP method, this method can be applied as a post-processing method to compute chemical potential.

● Thus, you could even use it on previous trajectories, unlike running a very long, expensive FEP calculation

● More elegant method that FEP that shows how to overcome approaches to calculating free energy.

● And … you can actually kind of use LAMMPS to do this...but compiling LAMMPS as a shared library and writing a post-processing code that uses LAMMPS functions.

– Have created such code Lennard-Jones Potential.

Page 41: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Deletion

If we added a particle to get change in free energy, can we delete a particle?

● Yes! We can. However, the process of deleting a particle is a lot more subtle that particle insertion and care must be given.

● The benefit of particle deletion is that you can delete a particle from a very dense system with no major sampling issues.

● However, there are some concerns.

– We shall see that the functional form has terms we must be conscious of when developing the theory.

– We get less statistics from one deletion of a fixed configuration for a single frame than from performing multiple insertions with possibly multiple configurations in a single frame.

Page 42: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Deletion

Some notes on the past studies of particle deletion methods:

● Pioneering work by K. S. Shing and K. E. Gubbins (1982, Mol. Phys. 1009)

● In the 1990's, particle deletion was considered inaccurate. See this article for a survey:

P. Cummings and D. Kofke “Quantitative comparison and optimization of methods for evaluating the chemical potential by molecular simulation”, Molecular Physics, 92,, 6, 1997.

Yet, the theory was not completely developed at that time (Shing & Gubbins work deemed it as an inaccurate method).

Page 43: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Deletion

D. Theodorou and G. Boulougouris have greatly advanced the particle deletion method :

● Beginning 2001 with the staged-particle deletion method

● Then in 2006-2007 with the direct-particle deletion method

● Up to now in 2010 with reinsertion method

Acknowledged that the N-1 system was not the same as the reference system (like in the Particle Insertion Method)

Instead it is an N-1 particle system with a “hole”, or cavity formation.

If not taken into account, this will bias the calculation.

Thus, introduced hard-core potentials to replace the molecule to add high Boltzmann weight for overlaps.

Page 44: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Deletion

Δ01 A

Δ N=−k B T ln [Q ( N ,V ,T )

Q ( N−1,V ,T ) ]=−k B T ln [( 1

Λ3 N )]−kB T ln [∫ ...∫ d rN e−βU ( N ,V ,T )

∫ ...∫ d rN−1e−βU ( N −1,V , T ) ]= μ ig+μex

If we proceed as before, will get averages in N-1 system. This is just particle insertion again. Instead, we want averages in the N system.

We now introduce a function that we use as an identity to insert into the equation above to proceed.

Similar to the particle insertion derivation, we can arrive at the following:

Page 45: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Deletion

We introduce the Heaviside step-function:

H qN(rN , d)

Where:

rN= The coordinate vector of the Nth particle we are deleting

We introduce the Heaviside step-function:

qN= All of the particle distances for the N-particle system

rN= The coordinate vector of the Nth particle we are deleting

d= The hard-core diameter we assign to the deleted particle with coordinates .rN

And we have:

H q N(rN , d)=0 When the Nth particle's diameter, , overlaps with any other particle in the N-particle system.

d

H qN(rN , d)=1 otherwise

Page 46: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Deletion

We use the following identity with our Heavside function and :

μex =−k B T ln [∫ ...∫ d rN e−βU ( N ,V ,T )

∫ ...∫ d rN−1 e−β U ( N−1,V ,T )

∫ ...∫ d rN H qN (rN , d)e−βU ( N −1,V , T )

∫ ...∫ d rN H qN (rN , d)e−βU ( N −1,V , T ) ]=−k B T ln [(∫ ...∫ d rN H

qN (rN , d )e−βU ( N−1,V ,T )

∫ ...∫ d rN e−βU ( N ,V , T ) )−1

∫ ...∫ d rN−1∫ rN HqN (rN , d)e−βU ( N−1, V ,T )

∫ ...∫ d rN−1 e−βU ( N−1,V ,T ) ]=−k B T ln [(∫ ...∫ d rN H qN (rN , d )e−β (U ( N ,V ,T )−Δ U )

∫ ...∫ d rN e−βU ( N ,V , T ) )−1

⟨∫ rN H q N (rN , d)⟩( N −1,V ,T ) ]

1 =∫ ...∫ d rN H qN (rN ,d )e−β U ( N−1,V ,T )

∫ ...∫ d rN HqN (rN ,d )e−β U ( N−1,V ,T )

And insert it into our excess chemical potential:

ΔU = U ( N ,V ,T )−U ( N−1,V ,T )

U ( N−1,V ,T ) = U ( N ,V ,T )−ΔU

Page 47: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle DeletionContinuing, we have

μex =−k B T ln [(∫ ...∫ d rN H qN (rN , d )e−β (U ( N ,V ,T )−Δ U )

∫ ...∫ d rNe−βU ( N ,V , T ) )−1

⟨ H q N (rN , d)⟩( N −1,V ,T ) ]=−k B T ln [(∫ ...∫ d rN H qN (rN , d )e−β ΔU eβU ( N ,V ,T )

∫ ...∫ d rNe−βU ( N ,V , T ) )−1

⟨H q N(rN ,d )⟩ ( N −1,V , T ) ]=−k B T ln [ (⟨ H

q N (rN , d)eβΔU⟩

( N ,V ,T ) )−1

⟨ HqN (rN , d )⟩

( N−1, V ,T ) ]=−k B T ln [ (⟨ H

q N (rN , d)eβΔU⟩

( N ,V ,T ) )−1 ]−k B T ln [⟨ H

q N (rN , d)⟩( N−1,V ,T ) ]

= μexenergy +μ ex

volume

This is the Stage Particle Deletion Method.

Page 48: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Deletion

Staged Particle Deletion Method:

What does it say?

● We can decompose the excess chemical potential potential into an energetic contribution and a volume / cavity formation term.

● To be rigorous, must perform 2 simulations.

– Energetic term: N particle simulation

– Accessible volume term: N-1 particle simulation

– We can relax this for large N and just run one N particle simulation.

● We must determine the best hard-core diameter for this calculation.

● Must have an accurate way to calculate accessible volume.

μex =−k B T ln [ (⟨ Hq N (rN , d)eβΔU⟩( N ,V ,T ) )

−1 ]−k B T ln [⟨ Hq N (rN , d)⟩ ( N−1,V ,T ) ]= μex

energy+μ ex

volume

Page 49: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Deletion

I don't want to have to run two simulations!

● Me neither! Let's try again... let's use this instead:

1 =∫d rN H q N (rN , d)

∫d rN Hq N (rN , d)

● And the identity:

∫ f ( y )dy =∫∫ g (x , y)dx

∫ g (x , y)dxf ( y )dy

= ∫∫ 1

∫ g (x , y)dxg (x , y ) f ( y )dx dy

Page 50: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Deletion

μex =−k B T ln [∫ ...∫ d rN e−βU ( N ,V ,T )

∫ ...∫ d rN−1∫d rN H qN (rN , d)

∫d rN H qN (rN , d)e−βU ( N −1,V , T ) ]

=−k B T ln [∫ ...∫ d rN e−βU ( N ,V ,T )

∫ ...∫ d rN 1

∫d rN Hq N (rN , d )H qN (rN , d )e−βU ( N −1,V ,T ) ]

=−k B T ln [∫ ...∫ d rN e−βU ( N ,V ,T )

∫ ...∫ d rN 1

∫d rN Hq N (rN , d )

H qN (rN , d )e−βU ( N −1,V ,T ) ]= k B T ln [∫ ...∫ d rN 1

∫d rN Hq N (rN , d )H qN (rN , d )e−βΔ U eβU ( N ,V , T )

∫ ...∫d rN e−βU ( N , V , T ) ]

Page 51: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Deletion

μex = k B T ln [∫ ...∫ d rN 1

∫d rN H qN (rN , d )H qN (rN , d )e−βΔ U eβU ( N ,V , T )

∫ ...∫d rN e−βU ( N , V , T ) ]= k B T ln ⟨

1

∫ d rN H qN (rN , d )H qN (rN , d)e−βΔU

⟩( N ,V ,T )

This last equation is the Direct Particle Deletion Method:

μex = k B T ln ⟨1

∫ d rN HqN (rN , d )

Hq N (rN , d)e−βΔU ⟩( N ,V ,T )

Good, one N particle simulation!

Page 52: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Deletion

Direct Particle Deletion Method:

What does it say?

● We must determine the best hard-core diameter for this calculation.

● Must have an accurate way to calculate accessible volume.

● Sadly, we lost our decomposition of energetic and volume terms...

μex = k B T ln ⟨1

∫ d rN HqN (rN , d )

Hq N (rN , d)e−βΔU⟩

( N ,V ,T )

But wait! From the staged particle deletion we know

μexenergy

=−kB T ln [(⟨ H q N (rN , d )eβΔU⟩ ( N ,V ,T ) )

−1 ]

Thus we can calculate and to back out the volume term!

μexenergyμex

Page 53: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Deletion

Figure from: De Angelis M. G., Boulougouris, G., and Theodorou D. “Prediction of Infinite Dilution Benzene Solubility in Linear Polyethylene Melts via the Direct Paricle Deletion Method.”, J. Phys. Chem. B 2010, 114, 6233-6246.

Page 54: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Based Methods

Figure from: De Angelis M. G., Boulougouris, G., and Theodorou D. “Prediction of Infinite Dilution Benzene Solubility in Linear Polyethylene Melts via the Direct Paricle Deletion Method.”, J. Phys. Chem. B 2010, 114, 6233-6246.

Page 55: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Notes on Solids

Solids are a little different but can still be handled via FEP

● Instead of an ideal gas reference system, must use a 0K solid as the reference

● Thus, use an Einstein crystal as the reference

● Use harmonic springs on lattice sites for State 0

● For more see

– Understanding Molecular Simulation by Frenkel and Smit

● Chapter 10: “Free Energies of Solids” ● Gives Thermodynamic Integration for Solids

● This is available in LAMMPS as compute ti/spring.

● Talk to me afterwards if you would like to know more about this.

Page 56: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Advanced Methods

These are fundamental methods. Entire books and conferences are dedicated to free energy calculations!

Advanced techniques (most in LAMMPS COLVARS module):

● Umbrella Sampling Method ( bridging gap with cancelling function )

● Potential Mean Force Method ( make potentials that reproduce force )

● Adaptive Biasing Force Method ( builds upon TI )

● Metadynamics ( “dropping computational sand” in energy wells )

● Steered Molecular Dynamics ( apply constant forces to sample )

● Gibbs Ensemble Monte Carlo ( two systems in contact but no interface)

● Gibbs-Duhem Integration (tracing coexistence curves)

Page 57: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Suggested References

Understanding Molecular Simulation

● Authors: Daan Frenkel &Berend Smit

● Part III: Chapters 7 – 11

– NOTE: Good for beginning to learn and understand. Has available code. Covers both Monte Carlo and Molecular Dynamics techniques. Some of the newer methods are not mentioned.

Free Energy Calculations

● Editors: Christophe Chipot & Andrew Pohorille

● More than 500 pages just on free energy calculations!

– NOTE: Gives a survey of the field. More of an intermediate text but also is a great book to learn from. Covers state-of-the-art techniques and relevant literature.

Page 58: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Conclusion● Free Energy

– Learned underlying theory and implementation in LAMMPS

● Free Energy Perturbation● Thermodynamic Integration

● Chemical Potential

– Learned underlying theory and discussed either implementation in LAMMPS or possible post-processing applications

● Free Energy Perturbation● Particle Insertion● Particle Deletion

Page 59: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Questions?

Email: [email protected]

Page 60: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Extra Slides

Page 61: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Crystal Structures – Polymorphic Behavior● Q: Why not perform (exhaustive) search for configuration with

lowest potential energy?

– This is in principle a free energy analysis but only using the minimum in the potential energy, thus neglecting entropic effects.

– Neglecting the entropic effects implies that we can only apply this for T = 0K.

– No description of the effect of temperature on the polymorphic behavior is given.

Page 62: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Δ F (δ)=−k bT ln [∫ dRA ' B' ' P (δ , RA ' B' ')]

Page 63: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Insertion

First you said this isn't available in LAMMPS. Now you can use LAMMPS. You are a LIAR!

● First, easy on the accusations!

● It is not available as a command but you can create post-processing software using LAMMPS - as a shared library!

● To do so, when compiling and installing LAMMPS, just use

make foo mode=lib

● A shared library list a libraries of functions / subroutines available that you can use in your own code.

– Examples: BLAS, LAPACK, and MPI.

Page 64: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle Insertion

What are the steps:

● First, create a LAMMPS shared library

● Should give you a liblammps_<machine>.so (shared library) or a liblammps_<machine> (static library)

● Include the LAMMPS header files in your C/C++ code to use the functions contained within LAMMPS.

Page 65: Evaluating Free Energy and Chemical Potential in …utkstair.org/clausius/docs/mse614/pdf/chemicalpotential_intro_v01.pdf · Evaluating Free Energy and Chemical Potential in Molecular

Chemical Potential: Particle InsertionWhat are the steps (cont.):

● Make sure you link against the libraries you want to use. You notice we link against the LAMMPS library we created (liblammps_newton.a) but also the ReaxFF library (libreax.a) for the Fortran version in LAMMPS (not the reax/c version).

● Now, you should have access to all the functions in LAMMPS to make your own code! It could be whatever you want!

● NOTE: You have more than enough “rope” to “hang yourself with” but it will give you intimate knowledge of the source code.

● I made such a code that does Particle Insertion using the Lennard-Jones Potential with cutoffs. Able to reproduce the curve we saw previously.