0% found this document useful (0 votes)
39 views43 pages

Lectures17 18

Molecular dynamics is a technique for simulating classical many-body systems by computing their equilibrium and non-equilibrium properties. It involves integrating Newton's equations of motion using algorithms like the Verlet algorithm. Reduced units are often used to make results applicable to all systems described by a given interaction potential, like the commonly used Lennard-Jones potential. Statistical mechanics provides the theoretical basis for relating microscopic molecular dynamics simulations to macroscopic observables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views43 pages

Lectures17 18

Molecular dynamics is a technique for simulating classical many-body systems by computing their equilibrium and non-equilibrium properties. It involves integrating Newton's equations of motion using algorithms like the Verlet algorithm. Reduced units are often used to make results applicable to all systems described by a given interaction potential, like the commonly used Lennard-Jones potential. Statistical mechanics provides the theoretical basis for relating microscopic molecular dynamics simulations to macroscopic observables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

Introduction to Simulation - Lectures 17, 18

Molecular Dynamics
Nicolas Hadjiconstantinou

Molecular Dynamics
Molecular dynamics is a technique for computing the equilibrium and
non-equilibrium properties of classical* many-body systems.
* The nuclear motion of the constituent particles obeys the laws of
classical mechanics (Newton).
References:
1)
2)
3)

Computer Simulation of Liquids, M.P. Allen & D.J. Tildesley,


Clarendon, Oxford, 1987.
Understanding Molecular Simulation: From Algorithms to
Applications, D. Frenkel and B. Smit, Academic Press, 1997.
Moldy manual

Moldy
A free and easy to use molecular dynamics simulation package can be found
at the CCP5 program library (http://www.ccp5.ac.uk/librar.shtml), under the
name Moldy. At this site a variety of very useful information as well as
molecular simulation tools can be found.
Moldy is easy to use and comes with a very well written manual which can
help as a reference. I expect the homework assignments to be completed using
Moldy.

Why Do We Need Molecular Dynamics?


Similar to real experiments.
1.
2.

Allows us to study and understand material behavior so that we can model it.
Tells us what the answer is when we do not have models.
Example: Diffusion equation

F |x

F | x + dx
dy

Conservation of mass:

dx
xx ++ dx
d
ndxdydz ) = ( F | x F | x + dx )dydz
(
dt

n = number density, F = flux


d
ndxdydz ) F | x
(
dt

F
2 F dx 2
| x dx + 2
F | x +
dydz

x
x 2

F
2 F dx
=
dxdydz 2
dydzdx
x
x 2

in the limit

dx 0,

n F
+
=0
t x

This equation cannot be solved unless a relation between n and F is provided.


Experiments or consideration of molecular behavior shows that
under a variety of conditions
n
F = D
x

n
2n

=D 2
t
x

diffusion equation!
5

Breakdown of linear gradient constitutive law


Large gradients

F = D

n
x

Far from equilibrium gaseous flows


- Shockwaves
- Small scale flows (high Knudsen number flow)
- Rarefied flows (low density) (high Knudsen number flow)

High Knudsen number flows (gases)


Kn is defined as the ratio of the molecular mean-free path to a characteristic
lengthscale
The molecular mean-free path is the average distance traveled by molecules
between collisions
Collisions tend to restore equilibrium
When Kn 1 particle motion is diffusive (near equilibrium)
When Kn 1 particle motion is ballistic (far from equilibrium)
0.1 Kn 10 physics is transitional (hard to model)
6

Example:

Re-entry vehicle aerobraking maneuver


in the upper atmosphere

In the upper atmosphere density is low (collision rate is low)


Long mean-free path
High Knudsen number flows typical

Other high Knudsen number flows


Small scale flows (mean-free path of air molecules at atmospheric pressure
is approximately 60 nanometers)
Vacuum science (low pressure)

From Dr. M. Gallis of Sandia National Laboratories

Brief Intro to Statistical Mechanics


Statistical mechanics provides the theoretical connection between the
microscopic description of matter (e.g. positions and velocities of molecules)
and the macroscopic description which uses observables such as pressure,
density, temperature
This is achieved through a statistical approach and the concept of an ensemble
average. An ensemble is a collection of a large number of identical systems
(M) evolving in time under the same macroscopic conditions but different
microscopic initial conditions.

( )

Let i M

be the number of such systems in state i :

( )

Then i can be interpreted as the probability of finding an ensemble


member in state i.
9

Macroscopic properties (observables) are then calculated as weighted


averages
A = (i ) A(i )
i

or in the continuous limit

A = ( ) A( )d.

One of the fundamental results of statistical mechanics is that the probability


of a state of a system with energy E in equilibrium at a fixed temperature T is
governed by

E
(E ) exp
kT
where k is Boltzmanns constant.
For non-equilibrium systems solving a problem reduces to the task of calculating
().
Molecular methods are similar to experiments where rather than solving for ()
we measure A directly.
10

A = (i ) A(i )
i

implies that given an ensemble of systems, any observable A


can be measured by averaging the value of this observable over all
systems.
However, in real life we do not use a large number of systems to do
experiments. We usually observe one system over some period of time.
This is because we use the ergodic hypothesis:
- Since there is a one-to-one correspondence between the initial
conditions of a system and the state at some other time, averaging
over a large number of initial conditions is equivalent to averaging
over time-evolved states of the system.
- The ergodic hypothesis allows us to convert the averaging from
ensemble members to time instances of the same system. THIS IS
AN ASSUMPTION THAT SEEMS TO WORK WELL MOST OF
THE TIME.
11

A Simplified MD Program Structure


Initialize:
-Read run parameters (initial temperature, number of timesteps,
density, number of particles, timestep)
-Generate or read initial configuration (positions and velocities
of particles)
Loop in timestep increments until t = tfinal
-Compute forces on particles
-Integrate equations of motion
-If t > tequilibrium, sample system
Output results
12

Equations of Motion
Newtons equations

For i = 1,K, N
r
d 2 ri r

r r r
mi 2 = Fi = r U r1 , r2 K rN )
ri
dt

