The Very Basics of Molecular Dynamics
Ali Hassanali, ICTP.
Where and What is ICTP
1 Ali Hassanali
“Scientific thought is the common heritage of mankind”
Molecular Dynamics
Trieste, Italy
Going beyond the Zero-K World
2 Ali Hassanali Molecular Dynamics
What is the structure of the water molecule?
O-H bond length?
H-O-H angle?
What is its dipole moment?
Imagine how the water molecule moves at 150K
3 Ali Hassanali Molecular Dynamics
The importance of fluctuations:
Structural and dipole
distributions
How quickly/slowly do things diffuse?
What is Classical Molecular Dynamics?
4 Ali Hassanali Molecular Dynamics
€
F(t) = MR..(t) = −∇V ( R(t){ })
Numerical Integration
V ( R(t){ })
Trajectory: positions and velocities over time
Molecular Dynamics: Make molecular movies
5 Ali Hassanali Molecular Dynamics
How does water dance on the surface of silica?
What is the diffusion constant of water around silica?
Once you have a trajectory …
Essential Ingredients to cook an MD simulation
6 Ali Hassanali Molecular Dynamics
€
F(t) = MR..(t) = −∇V ( R(t){ })
Interaction potential between the particles
(Empirical potential or Ab Initio – More later …)
Initial coordinates or structure of the physical system
(Chemical Intuition or Experiments: X-Ray)
How to model matter on the computer?
7 Ali Hassanali Molecular Dynamics
neutron proton electron
=
Quantum Mechanics
The World of Molecular Mechanics
8 Ali Hassanali Molecular Dynamics
Use classical mechanics to model molecular interactions
An empirical function is used to approximate the Born Oppenheimer potential energy surface as a function of
nuclear positions
ETotal = Ebonded +Enon−bonded
How to treat bonded Interactions
9 Ali Hassanali Molecular Dynamics
Harmonic distance interaction between neighboring atoms:
( )202
)( ijijijharm rrkrv −=
( )20
2)( θθθ −=kvang
Harmonic angle potentials:
θ
2, 3 and 4 particles bonded to each other
10 Ali Hassanali Molecular Dynamics
Dihedral angle potential:
vdihedral (ϕ ) = cos n ϕ −ϕ0( )⎡
⎣⎤⎦
φ
Peptide Backbone
Non-bonded interactions between molecules
11 Ali Hassanali Molecular Dynamics
i j
i j
i j
How does the potential energy change as a function of the different geometries shown?
The Potential Energy Surface of the Water Dimer
12 Ali Hassanali Molecular Dynamics
Empirical potential: distance and angular dependence
Behler and co-workers
How to treat non-bonded interactions?
13 Ali Hassanali Molecular Dynamics
Enon−bonded = Evan−der−Waals +Eelectrostatics
Lennard-Jones Potential
⎥⎥⎦
⎤
⎢⎢⎣
⎡⎟⎠
⎞⎜⎝
⎛−⎟⎠
⎞⎜⎝
⎛=612
4)(rr
rvLJσσ
ε
r
vLJ(r) σ
ε
21/6 σ
Actually, repulsive part of potential better described by an exponential: Ae-br
Electrostatic Interactions
14 Ali Hassanali Molecular Dynamics
Define atomic-based charges: RESP, Lowdin …
ba
ba
base
qqvrr −
= ∑∑−
molecule secondon sites
moleculefirst on sites
Example: SPC/E water
model
qH = +.4238 qH = +.4238
qO = -.8476
Effect of polarization in molecular systems
15 Ali Hassanali Molecular Dynamics
Dipole moment of isolated water molecule
D8.1OH2=µ
1D(Debye) = .208194e Ao
Dipole moment of water molecule in water or ice ≈ 2.6-3.0 D.
Why?
What about polarization?
16 Ali Hassanali Molecular Dynamics
E electric field of other molecules +
possible external applied field
electron cloud shifts, causing induced dipole
Eαµ ⋅=ind α is the polarizability tensor.
If molecule close to isotropic, the tensor α can be replaced by the scalar α, the polarizability.
Eµ α=ind
Force-Field: Potentials used to get Forces
17 Ali Hassanali Molecular Dynamics
€
F(t) = MR..(t) = −∇V ( R(t){ })
Potential (force-field) to derive forces
vLJ (r) = 4εσr
⎛
⎝⎜
⎞
⎠⎟12
−σr
⎛
⎝⎜
⎞
⎠⎟6⎡
⎣⎢⎢
⎤
⎦⎥⎥
−∂vLJ (r)∂r
= 4ε 12 σr
⎛
⎝⎜
⎞
⎠⎟13
− 6 σr
⎛
⎝⎜
⎞
⎠⎟7⎡
⎣⎢⎢
⎤
⎦⎥⎥
Numerical Integration: Verlet Algorithm
18 Ali Hassanali Molecular Dynamics
xk+1 = xk + hx 'k = xk + hf (tk, xk )Remember Euler’s Method?
L. Verlet, Phys. Rev. 159:98 (1967)
!+Δ+Δ−=Δ− )(21)()()( 2 ttttttt NNNN avrr
!+Δ+=Δ−+Δ+ )()(2)()( 2 ttttttt NNNN arrr
Forwards and backwards Taylor expansions
!+Δ+Δ−−=Δ+ )()()(2)( 2 ttttttt NNNN arrrVerlet algorithm (1st version)
!+Δ+Δ+=Δ+ )(21)()()( 2 ttttttt NNNN avrr
ADD 2 eq.’s
Obtaining the velocities
Ali Hassanali
L. Verlet, Phys. Rev. 159:98 (1967)
!+Δ+Δ+=Δ+ )(21)()()( 2 ttttttt NNNN avrr
!+Δ+Δ−=Δ− )(21)()()( 2 ttttttt NNNN avrr
!+Δ=Δ−−Δ+ )(2)()( tttttt NNN vrr
Forwards and backwards Taylor expansions
• Velocity: t
tttttNN
N
Δ
Δ−−Δ+=
2)()()( rrv
SUBTRACT 2 eq.’s
Molecular Dynamics 19
Numerical Errors in the Verlet Algorithm
Ali Hassanali
rN (t +Δt) = 2rN (t)− rN (t −Δt)+Δt2 aN (t)+O(Δt)Verlet algorithm (1st version)
4
vN (t) = rN (t +Δt)− rN (t −Δt)
2Δt+O(Δt)
2
Velocity verlet and Leap-frog verlet are variants that allow for better accuracy of the velocities.
Molecular Dynamics
Time-step in MD simulations (More Later)
20
Long Stability of Verlet Algorithm
Ali Hassanali
Compare Verlet algorithm to higher order ODE
Verlet, Δt = 1fs, 1.0 x 106 force evaluations.
tol=10-4, Δt = 2fs, 1.9 x 106 force evaluations
Gray, Noid, Sumpter J.Chem.Phys. 101:4062 (1994)
Molecular Dynamics 21
Periodic Boundary Conditions (in Liquids)
Ali Hassanali
Fluid can be strongly perturbed by wall out to ~5 molecular diameters.
Molecular Dynamics 22
Periodic Boundary Conditions (PBC)
Ali Hassanali
… …
. . .
. . . Molecular Dynamics 23
Minimum Image Convention
Ali Hassanali
Neglect all n except the one for which |ri - rj + nL| is smallest.
i j
The minimum image between particles i and j in the drawing
are within the same cell. i i
i
i i i
i i
j j
j j j
j j j
Molecular Dynamics
Consider determining the interaction between two particles with PBCs
24
Minimum Image Convention
Ali Hassanali
Neglect all n except the one for which |ri - rj + nL| is smallest.
i
j
The minimum image between particles i and j in the drawing are across two different cells.
i i
i i i
i i i
j j
j j j
j j j
Molecular Dynamics 25
Calculating force between two particles
Ali Hassanali
( )jiv rr −Suppose there is an interaction between particles i and j .
Calculate the force on particle i from this interaction
i j
Molecular Dynamics
( )jii
ix vx
f rr −∂
∂−=, ( ) ji
iji x
v rrrr −∂
∂−ʹ−=
ji
jiji
i
xxx rr
rr−
−=−
∂
∂
( ) .,ji
jijiix
xxvf
rrrr
−
−−ʹ−=( )jiv rr −If , then
26
Force discontinuity under minimum image
Ali Hassanali Molecular Dynamics
L
j i j i
j i
j i j i
j i
( )jii
xi vx
f rr −∂
∂−=,
( )ji
jiji
xxv
rrrr
−
−−ʹ−=
( )Lvx
f jii
xi xrr ˆ, +−∂
∂−=
( )LLxx
Lvji
jiji xrrxrr
ˆˆ
+−
+−+−ʹ−=
Force on particle i from interaction with j is calculated here.
opposite sign
The minimum image switches when the distance between particles is ½ L along any direction.
27
Calculating force between two particles
Ali Hassanali
L
j i j i
j i
j i j i
j i
xj
fx,i
Min.image typically used for r-n n ≥ 6, potentials.
Min.image only used for short range potentials for which v(L/2) ≈ 0 .
point where min.image neighbor switches
Molecular Dynamics
Truncation of potential → discontinuity of the force → numerical errors.
28
Treatment of short-range interactions
Ali Hassanali Molecular Dynamics
Example: 2.5σ is a traditional cut-off distance for Lennard-Jones interactions.
⎥⎥⎦
⎤
⎢⎢⎣
⎡⎟⎠
⎞⎜⎝
⎛−⎟⎠
⎞⎜⎝
⎛=612
4)(rr
rvLJσσ
ε
)(1 rvLJεσr
29
Shifted LJ Potential
Ali Hassanali
Massage the LJ Potential
)(1 rvLJε
σr
⎪⎭
⎪⎬
⎫
⎪⎩
⎪⎨
⎧
≥
<−⎥⎥⎦
⎤
⎢⎢⎣
⎡⎟⎠
⎞⎜⎝
⎛−⎟⎠
⎞⎜⎝
⎛=
cut
cutcutLJcutLJ
rr
rrrvrrrv,0
),(4)(
612
,
σσε
)(1, rv cutLJε
Force has a discontinuity at rcut .
Molecular Dynamics 30
Switching Function
Ali Hassanali
⎪⎪⎪⎪
⎭
⎪⎪⎪⎪
⎬
⎫
⎪⎪⎪⎪
⎩
⎪⎪⎪⎪
⎨
⎧
≥
<≤
<⎥⎥⎦
⎤
⎢⎢⎣
⎡⎟⎠
⎞⎜⎝
⎛−⎟⎠
⎞⎜⎝
⎛
=
cut
cutswitchLJ
rr
rrrrS
rrrr
rv
0
)(
4
)( 1
1
612
,
σσε
)(1, rv switchLJε σ
r
cubic polynomial switching function, r1=2.2σ, rcut=2.5σ.
Molecular Dynamics 31
Verlet Neighbor Lists
Ali Hassanali
Calculation of N(N-1)/2 distances rij can be avoided at most simulation steps using neighbor lists.
rcut
rlist
All neighbors within rlist are listed every nlist steps. (rlist ≈ 10Å)
At each simulation step, only distances between listed neighbors are calculated.
Interactions calculated for rij < rcut .
Valid when particles diffuse less than (rlist - rcut) in nlist steps.
Molecular Dynamics 32
How about Long-Range Interactions?
Ali Hassanali
( )∑ ∑ +−=∞→
cell
cell
N N
jijiNcell LvE
nnrr
,
'21lim
omit i=j when n = 0.
When potential is long range (Coulomb,…), the full sum must be calculated.
Full sum is often slowly (and conditionally) convergent.
Ewald method: Original slowly convergent sum → two rapidly convergent sums.
Molecular Dynamics 33
Coulomb Sums are Conditionally Convergent
Ali Hassanali
( )∑ ∑ +−=∞→
cell
cell
N N
jijiNcell LvE
nnrr
,
'21lim
( ) ( )∑ ∑ ∑⎥⎥⎦
⎤
⎢⎢⎣
⎡++−++−=
++ −+∈∈ ∈∈∞→
cell
cell
N N
ji
N
jijijiN
LvLvn
nrrnrrNa,Na Cl,Na
''21lim !
??=∞−∞+∞−∞=
rrdr
r
140
2∫∞
π
Coulomb sum with only like
or unlike charges ~
does not converge.
Molecular Dynamics 34
The Ewald Summation
Ali Hassanali
deLeeuw, Perram, Smith, Proc.RoySoc.Lond.A373:27 (1980)
Introduce integral representation for r - 1 .
∫∞
−−=0
2/1 211 tretdtr π
Break this integral into two parts.
∫∫∞
−−−− +=2
2
2
2 2/1
0
2/1 111
α
α
ππtrtr etdtetdt
r
long-range short-range
α will be chosen for numerical convenience.
Molecular Dynamics 35
Ewald Method
Ali Hassanali
∫∫∞
−−−− +=2
2
2
2 2/1
0
2/1 111
α
α
ππtrtr etdtetdt
r
long-range short-range rr)(erf α
rr
rr )(erfc)(erf-1 αα=
r rr)(erf α
−
r1
−
rr)(erfc α
−
Molecular Dynamics 36
Ewald Method
Ali Hassanali Molecular Dynamics
( )∑∑
+−
+−=
∞→
N
ji ji
jiji
N
Nreal L
LqqE
cell
cell ,
erfc'21lim
nrr
nrr
n
α
∑ ∫∑ −+−−−
→∞→=
N
ji
LLtN
jiNrecipji
cell
cell
etdtqqE, 0
2/1
0
2221
21limlim
αζ
ζ πnnrr
n
⎥⎥⎦
⎤
⎢⎢⎣
⎡⋅+⎟
⎠
⎞⎜⎝
⎛−⎟⎠
⎞⎜⎝
⎛= ∑∑∞
+−∞
rmmm
nr
n Li
LxxLe Lx π
ππ 2exp1 222/3
3
2
Jacobi sum formula.
Lm
is a reciprocal lattice vector for a cubic cell.
small x: left side is slowly convergent, right side rapidly convergent.
37
Ewald Method: Hidden Assumption
Ali Hassanali Molecular Dynamics
∑=
=N
iiq
1
0
( ).01∑=
≠=N
ii Qq
Simulations can be run with
( )[ ]
23
22
13
2
, 0
2
3
232
/2expexp21
αππ
παπ
π
LQq
L
LiLL
qqL
E
N
iii
ji
N
jijirecip
−⎟⎠
⎞⎜⎝
⎛−
−⋅⎥⎥⎦
⎤
⎢⎢⎣
⎡⎟⎟⎠
⎞⎜⎜⎝
⎛−⎟
⎠
⎞⎜⎝
⎛=
∑
∑ ∑
=
∞
≠
−
r
rrmmmm
Tacit assumption of a uniform neutralizing charge density with total charge - Q.
Effect is to add an overall constant to Erecip .
+ Z -
+ Z -
38
Connecting MD to Thermodynamic Ensembles
39 Ali Hassanali
isolated system (N,V,E) closed system in contact with heat bath (N,V,T) – (Rossi)
closed system in contact with heat bath and volume reservoir (N,P,T)
open system in contact with heat bath (μ,V,T)
Microcanonical ensemble Canonical ensemble
Isothermal-isobaric ensemble Grand-Canonical Ensemble
Molecular Dynamics
Fluctuations of System Energy in NVE and NVT
40 Ali Hassanali
isolated system
time
U = E
system maintained at a temperature T
time energy exchange between system
and surroundings
system energy E
EU =What are the properties of these energy fluctuations?
Molecular Dynamics
Fluctuations in Thermodynamic Properties
41 Ali Hassanali Molecular Dynamics
Ideal atomic gas example
β23NE =
VNE
E
,
2⎟⎟⎠
⎞⎜⎜⎝
⎛
∂
∂−=
βσ
2,
23
23
βββNN
VN
=⎟⎟⎠
⎞⎜⎜⎝
⎛⎟⎟⎠
⎞⎜⎜⎝
⎛
∂
∂−=
NN
N
N
EE 1
32
23
23
2
∝==
β
βσ22
3β
σN
E =
Relative fluctuations of energy/temperature in MD simulation
Constant Volume (NVT) vs Constant Pressure (NPT)
42 Ali Hassanali Molecular Dynamics
rigid container
Constant Volume Constant Pressure
Fluctuations in Volume at Constant Pressure
1 Ali Hassanali Molecular Dynamics
Consequences of
NVV 1∝
σ
( )2,
1 VVPV
NP
−=⎟⎟⎠
⎞⎜⎜⎝
⎛
∂
∂−β
2
,
11V
BTNT VTkP
VV
σκ =⎟⎟⎠
⎞⎜⎜⎝
⎛
∂
∂−=
Some general theoretical considerations with classical MD
1 Ali Hassanali Molecular Dynamics
MD: Time vs Ensemble Averages
43 Ali Hassanali
The Ergodic Hypothesis
ATime=T −>∞lim 1
TdtA(p(t), x(t))
0
T
∫
A(pN ,rN )ensemble
=1Ω
dpN drN∫ A(pN ,rN )δ H (pN ,rN )−E( )
Molecular Dynamics
What we can get from an MD simulation
Ensemble Average: Experimental measurement
ATime ≈ A(pN ,rN )ensemble
Classical Statistical Mechanics
44 Ali Hassanali
Classical statistical mechanics for 1 particles in 1-dimension
⎥⎥⎦
⎤
⎢⎢⎣
⎡⎟⎟⎠
⎞⎜⎜⎝
⎛+−∝ ∑
=
)(2
exp),(1
2N
N
i i
iNN Vm
P rppr β
TkB
1=β N
N rrrrr …,,, 321↔
NN ppppp …,,, 321↔
Classical stat. mech. for N particles in 3-dimensions
⎥⎦
⎤⎢⎣
⎡⎟⎟⎠
⎞⎜⎜⎝
⎛+−∝ )(
2exp),(
2
xVmppxP β
Molecular Dynamics
Classical Statistical Mechanics
45 Ali Hassanali
TkB
1=β
⎥⎦
⎤⎢⎣
⎡⎟⎟⎠
⎞⎜⎜⎝
⎛+−∝ )(
2exp),(
2
xVmppxP β
⎥⎦
⎤⎢⎣
⎡⎟⎟⎠
⎞⎜⎜⎝
⎛+−= )(
2exp1),(
2
xVmp
CpxP β
Normalization: 1),( =∫∫∞
∞−
∞
∞−
pxPdpdx
⎥⎦
⎤⎢⎣
⎡⎟⎟⎠
⎞⎜⎜⎝
⎛+−= ∫∫
∞
∞−
∞
∞−
)(2
exp2
xVmpdpdxC β
Molecular Dynamics
Classical Statistical Mechanics
46 Ali Hassanali
⎥⎦
⎤⎢⎣
⎡⎟⎟⎠
⎞⎜⎜⎝
⎛+−= )(
2exp1),(
2
xVmp
CpxP β
⎥⎦
⎤⎢⎣
⎡⎟⎟⎠
⎞⎜⎜⎝
⎛+−= ∫∫
∞
∞−
∞
∞−
)(2
exp2
xVmpdpdxC β
[ ] ⎥⎦
⎤⎢⎣
⎡−×−= ∫∫
∞
∞−
∞
∞− mpdpxVdx2
exp)(exp2
ββ
px CC ×=
[ ]px Cmp
CxV ⎥
⎦
⎤⎢⎣
⎡−
×−
=2
exp)(exp
2
ββ
)()( pPxP ×=
Probability factors
Molecular Dynamics
Properties of classical statistical mechanics
47 Ali Hassanali
Classical statistical mechanics
⎥⎥⎦
⎤
⎢⎢⎣
⎡⎟⎟⎠
⎞⎜⎜⎝
⎛+−∝ ∑
=
)(2
exp),(1
2N
N
i i
iNN Vm
P rppr β
)()(),( NNNN PPP prpr =
[ ])(exp2
exp),(1
2N
N
i i
iNN Vm
P rppr ββ −⎥⎦
⎤⎢⎣
⎡−∝ ∑
=
Probability distribution factors.
In classical statistical mechanics, momentum and configurational fluctuations are strictly uncorrelated (statistically independent).
Molecular Dynamics
Properties of classical statistical mechanics
48 Ali Hassanali Molecular Dynamics
∫ ∑
∑∞
∞− =
=
⎥⎦
⎤⎢⎣
⎡−
⎥⎦
⎤⎢⎣
⎡−
=N
i i
iN
N
i i
i
N
md
mP
1
2
1
2
2exp
2exp
)(pp
p
pβ
β
⎥⎦
⎤⎢⎣
⎡−⎟⎟
⎠
⎞⎜⎜⎝
⎛= ∑
=
− N
i
iN
mm
1
22/3
2exp2 p
ββπ
For simplicity, all mi = m here.
[ ])(exp1)( NN VZ
P rr β−= [ ]∫ −=V
NN VdZ )(exp rr β
Z is the configuration integral (partition function)
Most interesting features of equilibrium classical statistical mechanics arise from the configurational distribution .
Classical MD simulations of Light and Heavy Water
49 Ali Hassanali Molecular Dynamics
Classical statistical mechanics
)()(),( NNNN PPP prpr =
[ ])(exp2
exp),(1
2N
N
i i
iNN Vm
P rppr ββ −⎥⎦
⎤⎢⎣
⎡−∝ ∑
=
Compare simulations of H2O and D2O.
In classical stat. mech., is there a difference in their boiling or freezing point?
Is there a difference in their configurational distribution functions?
The Lagrangian and the Action
50 Ali Hassanali Molecular Dynamics
)(21),( 2
1
Nii
N
i
NN VmL rrrr −=∑=
!!
rN(t)
t
∫=2
1
),()]([t
t
NNN LdttA rrr !
∂L∂ri
−ddt∂L∂!ri
⎛
⎝⎜
⎞
⎠⎟ ⎟⎟
⎠
⎞⎜⎜⎝
⎛
∂
∂−
∂
∂−= ∑
=
2
1 21)( jj
N
ji
N
i
mdtdV rr
rr
!!
Principle of least action
Important information extracted from MD simulations
51 Ali Hassanali Molecular Dynamics
The Pair-Correlation Function: RDF
52 Ali Hassanali Molecular Dynamics
ρ (2)(r, ʹr ) Probability that any particle is as r and any other particle is at r′.
)()()(ˆ)(ˆ),( )1()1(large )2( rrrrrr rr ʹ=ʹ⎯⎯⎯ →⎯ʹ ʹ− ρρρρρ
When large, densities at r and r′ are uncorrelated. rr ʹ−
)()(),(),( )1()1(
)2()2(
rrrrrr
ʹ
ʹ=ʹ
ρρρg
1),( large )2( ⎯⎯⎯ →⎯ʹ ʹ−rrrrg
Define:
The RDF for LJ Liquid, Hard-Spheres, Water
53 Ali Hassanali Molecular Dynamics
)()2( rr ʹ−ρ
rr ʹ−
Hard Spheres/LJ Liquid Water
Number of Neighbors
54 Ali Hassanali
∫=R
rgrdrRN0
2 )(4)( πρ = number of neighbors out to distance R.
)(rg
1
r
1st solvation shell
Molecular Dynamics
What else can we calculate from the radial distribution function?
Thermodynamic Properties from RDF
55 Ali Hassanali Molecular Dynamics
E = 32NkT + N
24πρ drr2u(r)g(r)
0
∞
∫
PkT
= ρ −ρ2
6kTdr4πr3u '(r)g(r)
0
∞
∫
Total Energy
Pressure
Free energies from RDF
56 Ali Hassanali Molecular Dynamics
)( 21 rr −g
21 rr −
1
0 )( 21 rr −w
Under what conditions would the w(r) → v(r), the pair potential?
),(),(ln1 2121 rrrr wg ≡−β
1 2
Some Very Important References
57 Ali Hassanali Molecular Dynamics
B. J. Alder and T. E. Wainwright (1957). "Phase Transition for a Hard Sphere System". J. Chem. Phys. 27 (5): 1208.
A. Rahman (1964). "Correlations in the Motion of Atoms in Liquid Argon". Physical Review 136: A405-A411.
A. Rahman and Frank Stillinger (1964). “Molecular Dynamics Study of Liquid Water". Journal of Chemical Physics 55(7): 3336