lammps代码实例分享

1.lammps常用网站

Materials project:https://next-gen.materialsproject.org/
晶体库:https://www.crystallography.net/cod/index.php
        http://rruff.geo.arizona.edu/AMS/amcsd.php
        http://www.crystalstar.org/Index.html/
        https://aflowlib.org/prototype-encyclopedia/index.html
常用lammps命令:http://www.52souji.net/tag/lammps/
元素信息:https://periodictable.com/Properties/A/LatticeConstants.html
单位换算:https://jerkwin.github.io/gmxtools/calc/calc.html
          https://www.convertunits.com/
一键求导:https://www.derivative-calculator.net/
能量单位换算:https://www.colby.edu/chemistry/PChem/Hartree.html
势参数:
https://www.ctcms.nist.gov/potentials/
http://apot.mgedata.cn/InteratomicPotentials/
https://lammpstube.com/mdpotentials/
https://cmse.postech.ac.kr/html/research/2nnmeam.htm
https://sites.google.com/site/eampotentials/
https://www.scm.com/doc/ReaxFF/Included_Forcefields.html
http://www.lasphub.com/#/lasp/nnLibrary
https://jarvis.nist.gov/jarvisff/

2.单晶Al的弛豫模拟
# ------------------------------初始化----------------------
units        metal               # 单位制,金属体系
dimension    3                      # 模拟纬度,默认3维
boundary     p p p                # 边界条件,p周期性边界,f固定边界,s收缩性边界
atom_style   atomic             # 系统中只有原子类型

# -----------------------模拟区域信息设置------------------
lattice          fcc 4.05           # 晶格,FCC面心立方,晶格长度4.05埃米
region           box1 block 0 30 0 30 0 30 units box    #设置模拟区域,区域名称box1,block块状,xyz方向 30埃米
#region          box1 block 0 30 0 30 0 30  
#region          box1 block 0 30 0 30 0 30 units lattice # xyz方向30层原子(30*4.05)
create_box       1 box1              # box1区域中只有1种原子
create_atoms     1 region box1   # 向模拟区域中添加原子(ID为1)

# 模拟环境中的原子信息
mass       1 26.981  # Al,设置原子ID、质量

# ----------------------力场/势函数设置------------------------
pair_style      eam/alloy
pair_coeff      * * Al99.eam.alloy Al         # * *通配符,使原子间相互作用

# 保存模型
write_data    Al_model.xyz

timestep      0.001                    # 运行时间步长,0.001皮秒
velocity      all create 300 12345    #创建初始温度,所有原子300K,随机种子12345
fix            1 all npt temp 300 300 1 iso 0 0 1  #fixID为1,所有原子npt系综,初始温度300,结束温度300,阻尼系数1,iso控压方式(耦合),初始压强0,结束压强0,阻尼系数1

#设置输出信息/格式
thermo        1000                      # 每N步在显示器上输出一次
thermo_style  custom step lx ly lz press pxx pyy pzz pe temp  # 设置输出样式,lx x方向长度,pxx x方向压力,pe势能
dump         1 all custom 1000 Al.xyz type x y z   # 每N步在文件中输出一次

#设置运行步数
run         20000
3.高熵合金FeCoNiCr的升温模拟
# --------------------------------初始化----------------------------
units              metal                 # 单位制
dimension          3                      # 维度
boundary           p p p                # 边界条件

# ----------------------------模拟区域信息设置--------------------
lattice            fcc 3.6149        # Cu晶格
region             box1 block 0 15 0 15 0 15
create_box         4 box1              # 设置原子  种类数
create_atoms       1 region box1  # 向模拟区域中添加第一类Fe原子

# 原子类型转化,将Fe原子部分转化为其他原子
# set    type  被转换原子种类ID type/ratio 准换原子种类ID 转换比例 随机种子
set          type  1 type/ratio 2 0.25 87393       # 0.25 * 1.0= 1/4  Cr原子
set          type  1 type/ratio 3 0.33333 87393   # 0.33333 * 0.075 = 1/4Ni原子
set          type  1 type/ratio 4 0.5 87393       # 0.5 * 0.5 = 1/4 Co原子         四种原子各占1/4

# 模拟环境中的原子信息
mass 1 55.845                 # Fe
mass 2 51.996                 # Cr
mass 3 58.693                 # Ni
mass 4 58.933194              # Co

# -------------------------力场/势函数设置--------------------------
pair_style          eam/alloy
pair_coeff          * * FeNiCrCoCu-heafixed.setfl Fe Cr Ni Co

# 保存模型
write_data        CoCrFeNi_model.xyz

timestep          0.001                 # 0.001ps = 1fs
velocity          all create 300 12345     # 对原子组创建初始速度
fix               1 all npt temp 300 3500 0.1 iso 0 0 0.1      # 100*timestep

