molecular dynamics

10
MD - 1 Molecular Dynamics Computer Laboratory for Statistical Mechanics The basic idea of the statistical mechanics is to connect microscopic characteristics of the material, such as atomic interactions, bonding, vibration frequencies of molecules and solids, with macroscopic thermodynamics properties as temperature, pressure or transport characteristics. In experiment direct observation of the microscopic evolution of the material, particularly down to the level of atomic motion is essentially not possible. The connection between statistical mechanics and experimental observations is essentially at the level of macroscopic quantities as temperature, pressure, heat capacity, compressibility and others. Furthermore, thermodynamic experimental observations might be quite involving and difficult to perform, particularly in the case of extreme conditions. In view of these difficulties, to illustrate a number of concepts and of thermodynamics and statistical mechanics we will resort to a computer laboratory based on the method of molecular dynamics (MD), rather than to physical laboratory. The basic concept of the MD method is extremely simple. A number of atoms, ions or molecules (we will call them particles) is placed in a given volume, V, called the simulation cell. In addition to positions, initial velocities are also specified. From this point on the evolution of the system is monitored simply by solving Newton equations of motion, F i = m i a i , where F i is the total force acting on particle i, m i is particle mass and a i is particle acceleration. For a many particle system analytical solutions of the Newton’s equations of motion is not possible. Therefore, in MD simulations equations of motion are solved with numerical integration methods. Using this methodology one can obtains detail information on the time evolution of system, such as particle positions, velocities, and forces between particles. These quantities can be used to evaluate various properties including pressure, temperature, energy, and with more sophisticated approaches even free energy or transport coefficients. Energy Evaluation The critical component of MD method is the evaluation of the forces. Formally forces can be obtained as a gradient of the total potential energy of the system, V T (r 1 , r 2 , …r N ), where r i is the position of particle i, f i = −∇ r i V T (1) where f i is the total force acting on the particle i. The total potential energy of the system can be formally written in the following expansion: V T = v 1 (r i i=1 N ) + v 2 ( j> i N i=1 N r i , r j ) + v 3 (r i , r j , r k ) k > j> i N j> i N i=1 N + ... (2)

Upload: others

Post on 18-Dec-2021

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Molecular Dynamics

MD - 1

Molecular Dynamics Computer Laboratory for Statistical Mechanics

The basic idea of the statistical mechanics is to connect microscopic characteristics of the material, such as atomic interactions, bonding, vibration frequencies of molecules and solids, with macroscopic thermodynamics properties as temperature, pressure or transport characteristics.

In experiment direct observation of the microscopic evolution of the material, particularly down to the level of atomic motion is essentially not possible. The connection between statistical mechanics and experimental observations is essentially at the level of macroscopic quantities as temperature, pressure, heat capacity, compressibility and others. Furthermore, thermodynamic experimental observations might be quite involving and difficult to perform, particularly in the case of extreme conditions. In view of these difficulties, to illustrate a number of concepts and of thermodynamics and statistical mechanics we will resort to a computer laboratory based on the method of molecular dynamics (MD), rather than to physical laboratory.

The basic concept of the MD method is extremely simple. A number of atoms, ions or molecules (we will call them particles) is placed in a given volume, V, called the simulation cell. In addition to positions, initial velocities are also specified. From this point on the evolution of the system is monitored simply by solving Newton equations of motion, Fi = miai, where Fi is the total force acting on particle i, mi is particle mass and ai is particle acceleration. For a many particle system analytical solutions of the Newton’s equations of motion is not possible. Therefore, in MD simulations equations of motion are solved with numerical integration methods. Using this methodology one can obtains detail information on the time evolution of system, such as particle positions, velocities, and forces between particles. These quantities can be used to evaluate various properties including pressure, temperature, energy, and with more sophisticated approaches even free energy or transport coefficients. Energy Evaluation The critical component of MD method is the evaluation of the forces. Formally forces can be obtained as a gradient of the total potential energy of the system, VT (r1, r2, …rN), where ri is the position of particle i,

fi = −∇ riVT (1)

where fi is the total force acting on the particle i. The total potential energy of the system can be formally written in the following expansion:

VT = v1(rii=1

N

∑ ) + v2(j> i

N

∑i=1

N

∑ ri,r j ) + v3(ri,r j ,rk )k> j> i

N

∑j> i

N

