23
1 CE 530 Molecular Simulation Lecture 13 Molecular Dynamics in Other Ensembles David A. Kofke Department of Chemical Engineering SUNY Buffalo [email protected]

CE 530 Molecular Simulation - University at Buffalokofke/ce530/Lectures/Lecture13.ppt.pdfCE 530 Molecular Simulation ... rdr r r εσ σ σ ... 17 Nosé Thermostat 2. ¡ Extended-system

Embed Size (px)

Citation preview

1

CE 530 Molecular Simulation

Lecture 13 Molecular Dynamics in Other Ensembles

David A. Kofke

Department of Chemical Engineering SUNY Buffalo

[email protected]

2

Review ¡ Molecular dynamics is a numerical integration of the

classical equations of motion ¡ Total energy is strictly conserved, so MD samples the NVE

ensemble ¡ Dynamical behaviors can be measured by taking appropriate

time averages over the simulation •  Spontaneous fluctuations provide non-equilibrium condition for

measurement of transport in equilibrium MD •  Non-equilibrium MD can be used to get less noisy results, but

requires mechanism to remove energy via heat transfer ¡ Two equivalent formalisms for EMD measurements

•  Einstein equation •  Green-Kubo relation

time correlation functions

3

Molecular Dynamics in Other Ensembles

¡ Standard MD samples the NVE ensemble ¡ There is need enable MD to operate at constant T and/or P

•  with standard MD it is very hard to set initial positions and velocities to give a desired T or P with any accuracy

NPT MD permits control over state conditions of most interest

•  NEMD and other advanced methods require temperature control ¡ Two general approaches

•  stochastic coupling to a reservoir •  feedback control

¡ Good methods ensure proper sampling of the appropriate ensemble

4

What is Temperature? ¡ Thermodynamic definition

•  temperature describes how much more disordered a system becomes when a given amount of energy is added to it

high temperature: adding energy opens up few additional microstates low temperature: adding energy opens up many additional microstates

¡ Thermal equilibrium •  entropy is maximized for an isolated system at equilibrium •  total entropy of two subsystems is sum of entropy of each: •  consider transfer of energy from one subsystem to another

if entropy of one system goes up more than entropy of other system goes down, total entropy increases with energy transfer

equilibrium established when both rates of change are equal (T1=T2) –  (temperature is guaranteed to increase as energy is added)

,

1

1 ln ( , , )

V N

ST E

E V NkT E

∂⎛ ⎞= ⎜ ⎟∂⎝ ⎠∂= Ω∂

Number of microstates having given E

Disordered: more ways to arrange system and have it look the same

1 2totS S S= +

1 2 Q

5

Momentum and Configurational Equilibrium

¡ Momentum and configuration coordinates are in thermal equilibrium •  •  momentum and configuration coordinates must be “at same

temperature” or there will be net energy flux from one to other ¡ An arbitrary initial condition (pN,rN) is unlikely to have equal

momentum and configurational temperatures •  and once equilibrium is established, energy will fluctuate back

and forth between two forms •  ...so temperatures will fluctuate too

¡ Either momentum or configurational coordinates (or both) may be thermostatted to fix temperature of both •  assuming they are coupled

( , ) ( ) ( )N N N NE r p K p U r= +pN rN Q

6

An Expression for the Temperature 1.

¡ Consider a space of two variables •  schematic representation of phase space

¡ Contours show lines of constant E •  standard MD simulation moves along

corresponding 3N dimensional hypersurface

¡ Length of contour E relates to Ω(E) ¡ While moving along the EA contour,

we’d like to see how much longer the EB contour is

¡ Analysis yields

1x

2xBE

AE

BE

AE

2

21 x

x

EkT E

∇=∇

Relates to gradient and rate of change of gradient

7

Momentum Temperature

¡ Kinetic energy

¡ Gradient

¡ Laplacian

¡ Temperature

2

1( )

2

NN i

iK

m==∑ pp

d = 2

1

1 1N

i

NdKm m m=

⎛ ⎞∇ ⋅∇ = + =⎜ ⎟⎝ ⎠∑p p

2

2

22

2 21

2

1

1/

1

Niyix

i

Ni

i

