[lammps-users] save a variable

Dear Steve,

I did a simulation and I want to save the temperature at t=0 and use it to
normalize some other variables.
I think all variables are dynamic and I don't know how I can save a
variable at a specific time?

Any help would be appreciated.

Ali Rajabpour

I need to think about the best way to do this - the problem is that
variables can use quantities that are only normally available during
a simluatoin (energy, virial), so how (or if) to allow them to be computed
in between simulations.


I just realized that LAMMPS can already do what you ask,
which is to store a value as essentially a static variable.

See the bottom section of the doc page for the variable command
where it talks about referencing a variable as $x versus v_x in
another variable's formula.

Try adding these lines to the bottom of the bench/in.lj script
(before the run 100 command) to see the difference:

run 0
variable tstatic1 equal temp
variable tstatic2 equal ${tstatic1}

thermo_style custom step temp press v_tstatic1 v_tstatic2
thermo 10
run 100

You will see that the last column is truly static = initial temp. The
next-to-last column is really the dynamic temp since it is evaluated
anew every time thermo is printed.

The run 0 comand is needed b/c LAMMPS will not evaluate thermo
quantities unless it is sure they are current, due to thermodynamics
having been performed at the end of another run.