Repository navigation
fix: div by zero guard in find0_quadratic - #1106
Merged
Merged
Conversation
Co-authored-by: Ebraheem Farag <63124736+Debraheem@users.noreply.github.com>
Member
|
merged, since this is passing testing. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
In #1103 I hit a division by zero error in the
wind_fed_bbhmxbtest case during the iterative solve for the mass transfer rate. This occurred in what would be the final few timesteps when the mass transfer rate had fallen to near zero. With mass transfer rates at roundoff the solver struggled to "converge" and pushed themdot_lomdot_hibracket width to zero. This led to a division by zero infind0_quadratic. This wasn't really caused by anything in #1103, but the changes there perturbed the roundoff-level arithmetic just so to take a different path through the mass transfer solve.Note
The test sets
implicit_scheme_tiny_factor = 0d0which is what let the zero width bracket not register as converged. Setting that to the default1d-6, for example, bypassed the issue as well.Fix
When the denominator in
find0_quadraticis zero (which is the consequence of the bracket width reaching zero), setierr = -=to fall back to the saferfind0which should handle the case.