r r r
U (r1 , r2 K rN ) = Potential energy of the system
r
r r
r r r
= U1 (r1 ) + U 2 (ri , rj ) + U 3 (r1 , r j , rk )
i

i j >i

i j >i k > j >i

+K

r
U1 (r1 ) = external field K
r r
r r
U 2 (r1 , rj ) = pair interaction = U 2 (rij ), (rij ) = (ri r j )
r r r
U 3 (ri , rj , rk ) = three body interaction (expensive to calculate)
13

For this reason, typically

U U1 (ri ) + U 2eff (rij )


i

i j >i

where U2eff includes some of the effects of the three body interactions.

14

The Lennard-Jones Potential


One of the most simple potentials used is the Lennard-Jones.
Typically used to simulate simple liquids and solids.

12 6
U (r ) = 4
r
r

is the well depth [energy]


is the interaction lengthscale

Very repulsive for r <


Potential minimum at r = 6 2
Weak attraction

(~ 1/ r ) for r > 2
6

15

The Lennard-Jones potential (U) and force (F) as a function of separation (r)
( = = 1)

1
0
1
2

0.5

1.5

2.5

3.5

0.5

1.5

2
r

2.5

3.5

1
0
1
2

16

Reduced Units
What is the evaporation temperature of a Lennard-Jones liquid?

What is an appropriate timestep for integration of the equations


of motion of Lennard-Jones particles?

What is the density of a liquid/gas made up of Lennard-Jones


molecules?

17

Number density * = 3
Temperature T * =

kT

P 3
Pressure P =

*
Time t =

t
2
m

In these units, numbers have physical significance.


Results valid for all Lennard-Jones molecules.
Easier to spot errors: (10-32 must be wrong!)
18

Integration Algorithms
An integration algorithm should
a)

Be fast, require little memory

b) Permit the use of a long timestep


c)

Duplicate the classical trajectory as closely as possible

d) Satisfy conservation of momentum and energy and be


time-reversible
e)

Simple and easy to program

19

Discussion of Integration Algorithms


a)

Not very important, by far the most expensive part of simulation is in


calculating the forces

b)

Very important because for a given total simulation time the longer the
timestep the less the number of force evaluation calls

c)

Not very important because no numerical algorithm will provide the


exact solution for long time (nearby trajectories deviate exponentially in
time). Recall that MD is a method for obtaining time averages over all
initial conditions under prescribed macroscopic constraints. Thus
conserving momentum and energy is more important.

d)

Very important (see C)

e)

Important, no need for complexity when no speed gains are possible.

20

The Verlet Algorithm


One of the most popular methods for at least the first few decades of MD.
r
r
r
r
r t + t = 2r t r t t + t 2 a t
r
F t
r
at =
m
Derivation: Taylor series expansion of rr t about time t

()

() (
()

()

()

r
1 r
r
r
r t + t ) = r t ) + t V t ) + t 2 a t ) + K
2
r
1 r
r
r
r t t ) = r t ) t V t ) + t 2 a t ) + K
2

ADVANTAGES
1)
Very compact and simple to program
2)
Excellent energy conservation properties (helped by time-reversibility)
21

3)
4)

Time reversible

r
r
r (t + t ) r (t t )

( )

4
Local error O t

DISADVANTAGES
1)

r
r
r
r t + t ) r t t )
Awkward handling of velocities V t ) =
2t
r
r
a) Need r t + t ) solution before getting V t )

( )

2
b) Error for velocities O t

2)

May be sensitive to truncation error because in


