zhoulong的个人博客分享 http://blog.sciencenet.cn/u/zhoulong

博文

LAMMPS输入命令

已有 7781 次阅读 2020-12-29 09:54 |个人分类:lammps|系统分类:科研笔记

Commands 

 

       描述了 lammps 输入文件的格式和在定义 lammps 模拟所需要的命令. 

 

1.1 LAMMPS input script 

 

        我们用lammps做分子动力学模拟, 需要一个输入文件. lammps在执行计算的时候, 从这个文本文件中逐行

读入命令. 大多数情况, lammps 输入文件中各个命令的顺序并不是很重要. 但是你要注意以下几点: 

 

        (1)  lammps 并不是将你的输入文件全部读入之后才开始进行计算的, 或者说, 每条命令在它被读入之后

就会起作用了. 注意, 下面两组命令的执行效果是不相同的. 

 

        timestep 0.5 

        run 100 

        run 100 

 

和 

 

        run 100 

        timestep 0.5 

        run 100 

 

        (2)  有些命令只有在另一些命令已经被定义的情况下才有效. 例如如果你要设定一组原子的温度, 那么用

group 命令定义哪些原子属于这个组才行. 

 

        (3)  还有一种情况就是: 命令 B 要用到命 A 设置的一些数值, 这样你也不能颠倒这两个命令的顺序. 

 

        每个命令的详细介绍中的 Restrictions 部分会说明要使用该命令定义的时候哪些命令必须要被预先定义. 

 

        如果你的输入文件书写的格式有问题, lammps 在执行的时候会提示 ERROR 或者 WARNING , 出现类似信息

时, 你可以到手册的第九章中查询原因. 

 

1.2 Parsing rules 

 

        输入文件中的每一非空行都被认为是一条命令. lammps 中命令的书写是对大小写敏感的, 不过一般的命令

和参数都是小写的, 大写字母用于极少数的情况. 

 

        (1)  命令行后的 & 表示这一行跟下一行是同一条命令. 这一点跟 FORTRAN 很像. 

 

        (2)  命令行最开始的 # 表示这一行在执行过程中被忽略, 你可以用它来写注释. 

 

        (3)   $ 是跟声明变量有关系的, 我暂时还没用到过, 具体请参阅 variable 命令的详细介绍. 

 

        (4)  命令行被 tabs, spaces 间隔成各个“words”, 注意这里的“words”可以包含字母、数字、下划线、或

标点符号. 

 

        (5)  一行中第一个词是命令名, 后续的词是相关的参数. 

 

        (6)  双引号内的文字空格被整体地当作一个参数, 其中的 # 或 $ 就没有前面说的作用了. 

 

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 

 

        在你的模拟体系定义之前, 一些参数必须要被设置.  相关的命令有:units, dimension, newton, processors, 

boundary, atom_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_style. 

 

(2) Atom definition 

 

        lammps 提供 3 种方式定义原子: 

 

        ① 通过 read_data 或 read_restart 命令从 data 或 restart 文件读入, 这些文件可以包含分子拓扑结构信息. 

 

        ② 按照晶格的方式创建原子(不包含分子拓扑信息), 你会用到这几个命令: lattice, region, create_box, 

create_atoms. 

 

        ③ 已经设置好的原子可以用 replicate 命令复制以生成一个更大规模的模拟体系. 

 

(3)Settings 

 

        原子和分子的拓扑信息定义好后, 你要制定一系列的设置: 力场系数、模拟参数、输出选项 等等. 

 

力场系数可以通过这些命令定义: pair_coeff, bond_coeff, angle_coeff, dihedral_coeff, improper_coeff, kspace_style, 

dielectric, special_bonds. 注意, 其实力场系数也可以在 data 文件中制定, 详见 read_data 命令介绍. 

 

    各种模拟参数由这些命令设置: neighbor, neigh_modify, group, timestep, reset_timestep, run_style, min_style, 

min_modify. 

 

        我觉得 fix 命令是 lammps 中很重要的一个命令, 它包括很多子命令, 可以施加一系列的边界条件、时间积

分、诊断选项等等. 

 

        模拟过程中通过下面的命令制定 lammps 进行各种计算: compute, compute_modify, variable. 

 

        输出选项由 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 的一部

分, 也就是说只有在编译 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, replicate 

 

        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, 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, 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 switch 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) 

 

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         每个处理器中特定原子的数目   

 

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.34032 

 

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  (给出能量梯度,即所有原子的受力) 

 

Gradient 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 计算的时间及在总时间中占的百分比 

 

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 并不是全部读完所有指令才执行,而是读一行执行一次,因此下面的两组语句是不同的: 

 

    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 定义的变量 

 

 

 

四、语法规则 

 

  在 LAMMPS 中要区分大小写,一般指令名称用小写字母,文件及用户定义 ID 

 

Strings 用大写。 

 

 

 

  LAMMPS 对每行语句的语法要求如下: 

 

1         当语句太长一行放不下时,在语句一行结束的时候输入字符 “” 表示下一行的语句接着上一行继续。 

 

2         在#之后输入的字符认为是评论语句,是无用的,但有例外 

 

3         紧跟在$后定义变量(之前讲过) 

 

4         单词间用空格隔开 

 

5         第一个词为指令名,接下来的字母全都为自变量(arguments) 

 

6         If 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 real 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 create_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, units 

 

原子定义指令: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_write, 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, thermo_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 程序。在同一个程序中可多次使用运行命令。每次运行都会接着上一

条运行指令(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/value 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 every 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 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) 

 

 

 

对于 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 度,是一个发生在整个过程的渐变行为 

 

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, 输出 one-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.   在 run 语句

中的缺省值 

 

 

 

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 between 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 的情况下成立)




https://blog.sciencenet.cn/blog-3437453-1264667.html

上一篇:LAMMPS中in文件结构等总结(自写)
下一篇:[转载]谈谈分子模拟中的能量最小化,弛豫和平衡态
收藏 IP: 202.201.139.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-25 08:34

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部