49
1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo [email protected]ffalo.edu

1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo [email protected]

Embed Size (px)

Citation preview

Page 1: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

1

CE 530 Molecular Simulation

Lecture 11

Molecular Dynamics Simulation

David A. Kofke

Department of Chemical Engineering

SUNY Buffalo

[email protected]

Page 2: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

2

Review and PreviewMD of hard disks

• intuitive

• collision detection and impulsive dynamics

Monte Carlo• convenient sampling of ensembles

• no dynamics

• biasing possible to improve performance

Molecular dynamics• equations of motion

• integration schemes

• evaluation of dynamical properties

• extensions to other ensembles

• focus on atomic systems for now

Page 3: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

3

Classical Equations of Motion

Several formulations are in use• Newtonian

• Lagrangian

• Hamiltonian

Advantages of non-Newtonian formulations• more general, no need for “fictitious” forces

• better suited for multiparticle systems

• better handling of constraints

• can be formulated from more basic postulates

Assume conservative forcesU F

Gradient of a scalar potential energy

Page 4: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

4

Newtonian Formulation

Cartesian spatial coordinates ri = (xi,yi,zi) are primary variables

• for N atoms, system of N 2nd-order differential equations

Sample application: 2D motion in central force field

• Polar coordinates are more natural and convenient

2

2i

i id

m mdt

r

r F

r

ˆ( )f rF r

2 2

2 2

ˆ ˆ ˆ( )

ˆ ˆ ˆ( )

x x

y y

mx f r xf x y

my f r yf x y

F e r e

F e r e

2

2

3( )

mr

mr f rmr

constant angular momentum

fictitious (centrifugal) force

Page 5: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

5

Generalized Coordinates

Any convenient coordinates for description of particular system• use qi as symbol for general coordinate

• examples diatomic {q1,…,q6} = {xcom, ycom, zcom, r12, , }

2-D motion in central field {q1, q2} = {r, }

Kinetic energy• general quadratic form

• examples rotating diatomic

2-D central motion

r

10 2( ) ( ) ( )j j jk j kK M M q M q q q q q

2 2 2 2 2 2 2 21 11 2 32 8

( sin )K m q q q m r r r

2 2 212

K m r r

usually vanish

Page 6: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

6

Lagrangian Formulation

Independent of coordinate system Define the Lagrangian

Equations of motion

• N second-order differential equations

Central-force example

( , ) ( , ) ( )L K U q q q q q

0 1j j

d L Lj N

dt q q

2 ( )d L L

mr mr f rdt r r

2 2 212

( )L m r r U r

2 0d L L d

mrdt dt

( )r rU f r F

Page 7: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

7

Hamiltonian Formulation 1. Motivation

Appropriate for application to statistical mechanics and quantum mechanics

Newtonian and Lagrangian viewpoints take the qi as the fundamental variables• N-variable configuration space

• appears only as a convenient shorthand for dq/dt

• working formulas are 2nd-order differential equations

Hamiltonian formulation seeks to work with 1st-order differential equations• 2N variables

• treat the coordinate and its time derivative as independent variables

• appropriate quantum-mechanically

iq

Page 8: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

8

Hamiltonian Formulation 2. Preparation

Mathematically, Lagrangian treats q and as distinct•

• identify the generalized momentum as

• e.g.

• Lagrangian equations of motion

We would like a formulation in which p is an independent variable• pi is the derivative of the Lagrangian with respect to , and we’re looking

to replace with pi

• we need …?

q( , , )j jL q q t

jj

Lp

q

iqiq

212

if ( ); /L K U mq U q p L q mq

j

j

dp L

dt q

Page 9: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

9

Hamiltonian Formulation 3. Defintion

…a Legendre transform! Define the Hamiltonian, H

H equals the total energy (kinetic plus potential)

2

2

( , ) ( , )

( , ) ( )

( ) (2 )

( )

j j

jj

j j j j j

j j

H L p q

KK U q

q

a q U a q q

a q U

K U

q p q q

q q q

q

q

Page 10: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

10

Hamiltonian Formulation 4. Dynamics

Hamilton’s equations of motion• From Lagrangian equations, written in terms of momentum

dp Lp

dt q

L LdL dq dq

q q

pdq pdq

L

pq

Lagrange’s equation of motion

Definition of momentum

Differential change in L

Legendre transform( )

( )

H L pq

dH pdq qdp

dH pdq qdp

Hq

p

Hp

q

Hamilton’s equations of motion

0dH dq dp

p q pq qpdt dt dt Conservation of energy

Page 11: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

11

Hamiltonian Formulation 5. Example

Particle motion in central force field

Equations no simpler, but theoretical basis is better

r

2 2

2( )

2 2r

H K U

p pU r

m mr

( )r rU f r F

2

2

3

(1) (2)

(3) (4)( ) 0

r

r

dr p d p

dt m dt mr

dp p dpf r

dt dtmr

Hq

p

Hp

q

2 ( )mr mr f r

2 0d

mrdt

Lagrange’s equations

Page 12: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

12

Phase Space (again)

Return to the complete picture of phase space• full specification of microstate of the system is given by the values of all

positions and all momenta of all atoms = (pN,rN)

• view positions and momenta as completely independent coordinates connection between them comes only through equation of motion

Motion through phase space• helpful to think of dynamics as “simple” movement through the high-

dimensional phase space facilitate connection to quantum mechanics basis for theoretical treatments of dynamics understanding of integrators

Page 13: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

13

Integration Algorithms Equations of motion in cartesian coordinates

Desirable features of an integrator• minimal need to compute forces (a very expensive calculation)

• good stability for large time steps

• good accuracy

• conserves energy and momentum

• time-reversible

• area-preserving (symplectic)

j j

jj

d

dt md

dt

r p

pF

1

( , )

( , )

x y

x y

N

j ijii j

r r

p p

r

p

F F pairwise additive forces

2-dimensional space (for example)

More on these later

F

Page 14: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

14

Verlet Algorithm1. Equations

Very simple, very good, very popular algorithm Consider expansion of coordinate forward and backward in time

Add these together

Rearrange

• update without ever consulting velocities!

2 3 41 1 12 3!

2 3 41 1 12 3!

( ) ( ) ( ) ( ) ( ) ( )

( ) ( ) ( ) ( ) ( ) ( )

m m

m m

t t t t t t t t t O t

t t t t t t t t t O t

r r p F r

r r p F r

2 41( ) ( ) 2 ( ) ( ) ( )m

t t t t t t t O t r r r F

2 41( ) 2 ( ) ( ) ( ) ( )m

t t t t t t t O t r r r F

Page 15: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

15

Verlet Algorithm 2. Flow diagram

Configuration r(t)Previous configuration r(t-t)

Compute forces F(t)on all atoms using r(t)

Advance all positions according tor(t+t) = 2r(t)-r(t-t)+F(t)/m t2

Add to block sum

End of block?

No Blockaverages

Yes

Initialization

Reset block sums

Compute block average

Compute final results

blocks per simulation

Entire Simulation

1 move per cycle

New configuration

cycles per block

Add to block sum

One MD Cycle

One force evaluation per

time step

Page 16: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

16

Verlet Algorithm 2. Flow Diagram

r

v

F

t-t t t+t

Given current position and position at end of previous time step

Schematic from Allen & Tildesley, Computer Simulation of Liquids

Page 17: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

17

Verlet Algorithm 2. Flow Diagram

r

v

F

t-t t t+t

Compute the force at the current position

Schematic from Allen & Tildesley, Computer Simulation of Liquids

Page 18: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

18

Verlet Algorithm 2. Flow Diagram

r

v

F

t-t t t+t

Compute new position from present and previous positions, and present force

Schematic from Allen & Tildesley, Computer Simulation of Liquids

Page 19: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

19

Verlet Algorithm 2. Flow Diagram

r

v

F

t-2t t-t t t+t

Advance to next time step,repeat

Schematic from Allen & Tildesley, Computer Simulation of Liquids

Page 20: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

20

Verlet Algorithm 3. Java Code

U ser 's P erspe ctiv e o n the M o lec u la r S im u la tion A P I

S pa ce

In te g ra to rV e rle t

C on tro lle r

M ete r B ou nda ry C on fig u ra tion

