Vous êtes sur la page 1sur 53

Molecular Dynamics Simulations:

from Basics to Applications.

Lecture 5.

Molecular Dynamics: Basics.


14.05.2012 1
Long-range interactions

Molecular Dynamics: Basics.


14.05.2012 2
• A long-range force is often defined as one in which the spatial
interaction fall off no faster than r-d where d is the dimensionality
of the system.

• In this category fall charge-charge interaction between ions:

υ zz (r ) ~ r −1
• and the dipole-dipole interaction between molecules:

υ μμ (r ) ~ r −3

• These forces are serious problem for the computer simulations.


The brute force solution would be increase the box size L to
hundreds of nanometers, that the screening by neighbors would
diminish the effective range of the potentials. However, we have
to remember that simulation time is proportional to N2 or L6.

Molecular Dynamics: Basics.


14.05.2012 3
• The questions is: how can such potentials be handled?

1 N N qi q j
υ (r ) = ∑∑ ∑
zz

2 i =1 j =1 m∈Z 3 4πε 0 ri − r j + mL

Straight forward Lattice methods:


Reaction field
spherical cut off • Ewald sum
method.
• Particle mesh Ewald
(PME)
• Particle-Particle
Particle-Mesh (PPPM,
P3M)

Molecular Dynamics: Basics.


14.05.2012 4
• Straight forward spherical truncation of the potential can be ruled
out. The resulting sphere around a given ion could be charged,
since the number of anions and cations need not balance at any
instant.
+ +
- +
- -
+ +

- +
+ rc
- -
- + -
+ - +
+ - -
- - +

+
- -
+
-

Molecular Dynamics: Basics.


14.05.2012 5
• The questions is: how can such potentials be handled?

1 N N qi q j
υ (r ) = ∑∑ ∑
zz

2 i =1 j =1 m∈Z 3 4πε 0 ri − r j + mL

Straight forward Lattice methods:


Reaction field
spherical cut off • Ewald sum
method.
• Particle mesh Ewald
(PME)
• Particle-Particle
Particle-Mesh (PPPM,
P3M)

Molecular Dynamics: Basics.


14.05.2012 6
Lattice methods.

Molecular Dynamics: Basics.


14.05.2012 7
1. Ewald summation.

Molecular Dynamics: Basics.