∑i=1

N

∑ + ... (2)

Page 2: Molecular Dynamics

MD - 2

where the first term represents forces due to external fields, the second and the third terms are the sums over all distinct pairs, and triplets and higher order terms are not written explicitly.

To investigate basic thermodynamic behavior of the material it is sufficient to consider only pair interactions (assuming no external fields). In such as case we need to specify the form on the pair potential v2(r1, r2). Since the interaction energy between two atoms can depends only on the relative positions of the two atoms, rij = ri-rj, (translational symmetry) and has to be rotationally invariant, the pair potential is only a function of the distance between atoms, rij;

v2(ri,r j ) = v2(rij ) . (3)

For the purpose of the statistical mechanics computer laboratory we will select a relatively simple model potential called the Lennard Jones (LJ) potential, vLJ, defined as;

vLJ (r) = 4ε σr

⎝ ⎜

⎠ ⎟ 12

−σr

⎝ ⎜

⎠ ⎟ 6⎡

⎣ ⎢

⎦ ⎥ (4)

The LJ potential has only two parameters, ε, that sets the energy scale, and σ that sets the length scale. At short particle separations the (σ/r)12 term dominates and energy is high and positive. This represents a repulsion preventing overlap of particle cores. At larger separations an attractive (σ/r)6 dominates. This term is responsible for the cohesion and at sufficiently low temperatures will lead to condensation of the vapor and crystallization of the liquid. The minimum of the energy (equal to -ε) occurs at a distance r =

21/ 6σ (see problem MD.1) and represent the bonding energy and the equilibrium distance, respectively. Force Evaluation Once the energy is given in the analytical form the force on a particle i, fi, is evaluated as the sum over all forces coming from pair interactions involving particle i. For example x component of the total force acting on particle i is given by;

fix = fij

x

j≠ i

N

∑ = −∂v2(rij )∂xij≠ i

N

∑ . (5)

-1

-0.5

0

0.5

1

1.5

2

2.5

3

0 0.5 1 1.5 2 2.5 3

V LJ(r)

r/σ Figure 1. Energy vs. distance curve for the LJ potential.

Page 3: Molecular Dynamics

MD - 3

To obtain more practical formula for the force evaluation we notice that the x component of the force acting on particle i due to particle j,

fijx, is given by;

fij

x = −∂v(rij )∂xi

= −∂v(rij )∂rij

∂rij∂xi

, (6)

and with rij given by;

rij = (xi − x j )2(yi − y j )

2 + (zi − z j )2 , (7)

Eq. 6 simplifies to;

fij

x = −∂v(rij )∂xi

= −dv(rij )drij

xijrij

(8)

which can be also written in the vector form;

fij

= −dv(rij )drij

rijrij

. (9)

Eq. 9 recognizes that the force acting on particle i due to particle j is along the line connecting centers of the two particless. Combining Eqs. 5 and 9 we finally have a practical recipe to calculate forces acting on each particle;

fi

= −dv(rij )drij

rijrijj≠ i

N

∑ . (10)

For the LJ potential by differentiating pair energy given by Eq. 4 we obtain;

−dvLJ(rij )drij

=4εσ12 σ

rij

⎝ ⎜ ⎜

⎠ ⎟ ⎟

13

− 6 σrij

⎝ ⎜ ⎜

⎠ ⎟ ⎟

7⎡

⎢ ⎢

⎥ ⎥ . (11)

Evaluation of forces according to Eqs. 10 and 11 requires to calculate forces due

to (N2-N)/2 pairs present in the simulation cell, where N is the number of particles. For larger systems this leads to very expensive computations. On the other hand, most of the physical forces are short ranged, i.e., they have appreciable magnitude only if particles are within several (2-3) atomic distances. The LJ potential reflects this feature and for distances larger than several σ, interaction energy and forces are very small. This allows to limit the sum in Eq. 10 to particles j that are within a given cutoff distance, Rc, from the particle i, without introducing significant errors. With such a

Page 4: Molecular Dynamics

MD - 4

procedure, regardless of the system size, the number of pairs that need to be evaluated is of the order N, rather than N2.

The cutoff distance, however, introduces undesirable features. To start with, when two particles are at distance larger than Rc, their interaction energy is zero since they are not accounted for. At the instant the separation reaches Rc interaction energy jumps to small, but finite value. This discontinuity in the energy is damaging for the accuracy of numerical integrators that work well when all functions involved are continuous. To remedy for this problem we introduce the shifted potential, vs(rij), defined as;