r
r
r
r
r t + t = 2r t r t t + t 2 a t

() (

()

a small number is added to the difference of two large numbers.


22

Improvements To The Verlet Algorithm


Beeman Algorithm:

r
r
r
4

a
t
a
t t )
(
)
(
r
r
2
r (t + t ) = r (t ) + tV (t ) + t
6
r
r
r
r
r
2a (t + t ) + 5a (t ) a (t t )
V ( t + t ) = V ( t ) + t
6
Coordinates equivalent to Verlet algorithm

r
V more accurate than Verlet

23

Predictor Corrector Algorithms


Basic structure:
a)

Predict positions, velocities, accelerations at t + t.

b) Evaluate accelerations from new positions and velocities (if forces are
velocity dependent.
c)

Correct the predicted positions, velocities, accelerations using the new


accelerations.

d) Go to (a).
Although these methods can be very accurate, the nature of MD simulations is
not well suited to them. The reason is that any prediction and correction which
does not take into account the motion of the neighbors is unreliable.

24

The concept of such a method is demonstrated here by the modified Beeman


algorithm that handles velocity dependent forces (discussed later).

a)
b)
c)
d)
e)

r
t 2 r
r
r
r
r (t + t ) = r (t ) + tV (t ) +
a ( t ) a ( t t )
6
rP
r
t r
r
V (t + t ) = V (t ) + 3a (t ) a (t t )
2
rP
1
r
r
a (t + t ) = F r (t + t ),V (t + t )
m
r
rc
t r
r
V (t + t ) = V (t ) + 2a (t + t ) + 5a (t ) (t t )
6
rP
rc
Replace V with V and go to c.

If there are no velocity dependent forces this reduces to the Beeman method
discussed above.
25

Periodic Boundary Conditions

Periodic boundary conditions are


very popular: Reduce surface
effects

Adapted from Computer Simulation of Liquids


by M.P. Allen & D.J. Tildesley,
Oxford Science Publications, 1987.

Todays computers can easily treat N > 1000 so artifacts from small systems
with periodic boundary conditions are limited.
Equilibrium properties unaffected.
Long wavelengths not possible.
In todays implementations, particle interacts with closest images of other
molecules.
26

Evaluating Macroscopic Quantities


Macroscopic quantities (observables) are defined as appropriate averages of
microscopic quantities.
r2
N
1
P
T=3
i
Nk i =1 2mi
2

1 N
= mi
V i =1
rr
1
r r
= mViVi + rij Fij

V i
i j
r
P
r i i
u=
mi
i

(macroscopic velocity).

If the system is not in equilibrium, these properties can be defined as a


function of space and time by averaging over extents (space, time) over
which change is small.
27

Starting The Simulation Up

Need initial conditions for positions and velocities of all molecules in the
system.

Typically initial density, temperature, number of particles known.

Because of the highly non-linear particle interaction starting at completely


arbitrary states is almost never successful.
If particle positions are initialized randomly, with
overwhelming probability at least one pair of particles
will be very close and lead to energy divergence.

Velocity degrees of freedom can be safely initialized using the equilibrium


distribution

E
P( E ) exp
kT
28

because the additive nature of the kinetic energy

r2
P
Ek = i
i 2m
N

leads to independent probability distributions for each particle velocity.

Liquids are typically started in


- a crystalline solid structure that melts during the
equilibration part of the simulation
- a quasi-random structure that avoids particle overlap
(see Moldy manual for an example).

29

Equilibration
Because systems are typically initialized in the incorrect state, potential energy
is usually either converted into thermal energy or thermal energy is consumed
as the system equilibrates. In order to stop the temperature from drifting, one
of the following methods is used:

r
Td r
Vi
1) Velocity rescaling Vi =
T
where Td is the desired temperature and

r2
Pi
2
T=

3Nk i 2mi
N

is the instantaneous temperature.

This is the simplest and most crude way of controlling the temperature
of the simulation.
30

2) Thermostat. A thermostat is a method to keep the temperature


constant by introducing it as a constraint into the equations of motion.
Thermostats will be described under Constrained Dynamics.

31

Long Range Forces, Cutoffs,


And Neighbor Lists
Lennard-Jones potential decays as r-6 which is reasonably fast.
However, the number of neighbors interacting with a particle grows as r 3.
Interaction is thus cut off at some distance rc to limit computational cost.
Most sensitive quantitites (surface tension) to the long range forces usually
calculated with rc approximately 10.
Typical calculations for hydrodynamics use rc approximately 2.5.
Electrostatic interactions require special methods
(Multiple expansions, Ewald sums) - See Moldy manual
32

Although system behavior (properties: equation of state, transport


coefficients, latent heat, elastic constants) are affected by rc, the new
ones can be measured, if required.
The simplest cut-off approach is a truncation

