problem with if

I'm not sure what you are asking. If you want
to execute an "if" statement at every step of
an MD run, then you could use it as the argument
of the run every command, and for example, tell
LAMMPS to exit if some condition were met.

Steve