vS (rij ) =v2(rij ) − v2(Rc ) rij ≤ Rc

0 rij > Rc

⎧ ⎨ ⎩

. (12)

The shifted potential is continuous at Rc, however, its derivative with respect to distance is not. Since the derivative determines forces, the shifted potential is still introducing discontinuities in the problem. To finally eliminate the problem, the shifted force potential is used;

vSF (rij ) =v(rij ) − v(Rcut ) − (rij − Rc )

dv(rij )drij

⎝ ⎜ ⎜

⎠ ⎟ ⎟ rij =Rcut

rij ≤ Rc

0 rij > Rc

⎨ ⎪ ⎪

⎩ ⎪ ⎪

. (13)

The shifted force potential is continuous at Rc and its first derivative, i.e., forces are also continuous at Rc. The shifted or shifted force potentials are not exactly the same as the original potential. The difference is, however, becoming very small, if the cutoff distance is sufficiently large. For the LJ potential Rc = 2.5σ is a typical choice providing a balance between computational efficiency and accuracy of the representation of the original (unshifted) potential. Periodic Boundary Conditions and Size Effects For all MD simulations the simulation cell size is very small at the macroscopic scale. For example 10000 atoms represent a ~ 10nm cluster of the material, with a large percentage of atoms residing at the surface. If we want to study properties relating to macroscopic materials this high volume of surfaces has to be eliminated. This is achieved by the use of the periodic boundary conditions (pbc). As illustrated in Fig. 2, the simulation cell is surrounded by its periodic images filling the space. Consequently, instead of the vacuum, particles near the edge of the simulation cell “see” particles from the other side of the simulation cell. When the size of the simulation cell is at least twice larger than the potential cutoff, a given particle i interacts at most with particle j or one of the images of the particle j. Also, when pbc are employed, a particle crossing the edge of the simulation cell reenters the cell at the other edge.

Page 5: Molecular Dynamics

MD - 5

Use of the periodic boundary condition eliminates the most severe finite size effect. Of course, there are other finite size effects that might affect the results of the simulations. We already discussed that each dimension of the simulation cell should be at least twice larger than the cutoff distance. Otherwise, particle i can interact with particle j and/or with its multiple images. This condition can not be satisfied in the case of long-range interactions, such as Coulomb forces, and more involved approaches has to be used to model ionic systems.

A different class of finite size effects arises from the intrinsic correlations that exist in the system of interest. For example, a position of one particle can be correlated with positions of other particles over a characteristic distance, called the correlation length. If the size of the simulation cell is comparable with the correlation length, the results of the simulation can depart severely from the one characterizing large system.

Despite all possible sources of the finite size effects, in many cases, simulation cell containing just several hundred particles is sufficient to represent bulk behavior of the material. Of course it is always prudent to perform simulations with several sizes of the simulation cell, and assess the magnitude of the finite size effects, and determine the optimum size for the simulation. Integration of Newton’s Equations of Motion Once forces are calculated, the remaining task is monitor time evolution of the system using numerical integrator. The simplest possible integrator is called the Verlet algorithm. It is based on the following consideration. The Taylor expansions of the particle position at times t+δt and t−δt, where δt is a small time increment, are;

ri( t+δt) = ri(t) + δtvi(t) + 1/2δt2ai(t) (14a) ri( t-δt) = ri(t) - δtvi(t) + 1/2δt2ai(t) (14b)

where the expansion was carried out to the second order terms. By adding Eq. 14a to 14b, velocities can be eliminated and after rearrangement, the position r( t+δt) can be obtained from positions r(t), and r( t-δt) as;

ri( t+δt) = 2ri(t) - ri( t-δt) + δt2ai(t) (15)

where the acceleration is given by ai(t) = Fi/mi. Eq. 15 provides a recipe for advancement of particle positions. Once the new position ri( t+δt) is known, forces for

Figure 2. Illustration of the periodic boundary conditions used to eliminate free surfaces in molecular simulations.

Page 6: Molecular Dynamics

MD - 6

the new configuration are calculated and the system in advanced further. The velocities do not appear at all in the Eq. 15, however, they can be easily evaluated via the central derivative formula;

