Fix Single He star inlist layering - #893
Conversation
…ined in star1_controls_user, as intended. Added protection against overwriting star1_controls_user for single HMS
maxbriel
left a comment
There was a problem hiding this comment.
One question, but otherwise looks good
| if 'star1_controls_user' not in mesa_inlists or mesa_inlists['star1_controls_user'] is None: | ||
| mesa_inlists['star1_controls_user'] = [] | ||
|
|
||
| mesa_inlists['star1_controls_user'].append(special_single_star_user_inlist) |
There was a problem hiding this comment.
Are you sure that this is a list already? I thought that it was initialised as a string (with the filepath)
There was a problem hiding this comment.
In the case of single HMS I'm sure, but actually we need to add something more to the single HeMS case.
In general, mesa_inlists is first defined in main() after parsing the .ini file.
Later in find_inlist_from_scenario, this dictionary gets modified in various ways. Focusing on the single stars though:
- In the single HMS case, that
ifstatement above is the first check since reading the ini file as to whether or notmesa_inlists['star1_controls_user]exists or not (or if it is set toNone). If it does not exist, we need to create it, because we need it to hold at leastspecial_single_star_user_inlist. So, if isn't in the .ini file, it is initialized as an empty list here, thenstar1_controls_useris always appended to that list, or whatever pre-existing list there may have been. - In the single HeMS case, there's a line, actually two, that force
star1_controls_userto a specific set of inlists:
348 mesa_inlists['star1_controls_user'] = single_star_scenario
349 mesa_inlists['star1_job_user'] = single_star_scenarioso that will overwrite anything that was set in .ini in the case of the single He star grid.
I've now added a similar if statement in the single HeMS case now that checks if these dict items exist already, and if so, append single_star_scenario, and subsequently, append special_single_star_user_linlist as well.
The inlist layering in single star grids was modified in the past to avoid overwriting any provided
star1_controls_user. However, that patch took an approach that was incompatible with subsequent star formation scenario inlist layering. Inconstruct_static_inlist,will look for star formation settings in
mesa_inlist['star1_job_*']andmesa_inlist['star1_controls_*']. The previous fix added star1_controls_special as a separate, single-item entry rather than adding the special inlist to the existing star1_controls_user sequence. As a result, the special inlist was not layered consistently with the star-formation scenario inlists, and the resulting sequence could be incomplete.This PR instead keeps the existing star1_job_user and star1_controls_user dictionary items and removes the separate star1_controls_special entry. It prevents the original overwrite by modifying the line that caused the issue:
changing this to
This preserves any existing star-formation inlists while adding the special single-star control inlist, following the same layering approach already used for the CO-He_star scenario.