MESAHub / mesa

Modules for Experiments in Stellar Astrophysics
http://mesastar.org
GNU Lesser General Public License v2.1
142 stars 38 forks source link

Error in adjust_J_lost: last_q = nz #107

Closed jschwab closed 3 years ago

jschwab commented 3 years ago

Mathieu Renzo reports:

While testing with just the donor star and a point-mass companion I've hit

"Error in adjust_J_lost: last_q = nz"

which I had never seen before. This seems to come from adjust_mass.f90. I haven't investigated whether this happens with both stars or if it is easy to fix changing something in my setup, but I was surprised the code continues to run after that (which might make it easy for users to miss). Not sure whether this is the intended behavior or not.

[Here's a work directory.] I've included a photo at 4750 of a model computed with 14833 which hopefully speeds you up.

MWE.tar.gz

@orlox and/or @adamjermyn : Thoughts? I didn't understand if this was informational or indicative of a serious problem.

orlox commented 3 years ago

I know what this is about and I can work on it.

Essentially when losing mass if we just remove the angular momentum from the removed layers we can significantly underestimate angular momentum loss. Typically we'd expect angular momentum loss rate to be ~j_surf*Mdot (and I do find this by going to puny timesteps). But the outer layers removed in a single step can cover a large range of radii (particularly in stars with radiative envelopes), and the deeper layers have a surface j much smaller than j_surf.

To work around this we just scale down angular momentum in deeper layers of the star in a continuous way, such that the angular momentum lost corresponds to j_surf*Mdot. However under some extreme circumstances the algorithm really needs to dig deep, requiring to take away angular momentum from layers that are too deep. This can happen with some inflated envelopes. In Mathieu's case he's finding the algorithm is correcting jdot practically down to the core, which ain't good.

The solution is to just add a timestep control. We don't want this correction to operate too deep into the star, so we just create a normal and a hard limit with specific mass coordinates to constrain this correction. Seeing this time operating will also make people aware of the presence of this numerical fudge.

jschwab commented 3 years ago

Great. Very helpful! I'll add you (and this) to my email thread with Mathieu.

orlox commented 3 years ago

14917 has the aforementioned timestep limit included. Will wait to hear back from Mathieu to see how it works for him and close this issue if that goes well.

orlox commented 3 years ago

Mathieu appears to be happy with the results he's getting right now. Closing this issue.