zwicker-group / py-pde

Python package for solving partial differential equations using finite differences.
https://py-pde.readthedocs.io
MIT License
393 stars 50 forks source link

Extract result from last successful timestep when simulation fails to converge #559

Closed OliverPaulin closed 2 months ago

OliverPaulin commented 2 months ago

When running a simulation via eq.solve, the solver may fail if it cannot advance the solution without reducing the timestep to below the minimum allowable timestep. This gives the error message RuntimeError: Time step below 1e-10. To aid bug fixing, it would be helpful to be able to extract the solution at the last acceptable timestep before the simulation fails.

A method which almost achieves this is to use a storage tracker and then plot the last result which was tracked from this. If the tracker is sufficiently regular, this approach gives the solution close to the point at which the simulation fails, but it would be better to be able to extract the results from actual final successful timestep.