COSMIC-PopSynth / COSMIC

COSMIC (Compact Object Synthesis and Monte Carlo Investigation Code)
GNU General Public License v3.0
45 stars 58 forks source link

[general issue] NaN results produced in `bpp` table (when evolve to HeHG during stable MT) #608

Open TomWagg opened 8 months ago

TomWagg commented 8 months ago

When running COSMIC on large populations of binaries I frequently run into edge cases that result in NaN values in the bpp output. I've been chatting with @katiebreivik about this and realised I should probably organise a little. So here's an issue about this and I'll keep a list of commonalities that seem to result in NaNs up to date and post initC and bpp tables in the comments below.

NaN clues noticed so far:

  1. This appears to consistently happen when a star evolves on HeHG (kstar=8) during mass transfer
  2. Often the RRLO_1 column is the first one that seems to get a NaN
  3. I've only ever seen this happen with binaries (I ran simulations with binfrac=0.5 and kept all of the singles)

edit: GitHub won't let me upload hdf5 files so I'm going to attach separate CSVs instead!

Here's a quick confirmation that it is happening whenever you have a star evolving to HeHG during mass transfer:

nan_bpp = pd.read_csv("nans_bpp.csv", index_col=0)
nan_bin_nums = nan_bpp["bin_num"].unique()
hehg_during_mt = [False for _ in range(len(nan_bin_nums))]
for i, bin_num in enumerate(nan_bin_nums):
    single_bpp = nan_bpp.loc[bin_num][["kstar_1", "kstar_2", "evol_type", "RRLO_1", "RRLO_2"]]
    mt = False
    for j in range(len(single_bpp)):
        if single_bpp.iloc[j].isnull().any():
            if single_bpp.iloc[j]["kstar_1"] == 8 and mt:
                hehg_during_mt[i] = True
                break

        if single_bpp.iloc[j]["evol_type"] == 3:
            mt = True
        elif single_bpp.iloc[j]["evol_type"] == 3:
            mt = False

print(all(hehg_during_mt))

>>> True
TomWagg commented 8 months ago

nans_initC.csv nans_bpp.csv

TomWagg commented 8 months ago

Here's 100 more

nans_bpp(1).csv nans_initC(1).csv

TomWagg commented 8 months ago

As a test I also checked the successful binaries in the simulation (~1.5 million) and found that there were exactly zero that evolved onto HeHG (kstar_1=8) during stable mass transfer. I did find successful binaries that

  1. ~48,000 went through mass transfer whilst kstar_1=8, but they evolved to HeHG before mass transfer started
  2. A further ~5000 did evolve to HeHG during mass transfer, but it was during a common envelope

So in summary it seems like COSMIC can't currently handle a star evolving into HeHG during stable mass transfer I think.