8000 Fix cosmic by MathieuVenet · Pull Request #694 · COSMIC-PopSynth/COSMIC · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix cosmic #694

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

Merged
merged 4 commits into from
Apr 1, 2025
Merged

Conversation

MathieuVenet
Copy link
Contributor

-Check for periastron collision during stable R.L.O.F
-Fixing Nan after the C.E
-Fixing undisturbed system after C.E phase and supernova

@katiebreivik
Copy link
Collaborator

It looks like we are running into some changes with the kicks that don't agree with the previous version. We think this is probably because the periastron check is now leading the binary that is tested from the Pfahl kick test is now not hitting a second kick because there is a merger that happens with the new check.

@MathieuVenet is going to check this out but it will probably be on a week long timescale, so hold off until we hear from him @michaelzevin.

@@ -2449,29 +2454,27 @@ SUBROUTINE evolv2(kstar,mass,tb,ecc,z,tphysf,
*
evolve_type = 8.0

age = tphys - epoch(1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MathieuVenet can you explain to me what this line is doing and why it was changed, as well as the line that reads in aj(1) in hrdiag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally this line is supposed to define the current evolution time as an input for the hrdiag function. However, when the comenv function is called a new variable aj(1) (and (aj(2)) is defined. This variable is a new evolution time much shorter that the one before the comenv function is called.

When defining the current evolution time, and not this new value, as an input for the hrdiag function, an issue arises.

In such cases, luminosity is computed by the lgbtf function, which relies on this age parameter. If the age is too large, the function encounters a negative value raised to a specific power, which Fortran cannot process, resulting in a NaN. This NaN then propagates through key parameters such as the stellar radius, system separation, and other essential quantities, leading to erroneous results.

To resolve this issue, I removed the redundant redefinition of the evolution time, as it is unnecessary for the time step calculation. Instead, I modified hrdiag to use the time variable aj as defined by the comenv function, ensuring numerical stability and accurate computations.

@michaelzevin
Copy link
Collaborator

@MathieuVenet can you copy the kick test from the email here and your description about why the kick test failed?

I left one clarifying question but other than that this PR looks good. The one thing we'll have to do though is update the CI so the kick test doesn't fail. Although it looks like there might be other CI things that are failing with the current dev version. @katiebreivik, thoughts on this?

@MathieuVenet
Copy link
Contributor Author

For the kick :

I have investigated the reason why the kick test failed during the execution of the test_evolve.py function. The issue arises due to the collision test within R.L.O.F. In my case, the system merges during the R.L.O.F. phase, resulting in only one supernova. This explains the changes observed in the kick values.

To better illustrate this, I have attached two screenshots showing the outputs for both the standard evolution and the evolution with my modifications. In both screenshots, you will find key evolution parameters and the associated kick_info. Notably, the vsys_2_total value changes from the expected 17 to 0, simply because, in the second case, there is only one supernova and no binary disruption because of the merger.

cosmic_modifications
cosmic_standard

@katiebreivik
Copy link
Collaborator

Hey @MathieuVenet and @michaelzevin I think the only thing that isn't working is the natal kick check for the pfahl model. The way we fix this is to find a binary that does disrupt, then log it's ejection velocity and hard code the comparison as is done in the test right now. We'll also need to resave data over the current kick data stored in src/cosmic/tests/data/kick_initial_conditions.h5 and update the function here: https://github.com/MathieuVenet/COSMIC/blob/7a2a2b139612cd36e002d46908fe9eef2b4560aa/src/cosmic/tests/test_evolve.py#L104

@michaelzevin
Copy link
Collaborator

Thanks @katiebreivik!

@MathieuVenet, would you like to take a crack at updating these test functions for that this passes the CI?

@michaelzevin
Copy link
Collaborator

Although it also seems like the current development version isn't passing the CI either.

@katiebreivik
Copy link
Collaborator

Although it also seems like the current development version isn't passing the CI either.

Yeah this is because I need to fix the Docker image again. I think the tests do pass.

@MathieuVenet
Copy link
Contributor Author

Hi,
I have found a disrupted system and modified the test on my branch (fix_cosmic_final). I have no longer an error during this test and only the same warnings as the latest cosmic version.

Copy link
codecov bot commented Apr 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.56%. Comparing base (8772c07) to head (fed98d2).
Report is 100 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #694      +/-   ##
===========================================
- Coverage    86.91%   78.56%   -8.35%     
===========================================
  Files           40       48       +8     
  Lines        25542    27046    +1504     
  Branches         0      841     +841     
===========================================
- Hits         22198    21247     -951     
- Misses        3344     5527    +2183     
- Partials         0      272     +272     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@michaelzevin
Copy link
Collaborator

Unit tests all pass now, so will merge this in. Thanks again for your work on this @MathieuVenet!!

@michaelzevin michaelzevin merged commit 776047c into COSMIC-PopSynth:develop Apr 1, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0