Skip to content

Fix Single He star inlist layering - #893

Open
sgossage wants to merge 4 commits into
mainfrom
sg_fix_single_he_layering
Open

Fix Single He star inlist layering#893
sgossage wants to merge 4 commits into
mainfrom
sg_fix_single_he_layering

Conversation

@sgossage

Copy link
Copy Markdown
Contributor

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. In construct_static_inlist,

        for step in range(number_of_star1_formation_steps):
            star1_formation['step{0}'.format(step)] = {}
            star1_formation['step{0}'.format(step)]['inlist_file'] = os.path.join(working_directory, 'star1', 'inlist_step{0}'.format(step))
            for k, v in star1_formation_dictionary.items():
                star1_formation['step{0}'.format(step)][k] = v[step] if type(v) == list else v

will look for star formation settings in mesa_inlist['star1_job_*'] and mesa_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:

    if system_type == "HMS-HMS" and mesa_inlists['single_star_grid']:
        ...
        mesa_inlists['star1_controls_user'] = special_single_star_user_inlist

changing this to

        if system_type == "HMS-HMS" and mesa_inlists['single_star_grid']:
            ...
            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)

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.

…ined in star1_controls_user, as intended. Added protection against overwriting star1_controls_user for single HMS
@sgossage sgossage self-assigned this Aug 17, 2026
@sgossage sgossage linked an issue Aug 17, 2026 that may be closed by this pull request
@sgossage sgossage added the bug Something isn't working label Aug 17, 2026
@sgossage
sgossage requested a review from a team August 17, 2026 16:31

@maxbriel maxbriel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One question, but otherwise looks good

Comment thread bin/posydon-setup-grid
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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are you sure that this is a list already? I thought that it was initialised as a string (with the filepath)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 if statement above is the first check since reading the ini file as to whether or not mesa_inlists['star1_controls_user] exists or not (or if it is set to None). If it does not exist, we need to create it, because we need it to hold at least special_single_star_user_inlist. So, if isn't in the .ini file, it is initialized as an empty list here, then star1_controls_user is 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_user to a specific set of inlists:
348            mesa_inlists['star1_controls_user'] = single_star_scenario
349            mesa_inlists['star1_job_user'] = single_star_scenario

so 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.

@sgossage
sgossage requested a review from maxbriel August 20, 2026 04:00
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

Successfully merging this pull request may close these issues.

[BUG]: inlist_step2 not created for single_HeMS

2 participants