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

Unifying the code for finding grid boundaries and checking validity in case of ignored data. #271

Open
wants to merge 5 commits into
base: development
Choose a base branch
from

Conversation

kkovlakas
Copy link
Collaborator

@kkovlakas kkovlakas commented Mar 8, 2024

@kkovlakas kkovlakas requested review from ezapartas and maxbriel March 8, 2024 09:36
@astroJeff
Copy link
Contributor

Update (Apr 11): Code does not affect logic - just a more elegant solution to finding grid boundaries with fewer lines of code. @kkovlakas to test this with a grid to make sure boundaries are unaffected.

Copy link
Collaborator

@maxbriel maxbriel left a comment

Choose a reason for hiding this comment

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

This is a nice simplification of the code.
@kkovlakas I was just wondering if a function definition inside a function is a good idea, especially since this is quite a general function. It might be better to define it as another private function of the class. That will also be easier for testing.

Otherwise it looks fine!

@astroJeff
Copy link
Contributor

@kkovlakas, have you had a chance to test this PR yet?

@kkovlakas
Copy link
Collaborator Author

This is a nice simplification of the code. @kkovlakas I was just wondering if a function definition inside a function is a good idea, especially since this is quite a general function. It might be better to define it as another private function of the class. That will also be easier for testing.

Otherwise it looks fine!

I think this function is not going to be used in other methods of the class. So I would keep it hidden to be really "private".

@kkovlakas
Copy link
Collaborator Author

@kkovlakas, have you had a chance to test this PR yet?

Not yet. I was having some issues with Quest, but I am planning to continue again this week.

@astroJeff
Copy link
Contributor

Update (Aug 22): This is a very minor update that we should be able to accept with not too much conversation in the future. One check: we want to make sure that in the CO-HMS_RLO grid, we aren't accidentally setting the boundary to models that never overfilled their Roche lobes. Those simulated points are still stored in the grids for bookkeeping, even if they never interacted.

@kkovlakas kkovlakas marked this pull request as ready for review September 20, 2024 10:41
@maxbriel
Copy link
Collaborator

@kkovlakas asked me to check the grid boundaries between the dev and this PR:

HMS-HMS

PR271

5.5508124513 286.3926178896 0.5550812451 283.5286917107 0.1 5179.4746792312

dev

5.5508124513 286.3926178896 0.5550812451 283.5286917107 0.1 5179.4746792312

CO_HMS_RLO

PR

m1_min, m1_max, m2_min, m2_max, p_min, p_max
0.4528572095827115 242.2905821692 1.0 307.4623904763753 0.09776443350050948 4259.673746605375

dev

0.4528572095827115 320.9213780446 1.0 307.4623904763753 0.09776443350050948 4259.673746605375

CO_HeMS_RLO

PR

m1_min, m1_max, m2_min, m2_max, p_min, p_max
0.4799498483185959 191.91562108852466 1.0 307.4566117375904 0.0012552624375754397 1165.776701178937

dev

0.4799498483185959 191.9157747907 1.0 307.4566117375904 0.0012552624375754397 1165.776701178937

CO_HeMS

PR

m1_min, m1_max, m2_min, m2_max, p_min, p_max
0.5 191.9157747907 1.0 307.4561367244 0.02 1147.2305020897

dev

0.5 191.9157747907 1.0 307.4561367244 0.02 1147.2305020897

@mkruckow
Copy link
Collaborator

mkruckow commented Jan 7, 2025

The difference in the m1_max values in the RLO grids between dev and this PR are indeed from runs, where the final values of the mass are nan. All of them are systems labeled as forced_initial_RLO. I think, those are runs, where MESA does not produce any output and are reconstructed from the grid point, thus having no final values being set. Surely, those runs should not contribute to the interpolation area of a step. (There are more systems with initial RLO which could be excluded from the determination of the interpolation area, but this is an enhancement which might be beyond the scope of this PR)

"""Infer the grid boundaries (min/max of masses and orbital period)."""
def initial_values_min_max(parameter_name):
# get the request column from the initial values
arr = self._psyTrackInterp.grid.initial_values[parameter_name]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd suggest to give it a better name then arr, especially when having final in mind.

return np.min(arr), np.max(arr)

self.m1_min, self.m1_max = initial_values_min_max('star_1_mass')
self.m2_min, self.m2_max = initial_values_min_max('star_2_mass')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Beside m2 should we always calculate a q_min and q_max? At the moment this is still hard coded as 0.05 and 1.0 for the HMS-HMS grid.

state_2 == 'H-rich_Core_H_burning' and
event == 'ZAMS' and
self.m1_min <= m1 <= self.m1_max and
np.max([self.q_min, 0.5/m1]) <= mass_ratio <= self.q_max and
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we better use np.max([self.q_min, self.m2_min/m1])? The same applies at other places, too.

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.

4 participants