KkT

K

ppNd m m m

kTNd m

=

=

∇=

⎛ ⎞= +⎜ ⎟⎜ ⎟⎝ ⎠

=

p

p

p The standard canonical-ensemble “equipartition” result

1ˆ ˆ

Niyix

ix iyi

ppKm m=

⎛ ⎞∇ = +⎜ ⎟

⎝ ⎠∑p e e

8

Configurational Temperature

¡ Potential energy

¡ Gradient

¡ Laplacian

¡ Temperature

( )NU r

( )1 1

ˆ ˆ ˆ ˆN N

ix iy ix ix iy iyix iyi i

U UU F Fr r= =

⎛ ⎞∂ ∂∇ = + = − +⎜ ⎟⎜ ⎟∂ ∂⎝ ⎠∑ ∑r e e e e

1

Niyix

ix iyi

FFUr r=

⎛ ⎞∂∂∇ ⋅∇ = − +⎜ ⎟⎜ ⎟∂ ∂⎝ ⎠∑r r

2

2

2

1

1

N

ii

Niyix

ix iyi

UkT

U

FFr r

=

=

∇=

=⎛ ⎞∂∂− +⎜ ⎟⎜ ⎟∂ ∂⎝ ⎠

r

r

F

Butler, B. D., G. Ayton, O. G. Jepps, and D. J. Evans. 1998. Configurational temperature: verification of Monte Carlo simulations. J. Chem. Phys. 109, 6519.

9

Lennard-Jones Configurational Temperature

¡ Spherically-symmetric, pairwise additive model

¡ Force

¡ Laplacian

1( ) ( )

NN

ij iji j i

U u r= <

=∑∑r

ij iji

ij ijj i

dur dr≠

= −∑r

F

12 6( ) 4LJu r

r rσ σε

⎡ ⎤⎛ ⎞ ⎛ ⎞= −⎢ ⎥⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠⎢ ⎥⎣ ⎦14 8

248 1

2LJdu

r dr r rε σ σ

σ

⎡ ⎤⎛ ⎞ ⎛ ⎞= −⎢ ⎥⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠⎢ ⎥⎣ ⎦

r r

2 1 1ij ij iji

i ij ij ij ij ij ijj i

r du duFr r r r dr r dr

αα

α ≠

⎡ ⎤⎛ ⎞∂ ∂= − −⎢ ⎥⎜ ⎟⎜ ⎟∂ ∂⎢ ⎥⎝ ⎠⎣ ⎦∑

16 10

41 1 672 2

7LJd du

r dr r dr r rε σ σ

σ

⎡ ⎤⎛ ⎞ ⎛ ⎞ ⎛ ⎞= −⎢ ⎥⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠ ⎝ ⎠⎢ ⎥⎣ ⎦

N.B. Formulas not verified

10

Thermostats ¡ All NPT MD methods thermostat the momentum temperature ¡ Proper sampling of the canonical ensemble requires that the

momentum temperature fluctuates •  momentum temperature is proportional to total

kinetic energy •  energy should fluctuate between K and U •  variance of momentum-temperature fluctuation

can be derived from Maxwell-Boltzmann fluctuations vanish at large N rigidly fixing K affects fluctuation quantities,

but may not matter much to other averages

¡ All thermostats introduce unphysical features to the dynamics •  EMD transport measurements best done with no thermostat

use thermostat equilibrate r and p temperatures to desired value, then remove

2

1

1 2Ni

ikT K

Nd m Nd== =∑p

pN rN Q 2

223

Tp

pT N

σ=

11

Isokinetic Thermostatting 1.

¡ Force momentum temperature to remain constant ¡ One (bad) approach

•  at each time step scale momenta to force K to desired value advance positions and momenta apply pnew = λp with λ chosen to satisfy repeat

•  “equations of motion” are irreversible “transition probabilities” cannot satisfy detailed balance

•  does not sample any well-defined ensemble

2( )im NdkTλ =∑ p

12

Isokinetic Thermostatting 2. ¡ One (good) approach

•  modify equations of motion to satisfy constraint

•  λ is a friction term selected to force constant momentum-temperature

