Molecular Dynamics:
Integration SchemesMotions of subunits (normally atoms) of one or more "molecules".Two kinds of motions:Definition:
- Motions without disturbence to equilibrium state.
Example: Still water in a cup.
- Motions that changes macroscopic (global) state.
Example: Airflow.
Molecular dynamics is a method in which the motion of each individual atom or molecule is computed according to Newton's second law.
Applications:Macroscopic quantities are extracted from the microscopic trajectories of particles.
- The thermodynamic properties of gas, liquid, and solid.
- Phase transitions.
- Internal motions of macromolecules (e.g., polymers, DNA, proteins)
Equations of motions in molecular dynamics:
- Hydrodynamical fluid flow; plasma and electrons, transport phenomena, etc.
Newton's second law:
F = ma = m d2x/dt2
Its solution:
dx/dt = int F/m
For system of N atoms:x = int int F/m
which is an integration process.
mi d2xi/dt2 = sum j Fij
The integration is more complicated. Special computer numeric methods have been developed.
Solving differential equations is one of the major topics in numerical analysis. Several algorithms particularly suitable for molecular dynamics will be introduced.Runge-Kutta method
This is a very straightforward but less accurate method.
Verlet algorithm
Method
Our task is to solve the differential equation
dx/dt = f(t, y), x(t0)= x0
That is, given the function f(t,y), find the function x(t) such that it passes through the point (t0, x0), whose derivative is the given function. Any set of ordinary differential equations can be cast in this form if we allow x to be a vector of certain dimensions.
For example, a second-order differential equation can be rewritten as a set of two first-order differential equations. Thus it is suffice to just discuss how to solve the above equation, keeping in mind that x could mean
(x1, x2, ... , xd).Clearly, the most obvious scheme to solve the above equation is to replace the differential by finite differences:
dt -> h
We then get the Euler method or first-order Runge-Kutta formula:dx -> x(t+h) - x(t)
x(t+h) = x(t) + h f(t, y(t)) + O(h2)
The term first order refers to the fact that the equation is accurate to first order in the small step size h, thus the (local) truncation error is of order h2. The Euler method is not recommended for practical use, because it is less accurate in comparison to other methods and it is not very stable.
Improvement of accuracy
The accuracy of the approximation can be improved by evaluating the function f at two points, once at the starting point, and once at the midpoint. This lead to the second-order Runge-Kutta or midpoint method.
However, the most popular Runge-Kutta formula is the following fourth-order one:
k1 = h f(t, x(t))
k2 = h f(t+h/2, x(t)+k1/2)
x(t + h) = x(t) + k2 + O(h3)
k1 = h f(t, x(t))
The fourth-order Runge-Kutta method is suitable for many applications for systems involving few degrees of freedom. But it was almost never used for molecular dynamics involving many degrees of freedom. Reasons for this:k2 = h f(t+h/2, x(t)+k1/2)
k3 = h f(t+h/2, x(t)+k2/2)
k4 = h f(t+h, x(t)+k3)
x(t + h) = x(t) + k1/6 + k2/3 + k3/3 + k4/6 + O(h5)
- computationally demanding
four evaluations of the right-hand side of the equations
- lacks the time-reversal symmetry of the Newton equations.
This algorithm is particularly suited for molecular dynamics. It has been widely used in many areas from simulation of liquids and solids to biological molecules.
Method
Symplectic algorithmsOur problem is to solve the set of Newton's equations:
mi d2 xi / dt2 = Fi
where xi is the position vector of the i-th particle, mi is the mass of this particle, and Fi is the total force acting on this particle. We'll discuss the form of the forces later on.
To get approximate difference formula for derivatives, let's look at the Taylor expansion of the function x(t):
x(t + h) = x(t) + h x'(t) + h2/2 x''(t) + h3/6 x'''(t)
Replacing h by -h, we get:
+ O(h4)
x(t - h) = x(t) - h x'(t) + h2/2 x''(t) - h3/6 x'''(t)
By subtracting the 1st equation with the 2nd, we have:
+ O(h4)
x'(t) = [ x(t + h) - x(t - h) ]/2h + O(h2)
By adding the 1st equation with the 2nd, we have:
x''(t) = [ x(t + h) -2x(t) + x(t - h) ]/h2 + O(h2)
The same formula applies if x is a vector. Replacing the second derivative by a difference using the above approximation, Newton's equation can be written as:
xi(t + h) = - xi(t - h) + 2xi(t) + h2/mi Fi(t)
This equation was first used in 1791 by Delambre, and rediscovered many times, most recently by Verlet in 1960s for molecular dynamics. It is also called Stoermer algorithm.
+ O(h4)
It has the property that it is exactly time-reversible. That is, if you let the system develop according to this equation for some number of steps, you can back to your starting point exactly by reversing the time. This is the property of the original Newton's differential equation. If you were using the fourth-order Runge-Kutta, you do not have time-reversal symmetry exactly. This property is very important for long-time simulation.
The velocity of the particles can be computed from
vi(t) ~ [ xi(t + h) - xi(t - h) ]/2h
Initial condition used in Verlet algorithm
One problem with Verlet algorithm is that how we get started, since one needs the values at two previous times.
Usually, the second-order differential equation will have a unique solution if the variables and their first derivatives are given. In our case, if the initial positions xi(0) and velocities vi(0) are given, our solution x(t) is uniquely determined. One way to start the simulation is to use:
xi(h) = xi(0) + h vi(0) + h2/2mi Fi(0)
The subsequent values xi(2h), xi(3h), etc, are obtained from the Verlet difference equation.
What is symplectic algorithm?
In the Verlet algorithm, our basic dynamic variables are the coordinates of the particles. And we have a somewhat inconvenient situation that the initial conditions are specified as the initial positions and initial velocities, while the difference scheme involves position only. As you may have learned from mechanics, it is possible to reformulate the Newtonian mechanics so that both positions and momenta are the basic dynamic variables. This formulation is called Hamiltonian dynamics (which is equivalent to Newtonian dynamics). A Hamiltonian system is completely described by the Hamiltonian function (kinetic energy plus potential energy):
H(p,q) = K + V
together with Hamilton's equations of motion:
dpi/dt = - dH/dqi, dqi/dt = dH/dpi
where H is considered to be a function of the generalized coordinates qi and generalized momentum pi. The derivative on H is a partial derivative. The index i labels the degree of freedom, not the particle.
Algorithms for solving this set of Hamilton's equations of motion are symplectic algorithms.
Systems for which a symplectic algorithm can be derived:
The symplectic algorithm can be derived if the Hamiltonian takes a simple form:
H = K + V = sumi pi2/2mi + V(q1, q2, ...)
This is certainly the case if we use Cartesian coordinates and the interactions between particles depend only on the positions of the particles.
With this particular form of Hamiltonian, Hamilton's equations can be written as:
dpi/dt = - dV/dqi = Fi
Symplectic algorithms:dqi/dt = dK/dpi = pi/mi
This set of equationa reduce to Newton's equations if one eliminates the variable pi.
Algorithm A
We use an Euler type approximation for the momentum derivatives, and then a similar Euler algorithm for the position derivatives. However, for the positions, we use immediately the new result for the momenta. Thus, it is not exactly an Euler algorithm. For brevity, we'll use a vector notation:
p = ( p1, p2, ... )
q = ( q1, q2, ... )
F = ( F1, F2, ... )
and assume that all particles have the same mass m. With these notations and assumption, we have:
p(t + h) = p(t) + hF(q(t))
q(t + h) = q(t) + h/m p(t + h)
Clearly, the algorithm is accurate to first order in h.
Algorithm B
We do exactly the same thing as in algorithm A, except that we reverse the order of calculation. The new position is found first.
q(t + h) = q(t) + h/m p(t)
p(t + h) = p(t) + hF(q(t + h))
If you compare algorithms A and B, you will find that it is not exactly the same. It is very interesting to note that both algorithm A and B are in fact mathematically equivalent to the Verlet algorithm if you eliminate the momenta from the equations. However, they have better roundoff error control over the plain Verlet algorithm.
Algorithm C (second-order symplectic algorithm or velocity form of the Verlet algorithm):
This is the most widely used algorithm that we are really interested.
This algorithm is derived by dividing the step size h into two, for the first half step size h/2, we use the algorithm A, for the second half of the step, we use the algorithm B. In total, we have full step size h. That is, use the formula for algorithm A but set h/2. We get equations relating the quantities at time t to time t + h/2. Then we use the equations for algorithms B with step size again h/2, but the time is for t+h/2 to t + h. We get four equations:
p(t + h/2) = p(t) + h/2 F(q(t))
q(t + h/2) = q(t) + h/2m p(t + h/2)
q(t + h) = q(t + h/2) + h/2m p(t + h/2)
p(t + h) = p(t + h/2) + h/2 F(q(t + h))
Now we eliminate the intermediate quantities evaluated at time t + h/2, we get the final result for the symplectic algorithm:
q(t + h) = q(t) + h/m p(t) + h2/2m F(q(t))
Note that the coordinates q have to be evaluated first since the new values at time t+h are used to evaluate the forces.p(t + h) = p(t) + h/2 [ F(q(t)) + F(q(t + h)) ]
The algorithm C is also second-order in step size h. From the derivation it is not obvious that it is necessarily superior than Verlet algorithm. However, the symplectic algorithm has several advantages:
- It is time-reversible
- The system can be started naturally, with initial position q0 and initial momentum p0 = mv0
- The symplectic algorithms A, B, and C have one important property that share with the original Hamiltonian system---they preserve Poincare invariants.
This last property of Hamiltonian system is usually discussed in advanced mechanics or dynamical system courses. It is about the phase space (p,q) flow property. A solution with initial condition (p0,q0) of the Hamiltonian system p=p(t,p0,q0), q = q(t,p0, q0) can be viewed as a map in the phase space from the point (p0,q0) to the point (p,q), where the time parameter t is taken as some constant. The map is also called a canonical transformation, or symplectic transformation.
One of the series of Poincare invariants is the phase space volume. Certain region of points of volume V0 can be mapped to a set of new points forming volume V. Invariance means V=V0. This is called Liouville theorem.
Not only is the volume in phase space invariant under the mapping of the dynamics, but also there are other lower dimensional objects (hypersurfaces) which are invariant. The symplectic algorithms preserve this invariant property exactly.