Lectures17 18
Lectures17 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)
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.
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
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
n
2n
=D 2
t
x
diffusion equation!
5
F = D
n
x
Example:
( )
Let i M
( )
A = ( ) A( )d.
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
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
+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
i j >i
where U2eff includes some of the effects of the three body interactions.
14
12 6
U (r ) = 4
r
r
(~ 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?
17
Number density * = 3
Temperature T * =
kT
P 3
Pressure P =
*
Time t =
t
2
m
Integration Algorithms
An integration algorithm should
a)
19
b)
Very important because for a given total simulation time the longer the
timestep the less the number of force evaluation calls
c)
d)
e)
20
()
() (
()
()
()
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)
() (
()
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
b) Evaluate accelerations from new positions and velocities (if forces are
velocity dependent.
c)
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
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
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
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).
Need initial conditions for positions and velocities of all molecules in the
system.
E
P( E ) exp
kT
28
r2
P
Ek = i
i 2m
N
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
This is the simplest and most crude way of controlling the temperature
of the simulation.
30
31
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
-Verlet list
-Cell index method
34
(r
> rc )
so that neighbor pairs need not be calculated every timestep
rl
3
7
7`
1
rc
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
Nc =
N
m2
instead of
1
N ( N 1).
2
1
N ( N 1).
2
37
Constraint Methods
38
39
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
40
d
d
T Pi 2 = 0
dt
dt i
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
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. 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