fix scalar multiply#992
Merged
Merged
Conversation
Contributor
|
Yikes, good catch! I'm running the test suite on Do we not have unit tests to catch this? Presumably this error would jump out for appropriate choices of I don't think I was aware of this type and am also wondering why it's in |
Member
|
I would say |
Member
Author
|
I think this would have come out if the operators were switched, but i don't think it affects anything at the moment. |
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.
This PR fixes a typo in the accurate auto-diff multiply code.
When MESA did:
accurate_ad_value * scalarthe code accidentally multiplied by the accurate auto-diff value again, instead
of multiplying by the scalar.
So it was effectively doing:
value * valuewhen it should have done:
value * scalarThe fix changes the multiply routine, so it uses the scalar. This makes
accurate_ad * scalarbehave the same way asscalar * accurate_ad.This could have affected the hydro routines that use accurate auto-diff sums,
like
get1_energy_eqn,get1_momentum_eqn,do1_dudt_eqn, anddo1_turbulent_energy_eqn. But those routines avoided this bug because theyeither convert back to normal auto-diff before scaling, or use
the safe multiply direction. That small syntax difference prevented this bug from
breaking anything, because
scalar * accurate_ad_valueworked, whileaccurate_ad_value * scalarwas the broken operator overload.