Strange Thing on Conditional Control

Dear lammps users or developers:

I try to stop the simulation when some reduced quantity from compute meets some criteria. I find mailing list to do this.

I finally manage to do this by accidentally using an additional “fix print”.
I’d like to know why ?
I get really confused on the order of assigning variable and fix.
Is this depends on the order of fix we use in the input file??


Here’s my case.
I just list the key lines to avoid confusion:

When there’s no line 52:
ERROR: Compute used in variable between runs is not current (…/variable.cpp:1090)

When there is line 52 every thing works fine.

##fix setting
48 fix 1 mobile nve
49 fix 2 mobile langevin 1.0 1.0 10.0 904297
50 fix wall mobile wall/reflect ylo 0.0 yhi 10.0
51 fix drive mobile addforce 0.1 0.0 0.0
52 fix extra all print 100 “X: {vxlo} {vxhi} Z: {vzlo} {vzlo}”
*##The above line Turn Out to be critical and the “every” should be smaller than 1000

##compute and variable
55 compute 1 mobile reduce min x y z
56 compute 2 mobile reduce max x y z

58 variable vxlo equal “c_1[1]”
59 variable vxhi equal “c_2[1]”
60 variable vzlo equal “c_1[3]”
61 variable vzhi equal “c_2[3]”

Loop control

69 timestep 0.01
70 variable num_check equal 1000
71 variable checkrun loop {num_check} 72 label checkposition 73 run 1000 ##This is the criteria to end the simulation 74 if "{vxlo} > 30 && {vxhi} < 120 && {vzlo} > 30 && {vzhi} < 120" then "jump SELF Tover" 75 next checkrun 76 print "check={checkrun}"

77 if "{checkrun} == {num_check} " then “jump SELF Fover”
78 jump SELF checkposition

##This is the situation for not meeting te condition in 1000 cycles
80 label Fover
81 print “No sample found in ${num_check} *1000 steps”
82 quit

##This is the situation when condition meets
85 label Tover
86 print “Done!”
87 quit


ERROR: Compute used in variable between runs is not current (…/variable.cpp:1090)

See the variable doc page for an explanation of this error message, in the

section Variable Accuracy. LAMMPS has no simple way to insure a compute

can be evaluated safely and correctly in between 2 runs, since it may require

info that doesn’t exist or isn’t current. So you need to insure it was evalualted

on the last timestep of the preceeding run. Your print statement does that.