U (r ) r rc
U tr (r ) =
r > rc
O
Not favored because Utr(r) is discontinuous. Does not conserve energy.
This is fixed by the truncated and shifted potential

U (r ) U (rc ) r rc
U tr sh (r ) =
O
r > rc

33

Even with a small cut-off value the calculation cost is proportional to N 2


because of the need to examine all pair separations.
Cost reduced by neighbor lists

-Verlet list
-Cell index method

34

Verlet Neighbor Lists

(r

> rc )
so that neighbor pairs need not be calculated every timestep

Keep an expanded neighbor list

rl chosen such that need to test every 10-20 timesteps


Good for N < 1000
(too much storage required)

rl
3

7
7`

1
rc

Adapted from Computer Simulation


of Liquids, by M.P. Allen &
D.J. Tildesley, Oxford
Science Publications, 1987.

2
5

35

Cell-index Method
Divide simulation into m subcells in each direction (here m = 5 ).
Search only sub-cells within cut-off (conservative)
Example: If sub-cell size larger than cut-off for cell 13 only cells 7, 8, 9, 12, 13,
14, 17, 18, 19 need to be searched.

9 10

11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
36

In two dimensions cost is 4.5 NNc where

Nc =

N
m2

instead of

1
N ( N 1).
2

In three dimensions cost is 13.5 NNc instead of

1
N ( N 1).
2

(With Nc appropriately redefined)

37

Constraint Methods

Newtonian molecular dynamics conserves system energy, volume and


number of particles.

Engineering-physical systems typically operate at constant pressure,


temperature and exchange mass (i.e. they are open).

Methods to simulate these have been proposed*.

* These methods are capable of providing the correct statistical


description in equilibrium. Away from equilibrium there is no
proof that these methods provide the correct physics.
Therefore they need to be used with care, especially the crude
ones such as rescaling.

38

Constant Temperature Simulations

Newtons equations conserve energy and temperature is a variable.

In most calculations of practical interest we would like to prescribe temperature


(in reality, reservoirs, such as the atmosphere, interact with systems of interest
and keep temperature constant).

Similar considerations apply for pressure. We would like to perform constant


pressure calculations with variable system volume.

Three main types of approaches


-Velocity rescaling (crude)

39

- Extended system methods

(One or more extra degrees of freedom are


added to represent the reservoir.)

r
r r
r
dri Pi dPi r
Equations of motion
= ,
= Fi fPi
dt m dt
f is a dynamical variable and is given by

df kg
= (T Td )
dt Q

g = number of degrees of freedom


Q = reservoir mass (adjustable parameter-controls equilibration dynamics)

This method is known as the Nos-Hoover thermostat.

40

- Constraint methods (The equations of motion are constrained


to lie on a hyperplane in phase space).

In this case the constraint is

d
d
T Pi 2 = 0
dt
dt i

This leads to the following equations of motion

r r
dri Pi
= ,
dt m

N r r
r
P Fi
r
dPi r
= Fi Pi , = i =1N r
dt
Pi 2
i =1

is a Lagrange multiplier (not a dynamical variable).


A discussion of these and constant pressure methods can be found
in the Moldy Manual.
Note the velocity-dependent forces.

41

Homework Discussion

Use (and modify) control file control.argon. You can run short familiarization
runs with this file.
Control.argon calls the argon.in system specification file. Increase the number
of particles to at least 1000 (reduce small system effects and noise).
Note that density in control.argon is in units equivalent to
g/cm3 (= 1000 Kg/m3).
Reduce noise by increasing number of particles and/or averaging interval
(average-interval).
Make sure that temperature does not drift significantly from the original
temperature. You may want to rescale (scale-interval) more often and stop
rescaling (scale-end) later. Make sure you are not sampling while
rescaling!
By setting rdf-interval = 0 you disable the radial distribution function
calculation which makes the output file more readable.
42

Sample control file

#
# Sample control file. Different from the one provided with code.
#
sys-spec-file=argon.in
density=1.335
#density=1335 Kg/m3
temperature=120
#initial temperature=120K
scale-interval=2
#rescale velocities every 2 timesteps
scale-end=5000
#stop rescaling velocities at timestep 5000
nsteps=25000
#run a total of 25000 timesteps
print-interval=500 #print results every 500 timesteps
roll-interval=500
#keep rolling average results every 500 timesteps
begin-average=5001 #begin averaging at timestep 5001
average-interval=10000 #average for 10000 timesteps
step=0.01
#timestep 0.01ps
subcell=2
#subcell size for linked-cell method
strict-cutoff=1
#calculate forces using strict 0(N2) algorithm
cutoff=10.2
#3 * sigma
begin-rdf=2501 #begin radial distribution function calculation at timestep 2501
rdf-interval=0
rdf-out=2500
43

You might also like