DedalusProject / dedalus

A flexible framework for solving PDEs with modern spectral methods.
http://dedalus-project.org/
GNU General Public License v3.0
489 stars 115 forks source link

Add stop_iteration to NLBVP #256

Open bpbrown opened 1 year ago

bpbrown commented 1 year ago

It would be handy to have a method for stopping NLBVP iterations if they exceed some threshold. Sometimes a NLBVP can get stuck in oscillatory non-convergent states, and a user-defined threshold could prevent a solution in that space from continuing to run.

This can be done by the user inside their main loop, but we have the concept of solver.stop_iteration for IVP, and extending this to NLBVP would keep the same approach for addressing similar situations.

Default value should probably be:

solver.stop_iteration = np.inf

to parallel IVP behaviour and current experience with NLBVP.

kburns commented 1 year ago

I think the easiest thing is just to wrap this into the newton loop in the script, like:

while error > tolerance and solver.iteration < 20:
    ...