Skip to content

Feature/kicks redesign - #18

Merged
nmdickson merged 7 commits into
masterfrom
feature/kicks-redesign
May 5, 2026
Merged

Feature/kicks redesign#18
nmdickson merged 7 commits into
masterfrom
feature/kicks-redesign

Conversation

@nmdickson

Copy link
Copy Markdown
Member

This is a major redesign of how BH natal kicks are handled in SSPtools, motivated by a bug that was found during #17.

Originally (and for the entire history of the package) the BH natal kicks were computed (by default) based on fallback fractions which were being incorrectly interpolated from a function of BH-mass vs fallback. In reality, this should be a function of initial progenitor star mass, not BH mass.

This was probably originally done because the kicks were applied after-the-fact (same as the dynamical BH ejections) where you have only the final BH mass bins, and can compute these quantities.

In order to change all kick functions to be based on the initial mass, how the kicks are handled thus had to be changed entirely. Now, rather than computing and applying them after the solver is finished, the natal kicks are instead applied as retention fractions to the amount of BH mass formed at a given timestep.
This is the same way that e.g. NS kicks and the unused BH_ret_int were used originally.

This means that not all BHs in a given mass bin share the same retention function, and the incorrect fb-interpolation now no longer causes zero BHs in slightly larger BH mass bins to be ejected.

This is a major change under the hood, and comes with various "user-facing" side effects that make this somewhat backwards-incompatible (and thus a new major release).

  1. The natal kick stats KickStats (stored as emf._kick_stats) are no longer easy to compute (as we no longer kick BHs based on the BH bins, which these stats are a function of). The new way of computing them, by trying to autopsy the final results with and without kicks, are approximate at best, and can show non-physical results based on age and binning effects. Therefore they were made less relevant, and are only provided now as they are interesting to inspect. They should be actually used with caution.

  2. To stop needing the kick stats, the definition of the BH_ret_dyn parameter had to change. Now it only represents the retention function of BHs from dynamical ejections, not natal kicks as well. Similarly, the BH_ret_int parameter is entirely removed (replaced by the natal kicks themselves). This was likely actually the original intended use of this parameter, based on its name. This change is not backwards compatible, obviously.

  3. The InitialBHPopulation class is more important now, as in various places it can be useful to know how many BHs would form in total. To facilitate this, the class is vastly improved, and now based simply on going from IMF through IFMR to BHMF, rather than actually solving a binned ODE. It is much (100x) faster now, but also not backwards compatible.

And of course the most obvious change is that new models, run with entirely the same parameters, will have different amounts of final BHs (slightly lower), simply due to the fixes to the natal kicks.

nmdickson added 5 commits May 3, 2026 20:26
This is the source of a major bug that has been in pretty much
every version of SSPtools. The fallback fraction is a function of
the *initial* progenitor mass, not the final BH mass, as we have
been using.

This will, unfortunately, not be a simple fix, and will require
rethinking how natal kicks are implemented entirely.
While working on kick stuff, where this class became necessary in
order to work out some statistics, I realized that this entire thing,
which before consisted of the same ODE as the rest of the classes,
but stripped of anything not BH related, could be accomplished with
some simple math, given that we know the IMF and the IFMR.

This class should give (nearly) the same results as the previous,
but in a fraction of the time (~1 sec to ~0.02 sec). This allows
it to be used in other places without much worry.

Note that this *does* some of the init signatures, so it is not
entirely backwards compatible
The kick statistics cannot be easily computed now that the kicks
are done during the ODE solving directly, not on the BH bins after
the fact. However, these are still useful to have.
Therefore this commit changes `KickStats` to try to recreate this
logic as best as possible.

Note that these will be approximate at best, but it is less
important now, as they will not be used directly for anything
crucial.
This commit changes entirely how the BH natal kicks are handled
and applied to the `evolve_mf` classes. Namely, this is the fix
from the old incorrect computations based on the final mass, to the
correct version using progenitor masses.

This removes all kick logic from the after-the-fact BH ejection
stage, and instead replaces the largely unused `_frem` map with
a new function which calls the relevant retention functions from
`kicks`.
This means that the kicks are now applied during the creation of
the BHs themselves, removing some fraction over time based on the
progenitor star masses.

A lot of other logic had to change to account for these changes.
Notably, the kick stats are no longer as important, and have
become more approximate.
Relatedly, the meaning of `BH_ret_dyn` has now changed, in a
*not backwards compatible* manner, and now represents only the
dynamical ejection retention fraction.
Also changed is the handling of `f_kick`, which now has the
parameters determined once at the start, and the actual used kick
params stored.
Also bump version a major release, due to backwards-incompatibility.
@nmdickson nmdickson self-assigned this May 4, 2026
@nmdickson nmdickson added bug Something isn't working enhancement New feature or request labels May 4, 2026
@nmdickson

Copy link
Copy Markdown
Member Author

The tests will need to be entirely rewritten, I imagine

nmdickson added 2 commits May 5, 2026 11:36
In IFMRS with a wider range of BH masses (like SEVN, with PISN),
we both need to be sure we ignore the destroyed m=0 BHs, and need
to make sure any bins constructed for the BHs can hold BHs of mass
greater than `m_breaks[-1]`.
@nmdickson
nmdickson marked this pull request as ready for review May 5, 2026 20:54
@nmdickson

Copy link
Copy Markdown
Member Author

Testing with GCfit, clusterBH seem to be working, but this has quite a large impact on the kicks and is difficult to know exactly.
Should be okay for merging, I think.

@nmdickson
nmdickson merged commit c49cedd into master May 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant