make a variable constant

Dear all

During a Lammps simulation, I defined a variable which uses the value produced by compute command. the variable style was “equal”. When the variable was defined, the compute value had been computed in the previous run. Later, after a few runs, in which that value which aided the definition of variable was not re-computed, I tried using the variable value. But then, it showed the error “compute used in variable between runs is not current”.

I wanted to use the value of variable that it had at the time it was defined and not an updated value. But, I think that the Lammps interprets it as an updated value is to be returned to me, which is not correct. So, is there any method to make the variable defined using a value produced by compute command, a constant over the subsequent runs?

Thank you
Jeeno Jose

I think you can use the $-syntax for variables. At the point where you want the compute value to be frozen, add something like

variable frozen_value equal ${“Name of original variable that changes in time”}.

The variable will then be equal to the value of the original compute at the time the new variable is created and the var “frozen_value” will remain constant.

See the “Immediate Evaluation of Variables:”-section of this page for more info:

Thank you very much Mr. Stefan, it worked.