1、 作者: 御剑江湖 收录日期: 2011-03-31 发布日期: 2011-03-24 Commands 描述了lammps输入文件的格式和在定义lammps模拟所需要的命令. 1.1 LAMMPS input script 我们用lammps做分子动力学模拟, 需要一个输入文件. lammps在执行计算的时候, 从这个文本文件中逐行读入命令. 大多数情况, lammps输入文件中各个命令的顺序并不是很重要. 但是你要注意以下几点: (1) lammps并不是将你的输入文件全部读入之后才开始进行计算
2、的, 或者说, 每条命令在它被读入之后就会起作用了. 注意, 下面两组命令的执行效果是不相同的. timestep 0.5 run 100 run 100 和 run 100 timestep 0.5 run 100 (2) 有些命令只有在另一些命令已经被定义的情况下才有效. 例如如果你要设定一组原子的温度, 那么用group命令定义哪些原子属于这个组才行. (3) 还有一种情况就是: 命令B要用到命A设置的一些数值, 这样你
3、也不能颠倒这两个命令的顺序. 每个命令的详细介绍中的Restrictions部分会说明要使用该命令定义的时候哪些命令必须要被预先定义. 如果你的输入文件书写的格式有问题, lammps在执行的时候会提示ERROR或者WARNING , 出现类似信息时, 你可以到手册的第九章中查询原因. 1.2 Parsing rules 输入文件中的每一非空行都被认为是一条命令. lammps中命令的书写是对大小写敏感的, 不过一般的命令和参数都是小写的, 大写字母用于极少数的情况. (1) 命令行后的 & 表示这
4、一行跟下一行是同一条命令. 这一点跟FORTRAN很像. (2) 命令行最开始的 # 表示这一行在执行过程中被忽略, 你可以用它来写注释. (3) $ 是跟声明变量有关系的, 我暂时还没用到过, 具体请参阅variable命令的详细介绍. (4) 命令行被tabs, spaces间隔成各个“words”, 注意这里的“words”可以包含字母、数字、下划线、或标点符号. (5) 一行中第一个词是命令名, 后续的词是相关的参数. (6) 双引号内的文字空格被整体地当作一个参数
5、 其中的 # 或 $ 就没有前面说的作用了. 1.3 Input script structure lammps的输入文件一般分为4个部分Initialization, Atom definition, Settings, Run a simulation 后面的两个部分可以按照需要多次重复. Remember that almost all the commands need only be used if a non-default value is desired. (1) Initialization 在你的模拟体系定义之
6、前, 一些参数必须要被设置. 相关的命令有:units, dimension, newton, processors, boundary, atom_style, atom_modify. units: 选择单位系统, lammps提供了lj、real、metal三种单位系统 dimension: 2d模拟还是3d模拟, 默认是3d boundary: 边界条件:周期性边界or自由边界 atom_style: 定义你的模拟体系中的原子属性, 注意这个style要区分后面设置力场参数时命令里提到的atom
7、type 还有, 这些命令告诉lammps在你的模拟中使用何种力场: pair_style, bond_style, angle_style, dihedral_style, improper_style. (2) Atom definition lammps提供3种方式定义原子: ① 通过read_data或read_restart命令从data或restart文件读入, 这些文件可以包含分子拓扑结构信息. ② 按照晶格的方式创建原子(不包含分子拓扑信息), 你会用到这几个命令: lattice, regi
8、on, create_box, create_atoms. ③ 已经设置好的原子可以用replicate命令复制以生成一个更大规模的模拟体系. (3)Settings 原子和分子的拓扑信息定义好后, 你要制定一系列的设置: 力场系数、模拟参数、输出选项 等等. 力场系数可以通过这些命令定义: pair_coeff, bond_coeff, angle_coeff, dihedral_coeff, improper_coeff, kspace_style, dielectric, special_bonds. 注意, 其实力场系数也可以在d
9、ata文件中制定, 详见read_data命令介绍. 各种模拟参数由这些命令设置: neighbor, neigh_modify, group, timestep, reset_timestep, run_style, min_style, min_modify. 我觉得fix命令是lammps中很重要的一个命令, 它包括很多子命令, 可以施加一系列的边界条件、时间积分、诊断选项等等. 模拟过程中通过下面的命令制定lammps进行各种计算: compute, compute_modify, variable. 输出
10、选项由thermo, dump, restart命令设置. (4)Run a simulation 使用run命令开始一个分子动力学模拟, 用minimize命令来实施能量最小化(molecular statics), 使用temper命令来进行parallel tempering(replica-exchange) simulation. 1.4 Commands listed by category 这一节分门别类地列出了lammps的所有命令. 注意有些命令的有些选项是特定的lammps package的一部分, 也就是说只有在编译
11、lammps的时候包括了这些packages, 这些命令才能被使用. 默认情况下编译lammps并不包括所有的packages. 这些依赖关系在相关命令的详细介绍中Restrictions部分中列出了. Initialization: atom_modify, atom_style, boundary, dimension, newton, processors, units Atom definition: create_atoms, create_box, lattice, read_data, read_restart, region, r
12、eplicate Force fields: angle_coeff, angle_style, bond_coeff, bond_style, dielectric, dihedral_coeff, dihedral_style, improper_coeff, improper_style, kspace_modify, kspace_style, pair_coeff, pair_modify, pair_style, pair_write, special_bonds Settings: communicate, dipole, group,
13、 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 Output: dump, dump_modify, restart, thermo, thermo_modify, thermo_style, undump,
14、 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 作者:御剑江湖 一、各种文件的介绍: 1 in file:建立该文件以便程序的写入 2 log file:写入状态信息(if the switc
15、h is used?) 3 screen file 决定结果的是否进行屏幕输出 4 var name file 定义一个变量,name指变量名,可为字母也可为字符串,形式$x / $ {abc} 二、屏幕输出: 结果显示在屏幕上,同时在log file 中。开始前LAMMPS计算出所需的存储空间,运行中每隔几个时步显示一次热力学状态,直至输出最终状态。 Loop time of 49.002 on 2 procs for 2004 atoms 该部分显示了几个大类的计算时间 Pair time (%) = 35.0495 (71.5267)
16、 Bond time (%) = 0.092046 (0.187841) Kspce time (%) = 6.42073 (13.103) Neigh time (%) = 2.73485 (5.5811) Comm time (%) = 1.50291 (3.06703) Outpt time (%) = 0.013799 (0.0281601) Other time (%) = 2.13669 (4.36041) Nlocal: 1002 ave, 1015 max, 989 min 每个处理器中特定原子的数目
17、Histogram: 1 0 0 0 0 0 0 0 0 1 Nghost: 8720 ave, 8724 max, 8716 min Histogram: 1 0 0 0 0 0 0 0 0 1 Neighs: 354141 ave, 361422 max, 346860 min Histogram: 1 0 0 0 0 0 0 0 0 1 Total # of neighbors = 708282 Ave neighs/atom = 353.434 Ave special neighs/atom = 2.3
18、4032 Number of reneighborings = 42 Dangerous reneighborings = 2 当运用了能量最小化命令进行能量最小化时,还将出现如下所示语句: Minimization stats: E initial, next−to−last, final = −0.895962 −2.94193 −2.94342 (显示初终能量以及next-to-last 循环的能量) Gradient 2−norm init/final= 1920.78 20.9992 (给出能量梯度,即所有原子的受力) Gradi
19、ent inf−norm init/final= 304.283 9.61216 2-form是力向量的长度,inf-form是最大构成? Iterations = 36 循环次数 Force evaluations = 177 对力进行评定的次数 当程序中有kspace_style long−range Coulombics solve,将会显示以下语句: FFT time (% of Kspce) = 0.200313 (8.34477) 完成3d FFT计算的时间及在总时
20、间中占的百分比 FFT Gflps 3d 1d−only = 2.31074 9.19989 每秒执行的浮点指令次数(flops)为5N*log(2N),N为3维晶体中的节点数 The 3d rate is with communication; the 1d rate iswithout (just the 1d FFTs). 在GPU(图形处理单元)上的运行 三、指令系统介绍(*) 一般来说指令的顺序并不重要,胆在以下几种情况中必须注意: 1 LAMMPS并不是全部读完所有指令才执行,而是读
21、一行执行一次,因此下面的两组语句是不同的: timestep 0.5 以下的两个模拟其步长均为0.5 fmsec run 100 run 100 run 100 第一个模拟采用缺省值步长为1 fmsec timestep 0.5 run 100 第二个采用步长为0.5 fmsec 2 某些指令只在其他指令之后才生效,如要得到系统温度必须先进行各种定义 3 若A指令在B之前,B可以引用A定义的变量 四、语法规则
22、 在LAMMPS中要区分大小写,一般指令名称用小写字母,文件及用户定义ID Strings 用大写。 LAMMPS对每行语句的语法要求如下: 1 当语句太长一行放不下时,在语句一行结束的时候输入字符 “” 表示下一行的语句接着上一行继续。 2 在#之后输入的字符认为是评论语句,是无用的,但有例外 3 紧跟在$后定义变量(之前讲过) 4 单词间用空格隔开 5 第一个词为指令名,接下来的字母全都为自变量(arguments) 6 If
23、you want text with spaces to be treated as a single argument, it can be enclosed in double quotes 五、输入的语句结构 一个普通的LAMMPS程序通常由以下四部分组成: 1 初始化 2 原子定义 3 设定 4 进行模拟 初始化阶段:设定所需参数,相关各项命令,引入所需的力场参数 相关命令介绍: 1 units command 语句形式: units style · style = lj or r
24、eal or metal or si or cgs or electron Examples: units metal units lj 该语句定义了单元类型,除了LJ类型,其他物理常量来自于某网,定义实际单元的热能=4.184J。 而在LJ类型中,所有变量都是无单位的(参考陈义龙的论文) 实际量换算成简化单位量有系列公式。 以下列出了换算关系及其它各种类型中所使用的标准单位。 This command cannot be used after the simulation box is defined by a read_data or cr
25、eate_box command. 缺省状态默认为LJ类型 2 语句形式: dimension N · N = 2 or 3 例如:dimension 2 一般缺省为3d模拟,2d模拟的话要在建立simulation box之前进行设定(其余省略) COMMANDS LISTED BY CATEGORY 以下列出的LAMMPS命令以按类分好,其分类情况如下: 初始化指令:atom_modify, atom_style, boundary, dimension, newton, processors, u
26、nits 原子定义指令:create_atoms, create_box, lattice, read_data, read_restart, region, replicate 力场指令:angle_coeff, angle_style, bond_coeff, bond_style, dielectric, dihedral_coeff, dihedral_style, improper_coeff, improper_style, kspace_modify, kspace_style, pair_coeff, pair_modify, pair_style, pair_wr
27、ite, special_bonds 设定指令: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 Output: dump, dump_modify, restart, thermo, the
28、rmo_modify, thermo_style, undump, write_restart Actions: delete_atoms, delete_bonds, displace_atoms, displace_box, minimize, prd, run, temper Miscellaneous: clear, echo, if, include, jump, label, log, next, print, shell, variable 六 how to discussions() 重启一个模拟。有3种方法继续长的LAMMPS程序。
29、在同一个程序中可多次使用运行命令。每次运行都会接着上一条运行指令(run command)进行。Binary file 使用restart command将binary files存入硬盘中,之后用read-restart命令可将binary file读出。或者可转为text data files,经read-data命令读出。restart2data 涉及到的命令: 1 run command syntax run N keyword values……(N= # of timesteps; zero or more keyword/v
30、alue pairs may be appended; keyword= upto or start or stop or pre or post or every) Examples: run 10000 # 运行10000步;N=0意味着直接把现系统的热力学值输出 run 1000000 upto # 从当前开始一直运行至upto所指定的数值(该语句意为运行至10000000步止) run 100 start 0 stop 1000 run 1000 pre no post yes run 100000 start 0 stop 1000000 ev
31、ery 1000 "print Protein Rg = $r" run 100000 every 1000 NULL (补充说明 fix 指令: Syntax: 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
32、 names (see below) · args = arguments used by a particular style Examples: fix 1 all nve fix 3 all nvt temp 300.0 300.0 0.01 fix mine top setforce 0.0 NULL 0.0 fix指令的用途是对一组原子进行定义,可以用于更新原子的位置、速度、控制温度、加常力、施加边界条件等。当两个或更多fix在同一过程中作用时,根据程序中的先后顺序执行fix指令。Fix指令可通过unfix指令来消除,形式为unfix fix-ID
33、) 对于run 100 start 0 stop 1000 这个语句来说,主要与fix语句配合使用。 fix 1 all nvt 200.0 300.0 1.0 这两个指令的功能是在接下来的1000步运行中,每 run 1000 步的温度都要从200度升到300度 fix 1 all nvt 200.0 300.0 1.0 对于左侧的一组指令,温度随着从0到10000步的执行 run 1000 start 0 stop 10000 逐渐升至300.0度,是一
34、个发生在整个过程的渐变行为 run 1000 start 0 stop 10000 ... run 1000 start 0 stop 10000(共10个) 至于pre and post大概是这样的,pre no 的意思是跳过初始设定阶段,如果以下的计算是承接之前运行命令的话(意思是采用之前的参数) 但是如果该run指令是第一个指令是,该设定会被忽略。 注意:当两次运行指令之间使用了修改设定值的命令时(比如fix等),pre no是不允许的,必须重新设定,否则报错 若是post no,则跳过full timing summary, 输出o
35、ne-line summary timing Every 的作用是将一个run分成一系列较短的runs variable q equal x[100] run 6000 every 2000 "print Coord = $q" 每运行2000步输出一次某原子的x坐标值 Default: The option defaults are start = the current timestep, stop = current timestep + N, pre = yes, and post = yes. 在ru
36、n语句中的缺省值 2 restart command (将binary files存入硬盘) restart文件是lammps的一种输出文件形式 Syntax: restart 0 N = write a restart file every this many timesteps restart N root root = filename to which timestep # is appended restart N file1 file file1,file2 = two full filenames, toggle b
37、etween them when writing file Examples: restart 0 restart 1000 poly.restart restart 1000 restart.*.equil restart 10000 poly.%.1 poly.%.2 restart 0 意味着不输出restart files。与dump文件一样,restart不能包含两个wild card characters(即通配符)。若filename中含有*号,则它会被目前的值所代替(该情况只在仅有一个filename的情况下成立) 作者:wuchenwf 不错 作者:sg18408926 :D:D:D:D 作者:zb1123 :tiger37: 作者:Camilleyuxia 给力,给力!:D:D 作者:Camilleyuxia 可以再增加点哦,对于我们新手来说真的很给力啊 作者:jiangtao9571 很详细,很有用! 作者:hwt010101 要是有更多这样的帖子就好了!:like:
©2010-2025 宁波自信网络信息技术有限公司 版权所有
客服电话:4009-655-100 投诉/维权电话:18658249818