I’m testing different parameters for EAM potential. Some guesses are really bad and I have “NaN” for potential energy in a minimization run. I would like to avoid such bad trials by simply running LAMMPS for 1 step.
variable pe equal pe
run 0 post no
if " ${pe} > 0 " then “jump SELF end”
Unfortunately, if statement fails with the error:
ERROR: Invalid Boolean syntax in if command (…/variable.cpp:4042)
Do you have any suggestions how to check potential energy value and safely exit program.
If you’re wanting LAMMPS to recover and do something specific
when your simulation generates NaNs, b/c of a bad model,
I don’t think that’s easy to do.
If you defined
variable pe equal pe/2.0
or
variable foo equal v_pe/2.0
and then tried using those in your if statement, the code would throw an error
in different places. The variable.cpp file does a lot of complex parsing
of formulas of different kinds and with different elements in
the equations. Trying to make each of them aware of the possibility
that a NaN might be present would be very difficult. And for
many of them, there is not the option of simply returning “false”
as a result. They would need to generate an error.
It would be better if you thought about how to avoid running
a model with bogus EAM parameters. E.g. in your driver
script or program, do some simple tests of parameters you
generate to see if the EAM formulas will work vs croak.