lammps案例:小球随机碰撞模拟代码练习_初始化

分享一个小球碰撞模拟的代码,随机生成800个红色球(type 1)和1个蓝色球(type 2),获得初始速度后,小球之间相互碰撞。


代码相对简单,每行代码我都加了注释,对于初学者来说,是一个很好的学习例程。


代码如下:

#原子数量
variable npart equal 800
#体系单位lj
units lj
#二维体系
dimension 2
#原子类型atomic
atom_style atomic
#周期性边界
boundary p p p
#近邻参数
neighbor 6 bin
#邻居列表更新频率
neigh_modify every 1 delay 0 check yes
# box尺寸
region box block -20 20 -20 20 -0.1 0.1
#在box内生成2种原子
create_box 2 box
#转为二维计算
fix 2d all enforce2d
#在box内随机生成800个原子,原子类型为1
create_atoms 1 random ${npart} 324523 box
#随机生成1个类型为2的原子
create_atoms 2 random 1 32524523 box
#原子质量
mass 1 1
mass 2 5
#设置力场参数,soft势
pair_style soft 1.0
pair_coeff 1 1 10.0 1.0
pair_coeff 1 2 10.0 3.0
pair_coeff 2 2 10.0 3.0
#温度初始化
velocity all create 2.0 34234123 dist gaussian
#能量最小化,防止原子重叠
minimize 1e-4 1e-4 1000 1000
#步数初始化为0
reset_timestep 0
#输出设置
dump img all atom 10000 atom.xyz
#nve系综
fix integrator all nve
#热力学输出
thermo_style custom step temp ke pe
thermo 100
#模拟步长
timestep 0.001
#启动模拟
run 500000

END


陆续推出lammps基础教程,敬请扫码关注微信公众号:lammps加油站。

lammps案例:小球随机碰撞模拟代码练习_初始化_02