1

Recently I started to be familiar with DiffEqPhysics and DifferentialEquations package of Julia. I'm wondering if there is a way (like callback functions) to terminate the solver with certain output convergence condition. For example if the result obtained in previous step (or a range of previous steps) does not differ from the solution at current step by a threshold value, then end the process after the current step.

nero_bin
  • 65
  • 5

1 Answers1

2

Yes, you can use callbacks to do this. In the callback, doing terminate!(integrator) will halt the integration. In the docs this example shows using callbacks with terminate! in more detail.

But instead of building your own, for terminating at a steady state you can use TerminateSteadyState from the callback library. The callback library is just a set of pre-built callbacks, and this one terminates when the derivative is sufficiently small.

Chris Rackauckas
  • 18,645
  • 3
  • 50
  • 81