发布网友
共1个回答
热心网友
lammps中用variable设置循环语句的方法
C语言中for循环是:
for (x = 10; x <=1000; i=i+10)
那么在lammps中如何用variable变量来表示呢?
方法一:variable x index string ...
units metal
atom_style atomic
variable x index 5.4305 5.4306 5.4307 5.4308 5.4309 5.4310 5.4311 5.4312 5.4313 5.4314 5.4315
lattice diamond $x
region box block 0 3 0 3 0 3
create_box 1 box
create_atoms 1 box
pair_style lj/cut 2.8
pair_coeff 1 1 1.0 1.0
mass 1 12
timestep 0.005
mp 1 all cfg 1 a*.cfg id type xs ys zs id
#fix extra all print 100 "Coords of marker atom = $x"
#fix extra all print 100 "Coords of marker atom = $x" file coord.txt
fix extra all print 10 "$x $p" append data.d title ""
run 100
clear
next x
jump silicon.in
方法二:label loop
# label for loop # 这里是标记循环体,该语句之前的脚本不参与循环; 似乎这句不对!
variable i loop 100 # 这里设置i从1到100,步长为1
variable x equal 10*$i #这里设置x为i的10倍,即从10到1000,步长为10
……
clear
next i #下一个循环变量
jump in.filename ##for loop #这里输入该脚本的文件名