计算材料学第四章原子模拟方法赵纪军三束实验室,物理学院&高科技研究院Email:zhaojj@dlut.edu.cn,电话:847097484-4.Monte-Carlo方法计算材料学第四章MonteCarloDiceofCasino:randomnumberMonteCarlohotel,LasVegasMonteCarlo方法的来由-随机数MonteCarlo的思想起源于vonNeumann等人对裂变材料的中子扩散问题研究。在Metropolis等人建立了计算机模拟的MonteCarlo方法以后,这一方法在解决多粒子体系的相关物理问题的研究中被广泛使用。最早利用计算机模拟研究统计力学体系以及相关物理问题的是Metropolis等人于1953年在美国LosAlamos国立实验室的第一代电子计算机上完成的,并由此建立了计算机模拟的MonteCarlo方法。最早利用计算机模拟研究统计力学体系以及相关物理问题的是Metropolis等人于1953年在美国LosAlamos国立实验室的第一代电子计算机上完成的,并由此建立了计算机模拟的MonteCarlo方法。MonteCarlo方法的发展历史MonteCarlo方法的发展历史1968年,Wood建立了NPT正则系综的MonteCarlo方法。1969年Norman和Filinov建立了巨正则系综的MonteCarlo抽样方法。1987年Panagiotopoulos把MonteCarlo方法应用于Gibbs系综。1986年,Voter在点阵气体模型基础上提出了描述表面原子运动KineticMonteCarlo方法,被迅速应用于薄膜生长模拟。•MC方法在数学上成为随机模拟方法、随机抽样技术等;•MC方法的基本思想是:针对某一具体的问题,通过建立一个概率模型或随机过程模型,使其参数等于实际问题的解。MonteCarlo方法的基本思想WhatIsMCandWhatisitfor?•MCexploresthestatesofasystemstochasticallywithprobabilitiesthatmatchthoseexpectedphysically•Stochasticmeansinvolvingorcontainingarandomvariableorvariables,whichispracticemeansthatthemethoddoesthingsbasedonvaluesofrandomnumbers•MCisusedtogetthermodynamicaverages,thermodynamicpotentials(fromtheaverages),andstudyphasetransitions•MChasmanyotherapplicationsoutsidematerialsscience,whereiscoversalargerangeofmethodsusingrandomnumbers•CalledMonteCarlosincethatiswheregamblinghappens–lotsofchance!MonteCarlo积分-圆周率π的计算shothitsquarecirclettSS==π2121d()()d()()xxxxFxfxfxFxxxρρ=⎛⎞=⎜⎟⎝⎠∫∫MonteCarlo积分max21211max1()()xxxxxFfτττρζτ==−−≈∑xyx1x2f(x)分子动力学方法的局限统计力学与热力学简单回顾统计力学与热力学简单回顾系综平均系综平均¾简单抽样方法在随机选取事件(如:空间位型)时,只考虑事件存在的可能性,而不考虑事件本身存在的概率。¾在简单抽样过程中,统计平均量是通过已出现事件及其存在的概率进行统计平均而给出。¾抽样满足波尔兹曼统计,物理量A的期望值由下式给出:简单抽样∑∑==Γ−Γ−Γ≈ΓMlMlkTHkTHAA11)/)(exp()/)(exp()()(ProblemwithSimpleMCSamplingρ(s)isVerySharplyPeaked•ρ(s)isveryverysharp:Forasolid,fractionofstateswhereρ(s)issignificantis~e-N,whereN=numberofparticles(for100particlesyourchanceofchoosingarelevantstateis≈1ine100=1044,ie,never!)Statessρ(s)Samplingstatesherecontributes≈0tointegralAlmostallthecontributiontoanintegraloverρ(s)comesfromhere¾重要抽样方法在随机选取事件(如:空间位型)时,同时考虑事件存在的可能性和事件本身存在的概率。¾事件本身存在的概率通过Markov链中的转移矩阵而确定。¾在重要抽样过程中,统计平均量是通过已出现事件直接进行统计平均而给出。¾对于有限温度下的统计,不再是按照简单抽样那样随机生成样本,而是对温度T起重要作用的那些样本进行择优抽样。即采取与分布函数相同的概率形式抽取样本。重要抽样重要抽样Pickingstateswithabiasedprobablility:ImportanceSampling•Analgorithmtopickaseriesofstatessothattheyasymptoticallyappearwithprobabilityρ(s)=exp(-βE(s))1.Assumeweareinstatesi2.Chooseanewstates*,anddefineΔE=E(s*)-E(s)3.IfΔE0thenaccepts*4.IfΔE0thenaccepts*withprobabilityexp(-βΔE)5.Ifweaccepts*thensetsi+1=s*andreturnto1.instatesi+16.Ifwerejects*thenreturnto1.instatesi•ThisisaMarkovprocess,whichmeansthatthenextstatedependsonlyonthepreviousoneandnonebeforethan(notlikeMD).TheMetropolisAlgorithm(General)•Weonlyneedtoconsideratomicpositions(sincemomentadonotenterintoρ(s))1.Assumetheatomshavepositions(r1,…rj,…,rN)2.Chooseanewsetofpositionsrj*=rj+(2ε-1)δr,wherejischosenatrandomandδrisafixedsteplengthandεisarandomnumberbetween0and1.3.FindΔE=E(r1,…rj*,…,rN)-E(r1,…rj,…,rN)(notethatthiscanbedonequicklybeonlyrecalculatingtheenergycontributionofatomjanditsneighbors)4.IfΔE0thenacceptrj*5.IfΔE0thenacceptrj*withprobabilityexp(-βΔE)6.Ifwerejectrj*thenchangenothingandreturnto1•Theprobabilityofseeinganysetofcoordinates{r}willtendasymptoticallyto{}(){}()()expVZρβ=−rrrMetropolisAlgorithmforInteractingAtoms1.Startwithsomeconfiguration2.Chooseperturbationofthesystem,e.g.,moveoneatomfromRtoR′3.Computeenergychangeduetothatperturbation4.IfΔE0,acceptpertubation;IfΔE0,acceptperturbationwithprobabilityexp[-ΔE/kT]5.Choosenextperturbation6.……7.RunsufficientMCstepandaverageoverallthesestatesRR′MetropolisMonteCarlo样本的分布为正则分布,可以很好模拟NVT系综Metropolisetal.,J.Chem.Phys.21,1087(1958)随机数MonteCarlo轨迹ThermalAverageinMCδEMCStepEnergyEquilibrationperiod:Notequilibrated,thermalaverageswillbewrongConverged:Equilibrated,thermalaverageswillberightEObtainingThermalAveragesFromMC•TheMCalgorithmwillconvergetosamplestateswithprobabilityρ(s)=probabilityexpectedfromstatisticalmechanics.Soathermalaverageisgivenby•NotethatNmcsshouldbetakenafterthesystemequilibrates•Fluctuationsarealsojustthermalaveragesandcalculatedthesameway()()11mcsNisimcsAAssANρ===∑∑()()()211mcsNisimcsAAAAssANδδρδ=−===∑∑MetropolisAlgorithminDifferentEnsembles•StandardMCisforNVT.WhatdidwedotogetMCforNVT?–Writetheprobabilityofthesystembeinginstatesatequilibrium–Acceptstepss→s׳withprobabilitymax[1,(ρ(s׳)/ρ(s))=exp(-β(E(s׳)-E(s)](Metropolisalgorithm)•Sodothesameforanotherensemble,e.g.,NPT–Butwhatisρ(s׳)/ρ(s)?Onecanshow•ThendousualMetropolisalgorithmMCwithstepsin{r}andV(note,stepsinVrequirealotofrecalculationsotheyaredoneinfrequentlyandwithtricks)()()exp()EssZβρ−={}{}{}(){}()()1(,)ln(,)VPVPVNVVVρβφφβρ−′′⎡⎤′′′′=−−+−+⎣⎦rrrrMonteCarlo方法模拟系综性质的精度FiniteSizeEffect小结:MC方法是对系综的有效抽样MConSpinSystems•MCisoftenusedforspinsystems,usedtomodel,e.g.,magnetismandalloys.•TheIsingModel–eachsiteonalatticehasaspinthatcanbeupordown.Simplemodelformagneticmomentsinteractinginacrystal.({})1forupspin,-1fordownspinJ0ferromagneticorderingtendencyijijijiEJσσσσ≠==+⇒∑M