Group Abstract Group Abstract

Message Boards Message Boards

Can one use WhenEvent to react to NDSolve failures?

Posted 1 day ago

Hello,

While using NDSolve for solving 1st order ODE systems, I sometimes experience failures signalled by messages such as, for example, "Repeated Convergence Test Failures". Is there any way to use WhenEvent command to detect any such failures and prevent NDSolve to crash but rather to stop the calculations in a controlled way, so that the results obtained before the failure are not lost?

Lesław

POSTED BY: Leslaw Bieniasz

I've never found a way to recover from convergence test failure, while NDSolve[] is still operating. They (always?) indicate a failure in the library routine doing the integration, which signals the library routine cannot proceed.

On the other hand, when I get an NDSolve::ndcf error, NDSolve[] returns a partial solution, thus saving the results obtained before the convergence failure. This seems to be what you want. Do you not get the partial solution?

When the failure is at the first step, no data is computed, and the result is defined only at the initial condition.

In the case of the shooting method for BVPs, then in the shooting phase, if there is a failure in a test IVP, shooting is abandoned, NDSolve[] fails, and the input code is returned. There really are not partial results that can be returned in this case. What I do is to program my own shooting method that reacts to failures of different shots at initial conditions in a more robust way, which might vary with the system being solved. .

POSTED BY: Michael Rogers
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard