大家好,我是小马老师。

本文分享一个使用fix addforce命令进行拉伸的案例,运行效果如下:

模拟采用LJ单位,初始结构是由40个原子组成的一条链,原子之间设置键连接,共39个键。

在设置力场时,忽略pair势,只计算键的作用力,键的势函数为fene势。

#不计算非键连接原子之间的作用力
pair_style none
#设置键的势函数为fene
bond_style fene
bond_coeff 1 50.0 1.5 0.0 0.0
special_bonds fene

在模拟过程中,对最右侧原子施加一个随时间变化的作用力:

#定义力的大小
variable extforce equal ${maxforce}*step/${samplerun}
#在最右侧的原子(force组)施加作用力
fix externforce force addforce v_extforce 0 0

In文件代码如下,代码已经进行了注释。

#定义温度
variable temp equal 1.0
#设置最大力
variable maxforce equal 200
#模型基本参数
dimension 2
units lj
atom_style molecular
atom_modify sort 1000 2.0
comm_modify cutoff 2.0
boundary p p p
#近邻列表
neighbor 2.0 bin
neigh_modify every 1 delay 0 check yes
#读取data文件
read_data poly.txt
#设置摩尔质量
mass * 1
#对原子进行分组
group mobile type 1 3
group fixed type 2
group force type 3
#不计算非键连接原子之间的作用力
pair_style none
#设置键的势函数为fene
bond_style fene
bond_coeff 1 50.0 1.5 0.0 0.0
special_bonds fene
#时间步长
variable tstep equal 0.01
timestep ${tstep}
thermo 100
#输出原子坐标轨迹
dump 1 all atom 50000 dump.xyz
#设置系综+langevin控温
fix integrator mobile nve
fix dynamics mobile langevin ${temp} ${temp} 10.0 252111
fix run2d all enforce2d
#定义运行步数
variable eqrun equal 50000
variable samplerun equal 10000000
#驰豫50000步
run ${eqrun}
reset_timestep 0
#定义力的大小,该力随时间变化
variable extforce equal ${maxforce}*step/${samplerun}
#在最右侧的原子(force组)施加作用力
fix externforce force addforce v_extforce 0 0
#计算x方向伸长量
variable dist equal (x[40]-x[1])
#力和x方向伸长量保存到文件中
fix avg all ave/time 1 500000 500000 v_dist v_extforce file dist_vs_force ave one
#输出运行结果
thermo 500000
thermo_style custom step f_avg[1] v_extforce
#启动运算
run ${samplerun}

Data文件如下,新建一个文本文件poly.txt,复制以下所有代码,粘贴到poly.txt即可

LAMMPS Description

40 atoms
39 bonds

3 atom types
1 bond types

-40 40 xlo xhi
-40 40 ylo yhi
-40 40 zlo zhi

Masses

1 1
2 1
3 1

Atoms # id mol type xu yu zu

1 1 2 -40.00000 0.00000 0.00000
2 1 1 -39.03500 0.00000 0.00000
3 1 1 -38.07000 0.00000 0.00000
4 1 1 -37.10500 0.00000 0.00000
5 1 1 -36.14000 0.00000 0.00000
6 1 1 -35.17500 0.00000 0.00000
7 1 1 -34.21000 0.00000 0.00000
8 1 1 -33.24500 0.00000 0.00000
9 1 1 -32.28000 0.00000 0.00000
10 1 1 -31.31500 0.00000 0.00000
11 1 1 -30.35000 0.00000 0.00000
12 1 1 -29.38500 0.00000 0.00000
13 1 1 -28.42000 0.00000 0.00000
14 1 1 -27.45500 0.00000 0.00000
15 1 1 -26.49000 0.00000 0.00000
16 1 1 -25.52500 0.00000 0.00000
17 1 1 -24.56000 0.00000 0.00000
18 1 1 -23.59500 0.00000 0.00000
19 1 1 -22.63000 0.00000 0.00000
20 1 1 -21.66500 0.00000 0.00000
21 1 1 -20.70000 0.00000 0.00000
22 1 1 -19.73500 0.00000 0.00000
23 1 1 -18.77000 0.00000 0.00000
24 1 1 -17.80500 0.00000 0.00000
25 1 1 -16.84000 0.00000 0.00000
26 1 1 -15.87500 0.00000 0.00000
27 1 1 -14.91000 0.00000 0.00000
28 1 1 -13.94500 0.00000 0.00000
29 1 1 -12.98000 0.00000 0.00000
30 1 1 -12.01500 0.00000 0.00000
31 1 1 -11.05000 0.00000 0.00000
32 1 1 -10.08500 0.00000 0.00000
33 1 1 -9.12000 0.00000 0.00000
34 1 1 -8.15500 0.00000 0.00000
35 1 1 -7.19000 0.00000 0.00000
36 1 1 -6.22500 0.00000 0.00000
37 1 1 -5.26000 0.00000 0.00000
38 1 1 -4.29500 0.00000 0.00000
39 1 1 -3.33000 0.00000 0.00000
40 1 3 -2.36500 0.00000 0.00000

Bonds

1 1 1 2
2 1 2 3
3 1 3 4
4 1 4 5
5 1 5 6
6 1 6 7
7 1 7 8
8 1 8 9
9 1 9 10
10 1 10 11
11 1 11 12
12 1 12 13
13 1 13 14
14 1 14 15
15 1 15 16
16 1 16 17
17 1 17 18
18 1 18 19
19 1 19 20
20 1 20 21
21 1 21 22
22 1 22 23
23 1 23 24
24 1 24 25
25 1 25 26
26 1 26 27
27 1 27 28
28 1 28 29
29 1 29 30
30 1 30 31
31 1 31 32
32 1 32 33
33 1 33 34
34 1 34 35
35 1 35 36
36 1 36 37
37 1 37 38
38 1 38 39
39 1 39 40

更多lammps教程,请关注微信公众号:lammps加油站

lammps案例:addforce方法实现链的拉伸_微信公众号