LAMMPS loop循环·if条件

Posted by XiLock on October 14, 2020

loop循环

注意,用jump时,提交任务一定要用lmp -in input而非lmp < input,否则jump时找不到label!

代码示例

有时候需要在input里做循环,以升温为例,其循环部分代码如下:

variable mytemp index 500.0 700.0 900.0 1100.0 1300.0 1500.0 1700.0 1900.0 2100.0 2300.0
variable mytemp2 index 700.0 900.0 1100.0 1300.0  1500.0 1700.0 1900.0 2100.0 2300.0 2500.0

variable i loop 10
label loopa
fix 2 all nvt temp ${mytemp} ${mytemp2} 100.0
run 200
unfix 2

next mytemp
next mytemp2
next i
jump SELF loopa

说明:

  1. SELF是让程序执行到这里,跳回自己, 然后从标签 loopa开始执行. 当然loopa是随便取的, 你可以用CHN来做label.
  2. jumo命令
  3. next命令
xilock的代码
variable i loop 10
label loopa
print "system_after_nvt_$i.data"
velocity Octane set 0 0 0.005
velocity Mont set 0 0 -0.005
run             50000
write_restart nvt.restart
write_data      system_after_nvt_$i.data
next i
jump SELF loopa
参考:
  1. 尝试lammps中, 分享中
  2. ERROR: Label wasn’t found in input script

if条件

代码示例
if boolean then t1 t2 ... elif boolean f1 f2 ... elif boolean f1 f2 ... else e1 e2
    boolean : 布尔表达式
    then : 关键词
    t1 t2 : 被执行的命令块
    elif : 关键词
    else : 关键词
    f1 f2 : 被执行的命令块
参考资料
  1. (七)脚本结构


手机版“神探玺洛克”请扫码