COSMIC-PopSynth / COSMIC

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

fixing NaN that appear for second omega angle #525

Closed michaelzevin closed 3 years ago

michaelzevin commented 3 years ago

This small change fixes a (not-so) edge case. When both SNe have kicks of 0.0 (which is common for BBHs), the x_tilt that is calculated for the second SN is 0 since the angle between the angular momentum vectors is 0. When omega2 is then calculated, we get a divide by zero in a trigonometric function that leads to the NaN value in kick_info.

I just added a simple if/else to address this edge case (setting omega2 to 0). I checked that multiple binaries example on the Docs and it seems to have fixed things.

codecov[bot] commented 3 years ago

Codecov Report

Merging #525 (bcfdd68) into develop (dca7d98) will increase coverage by 0.00%. The diff coverage is 66.67%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #525   +/-   ##
========================================
  Coverage    87.03%   87.03%           
========================================
  Files           40       40           
  Lines        25364    25372    +8     
========================================
+ Hits         22075    22082    +7     
- Misses        3289     3290    +1     
Impacted Files Coverage Δ
cosmic/src/kick.f 74.41% <66.67%> (-0.13%) :arrow_down:
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 dca7d98...bcfdd68. Read the comment docs.

katiebreivik commented 3 years ago

agreed! This looks good to me! I'll go ahead and merge it in.