天天看點

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案例:分子自由落體運動模拟

繼續閱讀