本文主要把之前学习石墨烯deform拉伸做个总结。
一、模拟环境参数设置
这一部分主要设置一些模拟参数,比如模拟体系的单位(units)、边界条件(boundary)、原子类型(atom_style)、邻居列表的定义(neighbor)等。
units metal #单位为lammps 中的metel 类型
dimension 3 #模拟的维度 三维
boundary p p p #周期边界条件
atom_style atomic #原子类型自动
atom_modify map array sort 100 2.0
neighbor 3.0 bin
neigh_modify every 1 delay 0 check yes
二、定义全局参数
定义全局参数,方便后期修改。
variable temperature equal 300 #初始温度
variable relaxtemperature equal 100 #弛豫温度
variable tensiontemperature equal 100 #拉伸温度
variable tstep equal 0.001 #步长
variable tdamp equal 100*${tstep} #温度耦合步长
variable pdamp equal 1000*${tstep} #压强耦合步长
variable thermalstep equal 100 #输出模拟结果信息
variable dumpstep equal 100 #参数输出步长
variable medoldumpstep equal 1000 #模型输出步长
variable relaxtime equal 100000 #弛豫时长
variable tensiontime equal 10000000#拉伸时长
variable pressure equal 0 #压强控制
variable strain equal 0.3 #拉伸应变
variable deformrate equal 0.001 #deform拉伸速率
三、创建/读取模型
前面文章有介绍如何创建石墨烯模型,在此读取石墨烯模型即可。
read_data gp.lammpstrj #读取模型
四、势函数
选用势函数
pair_style airebo 3.0 1 1
pair_coeff * * CH.airebo C
五、能量最小化、温度初始化和步长
初始化温度300k
min_style cg #也可以选取sd
minimize 1.0e-10 1.0e-10 10000 10000
velocity all create ${temperature} 534567 dist gaussian units box
timestep ${tstep}
六、输出参数计算
力学参数输出(放在弛豫后)
variable num equal count(all) #计算原子数目
variable toval equal lx*ly*3.35 #计算系统总体积,单层石墨烯厚度为0.335nm
variable vol equal ${toval} #体系的初始体积
variable vatom equal v_vol/v_num #单个原子体积
variable lx equal lx
variable lx0 equal ${lx}
variable ly equal ly
variable ly0 equal ${ly}
variable xstrain equal "(lx - v_lx0) / v_lx0" #计算x方向应变
variable ystrain equal "(ly - v_ly0) / v_ly0" #计算y方向应变
compute stress all stress/atom NULL #计算体系中单原子应力
compute xalls all reduce sum c_stress[1] #计算体系中各方向应力
compute yalls all reduce sum c_stress[2]
compute zalls all reduce sum c_stress[3]
compute xyalls all reduce sum c_stress[4]
variable xstress equal "1.0e-4 * c_xalls/v_toval"
variable ystress equal "1.0e-4 * c_yalls/v_toval"
variable zstress equal "1.0e-4 * c_zalls/v_toval"
variable xystress equal "1.0e-4 * c_xyalls/v_toval"
能量参数输出
compute 2 all pe/atom
compute pe all reduce sum c_2
variable PE equal "c_pe"
fix pe all print 100 "${PE} " file PE.txt screen no
七、弛豫
1、nvt弛豫
thermo ${thermalstep}
thermo_style custom step temp press lx ly lz pe ke etotal
fix 1 all nvt temp ${relaxtemperature} ${relaxtemperature} ${tdamp}
fix pe all print ${dumpstep} "${PE} " file PE.txt screen no
dump 1 all custom ${medoldumpstep} relax_x.lammpstrj id type x y z
run ${relaxtime}
undump 1 #取消fix、dump设定,步数清零
unfix 1
reset_timestep 0
2、npt弛豫
thermo ${thermalstep}
thermo_style custom step temp press lx ly lz pe ke etotal
fix 1 all npt temp ${relaxtemperature} ${relaxtemperature} ${tdamp} iso ${pressure} ${pressure} ${pdamp} drag 1
fix pe all print ${dumpstep} "${PE} " file PE.txt screen no
dump 1 all custom ${medoldumpstep} relax_x.lammpstrj id type x y z
run ${relaxtime}
undump 1 #取消fix、dump设定,步数清零
unfix 1
reset_timestep 0
八、拉伸
deform拉伸(npt系综)
thermo ${thermalstep}
thermo_style custom step temp lx ly lz v_xstrain v_ystrain v_xstress v_ystress pe ke etotal
fix 2 all npt temp ${tensiontemperature} ${tensiontemperature} ${tdamp} y ${pressure} ${pressure} ${pdamp} z ${pressure} ${pressure} ${pdamp} drag 1
fix 3 all deform 1 x erate ${deformrate} remap x units box
fix 4 all ave/time 1 ${dumpstep} ${dumpstep} v_xstrain v_ystrain v_xstress v_ystress file x.txt
dump 2 all custom ${medoldumpstep} load_x.lammpstrj id type x y z c_stress[1] c_stress[2] c_stress[3] c_stress[4]
fix 5 all halt ${dumpstep} v_xstrain > ${strain} error continue #拉
run ${tensiontime}
九、完整代码及结果
deform拉伸完整代码
units metal #单位为lammps 中的metel 类型
dimension 3 #模拟的维度 三维
boundary p p p #周期边界条件
atom_style atomic #原子类型自动
atom_modify map array sort 100 2.0
neighbor 3.0 bin
neigh_modify every 1 delay 0 check yes
variable temperature equal 300 #初始温度
variable relaxtemperature equal 300 #弛豫温度
variable tensiontemperature equal 300 #拉伸温度
variable tstep equal 0.001 #步长
variable tdamp equal 100*${tstep} #温度耦合步长
variable pdamp equal 1000*${tstep} #压强耦合步长
variable thermalstep equal 100 #输出模拟结果信息
variable dumpstep equal 100 #参数输出步长
variable medoldumpstep equal 1000 #模型输出步长
variable relaxtime equal 100000 #弛豫时长
variable tensiontime equal 10000000#拉伸时长
variable pressure equal 0 #压强控制
variable strain equal 0.3 #拉伸应变
variable deformrate equal 0.001 #deform拉伸速率
variable velocityrate equal 0.001 #velocity拉伸速率
read_data gp.lammpstrj #读取模型
pair_style airebo 3.0 1 1
pair_coeff * * CH.airebo C
min_style cg #也可以选取sd
minimize 1.0e-10 1.0e-10 10000 10000
velocity all create ${temperature} 534567 dist gaussian units box
timestep ${tstep}
compute 2 all pe/atom
compute pe all reduce sum c_2
variable PE equal "c_pe"
thermo ${thermalstep}
thermo_style custom step temp press lx ly lz pe ke etotal
fix 1 all nvt temp ${relaxtemperature} ${relaxtemperature} ${tdamp}
fix pe all print ${dumpstep} "${PE} " file PE1.txt screen no
dump 1 all custom ${medoldumpstep} relax_x1.lammpstrj id type x y z
run ${relaxtime}
undump 1 #取消fix、dump设定,步数清零
unfix 1
reset_timestep 0
thermo ${thermalstep}
thermo_style custom step temp press lx ly lz pe ke etotal
fix 1 all npt temp ${relaxtemperature} ${relaxtemperature} ${tdamp} iso ${pressure} ${pressure} ${pdamp} drag 1
fix pe all print ${dumpstep} "${PE} " file PE2.txt screen no
dump 1 all custom ${medoldumpstep} relax_x2.lammpstrj id type x y z
run ${relaxtime}
undump 1 #取消fix、dump设定,步数清零
unfix 1
reset_timestep 0
variable num equal count(all) #计算原子数目
variable toval equal lx*ly*3.35 #计算系统总体积,单层石墨烯厚度为0.335nm
variable vol equal ${toval} #体系的初始体积
variable vatom equal v_vol/v_num #单个原子体积
variable lx equal lx
variable lx0 equal ${lx}
variable ly equal ly
variable ly0 equal ${ly}
variable xstrain equal "(lx - v_lx0) / v_lx0" #计算x方向应变
variable ystrain equal "(ly - v_ly0) / v_ly0" #计算y方向应变
compute stress all stress/atom NULL #计算体系中单原子应力
compute xalls all reduce sum c_stress[1] #计算体系中各方向应力
compute yalls all reduce sum c_stress[2]
compute zalls all reduce sum c_stress[3]
compute xyalls all reduce sum c_stress[4]
variable xstress equal "1.0e-4 * c_xalls/v_toval"
variable ystress equal "1.0e-4 * c_yalls/v_toval"
variable zstress equal "1.0e-4 * c_zalls/v_toval"
variable xystress equal "1.0e-4 * c_xyalls/v_toval"
thermo ${thermalstep}
thermo_style custom step temp lx ly lz v_xstrain v_ystrain v_xstress v_ystress pe ke etotal
fix 2 all npt temp ${tensiontemperature} ${tensiontemperature} ${tdamp} y ${pressure} ${pressure} ${pdamp} z ${pressure} ${pressure} ${pdamp} drag 1
fix 3 all deform 1 x erate ${deformrate} remap x units box
fix 4 all ave/time 1 ${dumpstep} ${dumpstep} v_xstrain v_ystrain v_xstress v_ystress file x.txt
dump 2 all custom ${medoldumpstep} load_x.lammpstrj id type x y z c_stress[1] c_stress[2] c_stress[3] c_stress[4]
fix 5 all halt ${dumpstep} v_xstrain > ${strain} error continue #拉伸终止
run ${tensiontime}
拉伸图像及曲线
若有问题欢迎讨论。会持续更新改正。