molecular dynamics simulations - helsinki

16
Molecular Dynamics simulations Lecture 02: Basics of MD Dr. Olli Pakarinen University of Helsinki Fall 2012 Lecture notes based on notes by Dr. Jani Kotakoski, 2010 I N T HE B EGINNING ... I History of MD goes back 50 years when Alder & Wainwright formulated the method 12 I The need for MD is expressed in the first article: “One of the great difficulties in the present theoretical attempts to describe physical and chemical systems is the inadequate methematical apparatus which has been available to solve the many-body problem.... Even a three-particle system presents great analytical difficulty. Since these difficulties are not conceptual but mathematical, high-speed computers are well suited to deal with them.” I So, MD is a method developed for numerically solving a many-body problem. 1 [J. Chem. Phys. 31, 459 (1959)] 2 [J. Chem. Phys. 33, 1439 (1960)]

Upload: others

Post on 24-Apr-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Molecular Dynamics simulations - Helsinki

Molecular Dynamics simulations

Lecture 02:

Basics of MD

Dr. Olli PakarinenUniversity of Helsinki

Fall 2012

Lecture notes based on notes by Dr. Jani Kotakoski, 2010

IN THE BEGINNING. . .

I History of MD goes back ∼ 50 years when Alder & Wainwrightformulated the method1 2

I The need for MD is expressed in the first article:

“One of the great difficulties in the present theoreticalattempts to describe physical and chemical systems is theinadequate methematical apparatus which has beenavailable to solve the many-body problem. . . . Even athree-particle system presents great analytical difficulty.Since these difficulties are not conceptual butmathematical, high-speed computers are well suited todeal with them.”

I So, MD is a method developed for numerically solving a many-bodyproblem.

1[J. Chem. Phys. 31, 459 (1959)]2[J. Chem. Phys. 33, 1439 (1960)]

Page 2: Molecular Dynamics simulations - Helsinki

I Numerical methods are needed since the N > 3 problem is notsolvable analytically.

I Case of N = 3 was solved by a Finnish mathematician, Karl FritiofSundman in 1912. The series solution is totally inpractical due tovery slow convergence.

I Initial system of interest for MD was “a small number of elasticspheres” which represented molecules. Hence the name.

I First interaction models were simple square potentials describinghard spheres rather than atoms or molecules (“billiard ball physics”).

I Nowadays MD is typically used for atomic systems (but alsomolecules, nanoclusters, etc.) with many different kinds ofinteraction models.

PARTIAL HISTORY OF ATOMISTIC SIMULATIONS

I Metropolis MC 1953.

I Alder and Wainwright: MD 1956: dynamics of hard spheres

I Vineyard 1959: radiation damage in copper

I Rahman 1964: Liquid argon (Lennard-Jones)

I Car-Parrinello 1985: ab initio MD

Page 3: Molecular Dynamics simulations - Helsinki

POTENTIAL ENERGY

I Note: this part of the lecture notes follows Allen Tildeslay Ch.3. 3

I As the first approximation, we assume the potential energy of thesystem to be a sum over particle-particle interactions as follows:

U(rN) =∑

iU1(ri)+

∑i,j

U2(ri, rj)+∑i,j,k

U3(ri, rj , rk)+ . . .

(1)

I The first term corresponds to an external potential.

I Second one includes two-particle interactions, and third onecorresponds to three-particle interactions.

I Typically, interactions between more particles than three areneglected, or included in an approximative way.

I How U1, U2, U3 are defined will be discussed during later lectures.

3[Allen & Tildeslay, Computer Simulation of Liquids, Oxford University Press (1987)]

EQUATIONS OF MOTION

Note that people often talk about “Newtonian equations of motion”when discussing MD. This is to be understood as “classical equationsof motion”, i.e., non-relativistic motion. Obviously, it doesn’t matter inwhich formalism the equations are given.

I Let’s start with the generalized way of representing the motion ofparticles, i.e., Lagrangian equation of motion

ddt∂L

∂qk−∂L

∂qk= 0 (2)

where the Lagrangian function L(q, q) is defined in terms of kineticand potential energies

L ≡ K− U (3)

