The variable command

Dear LAMMPS users and developers:
I am using lammps to do my project.I found a problem in my input script.The following is part of my input script.
#for loop
label forloop
variable i loop 20
variable f equal v_i*0.00025558
fix 7 mobile addforce 0.0 0.0 v_f
run 20000
next i
jump in.graphene forloop
run 40000
When the loop was over,an error(Invalid variable name in variable formula (variable.cpp:1098))came to the screen and the command-run 40000 couldn’t continue to run.I know there’s something wrong with the variable command.But i don’t know how to solve it.Can you help me to find the problem?

You probably have to reset fix addforce to use the final value instead of referring to the loop variable i.
Or you have to use unfix to turn that fix off again.

Axel

More precisely, in your run outside the
loop, the addforce fix is still defined,
so it will try to eval the "f" variable.
But the f variable depends on the "i"
variable, which is no longer valid,
since you exhausted its internal values
by running thru the loop.

So do what Axel said.

Steve