[lammps-users] command variable

Hello everyone,

I want to use the command “variable” to run a simulation; the variable is actually the length of the simulation. I’m using the syntax:

variable runtime index 5000
.
.
.
run $runtime

I’m using 8 processors and I get an error that says: Substitution for undefined variable

Thanks
Jaime Sanchez

Hi Jaime,

It's a bit weird, but because of the way LAMMPS's parser works, if your
variable name is more than one letter you have to surround it with braces
when using it as a substitution.

So your script should read:

variable runtime index 5000
.
.
run ${runtime}

The reason for this is that the parser works a character at a time when
initially parsing a line, it needs to know when a variable name
starts and ends. You might think it could use spaces to delimit
variable names, but then you can't do this:

variable prefix index somefile
dump 1 all atom 1 $prefix.dump

Naveen