Skip to content

VeryChord: treat increments below kappa as converged - #783

Open
raashish1601 wants to merge 1 commit into
patrick-kidger:mainfrom
raashish1601:fix/782-verychord-small-increments
Open

raashish1601 wants to merge 1 commit into
patrick-kidger:mainfrom
raashish1601:fix/782-verychord-small-increments

Conversation

@raashish1601

Copy link
Copy Markdown

Fixes #782

When the prediction of an implicit stage is already exact, every VeryChord increment is a rounding error. Scaled by tight tolerances these are still well above _small's threshold, so terminate compares the ratio of two rounding errors, often finds it above 2 and reports a divergence. The step is rejected and the same thing happens on the next one, until max_steps.

As suggested in the issue, terminate now also treats an increment smaller than kappa (in units of the tolerances) as converged, whatever its ratio to the previous one. _small is kept for the case where kappa is set very small.

With the reproducer from the issue, Kvaerno5 now takes 52 accepted and 0 rejected steps instead of hitting max_steps (19 accepted, 1981 rejected). The y' = 1.25 y case mentioned there is unchanged (270 steps).

Tests: added test_exact_prediction to test/test_very_chord.py, which fails on main and passes with this change. test/test_very_chord.py, test/test_solver.py, test/test_integrate.py and test/test_adaptive_stepsize_controller.py pass locally (CPU, float64).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VeryChord rejects every step when the prediction of a stage is exact: a ratio of rounding errors reads as divergence

1 participant