¡ Time-reversible equations of motion •  no momentum-temperature fluctuations •  configurations properly sample NVT ensemble (with fluctuations) •  temperature is not specified in equations of motion!

!ri = pi / m!pi = Fi − λp

K =pi

2

2mi=1

N

dKdt

=pi ⋅ !pi

mi=1

N

=pimi=1

N

∑ ⋅(Fi − λpi ) ≡ 01

1i

i

i im

i imλ

⋅=

⋅∑∑

p F

p p

13

Thermostatting via Wall Collisions ¡ Wall collision imparts random velocity to molecule

•  selection consistent with (canonical-ensemble) Maxwell-Boltzmann distribution at desired temperature

¡ Advantages •  realistic model of actual process of heat transfer •  correctly samples canonical ensemble

¡ Disadvantages •  can’t use periodic boundaries •  wall may give rise to unacceptable finite-size effects

not a problem if desiring to simulate a system in confined space •  not well suited for soft potentials

random p ( )

2

/ 21( ) exp

22 d mkTmkTπ

π

⎛ ⎞= −⎜ ⎟

⎝ ⎠

ppGaussian

Wall can be made as realistic as desired

14

Andersen Thermostat

¡ Wall thermostat without the wall ¡ Each molecule undergoes impulsive “collisions”

with a heat bath at random intervals ¡ Collision frequency ν describes strength of coupling

•  Probability of collision over time dt is νdt •  Poisson process governs collisions

¡ Simulation becomes a Markov process •  •  ΠNVE is a “deterministic” TPM

it is not ergodic for NVT, but Π is

¡ Click here to see the Andersen thermostat in action

( ; ) tP t e νν ν −=

( ) (1 )NVT NVEt tν νΠ = Δ Π + − Δ Π

random p

15

Nosé Thermostat 1.

¡ Modification of equations of motion •  like isokinetic algorithm (differential feedback control) •  but permits fluctuations in the momentum temperature •  integral feedback control

¡ Extended Lagrangian equations of motion •  introduce a new degree of freedom, s, representing reservoir •  associate kinetic and potential energy with s

•  momenta

Us = −gkT ln s

Ks =12 Q!s2

effective mass

LNose =

mi(s!ri )2

2i=1

N

∑ −U (rN )+ Q2!s2 − gkT ln s

pi ≡∂L∂!ri

= mis2!ri

ps ≡∂L∂s

= Q!s

17

Nosé Thermostat 2.

¡ Extended-system Hamiltonian is conserved

¡ Thus the probability distribution can be written

¡ What does this mean for the sampling of coordinates and momenta? How does this ensure a canonical distribution?

HNose =

pi2

2mis2

i=1

N

∑ +U (rN )+ps

2

2Q+ gkT ln s

π (rN ,pN ,s, ps ) = δ (HNose − E)

18

Nosé Thermostat 3.

¡ Get canonical ensemble for s, p' if g = 3(N+1) ¡ s can be interpreted as a time-scaling factor

•  Δttrue = Δtsim/s •  s varies during simulation, so“true” time step is of varying length

QNosé =1N !

dps ds∫ dpNdrNδ (HNosé − E)

= 1N !

dps ds∫ d ′p NdrN s3Nδ′pi2

2mi+U (rN ) +

ps2

2Q+ gkT ln s − E∑

⎣⎢⎢

⎦⎥⎥

′p = p

s

δ h(s)⎡⎣ ⎤⎦ =

δ (s− s0 )′h (s0 )

19

Nosé Thermostat 3.

¡ Get canonical ensemble for s, p' if g = 3(N+1) ¡ s can be interpreted as a time-scaling factor

•  Δttrue = Δtsim/s •  s varies during simulation, so“true” time step is of varying length

QNosé =1N !

dps ds∫ dpN drNδ (HNosé − E)

= 1N !

dps ds∫ d ′p N drN s3Nδ′pi2

2mi

+U (rN )+ps

2

2Q+ gkT ln s− E∑

⎣⎢

⎦⎥

= 1N !

dps ds∫ d ′p N drN s3N+1

gkTδ s− exp − 1

gkTH ( ′p N ,rN )+

ps2

2Q− E

⎝⎜⎞

⎠⎟⎛

