天天看点

lammps案例:分子自由落体运动模拟

大家好,我是小马老师。

本文分享一个比较有意思的lammps案例:分子的自由落体运动。

lammps提供了fix gravity命令可设置分子或者原子的加速度。

语法规则为:

fix ID group gravity magnitude style args
           

如设置x方向的加速度为100(单位为Force/mass,与units有关),可写为:

本文案例和原子沉积类似,在盒子上方随机产生一定数量的分子,经过自由落体后到达盒子底部。

在盒子底部设置一个“墙”,防止原子跑出盒子外面。

分子采用刚体设置,与底部墙碰撞后停止运动。

模拟效果如下图所示:

lammps案例:分子自由落体运动模拟

lammps in文件代码如下:

#模型基本设置
units 		si 
boundary	p p f
newton		on
atom_style	sphere
atom_modify	map array sort 0 0
neighbor    0.42 bin
timestep 	0.0001
#创建盒子 
region		reg block 0 120 0 60 0 85 units box
create_box	1 reg
#设置原子属性
fix prop all property/atom mol ghost yes
#势函数设置
pair_style	gran/hooke/history 4e5 NULL 1e2 NULL 0.5 0
pair_coeff	* *
#分组
group		particles type 1
atom_modify     first particles
group		rigid type 1
neigh_modify	every 1 delay 0 check yes exclude molecule/intra all 
#热力学信息输出
thermo 		1000
thermo_style	custom step atoms ke
thermo_modify	flush yes lost warn
comm_modify	vel yes cutoff 3
#创建分子模型
molecule	mymol molecule.data
region		pourreg block 5 115 5 55 60 80 side in units box
#设置重力加速度
fix		gravfix all gravity 9.8 vector 0 0 -1 disable
#定义分子为刚体
fix		rigidfix all rigid/small molecule mol mymol gravity gravfix
#在pourreg区域内随机生成400个分子
fix		pourfix all pour 400 0 1234 region pourreg mol mymol rigid rigidfix
#设置底部墙
fix		zwall all wall/gran hooke/history 4000.0 NULL 100.0 NULL 0.5 0 zplane 0.1 NULL
#保存坐标文件
dump		1 all custom 1000 molecule_pour.xyz id type mass radius x y z fx fy fz
#启动运行
run		50000


           

如果在使用lammps过程中遇到什么问题,可到公众号或者QQ群留言。

公众号案例代码以及学习交流,请加QQ群:754749935

lammps案例:分子自由落体运动模拟

扫描关注微信公众号:lammps加油站。

lammps案例:分子自由落体运动模拟

继续阅读