Run command with input variable


I would like to specify a variable with mathematical calculation in run command, but found it failed. Sicne I restart from previous steps, I have introduced a variable named “rstep” and substitute it into dump, fix bond and run.

In lammps input file, I have,

fix 2 all reax/c/bonds 100 bonds_${rsetp}.txt
dump 3 all custom 100 dumpsys_${rsetp}.lammpstrj id type x y z
run (100000-${rsetp})

And the terminal command, it is going to be,

lmp -var rsetp 10 -in

And it came out the warning message of “ERROR: Invalid syntax in variable formula (src/variable.cpp:2244)”. I wonder whether it is possible to conduct this subtraction with input variable in run command.



You would need to wrap the calculation in an immediate-style variable, not just parentheses. And inside an immediate-style variable, you can only call other variables using the “v_” syntax. So for your case, you should have run $(100000-v_rstep). In general, you should study the documentation for the variable command more carefully.

Wouldn’t it be simpler to use?

run 100000 upto
1 Like

Got it, thanks Michael and Axel for your useful information.