P ha se S p ec ies P o te n tia l D isp lay D ev ice

S im u la tion

Page 21: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

21

Verlet Algorithm 3. Relevant Methods in Java Code

//Performs one timestep increment in the Verlet algorithm public void doStep(double tStep) {

atomIterator.reset(); while(atomIterator.hasNext()) { //zero forces on all atoms ((Agent)atomIterator.next().ia).force.E(0.0); //integratorVerlet.Agent keeps a force Vector } pairIterator.allPairs(forceSum); //sum forces on all pairs

double t2 = tStep*tStep; atomIterator.reset(); while(atomIterator.hasNext()) { //loop over all atoms, moving according to Verlet Atom a = atomIterator.next(); Agent agent = (Agent)a.ia; Space.Vector r = a.position(); //current position of the atom temp.E(r); //save it r.TE(2.0); //2*r r.ME(agent.rLast); //2*r-rLast agent.force.TE(a.rm()*t2); // f/m dt^2 r.PE(agent.force); //2*r - rLast + f/m dt^2 agent.rLast.E(temp); //rLast gets present r } return;}

public class IntegratorVerlet extends Integrator

Page 22: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

22

Verlet Algorithm 3. Relevant Methods in Java Code

//(anonymous) class for incrementing the sum of the forces on each atomforceSum = new AtomPair.Action() { private Space.Vector f = simulation().space.makeVector(); public void action(AtomPair pair) { PotentialSoft potential = (PotentialSoft)simulation().getPotential(pair) //identify pot’l f.E(potential.force(pair)); //compute force of atom1 on atom2 ((Agent)pair.atom1().ia).force.PE(f); //increment atom1 force ((Agent)pair.atom2().ia).force.ME(f); //increment atom2 force }};

//Agent class for IntegratorVerlet; stores useful quantities in each Atompublic final static class Agent implements Integrator.Agent { public Atom atom; public Space.Vector force; //used to accumulate the force on the atom public Space.Vector rLast; //holds the position of the atom at the last step

public Agent(Atom a) { //constructor atom = a; force = atom.parentMolecule().parentPhase().parentSimulation.space.makeVector(); rLast = atom.parentMolecule().parentPhase().parentSimulation.space.makeVector(); } }

public class IntegratorVerlet extends Integrator

Page 23: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

23

Forces 1. Formalism

Force is the gradient of the potential

2 1 12

12 12

1 1

12 12 12

12 1 1

1212 12

12

( )

( ) ( )

( )

( )

x y

x y

x y

u r

u r u r

x y

du r r r

dr x y

f rx y

r

F

e e

e e

e e

2

1

r12

x12

y12

4

2

0

-2

2.52.01.51.0Separation, r/s

Energy Force

1/ 22 212 2 1 2 1( ) ( )r x x y y

Force on 1, due to 2

2 1 1 2 F F

Page 24: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

24

Forces 2. LJ Model

Force is the gradient of the potential

122 1 12 12

12

( )x y

f rx y

r F e e2

1

r12

x12

y12

4

2

0

-2

2.52.01.51.0Separation, r/s

Energy Force

1/ 22 212 2 1 2 1( ) ( )r x x y y

e.g., Lennard-Jones model

12 6

13 7

14 8

2 1 12 12212 12

( ) 4

( )

48 1

2

48 1

2 x y

u rr r

duf r

dr

r r

x yr r

s s

s ss

s ss

F e e

Page 25: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

25

Forces 3. Java Code

U ser 's P erspe ctiv e o n the M o lec u la r S im u la tion A P I

S pa ce

In te g ra to rV e rle t

C on tro lle r

M ete r B ou nda ry C on fig u ra tion

P ha se S p ec ies P o te n tia l D isp lay D ev ice

S im u la tion

Page 26: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

26

Forces3. Relevant Methods from Java Code

public class PotentialLJ implements PotentialSoft

//Space.Vector used to compute and return a forceprivate Space.Vector force = Simulation.space.makeVector(); public Space.Vector force(AtomPair pair) { double r2 = pair.r2(); //squared distance between pair of atoms if(r2 > cutoffDiameterSquared) {force.E(0.0);} //outside cutoff; no interaction else { double s2 = sigmaSquared/r2; // (sigma/r)^2 double s6 = s2*s2*s2; // (sigma/r)^6 force.E(pair.dr()); // f = (x12 ex + y12 ey) (vector) force.TE(-48*s2*s6*(s6-0.5)/sigmaSquared); // f *= -48*(sigma/r)^8 * [(sigma/r)^6 - 1/2] / sigma^2 } return force;}

Page 27: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

27

Verlet Algorithm. 4. Loose Ends

Initialization• how to get position at “previous time step” when starting out?

• simple approximation

Obtaining the velocities• not evaluated during normal course of algorithm

• needed to compute some properties, e.g. temperature diffusion constant

• finite difference

0 0 0( ) ( ) ( )t t t t t r r v

21( ) ( ) ( ) ( )

2t t t t t O t

t

v r r

Page 28: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

28

Verlet Algorithm 5. Performance Issues

Time reversible• forward time step

• replace t with t

• same algorithm, with same positions and forces, moves system backward in time

Numerical imprecision of adding large/small numbers

21( ) 2 ( ) ( ) ( )m

t t t t t t t r r r F

21

21

( ) 2 ( ) ( ) ( )

( ) 2 ( ) ( )

( ) ( ) (

( )

)m

m

t t t tt t

t t t t t t t

t

r r r F

r r r F

21( ) ( ) ( ) ( ) ( )m

t t t t t t t t r r r r F

O(t0) O(t0)

O(t1)

O(t2)

O(t1)

Page 29: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

29

Initial Velocities(from Lecture 3)

Random direction• randomize each component independently

• randomize direction by choosing point on spherical surface

Magnitude consistent with desired temperature. Choices:• Maxwell-Boltzmann:

• Uniform over (-1/2,+1/2), then scale so that

• Constant at

• Same for y, z components

Be sure to shift so center-of-mass momentum is zero

212( ) exp /x xprob v mv kT

/xv kT m

21, /i xN v kT m

1,

, ,

x i xN

i x i x x

P p

p p P

Page 30: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

30

Leapfrog Algorithm

Eliminates addition of small numbers O(t2) to differences in large ones O(t0)

Algorithm12

1 1 12 2

( ) ( ) ( )

( ) ( ) ( )m

t t t t t t

t t t t t t

r r v

v v F

Page 31: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

31

Leapfrog Algorithm

Eliminates addition of small numbers O(t2) to differences in large ones O(t0)

Algorithm

Mathematically equivalent to Verlet algorithm

12

1 1 12 2

( ) ( ) ( )

( ) ( ) ( )m

t t t t t t

t t t t t t

r r v

v v F

1 12

( ) ( ) ( ) ( )m

t t t t t t t t r r v F

Page 32: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

32

Leapfrog Algorithm

Eliminates addition of small numbers O(t2) to differences in large ones O(t0)

Algorithm

Mathematically equivalent to Verlet algorithm

12

1 1 12 2

( ) ( ) ( )

( ) ( ) ( )m

t t t t t t

t t t t t t

r r v

v v F

1 12

( ) ( ) ( ) ( )m

t t t t t t t t r r v F

12

( ) ( ) ( )t t t t t t r r vr(t) as evaluated from previous time step

Page 33: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

33

Leapfrog Algorithm

Eliminates addition of small numbers O(t2) to differences in large ones O(t0)

Algorithm

Mathematically equivalent to Verlet algorithm

12

1 1 12 2

( ) ( ) ( )

( ) ( ) ( )m

t t t t t t

t t t t t t

r r v

v v F

1 12

( ) ( ) ( ) ( )m

t t t t t t t t r r v F

12

( ) ( ) ( )t t t t t t r r vr(t) as evaluated from previous time step

21( ) ( ) ( ) ( ) ( )m

t t t t t t t t r r r r F

Page 34: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

34

Leapfrog Algorithm

Eliminates addition of small numbers O(t2) to differences in large ones O(t0)

Algorithm

Mathematically equivalent to Verlet algorithm

12

1 1 12 2

( ) ( ) ( )

( ) ( ) ( )m

t t t t t t

t t t t t t

r r v

v v F

1 12

( ) ( ) ( ) ( )m

t t t t t t t t r r v F

12

( ) ( ) ( )t t t t t t r r vr(t) as evaluated from previous time step

21( ) ( ) ( ) ( ) ( )m

t t t t t t t t r r r r F

21( ) 2 ( ) ( ) ( )m

t t t t t t t r r r F original algorithm

Page 35: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

35

Leapfrog Algorithm 2. Flow Diagram

r

v

F

t-t t t+t

Given current position, and velocity at last half-step

Schematic from Allen & Tildesley, Computer Simulation of Liquids

Page 36: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

36

Leapfrog Algorithm 2. Flow Diagram

r

v

F

t-t t t+t

Compute current force

Schematic from Allen & Tildesley, Computer Simulation of Liquids

Page 37: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

37

Leapfrog Algorithm 2. Flow Diagram

r

v

F

t-t t t+t

Compute velocity at next half-step

Schematic from Allen & Tildesley, Computer Simulation of Liquids

Page 38: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

38

Leapfrog Algorithm 2. Flow Diagram

r

v

F

t-t t t+t

Compute next position

Schematic from Allen & Tildesley, Computer Simulation of Liquids

Page 39: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

39

Leapfrog Algorithm 2. Flow Diagram

r

v

F

t-2t t-t t t+t

Advance to next time step,repeat

Schematic from Allen & Tildesley, Computer Simulation of Liquids

Page 40: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

40

Leapfrog Algorithm. 3. Loose Ends

Initialization• how to get velocity at “previous time step” when starting out?

• simple approximation

Obtaining the velocities• interpolate

1 10 0 0 2

( ) ( ) ( )m

t t t t t v v F

1 12 2

1( ) ( ) ( )

2t t t t t v v v

Page 41: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

41

Velocity Verlet Algorithm Roundoff advantage of leapfrog, but better treatment of velocities Algorithm

Implemented in stages• evaluate current force

• compute r at new time

• add current-force term to velocity (gives v at half-time step)

• compute new force

• add new-force term to velocity

Also mathematically equivalent to Verlet algorithm (in giving values of r)

212

12

( ) ( ) ( ) ( )

( ) ( ) ( ) ( )

m

m

t t t t t t t

t t t t t t t

r r v F

v v F F

Page 42: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

42

Velocity Verlet Algorithm 2. Flow Diagram

r

v

F

t-t t t+t

Given current position, velocity, and force

Schematic from Allen & Tildesley, Computer Simulation of Liquids

Page 43: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

43

Velocity Verlet Algorithm 2. Flow Diagram

r

v

F

t-t t t+t

Compute new position

Schematic from Allen & Tildesley, Computer Simulation of Liquids

Page 44: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

44

Velocity Verlet Algorithm 2. Flow Diagram

r

v

F

t-t t t+t

Compute velocity at half step

Schematic from Allen & Tildesley, Computer Simulation of Liquids

Page 45: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

45

Velocity Verlet Algorithm 2. Flow Diagram

r

v

F

t-t t t+t

Compute force at new position

Schematic from Allen & Tildesley, Computer Simulation of Liquids

Page 46: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

46

Velocity Verlet Algorithm 2. Flow Diagram

r

v

F

t-t t t+t

Compute velocity at full step

Schematic from Allen & Tildesley, Computer Simulation of Liquids

Page 47: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

47

Velocity Verlet Algorithm 2. Flow Diagram

r

v

F

t-2t t-t t t+t

Advance to next time step,repeat

Schematic from Allen & Tildesley, Computer Simulation of Liquids

Page 48: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

48

Other Algorithms

Predictor-Corrector• not time reversible

• easier to apply in some instances constraints rigid rotations

Beeman• better treatment of velocities

Velocity-corrected Verlet

Page 49: 1 CE 530 Molecular Simulation Lecture 11 Molecular Dynamics Simulation David A. Kofke Department of Chemical Engineering SUNY Buffalo kofke@eng.buffalo.edu

49

Summary

Several formulations of mechancs• Hamiltonian preferred

independence of choice of coordinates emphasis on phase space

Integration algorithms• Calculation of forces

• Simple Verlet algorithsmVerletLeapfrogVelocity Verlet

Next up: Calculation of dynamical properties