and is a function of the generalized coordinates qk and their timederivatives qk

Page 4: Molecular Dynamics simulations - Helsinki

I If, on the other hand, we consider a system of atoms in Cartesiancoordinates ri and define the kinetic energy – as usual – as

K ≡∑i,α

p2i,α

2mi(4)

where pi = midri/dt, i runs over the particles and α over thecoordinates (x, y, z) and mi denotes the mass of a particle i, thenthe equation of motion becomes

miri = fi (5)

where the force on atom i is (since ∇riK = 0)

fi = ∇riL = −∇riU (6)

I Generalized momentum is defined as

pk =∂L

∂qk(7)

and the Hamiltonian equations of motion for the generalizedcoordinates are

qk =∂H

∂pk

pk = −∂H

∂qk(8)

Page 5: Molecular Dynamics simulations - Helsinki

I As we saw before, the Hamiltonian is defined as

H(p, q) ≡ K(p) + U(q) (9)

I Since L ≡ K− U⇔ U = K− L and K ≡∑

i,αp2

i,α2mi

,

H(p, q) =∑

kqkpk − L(q, q) (10)

where qk is assumed to be a function of the momenta p, and U isassumed to be independent of velocities and time, U(rN).

I For Cartesian coordinates (x, y, z), Hamilton’s equations become

ri =pimi

(11)

pi = −∇riU = fi (12)

I Therefore, for following the trajectories of the particles in time, weneed to either solve 3N second-order differential equations(Newtonian formalism) or equivalent set of 6N first-orderdifferential equations (Hamiltonian formalism).

I How to do this will be the main topic of next week’s lecture.

Page 6: Molecular Dynamics simulations - Helsinki

WHAT TO LOOK FOR IN SIMULATIONS

I For a MD simulation to work, it has to preserve properties of a realsystem.

I Regarding equations of motion, there are some things to payattention to:

I L and H must be independent on the generalized coordinate qk ifthe corresponding generalized momentum pk is conserved (i.e.,pk = −∂H/∂qk = 0).

I Hence, for any set of particles, it is possible to choose sixgeneralized coordinates corresponding to translations of the centreof mass, and rotations about it, for the system as whole (the rest3N − 6 coordinates involve the motion of the particles relative toeach other).

I In Cartesian coordinates with origin at the center of mass of thesystem these correspond to the total linear momentum P and totalangular momentum L.

I These are defined as:

P =∑

i

pi

L =∑

i

ri × pi =∑

i

ri ×miri (13)

I For a completely isolated system:I P and L are conservedI Hamiltonian H is independent on time, i.e., dH/dt = 0 (total

energy is constant).

I Further, the equations of motion are reversible in time.I I.e., by changing the signs of all momenta, particles would retrace their

trajectories.

I A successfull atomistic simulation reproduces all thesefeatures!

Page 7: Molecular Dynamics simulations - Helsinki

SIMPLIFIED MD ALGORITHM

MD, GENERAL CONSIDERATIONS

I The most simple, and typical, system to model is the so-calledmicrocanonical ensemble (NVE), which was shortly discussedduring last lecture.

I This is closest to a real system because it’s a true solution for theN-body problem, and corresponds to the real atomic motion.

I Current limit is O(109) atoms in dynamical calculations forsimulations times ∼ a few ns with spatially parallelized codes.

I For a N-atomic system, one in principle needs to care about N2

interactions for each time step ∆t.I Obviously, this would become a problem for N > 106.

I Fortunately, most atomic interactions diminish quickly withincreasing inter-atomic distance (r →∞).

Page 8: Molecular Dynamics simulations - Helsinki

I Because U(r) −−−→r→∞ 0, we can limit the interactions to a sphere

close to each particle.

I This transforms the scalability O(N2)→ O(N).

I For example,

I an atom in a semiconductor typically has 2–4 neighbours→ we canlimit the interaction to 4 nearest neighbours→ 4N interactions in total

I metals are closely-packed, but atoms at r > 5 Å are typicallywell-enough screened→ ∼ 80N interactions

I worst case appears for ionic bonding; Coulomb’s law behaves asU ∝ r−1 → cutting the interactions is impossible. However, clevertricks have been developed to overcome this (subject to a later lecture).

