ERROR: Invalid variable name in variable formula (../variable.cpp:1320)

Dear LAMMPS users,
My input script always comes out the massage as “ERROR: Invalid variable name in variable formula (…/variable.cpp:1320)” after if command run. I do not know where is wrong. Please help me out. Thank you!

my input script:

1. Initialization

units real
dimension 3
boundary p p f
atom_style charge

2. Atom definition

lattice bcc 2.8700
region box block 0 11 0 11 0 27.875
create_box 2 box
create_atoms 1 box

region up block INF INF INF INF 19.2 INF
region down block INF INF INF INF INF 8.0
region substrate block INF INF INF INF 8.0 19.2
group up region up
group down region down
delete_atoms group up
delete_atoms group down
group substrate region substrate

read_dump dump.Featom 10000 x y z box yes replace yes

3. Settings

pair_style reax/c NULL checkqeq yes
pair_coeff * * ffield.reax.Fe_O_C_H Fe O

mass 1 55.8450
mass 2 15.9994

group Fe type 1
group oxygen type 2

neighbor 2 bin
neigh_modify every 1 delay 0 check yes


variable T equal 900
fix 1 substrate nve
fix 2 substrate langevin $T $T 100 587283
fix charge all qeq/reax 1 0.0 10.0 1e-6 reax/c
timestep 1
compute mtemp substrate temp
compute_modify mtemp dynamic yes
thermo 1

run 1
reset_timestep 0

#=================end relaxation=================

#=================oxidation kinetics==================

fix 4 oxygen nve
fix ref oxygen wall/reflect zhi EDGE

variable Nsubtot equal count(all,substrate) #基底内的所有原子
variable Oxysub equal count(oxygen,substrate) #基底内的氧原子数

variable Oxytot equal count(oxygen) #氧原子总数
variable Oxyup equal count(oxygen,up) #上半真空层内的氧原子数
variable Oxymolup equal v_Oxygen*0.5 #上半真空层内的氧分子数
variable a equal 280.0
variable m equal v_a-v_Oxymolup #需要加入的氧气数目

run 0
compute peratom up stress/atom
compute p all reduce sum c_peratom[1] c_peratom[2] c_peratom[3]
variable press equal -(c_p[1]+c_p[2]+c_p[3])/(3*(0.311*vol))

thermo_style custom step atoms temp etotal press v_press v_Nsubtot v_Oxysub v_Oxytot v_Oxyup v_Oxymolup v_m
thermo_modify temp mtemp

compute FeFerdf all rdf 100 1 1
fix FeFe all ave/time 100 1 100 c_FeFerdf file FeFerdf.txt mode vector
compute OOrdf all rdf 100 2 2
fix OO all ave/time 100 1 100 c_OOrdf file OOrdf.txt mode vector
compute FeOrdf all rdf 100 1 2
fix FeO all ave/time 100 1 100 c_FeOrdf file FeOrdf.txt mode vector

dump 1 all custom 100 dump.atom id type xs ys zs q
dump 2 all image 100 image2.*.jpg type type axes yes 0.8 0.02 view 80 -30 zoom 1.6 adiam 1.8
dump_modify 2 pad 5
dump_modify 2 backcolor white
dump_modify 2 adiam 2 1.2
dump_modify 2 acolor 1 blue
dump_modify 2 acolor 2 red

region upadd block 0 11 0 11 24 25
molecule mymol molecule.dimer

variable t loop 1000000
label loopt
if “$m > 0” then “fix 3 oxygen deposit 1 2 1 12345 region upadd near 1 mol mymol vz -0.00584 -0.00784”
run 1
next t
jump in.process loopt

write_restart restart.oxidation

When submitting scripts, please also include all other files it uses. You did not provide the dump file you read during the script, so it is difficult to reproduce your results.

I typically check the log file (log.lammps) when LAMMPS crashes because it usually prints the error message right after the command that caused the error.

In your log file, you will probably find that the variable Oxymolup is causing trouble, because it uses a variable called “Oxygen” which is not previously defined.