Skip to content
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

error in interpolation.py #286

Open
celiotine opened this issue Mar 27, 2024 · 3 comments
Open

error in interpolation.py #286

celiotine opened this issue Mar 27, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@celiotine
Copy link
Contributor

This error is being produced by interpolation.py for rare binary instances:

Screen Shot 2024-03-27 at 1 23 03 PM

This error is happening in this chunk of code in get_final_values():

while (kvalue_low is None or np.isnan(kvalue_low)):
           mass_low = np.max(self.grid_mass[mass_low > self.grid_mass])
           try:
               kvalue_low = self.grid_final_values[mass_low][key]
           except KeyError:
               self.load_grid(mass_low)
               kvalue_low = self.grid_final_values[mass_low][key]

During the iteration of the while loop, mass_low becomes <= all values in self.grid_mass, so the cut self.grid_mass[mass_low > self.grid_mass] returns an empty array, and np.max() fails.

Not sure if the logic needs to be fixed or if this should be caught in some sort of try/except.

Note: This error is happening for binaries out-of-hull (see Issue #265 for more info):
Screen Shot 2024-03-27 at 1 27 11 PM

You can reproduce this error by evolving the following binary with the posydon-error-checking branch:

star_1 = SingleStar(**{'mass': 23.17680615091953, 'state': 'H-rich_Core_H_burning',\
                'natal_kick_array': [190.85500146900986, 1.6094340867322998, 2.199150720317031, 1.5976269376867043]})
star_2 = SingleStar(**{'mass': 8.542829264179423, 'state': 'H-rich_Core_H_burning',\
                'natal_kick_array': [None, None, None, None]})

binary = BinaryStar(star_1, star_2,
                   **{'time': 0.0, 
                      'state': 'detached', 
                      'event': 'ZAMS',
                      'orbital_period': 39.47002178459404, 
                      'eccentricity': 0.0},
                    properties = sim_prop)

binary.evolve()
@celiotine celiotine added the bug Something isn't working label Mar 27, 2024
@astroJeff
Copy link
Contributor

@prinse1545, will you have a chance to look into this at all?

@philipp-rajah
Copy link
Contributor

@astroJeff I haven't done more than look at the very descriptive report provided by Camille and it's unclear to me how to proceed. My understanding is that the actual error is being raised outside the IFInterpolation, namely in what I think is the single star interpolation part of POSYDON. Presumably this is being caused by errors introduced by the 1NN approximation. If this is the case then I assume we need more tools to understand why this is happening in order to determine whether it is acceptable. In which case if it is I can edit the code so it doesn't throw an error, but instead throws a warning or continues the evolution in the most appropriate way (if possible).

From my end I need to know what specifically is needed for understanding why this happens in an astrophysical sense and then what is the most appropriate way to handle this from your perspective i.e just accept it and throw a warning / error that is more descriptive or continue the evolution of possible. As for actually answering your question, yes I can look into this but I am spread quite thin across research, classes, and some tasks I'm handling for Mathias, but if we could find a time to meet and get all of this straightened out I don't think this should take too long to resolve.

@maxbriel
Copy link
Collaborator

I've come across this too recently. I looked into the specific key it is trying to match. Although I don't remember it exactly, I believe it was trying to match something like the core_mass_at_He_depletion. But those values are NaN if the star doesn't reach it. Or something similar.
So mass_low is set to the maximum mass from the self.grid_mass[mass_low > self.grid_mass], but the kvalue is NaN. It keeps selecting the next one, but those are lower masses which will also have NaNs. Eventually, emptying the grid_mass array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants