introduction to molecular dynamics simulationssaraswati.phys.usm.edu/nsf-hbcu2019/lnotes/l7.pdf ·...

25
Raymond Atta-Fynn Raymond Atta-Fynn (University of Texas at Arlington) NSF Summer School on Disordered Materials Modeling Summer 2019 [email protected] Introduction to Molecular Dynamics Simulations 6/4/2019 NSF Summer School: Introduction to Molecular Dynamics 1

Upload: others

Post on 24-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

  • RaymondAtta-Fynn

    RaymondAtta-Fynn(UniversityofTexasatArlington)NSFSummerSchoolonDisorderedMaterialsModeling

    [email protected]

    IntroductiontoMolecularDynamicsSimulations

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 1

  • RaymondAtta-Fynn

    =WhatismolecularDynamics?=Numericalsolutionstoequationsofmotion= IngredientsofMolecularDynamicsSimulations

    =Constantenergymoleculardynamics=Constanttemperaturemoleculardynamics

    =OtherConsiderations=Summary

    Outline

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 2

  • RaymondAtta-Fynn

    = Moleculardynamicsprovidesameansfordynamicalquantities[i.e.time-dependentquantities]andthermalsquantitiesofasystemtobereadilycomputed.

    = Examplesofsuchpropertiesare:(i) therateofdiffusion (howfastorslowatomsmovewhensubjectedtothermaleffects)(ii) thermalconductivityofamaterial(howgoodorbadamaterialconductsheat)(iii) Phasetransformationsinmaterials (howmaterialschange,forexample,theirsoftnessor

    hardnesswhensubjecttotemperatureandpressure)

    WhatisMolecularDynamics?

    Whatismoleculardynamics?𝑀𝑜𝑙𝑒𝑐𝑢𝑙𝑎𝑟𝑑𝑦𝑛𝑎𝑚𝑖𝑐𝑠𝑖𝑠𝑡ℎ𝑒𝑡𝑖𝑚𝑒𝑒𝑣𝑜𝑙𝑢𝑡𝑖𝑜𝑛𝑜𝑓𝑎𝑠𝑦𝑠𝑡𝑒𝑚𝑜𝑓𝑎𝑡𝑜𝑚𝑠𝑑𝑒𝑠𝑐𝑟𝑖𝑏𝑒𝑑𝑏𝑦𝑁𝑒𝑤𝑡𝑜𝑛H𝑠𝑠𝑒𝑐𝑜𝑛𝑑𝑙𝑎𝑤𝑜𝑓𝑚𝑜𝑡𝑖𝑜𝑛𝑢𝑛𝑑𝑒𝑟𝑡ℎ𝑒𝑖𝑛𝑓𝑙𝑢𝑒𝑛𝑐𝑒𝑜𝑓𝑡𝑒𝑚𝑝𝑒𝑟𝑎𝑡𝑢𝑟𝑒(𝑎𝑛𝑑𝑝𝑟𝑒𝑠𝑠𝑢𝑟𝑒)

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 3

  • RaymondAtta-Fynn

    WhatisMolecularDynamics?

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 4

    Customizedmoleculardynamicssimulationscanbeemployedtoaccessdifferentenergeticstates ofasystemormaterial.

    Thisappliestocaseswherethesystemcanbetrappedinoneenergystateforalongtime[seecartoon;𝜉 denotesastateofthesystem and𝐹(𝜉) denotesenergyofthatstate]

  • RaymondAtta-Fynn

    = Newton’ssecondlawofmotion: Thenetforce �⃗� actingonobjectofmass𝑚 isproportionaltotheobject’sacceleration �⃗�:

    �⃗� ∝ �⃗� ⇒ �⃗� = 𝑚�⃗�

    = Since�⃗� istherateofchangeofvelocity �⃗� withtime 𝑡 [thatis, �⃗� = 𝑑�⃗� 𝑑𝑡⁄ ]and�⃗� istherateofchangeofdisplacement𝑟 with𝑡 [thatis,�⃗� = 𝑑𝑟 𝑑𝑡⁄ ],Newton’ssecondlawcanberestatedat:

    �⃗� = 𝑚𝑑�⃗�𝑑𝑡and�⃗� =

    𝑑𝑟𝑑𝑡

    WhatisMolecularDynamics?

    Newton′ssecondlawemployedinmoleculardynamics

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 5

  • RaymondAtta-Fynn

    = Considerasystemof𝑁 atomsofmasses{𝑚X,𝑚Y,….,𝑚Z} withatomicpositions{𝑟X,𝑟Y,….,𝑟Z},velocities{�⃗�X,�⃗�Y,….,�⃗�Z} undertheactionforces{�⃗�X,�⃗�Y,….,�⃗�Z} atagiveninstantintime𝑡.

    = PerNewton’ssecondlaw,thetimeevolutionofthesystemisgovernedbythepairofcoupledequations:

    𝑑�⃗�\(𝑡)𝑑𝑡

    =�⃗�\𝑚\

    𝑑𝑟\(𝑡)𝑑𝑡

    = �⃗�\

    [1]

    where𝑖 = 1, 2,… ,𝑁 labelstheatoms

    = Letusexamineafewstandardnumericalalgorithms tosolvingthesystemofequationsin1 above.

    WhatisMolecularDynamics?

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 6

  • RaymondAtta-Fynn

    = Beforewedelveintowidelyemployednumericalalgorithmsinmoleculardynamicssimulation,letusexamineafewheuristics.

    = First,wenotefollowingaboutnumericalapproximationtofirstderivatives:𝑑�⃗�\(𝑡) 𝑑𝑡⁄ ≈ �⃗�\ 𝑡 + ∆𝑡 − �⃗�\ 𝑡 ∆𝑡⁄𝑑𝑟\(𝑡) 𝑑𝑡⁄ ≈ 𝑟\ 𝑡 + ∆𝑡 − 𝑟\ 𝑡 ∆𝑡⁄

    whereitisimplicitlyassumedthat∆𝑡 issmallenough.= Pertheaboveapproximations,asimplesolutiontothepairofNewton’sequationsare:𝑑�⃗�\𝑑𝑡

    =�⃗�\𝑚\

    ⇒ �⃗�\ 𝑡 + ∆𝑡 ≈ �⃗�\ 𝑡 + �⃗�\ 𝑡 ∆𝑡 where�⃗�\ 𝑡 =�⃗�\ 𝑡𝑚\

    𝑑𝑟\𝑑𝑡

    = �⃗�\ ⇒ 𝑟\ 𝑡 + ∆𝑡 ≈ 𝑟\ 𝑡 + �⃗�\ 𝑡 ∆𝑡

    where𝑖 = 1, 2,… ,𝑁 and∆𝑡 isknownasthetimestep.= Letusexamineafewstandardnumericalapproaches

    WhatisMolecularDynamics?

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 7

  • RaymondAtta-Fynn

    Verletmethod:Theequationsofmotionare

    𝑟\ 𝑡 + ∆𝑡 = 2𝑟\ 𝑡 − 𝑟\ 𝑡 − ∆𝑡 + �⃗�\ 𝑡 ∆𝑡 Ywhere�⃗�\ 𝑡 =�⃗�\ 𝑡𝑚\

    �⃗�\ 𝑡 =𝑟\ 𝑡 + ∆𝑡 − 𝑟\ 𝑡 − ∆𝑡

    2∆𝑡

    = AdvantagesoftheVerlet method:(i)Straightforwardtoimplement;(ii)thepropagationoftheatomicpositionsdoesnotexplicitlyrequiretheatomicvelocities[thusonecanignorethevelocitiesunlesstheyarereallyneeded]

    = DisadvantagesoftheVerlet method:(i)Itisnon-selfstarting;(ii)thevelocitiesaccumulatesignificantround-offerrors(especiallyfordynamicsspanninglongtimescales)

    Numericalsolutionstoequationsofmotion

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 8

  • RaymondAtta-Fynn

    Leapfrogmethod:Theequationsofmotionare

    �⃗�\ 𝑡 +∆𝑡2

    = �⃗�\ 𝑡 −∆𝑡2

    + �⃗�\ 𝑡 ∆𝑡where�⃗�\ 𝑡 =�⃗�\ 𝑡𝑚\

    𝑟\ 𝑡 + ∆𝑡 = 𝑟\ 𝑡 + �⃗�\ 𝑡 +∆𝑡2

    ∆𝑡

    Thevelocityattime𝑡 isgivenby�⃗�\ 𝑡 = �⃗�\ 𝑡 − ∆𝑡 2⁄ + �⃗�\ 𝑡 + ∆𝑡 2⁄ 2⁄

    = AdvantagesoftheLeapfrogmethod:(i)Itistimereversible;(ii)itissymplectic (i.e.itconservestheenergyofthesystem)

    = DisadvantageoftheLeapfrogmethod:Thevelocitiesandpositionsarecomputedatdifferenttimes,thatis,theyleapfrogeachotherbyhalfatimestep[∆𝑡 2⁄ ]

    Numericalsolutionstoequationsofmotion

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 9

  • RaymondAtta-Fynn

    VelocityVerlet method:Theequationsofmotionare

    𝑟\ 𝑡 + ∆𝑡 = 𝑟\ 𝑡 + �⃗�\ 𝑡 ∆𝑡 +12�⃗�\ 𝑡 ∆𝑡 Ywhere�⃗�\ 𝑡 =

    �⃗�\ 𝑡𝑚\

    �⃗�\ 𝑡 + ∆𝑡 = �⃗�\ 𝑡 +12�⃗�\ 𝑡 + �⃗�\ 𝑡 + ∆𝑡 ∆𝑡

    = AdvantagesofthevelocityVerlet method:(i)Itistimereversible;(ii)itissymplectic (i.e.itconservestheenergyofthesystem)

    = Thisalgorithmisverypopular;itisveryreliableandaccurate.WewillemployitintheLabsessions.

    Numericalsolutionstoequationsofmotion

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 10

  • RaymondAtta-Fynn

    Thefollowingarethekeyingredientsrequiredtosuccessfullyexecuteamoleculardynamics:

    (1)Atomisticmodel

    (2)Interactionpotential(orpotentialenergy)

    (3)Atomicforces

    (4)Basicmoleculardynamicsobservables:kineticenergy,totalenergy,temperature,andpressure.

    (5)Thermodynamicensembles:microcanonicalandcanonicalensembles

    (6)Theergodichypothesis

    (7)Methodforsolvingtheequationsofmotion[alreadydiscussedinthreepreviousslides]

    IngredientsofMolecularDynamicsSimulations

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 11

  • RaymondAtta-Fynn

    Ingredient1:Atomisticmodel:= Comprisesasetofatoms,whichrepresentativeofthesystemofinterest,withwell-defined

    positions(orcoordinates){𝑟X,𝑟Y,….,𝑟Z}.

    = Normally,arandomsetofatomicpositionsarechosensubjecttogeometricconstraintsandotherconstraintssuchasthecorrectatomicdensity(i.e.thenumberofatomspervolume).

    IngredientsofMolecularDynamicsSimulations

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 12

    Atomisticmodelofachargedmetalionimmersedinliquidwater.

  • RaymondAtta-Fynn

    Ingredient2:Potentialenergy(orinteractionpotential):= Thepotentialenergy ofasystemof𝑁 atoms,denotedby 𝑈,tellsushowtheatomsinteract

    witheachorpositionthemselvesrelativetoeachother.

    = Thepotentialenergydependsontheatomicpositions:𝑈 ≡ 𝑈(𝑟X,𝑟Y,….,𝑟Z) .

    = 𝑈 usuallyhasawell-definedanalytic/mathematicalrepresentation.

    Example:thepotentialenergy duetothebondbetweentwoatoms𝑖 and𝑗 locatedatpositions𝑟\ = (𝑥\, 𝑦\, 𝑧\) and𝑟l = (𝑥l, 𝑦l , 𝑧l) respectively,mayberepresentedas

    𝑈(𝑟\,𝑟l) =12𝑘 𝑟\ − 𝑟l

    Y =12𝑘 (𝑥l − 𝑥\)Y+(𝑦l − 𝑦\)Y+(𝑧l − 𝑧\)Y

    where𝑘 isaconstant.

    IngredientsofMolecularDynamicsSimulations

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 13

  • RaymondAtta-Fynn

    Ingredient3:Atomicforces:= Theatomicforces(neededtosolvetheequationsofmotion)areobtainedfromthe

    potentialenergy𝑈 ≡ 𝑈(𝑟X,𝑟Y,….,𝑟Z).= Theforce �⃗�\ actingonatom𝑖 isgivenbythenegativegradientofthepotentialenergy𝑈

    withrespecttotheatom’sposition 𝑟\:

    �⃗�\ = −𝛻\𝑈 𝑟X,𝑟Y,….,𝑟Z = −𝜕𝑈𝜕𝑟\

    = −𝜕𝑈𝜕𝑥\

    , −𝜕𝑈𝜕𝑦\

    , −𝜕𝑈𝜕𝑧\

    = Example:ifthepotentialenergy ofa2-atomsystemisgivenby

    𝑈(𝑟\,𝑟l) =12𝑘 𝑟\ − 𝑟l

    Y =12𝑘 (𝑥l − 𝑥\)Y+(𝑦l − 𝑦\)Y+(𝑧l − 𝑧\)Y

    where𝑘 isaconstant,thenforce�⃗�\ onatom𝑖 isgivenby

    �⃗�\ = −𝜕𝑈𝜕𝑥\

    ,−𝜕𝑈𝜕𝑦\

    ,−𝜕𝑈𝜕𝑧\

    = 𝑘(𝑥l − 𝑥\), 𝑘(𝑦l − 𝑦\), 𝑘(𝑧l − 𝑧\)

    IngredientsofMolecularDynamicsSimulations

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 14

  • RaymondAtta-Fynn

    (4)Basicmoleculardynamicsobservables:

    (a)Thetotalkineticenergy(i.e.theenergyduetoatomicmotion)is

    𝐾𝐸 =12r 𝑚\𝑣\Y

    Z

    \sXwhere𝑚\ and𝑣\ = �⃗�\ arethemassandspeedofatom𝑖.

    (b)Thetotalenergy 𝐸 ofasystematanyinstantisthesumofthekineticenergy𝐾𝐸 andthepotentialenergy𝑈:

    𝐸 = 𝐾𝐸 + 𝑈 𝑟X,𝑟Y,….,𝑟Z =12r 𝑚\𝑣\Y

    Z

    \sX+ 𝑈(𝑟X ,𝑟Y,….,𝑟Z)

    IngredientsofMolecularDynamicsSimulations

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 15

  • RaymondAtta-Fynn

    Ingredient4:Basicmoleculardynamicsobservables:(c)Thetemperature 𝑇 ofthesystematanyinstantisgivenbytheequipartitiontheorem:

    12𝑁u𝑘v𝑇 = 𝐾𝐸 ⇒ 𝑇 =

    2𝐾𝐸𝑁u𝑘v

    =∑ 𝑚\𝑣\YZ\sX𝑁u𝑘v𝑇

    where𝑁u isthedegreesoffreedom(usually𝑁u = 3𝑁 − 3)and𝑘v istheBoltzmannconstant.

    (d)Thepressure𝑃 ofthesystematanyinstantisgivenbyvirialequation

    𝑃𝑉 = 𝑁𝑘v𝑇 −13r �⃗�\ { 𝑟\

    Z

    \sX⇒ 𝑃 =

    𝑁𝑘v𝑇𝑉

    −13𝑉

    r �⃗�\ { 𝑟\Z

    \sX

    where denotes averageoverallatomsinthesystem.

    IngredientsofMolecularDynamicsSimulations

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 16

  • RaymondAtta-Fynn

    Ingredient4:Basicmoleculardynamicsobservables:(c)Thetemperature 𝑇 ofthesystematanyinstantisgivenby:

    12𝑁u𝑘v𝑇 = 𝐾𝐸 ⇒ 𝑇 =

    2𝐾𝐸𝑁u𝑘v

    =∑ 𝑚\𝑣\YZ\sX𝑁u𝑘v𝑇

    where𝑁u isthedegreesoffreedom(usually𝑁u = 3𝑁 − 3)and𝑘v istheBoltzmannconstant.

    (d)Thepressure𝑃 ofthesystematanyinstantisgivenbyvirialequation

    𝑃𝑉 = 𝑁𝑘v𝑇 −13r �⃗�\ { 𝑟\

    Z

    \sX⇒ 𝑃 =

    𝑁𝑘v𝑇𝑉

    −13𝑉

    r �⃗�\ { 𝑟\Z

    \sX

    where denotes averageoverallatomsinthesystem.

    IngredientsofMolecularDynamicsSimulations

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 17

  • RaymondAtta-Fynn

    Ingredient5:Thermodynamicensembles:Anensemble,withinthecontextofstatisticalthermodynamics,denotesanassemblyofidenticalcopiesofasystemindifferentstates.Wewillconsideronlytwoofsuchensembles.

    (a)Microcanonicalor(N,V,E)ensemble:Inthisensemble,copiesofthesystemeachhavethesamenumberofparticles𝑁,thesamevolume𝑉,andthesameenergy 𝐸.Buteachcopycanbeinadifferentstate characterizedbytemperature𝑇 andpressure𝑃.

    Example: anmicrocanonicalensemblecomprising6copies;eachcopyhasthesamevaluesof𝑁,𝑉,and𝐸 [notethat𝑁 = 4].However,eachsystemcanbeindifferent𝑇 and𝑃 states.

    IngredientsofMolecularDynamicsSimulations

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 18

  • RaymondAtta-Fynn

    Ingredient5:Thermodynamicensembles:(b)Canonicalor(N,V,T)ensemble:Inthisensemble,copiesofthesystemeachhavethesamenumberofparticles𝑁,thesamevolume𝑉,andthesystemisconnectedtoaheatbath(orthermostat)tokeeptemperature 𝑇 constant.Buteachcopycanbeinadifferentstatecharacterizedbytheenergy𝐸 andpressure𝑃.

    Example: acanonicalensemblecomprising3copies;eachcopyhasthesamevaluesof𝑁,𝑉,and𝑇 [connectedtoheatbath].However,eachsystemcanbeindifferent𝐸 and𝑃 states.

    IngredientsofMolecularDynamicsSimulations

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 19

    heatbath𝑇

    heatbath𝑇

    heatbath𝑇

  • RaymondAtta-Fynn

    Ingredient6:ErgodicHypothesis:Ofteninmoleculardynamicssimulationsoneisinterestedinsomedynamicalproperty𝐴.

    Perstatisticalthermodynamics,arepresentativevalueofthequantity𝐴 istheaveragevalue𝐴 ,obtainedbyaveraging𝐴 isoveralargeensemble(i.e.overseveralcopies;seefig.below).

    Practically,computing 𝐴 isnotfeasible.Luckily,theergodichypothesis providesasolution.

    IngredientsofMolecularDynamicsSimulations

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 20

    ………… . 𝐴 isthevalueof𝐴 averagedoveralargeensemble

    ErgodicHypothesis:thetimeaveragedvalueof𝐴overalongtimespaninonlyasinglecopyofthesystem,denotedby �̅� isequaltotheemsembleaverage 𝐴 ,thatis,

    𝐴 = �̅�.

  • RaymondAtta-Fynn

    TemperatureControlinNVTsimulation:(i)Velocityscalingmethod

    = Scalevelocitiestomatchthetargettemperature[easytoimplement]= Efficient,butdoesnotcorrectlydescribedynamics

    (ii)Nose-Hooverthermostat= FictitiousdegreeoffreedomisaddedbutcorrectlydescribesNVTdynamics=Cancausetemperaturetofluctuate;notsoeasytoimplement

    (iii)Berendsenthermostat= Scalesvelocitiestomatchtemperature=Goodcompromisebetweenthe(i)and(ii);okaytouseinsimulations

    OtherConsiderations

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 21

  • RaymondAtta-Fynn

    Initialvelocities:Maxwell-Boltzmannvelocitydistribution= TheMaxwell-Boltzmann(MB)probabilityoffindingaparticlewithspeedvx atagiven

    temperatureT

    = Sameforvy and vz

    = Generaterandominitialatomicvelocitiesusingthe

    = Usetheequipartitiontheoremtoscaleeachinitialvelocity byafactor𝛾 sothatthekineticenergymatchesthetemperatureT :

    OtherConsiderations

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 22

    1/221( ) exp /

    2 2x x BB

    mP v mv k Tk Tπ

    ⎛ ⎞ ⎛ ⎞= −⎜ ⎟ ⎜ ⎟

    ⎝ ⎠⎝ ⎠

    2 2 23

    ( )B

    x y z

    k Tm v v v

    γ =+ +

  • RaymondAtta-Fynn

    Choosingthetimemoleculardynamicsstep∆𝑡

    = ∆𝑡 cannotbechosentobetoobigotherenergyconservationwillbedestroyed

    = Typically,∆𝑡 ≤ 4fs isemployed[fs denotes“femto-seconds” i.e.1fs = 10Xf].

    = Itisfairlycommontouse∆𝑡 = 1fs inpractice

    = Ifthecomputationalcostisverycheaporifhighlyaccuratedynamicalresultsarerequired,thenchoose∆𝑡 assmallaspossible.E.g.∆𝑡 = 0.1fs isconsideredsmall

    OtherConsiderations

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 23

  • RaymondAtta-Fynn

    MolecularDynamicsinAction

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 24

    Moleculardynamicssimulationsofachargedmetalioninteractingwithwatermoleculesatroomtemperature(300K).

  • RaymondAtta-Fynn

    Summary

    6/4/2019 NSFSummerSchool:Introduction toMolecularDynamics 25Calculate results and finish

    Set initial conditions and)( 0tir )( 0tiv

    Get the forces )( ii rF

    Use forces to olve the equations of motionnumerically over a short step

    )()( ttt ii Δ+→ rr)()( ttt ii Δ+→ vv

    ttt Δ+=

    Is ?maxtt >

    If NVT ensemble, then use thermostat to control temperature T