v(t) =r(t + δt) − r(t −δt)

2δt. (16)

To advance the particle positions accurately, it is necessary to employ

sufficiently small time step, δt, justifying truncation of the Taylor expansion at the second order term. The accuracy of the integrator is typically evaluated by monitoring the level of the total energy conservation during the evolution of the system.

Basic Structure of the MD Code The basic structure of the MD simulation code is shown in Fig. 3. In order to solve Newton’s equation of motion, we need initial positions and velocities, or as it is the case for the Verlet algorithm current and “old” positions. Before we start simulations we also need to specify ensemble used in the simulations. The microcanonical ensemble corresponds to constant energy and volume conditions (number of particles on MD is always constant). The canonical ensemble will employ a “ computational thermostat”. The the simplest version rescale velocities of particles to maintain desired temperature (see next section). Constant pressure ensemble will allow the simulation cell volume to

change to maintain the set value of pressure.

Once initial structure and simulation conditions are provided the program calculate forces and advances particle positions. For the micro-canonical ensemble, this procedure is repeated predetermined number of MD steps (δt). In the case of the canonical ensemble, particle velocities will be adjusted to keep temperature constant. For constant pressure simulations the volume of the simulation cell will be changed to keep the desired value of pressure.

The output of the program will involve main thermodynamic characteristics (temperature, pressure, volume or density, kinetic and potential energy) typically averaged over a given number of MD steps

Read initial structure, Read velocities

Thermodynamic coordinates, such as temperature, pressure. Type of ensemble: (microcanonical, canonical, constant pressure). Structure file name etc.

Main Program • Calculate forces • Update positions using one of the

integration scheme • Repeat for given number of MD

steps • For constant T rescale velocities • For constant P change the volume

of the simulation box

Main thermodynamics system characteristics: Total, kinetic, and potential energy, temperaure, volume, pressure (stress).

Final and intermediate atomic structures. May include also velocities and higher derivatives to "restart" exactly the same simulations. Other detail information.

Figure 3. Basic structure of the MD code

Page 7: Molecular Dynamics

MD - 7

(see next section). More detail data can be also output, such as particle positions, velocities and others.

Connection with Thermodynamics In previous sections we described methodology to execute molecular simulations and obtain particles trajectories. The key to the relevance of MD simulations is the ability to monitor values of thermodynamic variables, such as pressure or temperature. However, we did not specify explicitly how those variables are evaluated. MD simulations directly provide only microscopic variables as particle positions, velocities, and forces between particles. The connection between those microscopic variables and macroscopic thermodynamic variables is provided by statistical thermodynamics.

The evaluation of total energy (kinetic +potential) in the case of pair interaction potential is straightforward and given by;

E =pi2

mii=1

N

∑ + v2(rij )j> i

N

∑i=1

N

∑ . (17)

The first sum in Eq. 17 is the kinetic energy, with pi denoting momentum of particle i, pi=miVi, where Vi is particle velocity. The second term is the potential energy and was discussed in previous sections. Eq. 17 provides a formula for instantaneous value of the energy at time t.

In general values of thermodynamic variables will fluctuate as a function of, particularly since the number of particles involved in MD simulations is very small at macroscopic sclae. Therefore, the meaningful values of thermodynamic variables are obtained by time averaged instantaneous values. In particular, the average value of any quantity Aobs = A(r, p) is given by

Aobs =< A >time=1tobs

A(r(τ),p(τ))τ=1

τ obs

∑ , (18)

where the summations is over a given number (τobs) MD time steps. The knowledge of the equilibrium value of Aobs, apart for the requirement that the simulated system is in equilibrium, is also subject to sufficient averaging over time evolution of the system. Sufficient means that the system explored all important configurations, and therefore the time average becomes equal to the ensemble average.

To express the temperature in terms of microscopic variables we will use the equipartition of energy principle that can derived from canonical ensemble (see problem MD.2);

< pk∂E /∂pk >= kBT , (19)

where, kB is the Boltzmann constant, E is given by Eq. (17) and triangle brackets indicate ensemble average. Since

∂E /∂pk = pk /mi, (see Eq. (17)), by summing over all atoms, i, and all coordinates (k=x,y,z) one gets;

Page 8: Molecular Dynamics

MD - 8

< pi ,k

2 /mii=1,N ,k= x,y,z

i=N

