Getting information from previous time step

Hello everyone, I would like to ask if it is possible in lammps to have access to previous timestep thermodynamic quantities. I want to perform an if statement like the following:

if Etotal(curent time step) - Etotal(previous time step) > number
then:
[…]

Thanks a lot in advance!

First of all, it looks like you are mistaken about how the “if” command works.

It can be used for flow control, but since LAMMPS input is executed immediately when a line is encountered, it cannot be used to trigger actions during a run. So to trigger some action via the “if” command, you would first have to use fix halt to make a run stop because of a given condition, then execute your conditional command(s) and continue the run.

Please see this post for a bit hackish method for accessing data from a previous time step.

If you want something more sophisticated, you will likely have to resolve to writing a custom fix, either in C++ or in python via fix python/invoke.

Thank you very much akohlmey!