Molecular Dynamics

advertisement
3.3 Molecular Dynamics
This practical introduces:



Molecular Dynamics Simulations using the Verlet Algorithm
Conserved Quantities as tests of numerical accuracy
Correlation Functions
This practical is designed to:

illustrate how molecular dynamics simulations are performed and how properties of
the system under study are extracted from simulation trajectories.
Newton’s Equations of Motion as a system of coupled 1st order ODE’s
A second order ordinary differential equation can usually be expressed as a pair of first
order ode’s. For example, in the practical on integration of ode’s in the Senior Freshman
laboratory you integrated the equation of motion for the simple pendulum,
d2/dt2 +  = 0,
(1)
by introducing the variable
 = d/dt,
(2)
and solving two equivalent first order equations,
d/dt = ,
(3a)
d/dt = - 
(3b)
In molecular dynamics simulations one is again solving Newton’s equation of motion,
F = ma, which may be reduced to two first order ode’s
.
F(t)
v (t) = a =
,
m
.
r(t) = v(t) .
(4a)
(4b)
These equations could be solved by a Runge-Kutta technique. However, a second or
fourth order Runge-Kutta technique requires two or four evaluations of the force on each
particle per step. This makes these techniques accurate but expensive in computer time
and molecular dynamics simulations generally take many cpu hours and so less expensive
algorithms such as the Verlet algorithm are used. This algorithm is based on a Taylor
series expansion of the position of each particle about its current position. Each spatial
coordinate of each particle in the simulation is considered to be a function of time and the
Taylor expansion gives each coordinate a small time step ahead of the current time. The
expansion is
.
(t) 2 ..
(t) 3 ...
r (t + t) = r (t) + t r (t) +
r (t) +
r (t) + O (t 4 )
2!
3!
(5)
.
..
Note that r (t) is the velocity and r (t) is the acceleration. As you saw in the Junior
Sophister laboratory on Errors in Numerical Integration, truncation of an expansion such
as this leads to an error which depends on the stepsize of order O(tn) where n depends on
where the truncation is made. Taking the Taylor series in Eq. 5 as it stands, one could
...
obtain a method correct up to order O(t4) by computing all coefficients up to r (t) .
Computing high order derivatives would be expensive in computer time. However, by
making the Taylor expansion in Eq. 5 with the step in the negative time direction and
adding this to Eq. 5, one obtains an equation accurate to order O(t4) and one only has to
...
store r(t - t) rather than calculate r (t) - much easier!. The second Taylor expansion is
.
(t) 2 ..
(t) 3 ...
r (t - t) = r (t) - t r (t) +
r (t) r (t) + O (t 4 )
2!
3!
(6)
and adding Eq. 5 and 6 one obtains,
..
r(t + t) = 2r(t) - r(t - t) + (t)2 r(t) + O (t 4 )
(7a)
..
F (t)
r (t) =
.
m
(7b)
This is the Verlet algorithm. It requires a single evaluation of the force vector per
timestep.
Conserved Quantities in Dynamics
In the last practical you studied errors in integrals of functions of one variable for
functions for which you could verify the solution analytically. You could then
confidently calculate a definite integral to some numerical precision, knowing that the
error size would decrease in a particular way when the step size was increased. There is
no such check of the exact set of particle trajectories in molecular dynamics, except in
trivial cases. However, in a system of particles moving according to Newton’s equations
of motion where there are no sources of friction, at least two aspects of the particles’
motion have associated conserved quantities: the total energy of the particles and the
angular momentum. Keeping a check on the total energy is a good way to ensure that the
stepsize is small enough and the algorithm is adequate to maintain accuracy of the
numerical integration. If the stepsize is too large then the total energy diverges – runs off
to infinity. This may take many timesteps to occur.
Forces in Molecular Dynamics
Forces between particles in molecular dynamics simulations are usually divided into two
categories long range and short range depending on the range of the interparticle force. A
force is long range in 3 dimensions if particles in spherical shells of equal thickness about
some origin exert forces of the same or greater magnitude on a particle than a shell of
particles closer to the particle in question. The range of an interparticle force is
determined by the functional form of the potential. In 3 dimensions, any potential of the
form r-n with n > 3 is short range and with n  3 it is long range. Long range forces in
solids need to be evaluated by special techniques. Short range forces are easily evaluated.
The Lennard-Jones potential is an example of a potential which has an associated short
range force. The Coulomb potential is the most common potential you will encounter
with a long range force. Short range forces between particles can be further divided into
central force and non-central force categories. Central forces always act along the line of
centres of a pair of particles while non-central forces do not. Examples of potentials
which result in central forces are the Lennard-Jones potential and the gravitational
potential between two massive bodies. An example of a non-central potential is the
angle-bending force used in the Minimisation practical in the Senior Freshman laboratory
class.
Setting up a molecular dynamics programme
In order to perform a molecular dynamics run you need to specify a set of initial
conditions, i.e. initial positions and velocities for all of the molecules and then solve Eq.
7. The Verlet algorithm only requires positions and accelerations to obtain a trajectory
for each atom but particle positions at time, t = - t, must be specified and specification of
positions at t = 0 and t = -t is equivalent to specifying initial velocities.
The simplest way to specify initial positions is to use a random number generator
weighted by a probability distribution to place them at various points in a simulation
region. Initial velocities can be specified using a random number generator weighted by a
Maxwell-Boltzmann distribution. The actual configuration of atoms generated may be a
highly improbable configuration, so it is necessary to allow the particle trajectories to
evolve or equilibrate for some time before any properties are recorded. In order to
calculate the kinetic energy of the particles it is necessary to compute the particle
velocities. The particle velocity can be calculated using the central difference equation,
v (t) =
r (t + t) - r (t - t)
.
2 t
(8)
Analysing the Results
The usual aim of a molecular dynamics simulation is to obtain some properties of a liquid
or solid. For example, one might wish to calculate the atomic vibration spectrum for a
solid or the diffusion constant for a solute in a liquid. Most observable properties of
matter can be calculated using functions called correlation functions. The correlation
function is a broad concept and many different types of correlation function can be
defined. Correlation functions measure how a particular property of matter at one point
in time (or space) is correlated with that same property at a nearby point in time (or
space). The autocorrelation function is generally defined as

