detect if global variable is unchanged

Hi all -

I'm trying to figure out if there is a way to determine if a global
variable has remained unchanged over the last N time steps or time
units (prefer the latter due to variable time step size) over the
course of a run, and set a flag if the variable has achieved "steady
state". I plan on doing a nested loop where on each iteration I run
for a given number of steps, then check the flag and break out of the
loop when steady state is detected.

Is this achievable with some clever averaging with fix ave/time? Or
maybe with fix vector? Fix vector might work if I could access the
vector using negative indexing like in python/matlab, but I didn't
think LAMMPS supports that.

I could possibly get away with simply checking if the variable was the
same as it was N steps/time ago, rather than checking if it has been
constant the whole time over the last N steps.

   - Jesse

If you want to check every 1000 steps, you could use fix ave/time to generate
an average quantity, also every 1000 steps, based on values at intermediate times.
Then compare the new value to the old one. The variable doc page
explains how to store a previous value of a variable in a 2nd variable.
See the discussion near the bottom of the page about Immediate Eval of Vars
and the volume example with v0.