CONSTRUCTING A SIMULATION CELL

I Before any simulation, one has to create the positions and velocitiesfor the particles.

I Let’s consider an orthogonal simulation cell as a simple example.Actually, some codes do not go beyond this (only orthogonal cellsimplemented).

I Now, we have a box of size Sx × Sy × Sz [Å3] with lattice vectors:

ax = x, ay = y and az = z. (14)

I Next, we define the positions for the atoms inside the cell:

ri =∑α

xi,αSαaα (15)

where xi,α ∈ [0, 1] are relative coordinates for atom i (and α runsover Cartesian coordinates x,y,z).

Page 9: Molecular Dynamics simulations - Helsinki

I Obviously, no real system is exactly of this shape. Further, it isimpossible to model (most of the) real system sizes.

I Hence, we need to carefully consider how our simulation modelcan be made to represent a larger system.

Periodic Boundary Conditions (pbc)

I For example, if we are interested in bulk properties, we canintroduce periodic boundary conditions to estimate the behaviour ofan infinite system.

I This approach involves “copying” the simulation cell to each of theperiodic directions (1–3) so that our initial system “sees” anothersystem, exactly like itself, in each direction around it. So, we’vecreated a virtual crystal.

I So, if an atom moves out, if comes back in from the other side.

Example: pbc for a 2D system

I Note that the nearestneighbors of atom A,except for B, are now in theneighbouring “virtual” cellsinstead of the original cell.

I Obviously, this has to betaken into account whenevaluating the potentialU(r).

I Also, interactions betweenthe atoms have to belimited to r < Sα/2 for allperiodic α

Page 10: Molecular Dynamics simulations - Helsinki

Open Boundaries

I For certain systems, e.g., protein folding or molecularinteractions in vacuum, we can use open boundaries.

I In this case, if a particle reaches a boundary, it will be lost.Obviously, this only works for a system where the particlesthemselves are more or less stationary.

I Clearly, one would get problems modeling, e.g., a fluid withopen boundaries.

Partially Open Boundaries

I When surfaces are studied, we can’t rely on 3D-pbc, but alsoopen boundaries are problematic.

I Solution is to have open boundaries in the direction normal tothe surface (say, z) and periodic ones in the other directions(x and y).

Fixed Boundaries

I Sometimes, one needs to use fixed boundaries, i.e., preventthe particle motion at or close to a boundary.

I Clearly, this is completely unphysical and should be avoidedat all cost. With large sacrificial areas it can work though.

I Problems arising from fixed boundaries include sound wavereflection and increased overall stiffness of the material.

I Also, the system can not respond to heat effects in a naturalway with fixed boundaries.

Special Cases

I In some cases (like ion irradiation), one has to implementseveral of the above in a single simulation. This requiresextreme care!

Page 11: Molecular Dynamics simulations - Helsinki

I In the case of 3D pbc, one also needs to be careful.

I If the system is not big enough, there may be non-physicalinteractions over the cell boundaries – even if the interaction isshorter ranged.

I Problems can arise especially in the case of phonons (soundwaves), strained systems or large temperature gradients.

I The best solution to this problem is to repeat the simulations withseveral system sizes and to see how the observed phenomenondepends on the system size. In the best case, results allow for aprediction for an infinite system.

Example: Strain fieldAn example of a strain field causedby a single vacancy on a graphenesheet. Blue stands for contractionand red for expansion. This data isfrom [Phys. Rev. B 74, 245420(2006)].

Example 2: Temperature gradient

Modeling a swift heavy ion track:The cell has very high initialtemperature (∼ 5000-10000 K) at thecenter, while the borders need torepresent a heat bath, typically at 300 K.This leads into a different temperaturefor different cell sizes, and the cell sizeneeds to be large enough to findconvergence.

Page 12: Molecular Dynamics simulations - Helsinki

COORDINATES AND PBC

I For constructing thesimulation system, youobviously have to be ableto give the coordinates ofall the atoms in thesystem

I In the first exercise, youhave been writing asimple program togenerate a face-centeredcubic fcc 4× 4× 4supercell of Ag (4 unitcells in each direction, x,y and z).

I Due to pbc, attention has to be paid on the start and endcoordinates of the simulation box!

INITIALIZING ATOM VELOCITIES

I MD simulations are typically carried out at temperatures aboveT = 0 K.

I We need to know how to give a certain temperature to the system.

I To do this, we have to refer to the Maxwell-Boltzmann distribution(which works surprisingly well even for perfect crystals)

ρ(vi,α) =

√mi

2πkBT exp(−

12

miv2i,α

kBT

)(16)

which is simply the Gaussian function (or normal distribution)

ψ(x)µ,σ =1

σ√

2πexp

[−(x − µ)/2σ2] (17)

with µ = 0, σ =√

kBT/mi and x = vi,α

Page 13: Molecular Dynamics simulations - Helsinki

I In practice, we assign each particle velocity separately in eachdirection α:

vi,α =

√kBTmi

uGaα (18)

where uG is always a new independent random number, generatedaccording to a Gaussian distribution, and aα is a unit vector indirection α.

I When a simulation is started with a perfect crystal structure, thetemperature drops suddenly by a factor of two, i.e., the initializedtemperature must be twice the one wanted.

I This occurs when the atoms are initially set into the perfectcrystalline positions. The perfect structure is, obviously, the one withthe minimum energy U0.

I In order to allow the atoms to move, they must leave theirequilibrium positions r0.

I This means that the energy of the system increases U0 → U1.

I A schematic figure of thepotential energy of the systemU(r) as a function of a certaindisplacement d (d0 stands forno diplacement) is displayed onleft.

I The system is presented withthe green ball; first at perfectlattice coordinates with d0 andenergy of U0 and then slightlydisplaced towards a randomdirection (with a correspondingclimb in energy) due to thetemperature.

Page 14: Molecular Dynamics simulations - Helsinki

I Also, one has to set the total momentum of the system P =∑

i mivito zero in order to prevent the system from drifting during thesimulation.

I Instantaneous temperature of the system can be direcly obtainedfrom the kinetic energies of the particles:

kBT(t) ≡∑i,α

miv2i,α(t)

Nf(19)

where Nf is the number of degrees of freedom in the system(Nf = 3N − 6)

I This is based on the equipartition theorem which states that theaverage kinetic energy per degree of freedom is

⟨ 12 miv2

i,α⟩= 1

2 kBT

I Typically, the first few hundred simulation steps must be discarded inorder to the system to thermalize.

I An example of T fluctuation:

I In order to speed-up the thermalization phase, the randomdiplacements can be made directly.

I The needed displacements can be derived from the Debye model.

Page 15: Molecular Dynamics simulations - Helsinki

I A Gaussian probability function is also found for the displacementsfrom statistical mechanics, now

σ =

√9h2T

3kBuMΘ−1D (in Å) (20)

where ΘD is the Debye temperature of the material and M theatomic mass.

I On how to generate random numbers, check out the Monte Carlocourse.

I Note that the treatment above has been completely classical:

I Quantum mechanical zero-point vibrations are neglected.

I This may cause problems for materials with a high Debye temperature,depending on the features studied.

I Velocities thermalize very quickly, though, compared to spanning theposition space.

I At collisions velocities change drastically to opposite directions

I Position space has the glass transition problem

Page 16: Molecular Dynamics simulations - Helsinki

IN SUMMARY, TO OBTAIN (TIME-AVERAGED) PROPERTIES

OUT OF AN MD SIMULATION, THE FOLLOWING STEPS

MUST BE TAKEN:

I Setup the system, starting from initial (guessed) atomic positions

I Start integrating in time

I Equilibrate until system loses memory of its initial state

I Average: accumulate the quantities of interest

Summary

I MD dates back to late 50’s, when it was developed for simplemolecular systems.

I The idea is to solve numerically the classical equations of motion forthe given system (3N second degree or 6N first degree differentialequations).

I Always, new atomic coordinates are evaluated and the state of thesystem is calculated at t + ∆t.

I For modeling a large system using only a small number of atoms,periodic boundaries are used (when possible).

I The velocities can be initialized according to Maxwell-Boltzmanndistribution, but thermalization of the system is still needed.