Recovering from lost atoms in run via python interface

Hi - we’re using LAMMPS in a somewhat unconventional way, that sometimes involves running with crazy configurations that lead to lost atoms. We’ve always dealt with this by compiling with -DLAMMPS_EXCEPTIONS, catching those exceptions, and then issuing a “clear” command if one is caught, and starting over. However, as of the latest GitHub lammps the clear command itself fails, throwing an exception

Library error: issuing LAMMPS command during run (…/library.cpp:229)

Has anything changed in the last few months that’s likely to lead to this issue? Should my first step be to figure out what GitHub version started causing this problem?

Noam

noam,

this was a very deliberate change to keep people from issuing LAMMPS
commands through python functions during an MD or minimization run.
LAMMPS hasn't been designed for it. instead most LAMMPS commands
expect, that there is a "setup phase" happening afterwards, where all
kinds of data structures are filled to be used during the MD run.
fixes, that make changes to the system, like fix gcmc, fix
bond/create, fix deposit, have to take care of updating the
corresponding data structures, but this doesn't happen in the
aforementioned scenario, so the decision was made to disallow regular
commands completely during a run.

your special case is, that you are technically still in a run, but the
exception is brutally dropping you out of it. i'll have to think about
what can be done to clear the "inside a run" status when exceptions
happen. i think your use case is valid and different from what is
currently checked for.

i'll let you know,
       axel.

noam,

please try the attached patch and let me know, if that resolves your issue.

axel.

lammps-allow-command-after-exception.diff.gz (542 Bytes)