[lammps-users] Error occur when using dump_modify command used

Dear Lammps users

I try to dump atom positions at specified timestep which I determined through one previous calculation. I read the example from the dump_modify command and try to repeat it. The command I used is:

variable f file tmp.times
variable s equal next(f)
dump 1 all atom 100 tmp.dump
dump_modify 1 every v_s

run 100000

The tmp.times file contain the following one line:

1 100001

And the error occurred:

ERROR: Variable ID in variable formula does not exist (…/variable.cpp:4272)
Last command: run 100000

Appreciate your help and thanks very much!

Hao

from the documentation of the variable command:

For the file style, a filename is provided which contains a list of strings to assign to the variable, one per line.

and:

Since file-style and atomfile-style variables read and store the first line of the file or first set of per-atoms values when they are defined in the input script, these are the value(s) that will be returned the first time the next() function is invoked. If next() is invoked more times than there are lines or sets of lines in the file, the variable is deleted, similar to how the next command operates.

It looks to me that LAMMPS is behaving exactly as documented.

  • it reads the file, one line at a time
  • it converts the first non blank content of a line to a number
  • it deletes the file style variable after the last line is read

if I have a file: tmp.times with:
1
25

and then run the input

variable f file tmp.times
variable s equal next(f)
print “s={s}" print "s={s}”
print “s=${s}”

I get this:

LAMMPS (8 Apr 2021)
s=1
s=251
ERROR: Variable ID ‘f’ in variable formula does not exist (src/variable.cpp:4395)
Last command: s=${s

Which is consistent with the manual.

If I change the file to:
1 25

I get this:

LAMMPS (8 Apr 2021)
s=1
ERROR: Variable ID ‘f’ in variable formula does not exist (src/variable.cpp:4395)
Last command: s=${s

Again, exactly as documented, and that is what you seem to be seeing as well.

Axel.

Thanks very much. I changed the file to

1
10
100001
and it works.

Thanks very much for your help, Axel.

Hao

Axel Kohlmeyer <[email protected]> 于2021年5月6日周四 上午10:55写道: