COSMIC-PopSynth / COSMIC

COSMIC (Compact Object Synthesis and Monte Carlo Investigation Code)
GNU General Public License v3.0
48 stars 59 forks source link

flow change to evolv2 #541

Closed carlrodriguez closed 3 years ago

carlrodriguez commented 3 years ago

Ok, this is a tiny but significant change. Basically when tphysf is sufficiently large (e.g. in CMC) and the CMC timestep is also sufficiently large (e.g. large cluster virial radius) you can run into a condition where COSMIC merges stellar binaries due to a combination of mass transfer/GW by subtracting angular momentum from the orbit (line 3281 in evolv2.f).

However, if a binary is brought to 0 separation after that line (or ~1e-10), and the tphys if after the current tphysf, this binary can be returned to CMC having not been destroyed (even though the stars are well past contact), because the check for contact/collisions occurs after the goto at line 3557. These binaries have ~10000x the binding energy of the whole cluster, causing CMC to crash when it checks for energy conservation.

To solve this, I've added a check in line 3281 of evolv2, whereby if the change in orbital angular momentum is greater than the total angular momentum, the goto at line 3557 is skipped and BSE checks for collisions before returning the binary to CMC.

I've tested that this fixes the issues in CMC (it does) and doesn't change anything in COSMIC (at least for single binaries, it doesn't seem to). However, I haven't run a full COSMIC population.

codecov[bot] commented 3 years ago

Codecov Report

Merging #541 (1f1ac92) into develop (c68f682) will increase coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #541   +/-   ##
========================================
  Coverage    87.03%   87.03%           
========================================
  Files           40       40           
  Lines        25329    25336    +7     
========================================
+ Hits         22044    22051    +7     
  Misses        3285     3285           
Impacted Files Coverage Δ
cosmic/src/evolv2.f 57.68% <100.00%> (+0.02%) :arrow_up:
cosmic/sample/initialcmctable.py 95.49% <0.00%> (+0.14%) :arrow_up:
cosmic/sample/initialbinarytable.py 94.44% <0.00%> (+0.16%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c68f682...1f1ac92. Read the comment docs.

katiebreivik commented 3 years ago

Verified that this produces the exact same bpp array for populations of 10,000 DWD, BNS, and BBH progenitors with the PR and current develop branch so we are good to go!