∑ >= 2 < K >= 3NkBT (20)

This allow to define "instantaneous" microscopic temperature, T;

T =2K3NkB

=1

3NkBp

i ,k

2 /mii=1,N ,k= x,y,z

i=N

∑ , (21)

where K is the instantaneous kinetic energy. With sufficient time averaging of T the thermodynamics temperature T is obtained. We note that in case of internal constrains, such as fixed bond length of molecules, or fixed center of mass of the whole simulation cell, in Eq. 21 the factor 3N has to be replaced by 3N-Nc, where Nc is the total number of constrains.

Finally, in this chapter we outline how to calculate pressure from microscopic variables. To do this we use similar to Eq. 19 relationship (see problem MD.2),

< rk∂E /∂rk >= kBT (22)

By summing over x, y and z coordinates of i particle we obtain;

< xi∂E/∂xi + yi∂E/∂yi +zi∂E/∂zi >= 3kBT . (23)

Since,

∂E/∂xi = ∂V/∂xi = − f i,x , (24)

where fi,x is the x component of the force acting on particle i, by performing summation over all particles one gets;

<r r ir f i

i=1

N

∑ >= - 3NkBT . (25)

In the next step force on atom i can be represented as sum of internal and external forces

r f i =

r f

i

ext +r f

i

int . The pressure is associated with the external forces (see problem MD.3);

<r r ir f i

ext

i=1

N

∑ >= -3PV , (26)

so finally

PV = NkBT +13

<r r ir f iint

i=1

N

∑ >. (27)

The quantity

13

r r ir f iint

i=1

N

∑ is called the “internal virial” W. With this definition the

“instantaneous” pressure can be defined as;

Page 9: Molecular Dynamics

MD - 9

P=

NV

kBT+W/V. (28)

Note that for ideal gas internal forces are zero and Eq. 28 becomes the ideal gas equation of state.

Calculation of pressure can be simplified in the case of pair interactions. Inserting Eq. 5 into the virial definition we obtain:

W =13

r r ir f iint

i=1

N

∑ = 13

r r ir f ij

j≠ i∑

i=1

N

∑ =13x 12

r r ir f ij[

j≠ i∑

i=1

N

∑ +r r j

r f ji] (29)

where

r f ij is the force on particle i from particle j. The last equality follows from the

fact that indices i and j are equivalent. Newton’s third law

r f ij = −

r f ji can be then used to

get;

W = 16

r r ir f ij[

j≠ i∑

i=1

N

∑ +r r j

r f ji] =

16

r r ijr f ij

j≠ i∑

i=1

N

∑ =13

r r ijr f ij

j> i∑

i=1

N

∑ , (30)

hence the internal virial is given by;

W =−13

r r ij •∇ r r ij

j> i∑

i=1

N

∑ v2(rij ) = −13

rij

dv2(rij )drijj> i

∑i=1

N

∑ (31)

The Eq. 31 can be evaluated along with calculations of pair interaction forces. Problems MD.1. Demonstrate that the minimum value of the Lennard Jones (LJ) potential given by Eq. 4 is –e, and The minimum of the Lennard Jones (LJ) potential is equal to -ε and occurs at a distance r =

21/ 6σ . MD.2. Consider the canonical ensemble partition function, Q, calculated for a system of N classical particles,

Q= dr1xdr1ydr1z...drNxdrNydrNz-∞

∫ dp1xdp1ydp1z...dpNxdpNydpNz-∞

∫ e−E(r,p)/k BT (32)

The integrals are performed over all coordinates and momentums of all particles, and the energy E(r,p) is given by Eq. 17. By integrating by parts over dpk, where pk is one component of a particle momentum, prove Eq. 17;

< pk∂E /∂pk >= kBT , (33)

Page 10: Molecular Dynamics

MD - 10

where the triangle brackets indicate the canonical ensemble average. By performing similar integration over a coordinate rk, prove Eq. 18;

< rk∂E /∂rk >= kBT . (34)

MD.3. Consider a cubic macroscopic container having volume V and containing N particles. The pressure, P, on a given wall of the container is by definition equal to the total normal force exerted by particles on the wall divided by the wall area. Show that

xi fx,icon

i=1

N

∑ = -PV , (35)

where the x axis is normal to two walls of the container, and

fx,icon is the x component of

the force that the container wall exerts on the particle i.