-
Notifications
You must be signed in to change notification settings - Fork 70
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
Issue 1034 - angular momentum not conserved in tides code #1041
Conversation
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.
I think there may be a problem with units.
Line 2074 of BaseBinaryStar.cpp seems to be adding quantities in which distances are measured in RSOL to quantities in which distances are measured in AU. There is a function CalculateMomentOfInertiaAU which would solve the problem if this was used on lines 275-276.
[Aside: might not be a bad idea to note the expected units of inputs and outputs in complex functions like CalculateTotalEnergy() ]
Ahhh - that's what I meant to use! Thanks @ilyamandel - I'll change that. |
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.
Same unit issue in BaseStar::OrbitalAngularMomentum() will be addressed by the change above.
… BaseBinaryStar::SetRemainingValues
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.
Same change requested in
BaseStar.h,
doubleAngularMomentum() const { return CalculateMomentOfInertia() * m_Omega; }
-- should use CalculateMomentOfInertiaAU()
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.
I suggest we remove CalculateGyrationRadius() functions altogether -- they are currently inconsistent with the MomentOfInertia() calculations, and will only confuse the unwary user.
… BaseStar::AngularMomentum()
It is used in |
Issue 1034 - change calls to CalculateMomentOfInertia() to CalculateMomentOfInertiaAU()
Fixed typo
Yes. The gyration radius [squared] is just CalculateMomentOfInertia()/Mass()/Radius()/Radius() -- see text between Eq. 26 and 27 of Hurley, Pols, Tout (2002). |
Done.
Please look at what I did in |
@veome22 I'm not convinced these changes have completely addressed the original problem - let me know if, after running your tests, there's more work to do. |
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.
BaseStar.h, line 190:
virtual double CalculateMomentOfInertiaAU(const double p_RemnantRadius = 0.0) const { return CalculateMomentOfInertia(p_RemnantRadius * RSOL_TO_AU) * RSOL_TO_AU * RSOL_TO_AU; }
Why are you converting p_RemnantRadius to AU? You need to convert the output to AU (which is already done), not the input...
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.
I like the general approach to calculating the moment of inertia -- but, at the moment, it seems to be called without an argument when calculating the angular momentum, whereas it should either have the core radius passed in (as written, via p_RemnantRadius argument) or should determine its own core radius (OOP). Otherwise, the (0.21 * m_CoreMass * p_RemnantRadius * p_RemnantRadius) term never contributes anything. Did I miss something?
I don't think you did :-) I think the p_RemnantRadius is a hangover from the original refactor - it looks like we no longer use it. I'll take another look (I did look, but didn't want to deal with it now :-)) As far as why it is converted to AU - I can only think that in the original code it was passed in Rsol... I'll look at it later today. |
Fixed units
Fixed a few places that I had missed changing I believe this now resolves the issue of angular momentum not being conserved when tides are enabled - @veome22 could you confirm? |
@ilyamandel I have changed the implementation of EDIT: I have not checked if/how the changes made in this PR affect DCO yields. EDIT: I probably should pull the implementation of |
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.
BinaryConstituentStar.h, line 387:
double gyrationRadiusSquared = CalculateMomentOfInertiaAU() / Mass() / Radius() / Radius();
Isn't Radius() returning results in Rsun? Then this should use CalculateMomentOfInertia(), not CalculateMomentOfInertiaAU()
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.
BH.h, line 58 [and similarly in MR.h, NS.h, MS.h]:
double CalculateMomentOfInertiaAU() const { return CalculateMomentOfInertia() * RSOL_TO_AU * RSOL_TO_AU; }
Why do we need this? Isn't CalculateMomentOfInertiaAU() always just
{ return CalculateMomentOfInertia() * RSOL_TO_AU * RSOL_TO_AU; }
?
If so, we don't need to over-write it -- just define that once at the top of the inheritance hierarchy, it should automatically pick up the relevant CalculateMomentOfInertia(), right?
Other than the two comments above (the first needs to be fixed, the second is optional), looks good, happy to approve -- thank you, @jeffriley ! |
@jeffriley I just ran the same binary as before, and angular momentum is indeed conserved now! I am running a larger test now and will keep you posted. |
Ah - yes, I went too far :-) I'll fix that.
Yes, it should - I'll take that out. Good catch. |
Excellent - thanks @veome22 |
Requested changes
@ilyamandel Requested changes made. Thanks for the review and picking up my missteps :-) |
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.
Looks good -- thanks again, @jeffriley !
Will leave it for you to merge.
Just completed the final check. Angular momentum is now conserved in all binaries! |
Fix for issue #1034
. BaseBinaryStar::CalculateAngularMomentum(),
. BaseBinaryStar::CalculateTotalEnergy(), and
. BaseStar::AngularMomentum()
to use moment of inertia rather than gyration radius. This has wider implications than just issue --enable-tides Angular Momentum is not conserved #1034 and may change DCO yields slightly.
@ilyamandel ready for review
@veome22 can you run your tests and check this does what you expect?