Detect end of run due to an elapsed timeout

Is it possible to detect whether a run or a minimize command was stopped due to the limit specified by a timeout is reached?

I have multiple “run” commands being executed sequentially using a “loop” variable and if I understand correctly, all the loops will be executed, sans the “run” commands contained therein. However, I would like to use an “if” command to write-out a restart file when such an even transpires so that nothing else in the subsequent loops are executed. Can I do that?

Not yet.

Since the timer is expired all following run or minimize commands will have no effect until the timer is reset. If you want to stop, you would have to use the “quit” command.

I’ve just added support for an “is_timeout()” special function to the variable command in a pending pull request: Collected small changes and fixes by akohlmey · Pull Request #4212 · lammps/lammps · GitHub

So that it will be possible to do the following:

   variable timeout equal is_timeout()
   timer timeout 0:10:00 every 10
   run 10000
   if ${timeout} then "print 'Timer has expired'"
1 Like

That would be perfect!

Yes, I understand that even current, none of the run/minimize commands will be executed, but I am assuming print and dump commands will be, and I would rather not have them be executed by switching straight to writing a restart file and then quitting.

Thanks! I will wait for your feature to be released, or use it as a patch.