Is the if command executed every step

Dear LAMMPS users,

I wonder whether the if command is executed every step of the simulation.
I use as following commands to define the variable avelo which is a function of step.

variable astep equal step
if “${astep}<=10” then &
“variable avelo equal 1” &
else &
“variable avelo equal 2”

and I output the variable avelo using the thermal_style command.

I expected that the value of the variable avelo should be 1 for step 0-10 and be 2 for steps larger than 1. But in my log file, it shows the value of the variable avelo equals to 1 at each step. It seems to me that the if statement is only executed at the first step. I wonder how the if command works. Thanks.

Han Hu

Complex Fluids and Multiphase Transport Lab
Mechanical Engineering and Mechanics Department
Drexel University
Hess Engineering Research Laboratories
[email protected]…1685…, [email protected]…92…

Dear LAMMPS users,

I wonder whether the if command is executed every step of the simulation.
I use as following commands to define the variable avelo which is a function
of step.

variable astep equal step
if "${astep}<=10" then &
"variable avelo equal 1" &
else &
"variable avelo equal 2"

and I output the variable avelo using the thermal_style command.

I expected that the value of the variable avelo should be 1 for step 0-10
and be 2 for steps larger than 1. But in my log file, it shows the value of
the variable avelo equals to 1 at each step. It seems to me that the if
statement is only executed at the first step. I wonder how the if command
works. Thanks.

all lammps script commands are executed *immediately*.
if you want something to be executed *during* the execution of the run
command, you have to stick it into the "every" clause of said command.

axel.

Hi Alex,

Many thanks.

Bests,

Han Hu