C( ) =
  (t) (t +  )dt .
(9)
0
 is the value of the property of interest. The normalised autocorrelation function is
C()/C(0). Observe that the correlation function measures the decay in correlations of the
property as a function of time. In this practical you will calculate the velocity-velocity
correlation function for several particles confined by a harmonic potential, V = ½ Kr2,
where r is the distance from the centre of a confining potential energy well. Interactions
between particles are via Lennard-Jones potentials.
Exercises
1. The file verlet.c contains a molecular dynamics programme, which is capable of
performing molecular dynamics runs for several atoms interacting via the Lennard-Jones
potential. The programme contains a main() function in which a file for data output is
opened, particle positions and velocities are initialised and the Verlet algorithm is used
nsteps times to update particle positions and velocities and calculate the total energy at
each timestep. It calls the functions newpos, newvel, etotal, potential and gradpotential.
The purposes of these functions are:
newpos
newvel
etotal
potential
gradpotential
calculate r(t+t) using Eq. 7a
calculate v(t+t) using Eq. 8
calculate total energy (potential energy + kinetic energy)
calculate potential energy
calculate gradient of potential energy, need for force calculation
Particle position and velocity vectors are declared as two-dimensional arrays, the first
array index represents the particle label and the second the particle Cartesian coordinate.
Enough space has been allocated in the programme arrays for up to 40 particles.
Parameters in the programme are specified in SI units, although you may wish to present
results in your write up in other units, e.g. Å for distance or eV/particle for energies.
Compile and run the programme and use it to obtain trajectories for 3 particles interacting
by Lennard-Jones potentials which are confined by a potential, Vconf (r) , of the form
Vconf (r) = 0.5 K r 2
(10)
where K is a constant and r is the distance of any particle from the origin. Modify the
programme so that it writes out the total energy and positions of one of the particles to a
file as a function of time and plot each of these as a function of time using Gnuplot and/or
Xgraphics. Declarations and example calls to Xgraphics functions are included in
verlet.c but are commented out. Increase the stepsize until the total energy diverges
during a molecular dynamics run.
2. Review the programme listing to see how the particle trajectories and total energy of
the particles is calculated.
3. Set the Lennard-Jones potential energy well-depth, , to zero and replot the trajectory
of one particle. Explain why the trajectories of the interacting and non-interacting
particles differ as they do.
4. The angular momentum of a particle is given by L = r x mv. The total angular
momentum of the system is the sum of individual angular momenta. Write a routine to
calculate the total angular momentum of the particles and the angular momentum of one
particle and plot both of these as a function of time for several different numbers of
particle in the simulation. Demonstrate that the total angular momentum is conserved.
5. Write a particle energy scaling routine which rescales the particle velocities gradually
so that the total energy of the system can be changed to any desired total energy. The
energy should converge exponentially to the desired value. Use this function to obtain
the instantaneous temperature of the system and plot this as a function of time.
6. The velocity-velocity correlation function is given in Eq. 9 above. In a molecular
dynamics simulation this can be approximated by
1 N
C( n ) =
 v .v
N i=1 i i+n
 n = n . stepsize .
(11)
Write a routine to calculate the velocity-velocity correlation function for the a 27 particle
systems with temperatures ranging from 10K – 50K in steps of 10K.
Supplementary problem
7. The vibrational density of states can be obtained by Fourier transforming the velocity
autocorrelation function. Use the discrete Fourier transform routine you wrote in the SF
laboratory to calculate this density of states.
Download