# 设置输出信息/格式
thermo         1000    #每N=1000步在显示器输出一次
thermo_style   custom step lx ly lz press pxx pyy pzz pe temp
dump           1 all custom 1000 CoCrFeNi.xyz type x y z

# 设定运行步数
run            20000
4.单晶Al的拉伸模拟
# Input file for uniaxial tensile loading of single crystal aluminum

# ----------------------initialization/初始化-------------------
units              metal
dimension         3
boundary          p p p
atom_style       atomic                            
variable         latparam equal 4.05       # 定义常量,晶格长度

# ------------------atom definition/定义原子------------------
lattice          fcc ${latparam}
region           whole block 0 30 0 30 0 30     # 定义区域whole
create_box       1 whole                                    # 定义原子种类数
lattice          fcc ${latparam} orient x 1 0 0 orient y 0 1 0 orient z 0 0 1
# orient 设置x方向100,y方向010,z方向001
create_atoms     1 region whole                          # 向区域中填充种类1的原子

# ---------------------force fields/力场-------------------------
pair_style          eam/alloy
pair_coeff          * * Al99.eam.alloy Al

# ----------------------settings/设置--------------------------
compute            csym all centro/atom fcc           # 计算操作,csym命名,所有原子,参考FCC计算中心对称参数
compute            peratom all pe/atom                 # 计算操作,peratom命名,所有原子,计算原子势能

# equilibration/平衡化
reset_timestep     0                                                # 将当前模拟步长置0
timestep           0.001                                         # 0.001 ps = 1 fs
velocity           all create 300 12345 mom yes rot no  # 创建初始温度,线性动量(mom)为零,角动量(rot)非零
fix                1 all npt temp 300 300 0.1 iso 0 0 1 drag 1         # drag 1 阻尼值为1,对温度和压力

# set thermo output/设置热力学输出
thermo             1000
thermo_style       custom step lx ly lz press pxx pyy pzz pe temp   #设置输出样式

# run for at least 10 picosecond(assuming 1 fs timestep)
# 运行至少10皮秒(假设1 fs时间步长)
run                50000                                   # 弛豫
unfix              1                                           # fix为1操作解除

# store final cell length for strain calulations/存储应变计算的最终晶格长度
variable           tmp equal "lx"                      # 定义变量,设为x方向的长度lx
variable           L0 equal ${tmp}                    # 设置L0为盒子初始长度,L0不随lx变化
print              "Initial Length,L0:${L0}"          # 输出初始长度

# deformation/变形
reset_timestep     0                                         # 当前模拟步长置0
fix                1 all npt temp 300 300 0.1 y 0 0 1 z 0 0 1 drag 1      # y 0 0 1 z 0 0 1,对y和z方向控压,
variable          srate equal   1.0e10                                                   # 定义变量
variable          srate1 equal "v_srate / 1.0e12"                                  # 定义应变率计算公式
fix               2 all deform 1 x erate ${srate1} units box remap x  # deform变形,每1步执行一次,x方向,units box单位制与盒子相同,remap x在盒子产生变形时将位置重新映射,但原子速度不变

# output strain stress info to file/将应变应力信息输出到文件
# for units  metal,pressure is in 1[bars] = 100 [kPa] = 1/10000 [GPa] 
# 对于金属单位,压力单位为1 [bars] = 100 [kPa] = 1/10000 [GPa]
# p2,p3,p4 are in Gpa
variable           strain equal "(lx - v_L0)/v_L0"                                    # 定义应变计算公式
variable           p1 equal "v_strain"                                                    # p1为应变
variable           p2 equal "-pxx/10000"                                             # p2为x方向应力
variable           p3 equal "-pyy/10000"                                             # p3为y方向应力
variable           p4 equal "-pzz/10000"                                             # p4为z方向应力
fix                def1 all print 1000 "${p1} ${p2} ${p3} ${p4}" file Al_SC_100.def1.txt screen no
#  每1000步,将p1、p2、p3、p4输出到Al_SC_100.def1.txt文件中,sreen no不在屏幕上显示

# use cfg for atomeye/用atomeye写cfg
dump               1 all custom 5000 dump_tensile.lammpstrj mass type xs ys zs c_csym c_peratom fx fy fz
# 每5000步输出一次,dump_tensile.lammpstrj文件,xs ys zs xyz方向收缩后长度,fx fy fz xyz方向拉力
dump_modify        1 element Al                       # 将in文件元素名称与lammps默认的相关联

# display thermo/显示热力学信息
thermo             1000                                   
thermo_style       custom step v_strain temp v_p2 v_p3 v_p4 ke pe press     # ke动能
run                200000

# simulation done/模拟完成
print             "All done!"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值