14.05.2012 8
• Let assume, that we have a system, which contains in total N
positively and negatively charged particles. These particles are
located in the cubic box of size V=L3, where L is the side of the
box.
• We also assume a periodic boundary conditions.
• In addition we assume, that the system is electrically neutral.
• The Coulomb contribution to the potential energy of the system is:
1 N
υ = ∑ ziφ (ri )
zz
(3.5)
2 i =1
where φ(ri) is electrostatic potential at the position of particle i:
` zj
φ (ri ) = ∑ (3.6)
j ,n rij + nL
where the prime of the summation indicates that the sum is over all
periodic images n and over all particles j, except j = i if n = 0.

Molecular Dynamics: Basics.


14.05.2012 9
• The problem is, that we can not use eq. (3.6) to compute the
electrostatic energy in a simulation, because it contains a poorly
convergent sum (in fact, the sum is also conditionally
convergent.)
• In the eq. (3.6) we have represented the charge density as a sum
of δ functions. The contribution to the electrostatic potential due to
these point charges decays as 1/r.
• Let us now surround every particle i with charge zi by a diffuse
charge distribution of opposite sign, such that the total charge
of this cloud exactly cancels zi.
• If we do so, the electrostatic potential due to particle i is due
exclusively to the fraction of zi which is not screened. At long
distances this fraction rapidly goes to 0. How rapidly depends
on the functional form of the screening charge distribution, so
shall assume Gaussian distribution.
• We can easily compute the contribution to the electrostatic
potential at point ri due to set of screened charges by direct
summation, because this potential is rapidly decaying with r.
Molecular Dynamics: Basics.
14.05.2012 10
• However, we are not interested in the potential due to a set of
screened charges but point charges.

• So we have to add a compensating charge distribution which


will correct for the fact that we added a screening charge cloud to
every particle.

= +

Molecular Dynamics: Basics.


14.05.2012 11
• If we wish to compute the electrostatic energy at the site of
particle i, we should exclude the contribution of the charge zi to
the electrostatic potential.

• It is convenient to add the screening charge around particle i to


the compensating charge distribution, that we must subtract. If we
do so, the compensating charge distribution becomes a smoothly
varying periodic function.

• The idea is that such a function can be represented by a rapidly


converging Fourier series.

• Of course, in the end we have to correct for our inclusion of a


spurious self interaction between ion i and its screening charge
cloud.

Molecular Dynamics: Basics.


14.05.2012 12
• We assume, that the screening charge distribution surrounding a
particle i is a Gaussian with width (2/α)1/2
ρ Gauss (r ) = − zi (α π ) 3 / 2 exp(−αr 2 ) (3.7)

where α is determined later by consideration of computational efficiency.

• We have to perform following steps:

– Evaluate the contribution to the Coulomb energy due to continuous


background charge.

– Compute the spurious “self” term

– Calculate the real-space short-range contribution due to screened


charges.

Molecular Dynamics: Basics.


14.05.2012 13
• We must compute the electrostatic potential at a point ri due to a
charge distribution ρ1(r) that consists of a periodic sum of Gaussians:
N
ρ1 ( r ) = ∑ ∑ z j (α π )
j =1 n
3/ 2
[
exp − α r − (r j + n L )
2
] (3.8)

• To compute the electrostatic potential due to this charge


distribution, we will use Poisson’s equation:

− ∇ φ1 (r ) = 4πρ1 (r )
2
(3.9)

• or in Fourier form:

k φ (k ) = 4πρ1 (k )
2
(3.10)

Molecular Dynamics: Basics.


14.05.2012 14
• Fourier transforming the charge density ρ1 yields:
1
ρ1 (k ) = ∫ dr exp(−ik ⋅ r) ρ1 (r) =
V V
1 N
= ∫ dr exp(−ik ⋅ r)∑∑ z j (α π ) exp − α r − (r j + nL) =
V V j =1 n
3/ 2 2
[ ]
1
= ∫
V all space
N
dr exp(−ik ⋅ r)∑ z j (α π )
j =1
3/ 2
[
exp − α r − r j
2
]=
1 N
ρ1 (k ) = ∑ exp(−ik ⋅ r j ) z j exp(− k 2 4α ) (3.11)
V j =1

Molecular Dynamics: Basics.


14.05.2012 15
• If we now insert this expression in Poisson’s equation, we obtain:
4π 1 N
φ1 ( k ) = 2
k V
∑ j
z
j =1
exp( − i k ⋅ r j ) exp( − k 2
4α ) (3.11)

where it should be noted that this expression is defined for k ≠ 0. In what


follows we shall assume that the term with k = 0 , in fact, can be neglected.

• Then we need to compute φ1(r)

φ1 ( r ) = ∑ φ1 (k ) exp( ik ⋅ r ) =
k ≠0

4πz j
[ ]
N
1
=
V
∑∑
k ≠ 0 j =1 k 2
exp − ik ⋅ (r − r j ) exp( − k 2 4α ) (3.12)

Molecular Dynamics: Basics.


14.05.2012 16
• And the contribution to the potential energy due to φ1 is:
1
υ1 ≡ ∑ z iφ1 ( ri ) =
2 i
N 4π z z
1
= ∑∑
2 k ≠ 0 i , j =1 Vk
i j
2
exp[− i k ⋅ ( ri − r j ) ]
exp( − k 2
4α ) =

V 4π
= ∑ ρ − 4α )
2
2
( k ) exp( k 2
(3.13)
2 k ≠0 k

• where we have used the definition,

N
1
ρ (k ) ≡
V
∑z
i =1
i exp( ik ⋅ ri ) (3.14)

Molecular Dynamics: Basics.


14.05.2012 17
• The contribution to the potential energy given in eq. (3.13) includes a
spurious term due to the interaction between a continuous Gaussian
charge cloud of charge zi and a point charge zi located at the center of
the Gaussian.

• We, therefore should correct for it. And so, we have to compute the
potential energy at the origin of a Gaussian charge cloud.

• The charge distribution that we have over-counted is:

ρ Gaus ( r ) = z j (α π ) 3 / 2 exp( −α r 2 ) a

• We can compute the electrostatic potential due to this charge


distribution using Poisson’s equation.

Molecular Dynamics: Basics.


14.05.2012 18
• Using the spherical symmetry of the Gaussian charge cloud, we can
write Poisson’s equation as follows:

1 ∂ φGaus (r )
2
− = 4πρGaus (r )
r ∂r 2

or

∂ φGaus (r )
2
− = 4πrρ Gaus (r )
∂r 2

Molecular Dynamics: Basics.


14.05.2012 19
• The first partial integration yields:
z j (α π ) 3 / 2 exp( −α r 2 )

1 ∂ φGaus (r ) r
2
− = ∫ 4πρGaus (r ) =
r ∂r 2 ∞


= −2πzi (α π ) ∫ dr exp(−αr ) =
3/ 2 2 2
r

= −2 zi (α π ) 1/ 2
exp(−αr ) 2
(3.15)

Molecular Dynamics: Basics.


14.05.2012 20
• The second partial integration gives:

r
rφGaus (r ) = −2πzi (α π ) ∫ dr exp(−αr )=
1/ 2 2
0

= zi erf ( αr ) (3.16)

where, in the last line, we have employed the definition of the error function:
x
erf ( x) ≡ (2 π ) ∫ exp(−u 2 )du
o

• Hence,
zi
φGaus (r ) = erf ( αr ) (3.17)
r
Molecular Dynamics: Basics.
14.05.2012 21
• To compute the spurious self term to the potential energy, we have to
compute φGauss(r) at r = 0. It is easy to verify that:

φGauss (r = 0) = 2 zi (α π )1/ 2

• And the spurious contribution to the potential energy is:

1 N N
υ Self = ∑ ziφSelf (ri ) = (α π ) ∑ zi
1/ 2 2
(3.18)
2 i =1 i =1

Molecular Dynamics: Basics.


14.05.2012 22
• Finally, we have to compute the electrostatic energy due to the point
charges screened by oppositely charged Gaussian clouds.
• Using the previously obtained results, namely eq. (3.17), we can
immediately write the short-range electrostatic potential due to a point
chare zi surrounded by a Gaussian with net charge –zi:
zi zi zi
φShort − range (r ) = − erf ( αr ) = erfc( αr )
r r r
where
erfc( x) ≡ 1 − erf ( x)

• The total contribution of the Coulomb screened interaction to the


potential energy is given by:

( )
N
1
υ Short − range = ∑ zi z j erfc αrij (3.19)
2 i≠ j
Molecular Dynamics: Basics.
14.05.2012 23
• So the total electrostatic contribution to the potential energy now
becomes the sum of equations (3.13), (3.18) and (3.19):
υCoul = υ1 − υ Self + υ Shor −range =
1 N 4πV
= ∑ 2 ρ (k ) exp(− k 2 4α ) −
2

2 k ≠0 k
N
− (α π )1/ 2 ∑ zi2 +
i =1

1 N
+ ∑ zi z j erfc αrij
2 i≠ j
( ) (3.20)

• It is also straightforward to derive the corresponding expressions for


the potential energy of a system containing dipolar molecule. This
derivation could be find elsewhere.
Molecular Dynamics: Basics.
14.05.2012 24
Box with charged particles.

+ +
+
-
-
-
+ +

- +
- + -
- + -
+ - +
+ -
-
- +
-
+
- -
+
-
Molecular Dynamics: Basics.
14.05.2012 25
Background potential which is calculated in the reciprocal space.

+ +
- +
-
-
+ +

- +
- + -
- + -
+ - +
+ -
-
- +
-
+
- -
+
-
Molecular Dynamics: Basics.
14.05.2012 26
Correction for the self-interaction of the green particle with background potential.

+ +
+
-
-
-
+ +

- +
- + -
- + -
+ - +
+ -
-
- +
-
+
- -
+
-
Molecular Dynamics: Basics.
14.05.2012 27
Calculation of the short-range interactions in the direct space.

+ +
+
-
-
-
+ +

- +
+ rc
- -
- + -
+ - +
+ -
-
- +
-
+
- -
+
-
Molecular Dynamics: Basics.
14.05.2012 28
2. Particle Mesh Ewald.

Molecular Dynamics: Basics.


14.05.2012 29
• The Ewald sum scales with the N3/2, due to the bad scaling of the
Fourier part.

• To improve the reciprocal sum Darden et. al. proposed a method


called Particle-Mesh-Ewald (PME).

• Instead of directly summing wave vectors, the charges are


assigned to a grid using cardinal B-spline interpolation. The grid is
then transformed with a 3D FFT algorithm and the reciprocal term
obtained by a single sum over the grid in k-space.

• The potential at the grid points is calculated by inverse


transformation, and we obtain the forces on each atom by using
interpolation factors.

• The PME method scales with Nlog(N) and is much faster than the
ordinary Ewald summation on the large systems.

Molecular Dynamics: Basics.


14.05.2012 30
Box with charged particles.

+ +
- +
-
-
+ +

- +
- + -
- + -
+ - +
+ -
-
- +
-
+
- -
+
-
Molecular Dynamics: Basics.
14.05.2012 31
B-spline interpolation of the charge on the grid points and
calculation of the background potential using 3D FFT

Molecular Dynamics: Basics.


14.05.2012 32
Calculation of the short-range interactions in the direct space.

rc
- + -
-
+ -
+
-

Molecular Dynamics: Basics.


14.05.2012 33
3. Particle-Particle Particle-Mesh
(PPPM).

Molecular Dynamics: Basics.


14.05.2012 34
• The particle-particle particle-mesh algorithm was proposed by
Eastwood et. al. for the ionic systems.
• In common with Ewald method, it separates the total force on
particle i into a long-range and short-range part. The short-range
part is handled normally and the long-range part of the force on
particle i is calculated using the particle-mesh method.

• There are the three steps:


– The charge density in the system is approximated by assigning the
charges to a finely-spaced mesh in the simulation box.

– The fast Fourier transform method is used to solve Poisson’s


equation for the electrostatic potential due to the charge distribution
on the mesh. This gives the potential at every mesh point.

– The field at every mesh point is calculated numerically differentiating


the potential, and then the force on a particle i is computed from the
mesh field by interpolation.

• The PPPM method scales only with N.


Molecular Dynamics: Basics.
14.05.2012 35
Constraints

Molecular Dynamics: Basics.


14.05.2012 36
• In Molecular Dynamics simulation, the time step should be choose
such that it is appreciably shorter than the shortest relevant time
scale in the simulation.
• The problem is that the characteristic time scales associated with
intra-molecular motions are typically a factor 10-50 shorter than
the time over which the translational velocity of a molecule
changes appreciably.
• If we would like to simulate the intra-molecular dynamics explicitly,
we have to use time step which is shorter than the period of the
highest-frequency intra-molecular vibration.

• For example, the frequencies of stretching vibrations in alkanes


(C-H, C-H2, C-H3) are 2850-3000 cm-1. Our time step should be at
least factor 20 shorter than the time of vibrations, what gives us
the largest possible time step 5*10-16 s (0.5 fs).
• The largest time step which is available due to the integration
inaccuracy is ~2fs, so the explicit simulation of bond stretching
with 0.5fs time step will be 4 times more expensive.
Molecular Dynamics: Basics.
14.05.2012 37
• There are two ways to overcome this problem:

1. The forces which are associated with the high-frequency intra-


molecular vibration can be integrated efficiently with time step
different from that one which is used for the integration of inter-
molecular forces.

2. Another possibility is to treat the bonds (and, sometimes bond


angles) in molecules as rigid.

• The equations of motion should then be solved under the


constraint that the rigid bonds and bond angles do not change
during the simulation run.

• However, it should be stressed that, although we discuss


constraint dynamic here in context of the simulation of polyatomic
molecules, this technique has many other applications.

Molecular Dynamics: Basics.


14.05.2012 38
.
.
• Assume that we have equations of motion of the form:

mr j =fj +gj (4.1)


• The terms gj in the eq. (4.1) are the constraint forces: their role is
to keep the desired bond lengths constant, that is to ensure the
equation:
χ ji = r ji2 (t ) − d 2ji = 0 (4.2)

(where dij are the bond length, are rij=|ri - rj| )are satisfied at all
times.
• The Lagrangian equations of motion derived from these
constraints are eq. (4.1) with:
1
g j = ∑ λ ji ∇ r j χ ji (4.3)
j 2
where λji are undetermined Lagrange multipliers, and factors ½ are
introduced so that this definition of the multipliers agrees with later
equations.
Molecular Dynamics: Basics.
14.05.2012 39
• The problem is, that we are bound to solve the equations of
motion approximately, using finite difference method, in practice
this will lead to the to bond lengths that steadily diverge from the
desired values.

• Ruckaert et. al. suggested an approach in which he constraints


are satisfied at each time step; by implication, the constraint
forces themselves are only correct to the same order of accuracy
.
.
as the integration algorithm. Thus we can write:

m r j = f j + g j ≈ f j + g (rj ) (4.4)

where gj(r) is an approximation to the true forces of constraint, gj


acting on each atom j.

Molecular Dynamics: Basics.


14.05.2012 40
• Using Verlet algorithm we can write:

f j (t ) g (jr ) (t )
r j (t + Δt ) ≈ 2r j (t ) − r j (t − Δt ) + Δt 2 + Δt 2
2m 2m
g (jr ) (t )
r j (t + Δt ) = r′j (t + Δt ) + Δt 2 (4.5)
2m
where rj’(t+Δt) is the position which would have been reached
without any constraints.

• So the main idea is:

1. Perform unconstrained Verlet step to get rj’(t)

2. Account for the constraints after Verlet step.

Molecular Dynamics: Basics.


14.05.2012 41
• Recognizing that constraint forces must be directed along the
bonds and must conform to Newton’s third law, we can write:

g (jir ) = ∑ λ ji r ji (4.6)
i
• Inserting these forces in the Verlet algorithm:

Δt 2
r j (t + Δt ) = r′j (t + Δt ) + ∑ λ ji r ji (4.7)
i mj
• And for the constraint bond:

Δt 2 Δt 2
r jk (t + Δt ) = r′jk (t + Δt ) + ∑ λ jk r jk + ∑ λki rki (4.8)
k mj k mi

Molecular Dynamics: Basics.


14.05.2012 42
• Keeping in mind that constraints are:
2 2
r ji (t + Δt ) = r ji (t ) = d 2ji (4.9)

• For the nc (number of constraints) we get the system of nc


quadratic equations, which can, in principle, be solved.
• In practice, we can solve this system of equations in iterative
fashion. As far as
λ ~ Δt
ji
2

λ ~ Δt
2
ji
4

• we can neglect the quadratic terms, and solve the linear


equations for λji. Then obtained values for λji are substituted into
the quadratic terms, to give new linear equations, which yield
improved values of λji, and so on.
Molecular Dynamics: Basics.
14.05.2012 43
• Here is a block scheme, for the procedure described above:

Quadratic equations

Solution gives new


Neglect λ2ji terms estimates for rji

Linear equations

• Set of the linear equations can be solved by inversion of nc×nc


matrix.

– Easy to do for the small molecules (water, methane, etc.)

– We need special schemes do this for the large molecules, which have
the large number of constraints. (polymers, proteins, etc.)

Molecular Dynamics: Basics.


14.05.2012 44
SHAKE algorithm.

Molecular Dynamics: Basics.


14.05.2012 45
• First of all we can assume that constraints are acting on the
bonds and bond angles only. So we get sparse constraint
matrix.

• In 1977 Ruckaert et. al. proposed an approach for the solution of


the constraints, treating them one by one, cyclically adjusting
coordinates so as to satisfy each in turn. This procedure called
SHAKE, and can be repeated until all the constraints are satisfied
within given tolerance.

• The algorithm looks like this:

λ ji
r′ ⎯⎯→ r (1)
→r ( 2)
→→→ r (n)

Molecular Dynamics: Basics.


14.05.2012 46
LINKS algorithm.

Molecular Dynamics: Basics.


14.05.2012 47
• Alternative method: Linear constraint solver (LINKS) was
proposed by Hess et. al. 1997.
• We consider again the system of size N, with positions given by a
3N vector r(t).

• We again can write equations of motion like:

d 2r −1
2
= M f (4.10)
dt
where f is 3N force vector, and M is 3N×3N diagonal matrix containing
the masses of the particles.

• The system is constrained by K time-independent constraint


equations:
g i (r ) = 0 i = 1,....., K (4.11)

Molecular Dynamics: Basics.


14.05.2012 48
• It was shown by Bekker et. al. that the constrained system can
still be described by 3N second order differential equations in
Cartesian coordinates.
• We a going to proof this right now.

• In accordance with the principle of least action, the constraints are


added as a zero term to the potential V(r) multiplied by the
Lagrange multipliers λi(t):
d 2r ∂
− M 2 = (U − λg ) (4.12)
dt ∂r
• The new notation for the gradient matrix of constraint equations is:

dg h
Bih = (4.13)
dri
where B is K×3N matrix, which contains the directions of the constraints

Molecular Dynamics: Basics.


14.05.2012 49
• Thus, we can rewrite eq. (4.12) in form:

d 2r
− M 2 + BT λ + f = 0 (4.14)
dt
• Because the constraints equations are zero, the first and the
second derivatives of the constraints are also equal zero. So we
can write:

dg dr
=B =0 (4.15)
dt dt
and

d 2g d 2r dB dr
2
=B 2 + =0 (4.16)
dt dt dt dt

Molecular Dynamics: Basics.


14.05.2012 50
• To solve for λ, we multiply eq. (4.14) by BM-1 and use eq. (4.16)
to get:

dB dr
+ BM −1BT λ + BM −1f = 0 (4.17)
dt dt

• Thus the constraints forces are:

BT λ = −BT (BM −1BT ) −1 BM −1f −


−1 T −1 dB dr
(4.18)
− B (BM B )
T

dt dt

Molecular Dynamics: Basics.


14.05.2012 51
• Substituting eq. (4.18) into the eq. (4.14) we get the constrained
equations of motion:

d 2r −1 dB dr
2
= (I − TB)M f − T (4.19)
dt dt dt
where T = −M −1BT (BM −1BT ) −1

• I – TB is a projection matrix which sets the constrained


coordinates to zero, BM-1f is a K vector of the second derivatives
of bond lengths in the direction of the bonds, T is a 3N×K matrix
that transforms motions in the constrained coordinates into the
motion in the Cartesian coordinates, without changing the
equation of motion of the unconstrained coordinates.
• The last term in the eq. (4.19) represents centripetal forces
caused by rotating bonds.
Molecular Dynamics: Basics.
14.05.2012 52
• So if the constraints are satisfied in the starting configuration, the
eq. (4.19) will conserve them.

• The LINCS algorithm is more stable and faster than the SHAKE
scheme. However, it can only be used for the bond and isolated
bond angles, like a proton angle in OH.

Molecular Dynamics: Basics.


14.05.2012 53