1、单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,2,#,Lammps,程序,1,2025/8/12 周二,关于,lammps,基础知识,lammps,的输入文件一般分为,4,个部分,Initialization,Atom definition,Settings,Run a simulation,,,后面的两个部分可以按照需要多次重复,;,2,2025/8/12 周二,(1)Initialization,在你的模拟体系定义之前,一些参数必须要被设置,.,相关的命令有,:units,dimension,newton,processors,boundary,ato
2、m_style,atom_modify,。,其中,,units:,选择单位系统,lammps,提供了,lj,、,real,、,metal,三种单位系统,;,dimension:2d,模拟还是,3d,模拟,默认是,3d,;,boundary:,边界条件:周期性边界,or,自由边界,;,atom_style:,定义你的模拟体系中的原子属性,注意这个,style,要区分后面设置力场参数时命令里提到的,atom type,;,还有,这些命令告诉,lammps,在你的模拟中使用何种力场,:pair_style,bond_style,angle_style,dihedral_style,improper_
3、style.,3,2025/8/12 周二,在,LJ,类型中,所有变量都是无单位的,,,实际量换算成简化单位量有系列公式,缺省状态默认为,LJ,类型,4,2025/8/12 周二,(,2,),Atom definition,lammps,提供,3,种方式定义原子,:,通,过,read_data,或,read_restart,命令从,data,或,restart,文件读入,这些文件可以包含分子拓扑结构信息,.,按照晶格的方式创建原子,(,不包含分子拓扑信息,),你会用到这几个命令,:lattice,region,create_box,create_atoms.,已经设置好的原子可以用,repli
4、cate,命令复制以生成一个更大规模的模拟体系,.,5,2025/8/12 周二,(3)Settings,原子和分子的拓扑信息定义好后,你要制定一系列的设置,:,力场系数、模拟参数、输出选项 等等,.,力场系数可以通过这些命令定义,:pair_coeff,bond_coeff,angle_coeff,dihedral_coeff,improper_coeff,kspace_style,dielectric,special_bonds.,注意,其实力场系数也可以在,data,文件中制定,;,各种模拟参数由这些命令设置,:neighbor,neigh_modify,group,timestep,r
5、eset_timestep,run_style,min_style,min_modify.,6,2025/8/12 周二,Suppliment,fix,命令是,lammps,中很重要的一个命令,它包括很多子命令,可以施加一系列的边界条件、时间积分、诊断选项等等,;,fix,指令的用途是对一组原子进行定义,可以用于更新原子的位置、速度、控制温度、加常力、施加边界条件等。当两个或更多,fix,在同一过程中作用时,根据程序中的先后顺序执行,fix,指令。,Fix,指令可通过,unfix,指令来消除,形式为,unfix fix-ID),模拟过程中通过下面的命令制定,lammps,进行各种计算,:com
6、pute,compute_modify,variable.,输出选项由,thermo,dump,restart,命令设置,.,7,2025/8/12 周二,fix ID group,ID style args ID=user,assigned name for the fix ID,是用自己定义的名字,便于通过,fix,定义,group,ID=ID of the group of atoms to apply the fix to style=one of a long list of possible style names(see below)args=arguments used by
7、a particular styleExamples:fix 1 all nvefix 3 all nvt temp 300.0 300.0 0.01fix mine top setforce 0.0 NULL 0.0,8,2025/8/12 周二,对于,run 100 start 0 stop 1000,这个语句来说,主要与,fix,语句配合使用。,fix 1 all nvt 200.0 300.0 1.0,这两个指令的功能是在接下来的,1000,步运行中,每,run 100,步,,,温度都要从,200,度升到,300,度,9,2025/8/12 周二,fix 1 all nvt 200.0
8、 300.0 1.0,对于左侧的一组指令,温度随着从,0,到,10000,步的执行,run 1000 start 0 stop 10000,逐渐升至,300.0,度,是一个发生在整个过程的渐变行为,run 1000 start 0 stop 10000.run 1000 start 0 stop 10000,(共,10,个),10,2025/8/12 周二,至于,pre and post,大概是这样的,,pre no,的意思是跳过初始设定阶段,如果以下的计算是承接之前运行命令的话(意思是采用之前的参数)但是如果该,run,指令是第一个指令是,该设定会被忽略。,若是,post no,,则跳过,f
9、ull timing summary,输出,one-line summary timing,11,2025/8/12 周二,Every,的作用是将一个,run,分成一系列较短的,runs variable q equal x run 6000 every 2000 print Coord=$q,每运行,2000,步输出一次某原子的,x,坐标值,12,2025/8/12 周二,要设定一组原子的温度,那么用,group,命令定义哪些原子属于这个组才行,;,每个命令的详细介绍中的,Restrictions,部分会说明要使用该命令定义的时候哪些命令必须要被预先定义,;,如果你的输入文件书写的格式有问题
10、lammps,在执行的时候会提示,ERROR,或者,WARNING,出现类似信息时,你可以到手册的第九章中查询原因,;,13,2025/8/12 周二,(4)Run a simulation,使用,run,命令开始一个分子动力学模拟,用,minimize,命令来实施能量最小化,(molecular statics),使用,temper,命令来进行,parallel tempering(replica-exchange)simulation.,14,2025/8/12 周二,Commands listed by category,15,2025/8/12 周二,Initialization:a
11、tom_modify,atom_style,boundary,dimension,newton,processors,units;,Atom definition:create_atoms,create_box,lattice,read_data,read_restart,region,replicate;,Force fields:angle_coeff,angle_style,bond_coeff,bond_style,dielectric,dihedral_coeff,dihedral_style,improper_coeff,improper_style,kspace_modify,k
12、space_style,pair_coeff,pair_modify,pair_style,pair_write,special_bonds;,16,2025/8/12 周二,Settings:communicate,dipole,group,mass,min_modify,min_style,neigh_modify,neighbor,reset_timestep,run_style,set,shape,timestep,velocity;,Fixes:fix,fix_modify,unfix;,Computes:compute,compute_modify,uncompute;,Outpu
13、t:dump,dump_modify,restart,thermo,thermo_modify,thermo_style,undump,write_restart;,Actions:delete_atoms,delete_bonds,displace_atoms,displace_box,minimize,run,temper;,Miscellaneous:clear,echo,if,include,jump,label,log,next,print,shell,variable.,17,2025/8/12 周二,Lammps,中特殊符号含义,(1),命令行后的,&,表示这一行跟下一行是同一条
14、命令,.,(2),命令行最开始的,#,表示这一行在执行过程中被忽略,你可以用它来写注释,.,(,3,),$,是跟声明变量有关系的,。,(4),命令行被,tabs,spaces,间隔成各个,“words”,注意这里的,“words”,可以包含字母、数字、下划线、或标点符号,.,18,2025/8/12 周二,(5),一行中第一个词是命令名,后续的词是相关的参数,.,(6),双引号内的文字空格被整体地当作一个参数,其中的,#,或,$,就没有前面说的作用了,.,19,2025/8/12 周二,Pure Cu crystal,20,2025/8/12 周二,(1)Initialization,unit
15、s,metal,金属单位制:,mass=grams/mole,质量:,g/mol,distance=Angstroms,距离:埃,time=picoseconds,时间:皮秒,energy=eV,能量:,velocity=Angstroms/picosecond,速度,force=eV/Angstrom,力:,21,2025/8/12 周二,temperature=degrees K,温度,pressure=bars,压力,dynamic viscosity=Poise,动力学粘性系数:泊,charge=multiple of electron charge(+1.0 is a proton)
16、电荷:电荷整数倍,dipole=charge*Angstroms,偶极矩,electric field=volts/Angstrom,density=gram/cmdim,torque=eV,力矩,22,2025/8/12 周二,atom_style,charge,原子属性:带电粒子系统,dimension 3,维数:,3,boundary p p p,边界条件:,p is periodic p,指周期性,f is non-periodic and fixed,:固定非周期,s is non-periodic and shrink-wrapped,:收缩的非周期性的,m is non-per
17、iodic and shrink-wrapped with a minimum value,有最小值的收缩的非周期,23,2025/8/12 周二,(,2,),Atom definition,lattice,fcc 3.615,晶格点阵:,Lattices of style sc,fcc,bcc,and diamond are 3d lattices that define a cubic unit cell with edge length=1.0.fcc,类型的点阵是定义的一个边长为,1.0,埃的立方体三维晶格点阵,specifying scale=3.,would create a cu
18、bic lattice with a spacing of,Angstroms.,边长为,3,。埃,24,2025/8/12 周二,region,box block 0 4 0 4 0 4,区域:以,0 4 0 4 0 4,为立方箱、边界条件;,create_box,1 box,在上述区域创建一个只有,1,个原子类型的模拟箱,The argument N is the number of atom types that will be used in the simulation,create_atoms,1 box,:,This command creates atoms on a latt
19、ice,or a single atom,or a random collection of atoms,as an alternative to reading in their coordinates explicitly via a read_data or read_restart command.A simulation box must already exist,which is typically created via the create_box command.Before using this command,a lattice must also be defined
20、 using the lattice command.The only exceptions are for the single style with units=box or the random style.,这个命令用于在晶格点阵、单个原子和原子随机组合中创建原子,这样通过从文件中读数据命令读出原子在晶格中的相对位置来替代原子的位置坐标。,25,2025/8/12 周二,For the box style,the create_atoms command fills the entire simulation box with atoms on the lattice.If your
21、simulation box is periodic,you should insure its size is a multiple of the lattice spacings,to avoid unwanted atom overlaps at the box boundaries.If your box is periodic and a multiple of the lattice spacing in a particular dimension,LAMMPS is careful to put exactly one atom at the boundary(on eithe
22、r side of the box),not zero or two.,对于箱类型,创建原子命令是针对整个模拟箱的,同时原子必须在格点上,若模拟箱是周期性的,你必须确保它的大小是一个晶格间距的整数倍以避免边界上不必要的原子重叠。若箱在特定的维度是周期性的,并且它的大小是一个晶格间距的整数倍,,lammps,就会在边界两侧各放一个原子。,26,2025/8/12 周二,mass,1 63.54,只有一种原子类型,且该原子类型的质量为,63,,,54g/mol,pair_style,comb,电荷之间作用,力场,类型为:,晶格,体系之间的作用势Set the formula(s)LAMMPS us
23、es to compute pairwise interactions.In LAMMPS,pair potentials are defined between pairs of atoms that are within a cutoff distance and the set of active interactions typically changes over time.确立lammps计算,粒子,之间相互作用的方程式。,27,2025/8/12 周二,pair_coeff*b Cu,Specify the pairwise force field coefficients fo
24、r one or more pairs of atom types.The number and meaning of the coefficients depends on the pair style.,指定一种或多种粒子对之间势能的力场系数,其含义和数值由粒子对类型决定。系数由cu的作用力场决定,28,2025/8/12 周二,neighbor0.5 bin,邻位原子,参数为0,.,5,以二机制算法,The style value selects what algorithm is used to build the list.The bin style creates the list
25、 by binning which is an operation that scales linearly with N/P,the number of atoms per processor where N=total number of atoms and P=number of processors.,类型选择决定建立列表时的算法,其中,bin类型表示通过分级建立列表该列表以n/p的规模线性拓展。,29,2025/8/12 周二,neigh_modifyevery 1 delay 1 check yes,该命令用于,设置,影响粒子,之间,势能和列表的参数,The every,delay
26、check,and once options affect how often lists are built as a simulation runs.The delay setting means never build a new list until at least N steps after the previous build.The every setting means build the list every M steps(after the delay has passed).If the check setting is no,the list is built o
27、n the 1st step that satisfies the delay and every settings.If the check setting is yes,then the list is only built on a particular step if some atom has moved more than half the skin distance(specified in the neighbor command)since the last build.If the once setting is yes,then the neighbor list is
28、only built once at the beginning of each run,and never rebuilt.This should only be done if you are certain atoms will not move far enough that the list should be rebuilt.E.g.running a simulation of a cold crystal.,The every,delay,check,and once 这些选项会影响随着模拟的进行,列表多久会,更新,一次。延迟设置意味着不建立一个新的列表,直到在以前的版本进行N
29、个步骤后。,every设置意味着每m步生成列表(延迟后已通过)。,如果If the check setting is no,,该列表是建立在第一步基础上,并满足every,delay设置的。如果检查设置为Yes,则该列表是建立在一个特定的步骤上,如果一些原子移动自上次构建一半以上的,小,距离(neighbor命令中指定)。如果once设置yes的话,那么列表中只有在每次运行开始时创建,而从来没有重建,,你必须确定原子不会运动的太远以至于你必须重建列表。例如运行模拟冷晶体,。,30,2025/8/12 周二,#dump1 all custom 10 tmp.dump id type xs ys
30、zs q vx vy vz,fx fy fz,输出,单个原子的,热力学信息,:对于所有的原子体系以,1,为自定义名字,以常规文本类型输出,每,10,步输出一次结果到,tmp.dump,文件,并且输出以下参数:自定义名字,类型,原子的分数坐标,象限,速度,,#dump_modify1 append yes element Cu,更改输出值及文本的格式,31,2025/8/12 周二,fix1 all nve,指定 NVE是微正则系综,宏观上的孤立系统:即N、V、E三个参数是不变的;Set a fix that will be applied to a group of atoms.In LAMM
31、PS,a fix is any operation that is applied to the system during timestepping or minimization.Fixes perform their operations at different stages of the timestep设定对于一组原子适用的常数,一个常数代表一个适用于在时间步和最小化过程的系统的操作,常数在特定时间步中实现其操作。,32,2025/8/12 周二,timestep 0.00020,时间步长,thermo_stylecustom step temp etotal pe evdwl e
32、coul press vol lx ly lz xz,输出:,系统常规属性:时间步长,温度,总能量,势能,范德瓦耳斯能量,库伦能,压力,体积,箱的边长,三斜晶系(非正交)的模拟箱的倾斜角,33,2025/8/12 周二,对比,press,stress,thermo-style,同样是计算力的,三者有什么主要区别呢?,press,是系统力,,stress,是原子应力,,用,thermo_style,输出的,pxx,是整个系统,(,包括边界,),全部原子的势能应力在,XX,方向分力的平均值,为标量,;,thermo_style,输出的,press,是整个系统,(,包括边界,),全部原子的势能应力,
33、6,方向合力的平均值,为标量,;,compute stress/atom,算出来的是每个原子的,6,个方向应力值,(,注意,LAMMPS,算出来的这个值是没有除体积的,),每个原子都有一个这样的,vector,里面有,6,个量,.,34,2025/8/12 周二,thermo_modifynorm yes,Set options for how thermodynamic information is computed and printed by LAMMPS为热动力学信息的计算设置选项,norm keyword determines whether various thermodynami
34、c output values are normalized by the number of atoms or not,depending on whether it is set to yes or no.Different unit styles have different defaults for this setting(see below).Even if norm is set to yes,a value is only normalized if it is an extensive quantity,meaning that it scales with the numb
35、er of atoms in the system.norm,关键词设置为是或者否,决定不同的热动力学结果的数值是否通过原子的数量进行归一化求解。不同的单位类型有对于设置具有不同的默认值,即使被设定为是,数值也只有在数值很大时才被归一化,即它可以和体系的原子数目相比时才要归一化。,35,2025/8/12 周二,velocityall create 10.1 2398378,Set or change the velocities of a group of atoms in one of several styles.For each style,there are required arg
36、uments and optional keyword/value parameters.The create style generates an ensemble of velocities using a random number generator with the specified seed as the specified temperature.,设置及改变一种或多种原子类型的原子的速度。对于每种类型的原子,有特定自变量和特定的关键词或参量。creat类型通过一个随机数生成设备,利用特定的初始温度创建一个整体速度。,36,2025/8/12 周二,thermo 1,N=out
37、put thermodynamics every N timesteps 每N步输出一次热动力学量的结果,run 10,运行10次,37,2025/8/12 周二,The end of pure Cu,38,2025/8/12 周二,supliment,PS,的输出文件主要可以分为三种:一种是,log.lammps,,这里面记录了,整个计算过程屏幕上显示的所有信息,可由,thermo,、,thermo_modify,等命令控制;另一种是输出应力、能量、原子位置、速度等等信息,由,dump,命令控制输出文件;第三种是断点续算的,restart,文件输出信息,,由,write_restart,命令
38、控制,39,2025/8/12 周二,dump,Dump,命令主要是用来输出计算后单个原子的相关信息的。,Dump ID group-ID style N file args,ID:,自己给这个,dump,命令定义的一个代号(随便取),group-ID,:那些信息需要被输出的原子群(预先定义好,group,),style,:类型,N,:,每,经过多少时间步输出信息,File,:输出名称,Args,:相关参数(每个类型不同),40,2025/8/12 周二,注意:对于周期性边界条件而言,输出的原子坐标可能不在盒子定义的范围之中,因为,because periodic boundary condi
39、tions are enforced only on timesteps when neighbor lists are rebuilt,(个人翻译,不很确定:只有当临位原子列表被更新的时候,周期性边界条件才执行)。同时还需注意的是,当,lammps,并行运算的时候,输出的原子信息的秩序可能有点混乱。因为,同一个量的相关信息可能来自于不同的处理器。一般这种情况多出现在,atom,bond,and,custom,styles,。对于,style xyz,,当,group,的值不是,all,的时候也会出现这种情况。而,dcd,and,xtc,styles,这两种类型输出的原子都是按顺序排列好的。当
40、xyz,的,group,是,all,的时候,原子也是按序排列的。,41,2025/8/12 周二,Style,这个关键词定义了输出量以及相关的格式。通过,dump_modify,可以改变输出值以及文件本身的格式。,atom,bond,and,custom,styles,这些类型输出的都是比较简单的文本格式,直接打开就可以阅读里面的内容。一些,lammps,的后处理工具例如,Pizza.py,也可以处理这种文件。,对于,atom,类型,原子的坐标,,ID,,以及类型被输出到,dump,文件中。默认情况下,原子的坐标以分数坐标的形式显示。,42,2025/8/12 周二,举个简单例子,如果定义的
41、盒子长度,=xh-xl,,则原子的分数坐标,x0=,(,x-xl,),/(xh-xl),。通过,dump_modify,可以把分数坐标变为绝对坐标。同时,,Image flags,也可以在,dump_modify,中进行相应的设置。,43,2025/8/12 周二,对于,bond,类型,原子间的键拓扑信息输入到文件中,格式与在,read-data,命令中的,data,中指明的格式一致。(简单点就是与,data,中设置的,bond,的格式一致)。同时与键有关的原子的信息也会输入到,dump,文件中。运行过程中,一旦有,bond,被破坏了,那么,bond style,会被置零,同时该键不输入到,f
42、ile,中。而那些被,turn off,的键(,see the fix shake or delete_bonds commands),的键类型将会被置负数输入到,file,中,44,2025/8/12 周二,文件以,.bin,结尾的话,则文件将以二进制的形式写出,这中方式只适用于,atom and custom style.,45,2025/8/12 周二,这一部分解释在,custom,类型中,哪些原子信息可以被输出。,Tag,是原子序号,,Mol,是分子序号(对于分子系统而言)。,X,y,z,是原子的绝对坐标,,xs,ys,zs,是原子的分数坐标(,0.0-1.0,),c_ID,and,c
43、IDN,用于输出,compute,命令计算出的标量或矢量。,ID,已经预先定义好了的。对此可以查看,compute,命令得到详细的信息。,c_IDN,表示的是输出标号为,ID,的,compute,计算出来的对应矢量的第,N,个分量。,46,2025/8/12 周二,f_ID and f_IDN,的作用与上面类似,只是换成了,fix,。因此,通过,dump,命令,我们几乎可以输出任意我们感兴趣的量。,xu,yu,zu,代表的是固定对于每个原子的实际运动坐标,,即某个原子运动出模拟区域后,不会删除自己并替换成镜像原子重新映射到模拟,box,内,,而是真实地给出原来原子的运动后坐标,不管它离开,box,多远。,47,2025/8/12 周二,但是在实际计算中,程序还是考虑镜像原子的,程序只不过记录镜像原子的坐标和模拟过程原子穿过了几次边界,也就是,ix,iy,iz,,结合映射到,box,内的镜像原子的坐标,就可以知道原来原子跑到哪里了。,适合周期性结构,但又存在大变形,超出计算,box,的情况。,用,xu,yu,zu,可以更直观和明确地显示原来每个周期单元的变形。,48,2025/8/12 周二,Merry Christmas,49,2025/8/12 周二,