⎝⎜

⎠⎟

⎣⎢⎢

⎦⎥⎥

= 1N !

1gkT

eE ( 3N+1)

gkT dps∫ e− ( 3N+1)

gkTps

2

2Q d ′p N drN exp − 3(N +1)gkT

H ( ′p N ,rN )⎛⎝⎜

⎞⎠⎟

= C 1N !

d ′p N drN exp − 3(N +1)gkT

H ( ′p N ,rN )⎛⎝⎜

⎞⎠⎟∫

′p = p

s

δ h(s)⎡⎣ ⎤⎦ =

δ (s− s0 )′h (s0 )

20

Nosé-Hoover Thermostat 1.

¡  Scaled-variables equations of motion •  constant simulation Δt •  fluctuating real Δt

!ri =∂H∂pi

=pi

mis2

!pi = − ∂H∂ri

= Fi

!s =∂H∂ps

=psQ

!ps = − ∂H∂s

= 1s

pi

mis2 − gkT

i=1

N

∑⎛

⎝⎜

⎠⎟

¡  Real-variables (' removed) equation of motion

!ri =pimi

!pi = Fi −spsQ

pi

!ss=

spsQ

∂(sps / Q)∂t

= 1Q

pimi

− gkTi=1

N

∑⎛

⎝⎜

⎠⎟

¡  Advantageous to work with non-fluctuating time step

′r = r′p = p / s′s = s

Δ ′t = Δt / s

d ′rd ′t

= s drdt

= s pms2

= pms

= ′pm

HNose =

pi2

2mis2

i=1

N

∑ +U (rN )+ps

2

2Q+ gkT ln s

21

Nosé-Hoover Thermostat 2.

¡ Real-variable equations are of the form

¡ Compare to isokinetic equations

¡ Difference is in the treatment of the friction coefficient •  Nosé-Hoover correctly samples NVT ensemble for both momentum and

configurations; isokinetic does NVT properly only for configurations

!ri =pimi

!pi = Fi −ξpi

!ss= ξ

!ξ = 1Q

pimi

− gkTi=1

N

∑⎛

⎝⎜

⎠⎟

!ri = pi / m!pi = Fi − λp

1

1i

i

i im

i imλ

⋅=

⋅∑∑

p F

p p

(redundant; s is not present in other equations)

22

Nosé-Hoover Thermostat 3. ¡ Equations of motion

¡ Integration schemes •  predictor-corrector algorithm is straightforward •  Verlet algorithm is feasible, but tricky to implement

r

v

F

t-dt t t+dt

!ri =pimi

!pi = Fi −ξpi

!ss= ξ

!ξ = 1Q

pimi

− gkTi=1

N

∑⎛

⎝⎜

⎠⎟

!pi = Fi −ξpi

!ξ = 1Q

pimi

− gkTi=1

N

∑⎛

⎝⎜

⎠⎟

At this step, update of ξ depends on p; update of p depends on ξ

23 Barostats ¡ Approaches similar to that seen in thermostats

•  constraint methods •  stochastic coupling to a pressure bath •  extended Lagrangian equations of motion

¡ Instantaneous virial takes the role of the momentum temperature

¡ Scaling of the system volume is performed to control pressure

¡ Example: Equations of motion for constraint method

P(rN ,pN ) =

NkTp(pN )V

+ 13V

!rij ⋅!fij

pairs i,j∑

!ri = pi / m+ χ(rN ,pN )r

!pi = Fi − χ(rN ,pN )p

!V = 3V χ(rN ,pN )

χ(t) is set to ensure dP/dt = 0

24

Summary ¡ Standard MD simulations are performed in the NVE ensemble

•  initial momenta can be set to desired temperature, but very hard to set configuration to have same temperature

•  momentum and configuration coordinates go into thermal equilibrium at temperature that is hard to predict

¡ Need ability to thermostat MD simulations •  aid initialization •  required to do NEMD simulations

¡ Desirable to have thermostat generate canonical ensemble ¡ Several approaches are possible

•  stochastic coupling with temperature bath •  constraint methods •  more rigorous extended Lagrangian techniques

¡ Barostats and other constraints can be imposed in similar ways