Lammps初学者——in文件中文解析
(1)初始化
Units:
Units命令是用来设定模拟的原子类型。
Units style(lammps现在提供的有style=LJ、real、metal、si、cgs、electron) LJ是硬球模型
Real是真实的原子模型 Metal是金属原子模型 Si是硅(半导体)原子模型 Cgs
Electron是电子模型 Dimension:
Dimension命令是用来定义模拟的维度,默认情况为三维。 Dimension N (N=2,3) Boundary:
Boundary命令是用来设定模拟的边界条件。
Boundary x y z (x,y,z=p,s,f,m四种类型中的一种或者两种) P是周期性边界条件
S是自由边界条件(但是具有收缩性)
F是固定边界条件
M是具有最小值的自由边界条件(但是具有收缩性) Atom-style:
Atom-style定义了模拟体系中的原子属性。 Delete-atoms: Pair-style:
Pair-style定义了相互作用力场类型,即势函数。 (2)原子定义
1、
Read-data/read-restart:
Read-data或read-restart为从data或restart文件中读取容来定义原子。 2、
Lattice:
lattice是用来原子类型构建模型晶格结构。 Lattice style scale keyword values...
Style表示点阵类型,点阵类型有none、sc、bcc、fcc、hcp、diamond、sq、sq2、hex、custom。
Scale表示构建的点阵类型的单位长度
Keyword表示后面可以追加0个或者多个关键字,关键字有origin、orient、spacing、
a1、a2、a3、basis。
各关键字意思为: Region: Create-box:
Create-box命令用于在region box命令指定的区域创建一个模拟的盒子。 Create_box N region-ID N为使用该原子类型进行模拟
Region-ID为使用区域的ID使用模拟域 Create-atoms:
Create-atoms用于在所创建的模拟的盒子中填充某种原子。 Create_atoms type style args keyword values ... (3)设定:
力场系数
Pair-coeff: 模拟参数
Neighbor Neighbor是定义 Neighbor skin style Skin为
Style可取bin、nsq、multi Neighbor-modify: Group: Timestep:
Timestep是定义模拟的时间步长。 Timestep dt
Dt为时间步长(时间单位),默认为1ps Reset-timestep: Fix
Fix为定义对部分原子或者对系综的操作。 lammps.sandia.gov/doc/fix.html Fix ID group-ID style args
ID=指定的操作名称编号(如1、2、3…….) Group-ID=制定操作围的原子(如all……) Style=操作容,如何操作 Args=相关操作容的相关操作参数
Fix-nvt:恒定N(原子数量)、V(体积)、T(温度)对时间积分 Fix-npt:恒定N、P、T对时间积分 Unfix:
Compute/compute-modify:
输出选项
Thermo:
Thermo命令用于定义每隔一定时间步长输出一次采样容。 Thermo N
每隔N个时间步长输出一次采样容至屏幕或者log文件 Thermo_style:
Thermo_style命令主要是用来说明采样的容,即输出到屏幕或者LOG文件中的容。(lammps.sandia.gov/doc/thermo_style.html)
Thermo_style style args Style=one、multi、custom Args=特定的参数列表 One args=none Multi args=none
Custom args=list of attributes
Possible attributes=step、elaosed、elaplong、dt、cpu、tpcpu、spcpu、 Atoms、temp、press、pe、ke、otatal、enthalpy、 Evdwl、ecoul、epair、ebond、eangle、edihed、eimp、 Emol、elong、etail、
Vol、lx、ly、lz、xlo、xhi、ylo、yhi、zlo、zhi、 Xy、xz、yz、xlat、ylat、zlat、
Pxx、pyy、pzz、pxy、pyz、pxz、 Fmax、fnorm、
Cella、cellb、cellc、cellalpha、cellbeta、cellgamma、 c_ID、c_ID[I]、c_ID[I][J]、 f_ID、f_ID[I]、f_ID[I][J]、 V_name Dump:
Dump命令主要是用来输出计算后单个原子的相关信息的。 Dump ID group-ID style N file args
ID:自己给这个dump命令定义的一个代号(自定义)
group-ID:那些信息需要被输出的原子群(预先定义好group) Style:类型
N:每经过多少时间步输出信息 File:输出名称
Args:相关参数(每个类型不同) Restart: (4)运行
Run: Minimize: 例一
units metal # 单位为lammps 中的metel 类型
boundary p p p # 周期性边界条件
atom_style atomic # 原子模式
lattice fcc 3.61 # Cu 的晶格常数3.61
region box block 0 4 0 4 0 4 # x,y,z 各方向上的晶胞重复单元数,也即区域大小
create_box 1 box # 将上述区域指定为模拟的盒子
create_atoms 1 box # 将原子按晶格填满盒子
pair_style eam # 选取 Cu 的EAM 势作为模型
pair_coeff * * Cu_u3.eam # EAM 势文件名称
run 0 # 运行0 步,仅为启动lammps 的热力学数据计算
variable E equal pe # 定义变量 E 为系统总势能
variable N equal atoms # 定义变量 N 为系统总原子数
print \"the number of atoms & system energy now are $N $E\" # 打印信息
create_atoms 1 single 2.45 2.05 2.05 # 在该位置插入一个原子
min_style sd # 能量最小化模式,sd
minimize 1.0e-12 1.0e-12 1000 1000 # 能量最小化参数,指数越大最小化程度越深
print \"interstitial introduced, minimized: $N atoms, energy is $E\"
fix 1 all nvt 100 100 100 drag 0.2 # nvt 系综,原子数、体积和温度保持不变;T=100K
timestep 0.005 # 步长 0.005fs
run 1000 # 运行 1000 步
print \"nvt performed, temperature up: $N atoms, total energy is $E\"
fix 1 all nvt 100 0.0001 100 drag 0.2 # nvt 系综,温度由100K 到0.0001K
run 1000 # 运行 1000 步
print \"nvt performed, temperature down: $N atoms, total energy is $E\"
compute 3 all pe/atom # 计算每个原子的势能
compute 4 all ke/atom # 计算每个原子的动能
compute 5 all coord/atom 3.0 # 计算每个原子的近邻原子数
dump 1 all custom 1 dump.atom id xs ys zs c_3 c_4 c_5 # 将信息写入dump.atom
min_style sd
minimize 1.0e-12 1.0e-12 10000 10000 # 再次能量最小化
print \"the final state: $N atoms, total energy is $E\" # 打印信息
~
例二
boundary  p s s                                    # 边界条件,拉伸方向是周期性,其余是自由边界;如果是薄膜拉伸则是两个周期性,块体则是三个周期性
units       metal                                     #单位制定义为metal
atom_style  atomic                              #原子类型自动
neighbor 2.0 bin                                   #截断半径相关的东西
neigh_modifydelay 1 check yes            # 邻近原子列表更新速度
#create geometry
lattice    fcc 3.61                                  # 定义晶胞为fcc,晶格常数3.61A
region  box block 0 30 0 3 0 3              30,宽和高是3
create_box 1 box                            create_atoms 1 box                          mass    1 63.546                          63.546
# potentials
pair_style    eam                           pair_coef   * * Cu_u3.eam                   #define groups
region     1 block INF 1 INF INF INF INF     #定义一个长方体区域叫box,长    #创建了这样一个box
#在box里创建了一种原子
#定义这种原子的质量是       # 定义势函数是EAM
#势所需要的参数在此文件里
# 定义了一个叫1
的区域
group  left region 1                                                    #定义此区域里的原子叫left
region   2 block  29 INF INF INF INF INF                    #定义了一个叫2的区域
group    right region 2                                               #定义此区域里的原子叫right
group    boundary union left right                               #定义left+ right = boundary
group     mobile subtract all left                                 # 定义mobile= all - left
# initialvelocities
velocity   left set 0.0 0.0 0.0                                      # 设置原子初速度为0
computep all pressure thermo_temp      # 计算应力,计算结果记为p
variable    pressx equal c_p[1]               #定义变量pressx=c_p[1],c_p[1]的意思是p里第一个值
variable   pressy equal c_p[2]                #定义变量pressy=c_p[2],c_p[2]的意思是p里第二个值
variable   pressz equal c_p[3]                #定义变量pressz=c_p[3],c_p[3]的意思是p里第三个值
thermo_style custom step temp etotal press v_pressx   v_pressy v_pressz vol
dump 1 all atom 1000 dump.tensile                          #  输出结果到dump.tensile
minimize 1.0e-6 1.0e-6 1000 1000                            #   驰豫
fix   1 left setforce 0.0 NULL NULL                            #固定左边的原子
fix   2 all npt 1.0 1.0 1.0 aniso 0.0 0.0 NULL NULL NULL NULL 10.0 drag 1.0
thermo 1000                                                         # 每1000步输出一次结果
timestep    0.002                                                   #时间步长0.002ps
run  10000                                                             #运行10000步
unfix2
fix  3  all nve
fix  4  all temp/rescale 100 1.0 1.0 5 1.0
fix  5  all deform 1000 x erate 0.002 units box 率为0.002(1/ps)
compute       s all stress/atom               应力,计算结果记为s
compute       strea all reduce sum c_s[1]     算结果记为strea
variable       stressa equal c_strea/vol       strea/vol, vol是体积
compute       streb all reduce sum c_s[2]
variable        stressb equalc_streb/vol
compute      strec all reduce sum c_s[3]
variable      stressc equal c_strec/vol
#设置沿x方向拉伸,应变      #计算每个原子上的#将s里第一个值求和,计   # 定义变量stressa=                       thermo_style    custom step tempetotal press v_stressa  v_stressb v_stressc vol
run    300000