Repository navigation
Equilibrium - BUGFIX! - π¨ Tie the equilibrium ODE absolute tolerance to etol #491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9334c22
Equilibrium - BUGFIX! - Tie the equilibrium ODE absolute tolerance toβ¦
d-burg d0859be
Equilibrium - REFACTOR - Name the equilibrium ODE abstol ceiling and β¦
d-burg bd4a5fb
Repo - MINOR - Apply the formatter to the audit fixes
d-burg 665357a
Equilibrium - BUGFIX - Reject a non-positive or non-finite etol when β¦
d-burg 79ab504
Repo - MINOR - Apply the formatter to the audit fixes
d-burg e875c3c
Equilibrium - BUGFIX - Error when an equilibrium ODE solve stops earlβ¦
d-burg f613874
Merge remote-tracking branch 'origin/develop' into bugfix/equilibriumβ¦
d-burg 41762de
Equilibrium - BUGFIX - Require the arc-length field line to close andβ¦
d-burg 0e70bb2
Merge remote-tracking branch 'origin/develop' into bugfix/equilibriumβ¦
d-burg 6d6a493
Equilibrium - BUGFIX - Let a failed shaping solve out of the Ξ½ root-fβ¦
d-burg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # SolveTolerances.jl | ||
| # | ||
| # Absolute tolerance and completion check shared by the equilibrium ODE solves | ||
| # (direct field-line, large-aspect-ratio and TJ-analytic integrations). | ||
|
|
||
| """ | ||
| Ceiling on the absolute tolerance of the equilibrium ODE solves; the historical fixed value, kept so a loose `etol` never loosens abstol. | ||
| """ | ||
| const EQUIL_ABSTOL_MAX = 1e-8 | ||
|
|
||
| """ | ||
| equil_abstol(etol, cap=EQUIL_ABSTOL_MAX) | ||
|
|
||
| Absolute tolerance of an equilibrium ODE solve: follows `etol` but is never looser than `cap`. | ||
| """ | ||
| equil_abstol(etol::Real, cap::Real=EQUIL_ABSTOL_MAX) = min(etol, cap) | ||
|
|
||
| """ | ||
| check_equil_solve(sol, what) | ||
|
|
||
| Return the equilibrium ODE solution `sol`, or raise an error naming the solve `what` if the integrator | ||
| stopped early (step limit, step-size underflow, instability) instead of finishing or terminating on its callback. | ||
| """ | ||
| function check_equil_solve(sol, what::AbstractString) | ||
| sol.retcode == ReturnCode.Success || sol.retcode == ReturnCode.Terminated || | ||
| error("Equilibrium ODE solve ($what) stopped early at t = $(sol.t[end]) with retcode $(sol.retcode).") | ||
| return sol | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude's addition to this - a bit in the weeds for me, probably just combine the recommendation:
This catch swallows the new solve check.
check_equil_solvethrowsErrorExceptionon MaxIters, step-size underflow, or an unstable right-hand side, andfind_zerolets that exception out. Roots only raisesRoots.ConvergenceFailed(no convergence) orArgumentErrorwhose message contains "not a bracketing interval" (the bracket has no sign change). Every other exception should propagate.As written, one trial Ξ½ that stops early is logged as a root-find miss and replaced with Ξ½ = qa/qc. The final
tj_analytic_shape_solveat that fallback can then succeed, so the equilibrium is built at the wrong Ξ½.exception=(err, catch_backtrace())is what prints the stack;error=erronly stores the object.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done with the patch as written. The fallback is taken only for
Roots.ConvergenceFailedor the no-bracketArgumentError, everything else rethrows, and the warning now carries the backtrace. I added a test that forces a failed trial solve (NaNabstol) and checks the error comes out oftj_analytic_find_nu.One caveat: the no-bracket case is matched on Roots' message text, which I checked against the pinned Roots 2.3.0. If that text ever changes, the case will rethrow, so it fails loudly and not silently.