Restarting a binary¶
COSMIC allows you to restart a binary from any point in its evolution from a COSMIC generated bpp array.
In [1]: from cosmic.sample.initialbinarytable import InitialBinaryTable
In [2]: from cosmic.evolve import Evolve
Below we provide an example of the same evolutionary track started from the beginning and three different points in the evolution:
sometime between the beginning and the first object going supernova
between the first and second supernova
after both supernova
In [3]: single_binary = InitialBinaryTable.InitialBinaries(m1=25.543645, m2=20.99784, porb=446.795757, ecc=0.448872, tphysf=13700.0, kstar1=1, kstar2=1, metallicity=0.002)
In [4]: BSEDict = {'xi': 1.0, 'bhflag': 1, 'neta': 0.5, 'windflag': 3, 'wdflag': 1, 'alpha1': 5.0, 'pts1': 0.001, 'pts3': 0.02, 'pts2': 0.01, 'epsnov': 0.001, 'hewind': 0.5, 'ck': 1000, 'bwind': 0.0, 'lambdaf': 0.0, 'mxns': 3.0, 'beta': -1.0, 'tflag': 1, 'acc2': 1.5, 'remnantflag': 3, 'ceflag': 0, 'eddfac': 1.0, 'ifflag': 0, 'bconst': 3000, 'sigma': 265.0, 'gamma': -2.0, 'pisn': 45.0, 'natal_kick_array' : [[-100.0,-100.0,-100.0,-100.0,0.0], [-100.0,-100.0,-100.0,-100.0,0.0]], 'bhsigmafrac' : 1.0, 'polar_kick_angle' : 90, 'qcrit_array' : [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0], 'cekickflag' : 2, 'cehestarflag' : 0, 'cemergeflag' : 0, 'ecsn' : 2.5, 'ecsn_mlow' : 1.4, 'aic' : 1, 'ussn' : 0, 'sigmadiv' :-20.0, 'qcflag' : 1, 'eddlimflag' : 0, 'fprimc_array' : [2.0/21.0,2.0/21.0,2.0/21.0,2.0/21.0,2.0/21.0,2.0/21.0,2.0/21.0,2.0/21.0,2.0/21.0,2.0/21.0,2.0/21.0,2.0/21.0,2.0/21.0,2.0/21.0,2.0/21.0,2.0/21.0], 'bhspinflag' : 0, 'bhspinmag' : 0.0, 'rejuv_fac' : 1.0, 'rejuvflag' : 0, 'htpmb' : 1, 'ST_cr' : 1, 'ST_tide' : 0, 'bdecayfac' : 1, 'randomseed' : -1235453, 'grflag' : 1, 'rembar_massloss' : 0.5, 'kickflag' : 1, 'zsun' : 0.014, 'grflag' : 1, 'bhms_coll_flag' : 0, 'don_lim' : -1, 'acc_lim' : -1, 'rtmsflag' : 0, 'wd_mass_lim': 1}
In [5]: for i in [3, 7, 11]:
...: bpp, bcm, initC, kick_info = Evolve.evolve(initialbinarytable=single_binary, BSEDict=BSEDict)
...: for column in bpp.columns:
...: initC = initC.assign(**{column:bpp.iloc[i][column]})
...: bpp_mid, bcm_mid, initC_mid, kick_info = Evolve.evolve(initialbinarytable=initC, BSEDict={})
...: if i == 3:
...: print("From beginning")
...: print(bpp)
...: print("Started in middle at Index {0}".format(i))
...: print(bpp_mid)
...:
From beginning
tphys mass_1 mass_2 kstar_1 kstar_2 sep porb ecc RRLO_1 ... bacc_1 bacc_2 tacc_1 tacc_2 epoch_1 epoch_2 bhspin_1 bhspin_2 bin_num
0 0.000000 25.543645 20.997840 1 1 884.378139 446.795757 0.448872 0.028718 ... 0.0 0.0 0.0 0.0 0.000000 0.000000 0.0 0.0 0
0 7.710210 24.912154 20.771614 2 1 900.982085 463.730258 0.448872 0.069956 ... 0.0 0.0 0.0 0.0 -0.119527 -0.057630 0.0 0.0 0
0 7.721745 24.907454 20.771066 4 1 901.078093 463.831023 0.448870 0.443298 ... 0.0 0.0 0.0 0.0 -0.119527 -0.057862 0.0 0.0 0
0 8.032373 24.637985 20.771096 4 1 498.880188 191.643984 0.000000 1.000398 ... 0.0 0.0 0.0 0.0 -0.119527 -0.057781 0.0 0.0 0
0 8.118834 23.485300 21.763718 4 1 487.749949 185.593786 0.000000 2.570939 ... 0.0 0.0 0.0 0.0 -0.119527 0.700017 0.0 0.0 0
0 8.118834 23.485300 21.763718 4 1 487.749949 185.593786 0.000000 2.570939 ... 0.0 0.0 0.0 0.0 -0.119527 0.700017 0.0 0.0 0
0 8.118834 8.667346 21.763718 7 1 77.277935 14.272395 0.000000 0.990000 ... 0.0 0.0 0.0 0.0 -0.119527 0.700017 0.0 0.0 0
0 8.118834 8.667346 21.763718 7 1 77.277935 14.272395 0.000000 2.570939 ... 0.0 0.0 0.0 0.0 7.755716 0.701981 0.0 0.0 0
0 8.475465 8.308986 21.742361 8 1 78.254098 14.635273 0.000000 0.035647 ... 0.0 0.0 0.0 0.0 7.738107 0.693769 0.0 0.0 0
0 8.508776 8.257190 21.740508 8 1 78.393282 14.687452 0.000000 0.035647 ... 0.0 0.0 0.0 0.0 7.738107 0.693038 0.0 0.0 0
0 8.508776 7.757190 21.740508 14 1 79.744998 15.196139 0.016950 0.000001 ... 0.0 0.0 0.0 0.0 8.508776 0.693038 0.0 0.0 0
0 9.733484 7.757206 21.659308 14 2 80.414971 15.409265 0.017207 0.000001 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.744085 7.757291 21.656867 14 2 79.538903 15.158748 0.000000 0.000001 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.748186 7.758263 21.651144 14 4 79.586218 15.173502 0.000000 0.000001 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.924034 7.817984 19.332325 14 4 60.943332 10.582154 0.000000 0.000002 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.924034 7.817984 19.332325 14 4 60.943332 10.582154 0.000000 0.000002 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.924034 7.817984 6.622061 14 7 8.539843 0.761137 0.000000 0.000002 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.924034 7.817984 6.622061 14 7 8.539843 0.761137 0.000000 0.000002 ... 0.0 0.0 0.0 0.0 8.511599 9.755041 0.0 0.0 0
0 10.654655 7.835389 6.331263 14 8 8.664570 0.785342 0.000000 0.000010 ... 0.0 0.0 0.0 0.0 8.511599 9.731731 0.0 0.0 0
0 10.705711 7.838450 6.290103 14 8 8.681056 0.788646 0.000000 0.000010 ... 0.0 0.0 0.0 0.0 8.511599 9.731731 0.0 0.0 0
0 10.705711 7.838450 1.675145 14 13 -1.000000 -1.000000 -1.000000 0.000000 ... 0.0 0.0 0.0 0.0 8.511599 10.705711 0.0 0.0 0
0 13700.000000 7.838450 1.675145 14 13 -1.000000 -1.000000 -1.000000 0.000100 ... 0.0 0.0 0.0 0.0 8.511599 10.705711 0.0 0.0 0
[22 rows x 44 columns]
Started in middle at Index 3
tphys mass_1 mass_2 kstar_1 kstar_2 sep porb ecc RRLO_1 ... bacc_1 bacc_2 tacc_1 tacc_2 epoch_1 epoch_2 bhspin_1 bhspin_2 bin_num
0 8.032373 24.637985 20.771096 4 1 498.880188 191.643984 0.000000 1.000398 ... 0.0 0.0 0.0 0.0 -0.119527 -0.057781 0.0 0.0 0
0 8.118986 23.475794 21.772953 4 1 487.717284 185.575699 0.000000 2.577313 ... 0.0 0.0 0.0 0.0 -0.119527 0.706605 0.0 0.0 0
0 8.118986 23.475794 21.772953 4 1 487.717284 185.575699 0.000000 2.577313 ... 0.0 0.0 0.0 0.0 -0.119527 0.706605 0.0 0.0 0
0 8.118986 8.667779 21.772953 7 1 77.459035 14.320321 0.000000 0.990000 ... 0.0 0.0 0.0 0.0 -0.119527 0.706605 0.0 0.0 0
0 8.118986 8.667779 21.772953 7 1 77.459035 14.320321 0.000000 2.577313 ... 0.0 0.0 0.0 0.0 7.755743 0.708552 0.0 0.0 0
0 8.475461 8.309496 21.751553 8 1 78.436664 14.684148 0.000000 0.035569 ... 0.0 0.0 0.0 0.0 7.738137 0.700336 0.0 0.0 0
0 8.508770 8.257698 21.749694 8 1 78.576103 14.736480 0.000000 0.035569 ... 0.0 0.0 0.0 0.0 7.738137 0.699604 0.0 0.0 0
0 8.508770 7.757698 21.749694 14 1 79.930518 15.246694 0.016945 0.000001 ... 0.0 0.0 0.0 0.0 8.508770 0.699604 0.0 0.0 0
0 9.735862 7.757713 21.668160 14 2 80.595158 15.458627 0.017197 0.000001 ... 0.0 0.0 0.0 0.0 8.508770 0.664761 0.0 0.0 0
0 9.746470 7.757798 21.665712 14 2 79.716348 15.207086 0.000000 0.000001 ... 0.0 0.0 0.0 0.0 8.508770 0.664761 0.0 0.0 0
0 9.750553 7.758765 21.660049 14 4 79.763570 15.221815 0.000000 0.000001 ... 0.0 0.0 0.0 0.0 8.508770 0.664761 0.0 0.0 0
0 9.929751 7.819623 19.251575 14 4 60.467695 10.473782 0.000000 0.000002 ... 0.0 0.0 0.0 0.0 8.508770 0.664761 0.0 0.0 0
0 9.929751 7.819623 19.251575 14 4 60.467695 10.473782 0.000000 0.000002 ... 0.0 0.0 0.0 0.0 8.508770 0.664761 0.0 0.0 0
0 9.929751 7.819623 6.633627 14 7 8.653579 0.776038 0.000000 0.000002 ... 0.0 0.0 0.0 0.0 8.508770 0.664761 0.0 0.0 0
0 9.929751 7.819623 6.633627 14 7 8.653579 0.776038 0.000000 0.000002 ... 0.0 0.0 0.0 0.0 8.511433 9.757515 0.0 0.0 0
0 10.655673 7.836718 6.342619 14 8 8.780924 0.800856 0.000000 0.000010 ... 0.0 0.0 0.0 0.0 8.511433 9.734241 0.0 0.0 0
0 10.706576 7.839724 6.301393 14 8 8.797818 0.804253 0.000000 0.000010 ... 0.0 0.0 0.0 0.0 8.511433 9.734241 0.0 0.0 0
0 10.706576 7.839724 1.677151 14 13 -1.000000 -1.000000 -1.000000 0.000000 ... 0.0 0.0 0.0 0.0 8.511433 10.706576 0.0 0.0 0
0 13708.032373 7.839724 1.677151 14 13 -1.000000 -1.000000 -1.000000 0.000100 ... 0.0 0.0 0.0 0.0 8.511433 10.706576 0.0 0.0 0
[19 rows x 44 columns]
Started in middle at Index 7
tphys mass_1 mass_2 kstar_1 kstar_2 sep porb ecc RRLO_1 ... bacc_1 bacc_2 tacc_1 tacc_2 epoch_1 epoch_2 bhspin_1 bhspin_2 bin_num
0 8.475465 8.308986 21.742361 8 1 78.251768 14.634619 0.000000 0.035648 ... 0.0 0.0 0.0 0.0 7.738107 0.693769 0.0 0.0 0
0 8.508776 8.257190 21.740508 8 1 78.390675 14.686719 0.000000 0.035648 ... 0.0 0.0 0.0 0.0 7.738107 0.693038 0.0 0.0 0
0 8.508776 7.757190 21.740508 14 1 79.742346 15.195381 0.016950 0.000001 ... 0.0 0.0 0.0 0.0 8.508776 0.693038 0.0 0.0 0
0 9.733484 7.757206 21.659308 14 2 80.362697 15.394242 0.017178 0.000001 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.744085 7.757291 21.656867 14 2 79.492037 15.145353 0.000000 0.000001 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.748186 7.758265 21.651121 14 4 79.540650 15.160478 0.000000 0.000001 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.923706 7.817875 19.328905 14 4 60.884458 10.567510 0.000000 0.000002 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.923706 7.817875 19.328905 14 4 60.884458 10.567510 0.000000 0.000002 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.923706 7.817875 6.621344 14 7 8.538937 0.761037 0.000000 0.000002 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.923706 7.817875 6.621344 14 7 8.538937 0.761037 0.000000 0.000002 ... 0.0 0.0 0.0 0.0 8.511592 9.755010 0.0 0.0 0
0 10.654718 7.835284 6.330535 14 8 8.663655 0.785241 0.000000 0.000010 ... 0.0 0.0 0.0 0.0 8.511592 9.731697 0.0 0.0 0
0 10.705783 7.838346 6.289379 14 8 8.680136 0.788544 0.000000 0.000010 ... 0.0 0.0 0.0 0.0 8.511592 9.731697 0.0 0.0 0
0 10.705783 7.838346 1.675016 14 13 -1.000000 -1.000000 -1.000000 0.000000 ... 0.0 0.0 0.0 0.0 8.511592 10.705783 0.0 0.0 0
0 13708.118834 7.838346 1.675016 14 13 -1.000000 -1.000000 -1.000000 0.000100 ... 0.0 0.0 0.0 0.0 8.511592 10.705783 0.0 0.0 0
[14 rows x 44 columns]
Started in middle at Index 11
tphys mass_1 mass_2 kstar_1 kstar_2 sep porb ecc RRLO_1 ... bacc_1 bacc_2 tacc_1 tacc_2 epoch_1 epoch_2 bhspin_1 bhspin_2 bin_num
0 9.744085 7.757291 21.656867 14 2 79.538903 15.158748 0.0 0.000001 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.748186 7.758263 21.651144 14 4 79.586218 15.173502 0.0 0.000001 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.924034 7.817984 19.332325 14 4 60.943333 10.582154 0.0 0.000002 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.924034 7.817984 19.332325 14 4 60.943333 10.582154 0.0 0.000002 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.924034 7.817984 6.622061 14 7 8.539843 0.761137 0.0 0.000002 ... 0.0 0.0 0.0 0.0 8.508776 0.658292 0.0 0.0 0
0 9.924034 7.817984 6.622061 14 7 8.539843 0.761137 0.0 0.000002 ... 0.0 0.0 0.0 0.0 8.511599 9.755041 0.0 0.0 0
0 10.654655 7.835389 6.331263 14 8 8.664570 0.785342 0.0 0.000010 ... 0.0 0.0 0.0 0.0 8.511599 9.731731 0.0 0.0 0
0 10.705711 7.838451 6.290103 14 8 8.681056 0.788646 0.0 0.000010 ... 0.0 0.0 0.0 0.0 8.511599 9.731731 0.0 0.0 0
0 10.705711 7.838451 1.675145 14 13 -1.000000 -1.000000 -1.0 0.000000 ... 0.0 0.0 0.0 0.0 8.511599 10.705711 0.0 0.0 0
0 13709.733484 7.838451 1.675145 14 13 -1.000000 -1.000000 -1.0 0.000100 ... 0.0 0.0 0.0 0.0 8.511599 10.705711 0.0 0.0 0
[10 rows x 44 columns]
Natal kick example¶
One example of where restarting a binary can be extremely helpful is studying how natal kicks affect a binary independently of its previous evolution. This is particularly relevant for Gaia BH1 and Gaia BH2 which are difficult to produce through the standard common envelope channels. We can still study the effect of natal kicks on these binaries if we restart the evolution after the mass transfer would occur. We can do this by using a binary which gets us to the right masses given the metallicity, then overwrite some of the initial conditions to resample the natal kicks and pre-explosion separation.
In [6]: from cosmic import utils
...: import pandas as pd
...:
In [7]: single_binary = InitialBinaryTable.InitialBinaries(m1=65.0, m2=0.93, porb=4500, ecc=0.448872,
...: tphysf=13700.0, kstar1=1, kstar2=1, metallicity=0.014*0.6)
...:
In [8]: bpp, bcm, initC, kick_info = Evolve.evolve(initialbinarytable=single_binary, BSEDict=BSEDict)
In [9]: for column in bpp.columns:
...: initC = initC.assign(**{column:bpp.iloc[6][column]})
...:
In [10]: initC = pd.concat([initC]*1000)
....: initC['natal_kick_1'] = np.random.uniform(0, 100, 1000)
....: initC['phi_1'] = np.random.uniform(-90, 90, 1000)
....: initC['theta_1'] = np.random.uniform(0, 360, 1000)
....: initC['mean_anomaly_1'] = np.random.uniform(0, 360, 1000)
....: initC['porb'] = np.random.uniform(50, 190, 1000)
....: initC['sep'] = utils.a_from_p(p=initC.porb.values, m1=initC.mass_1.values, m2=initC.mass_2.values)
....: initC['bin_num'] = np.linspace(0, 1000, 1000)
....:
In [11]: bpp_restart, bcm_restart, initC_restart, kick_info_restart = Evolve.evolve(initialbinarytable=initC, BSEDict={})
In [12]: bpp_BH = bpp_restart.loc[(bpp_restart.kstar_1 == 14) & (bpp_restart.kstar_2 == 1) & (bpp_restart.porb > 0)].groupby('bin_num', as_index=False).first()
In [13]: bpp_BH[['tphys', 'mass_1', 'mass_2', 'porb', 'ecc']]
Out[13]:
tphys mass_1 mass_2 porb ecc
0 4.558013 9.416669 0.931310 608.557088 0.254016
1 4.558013 9.416669 0.931310 9075.496384 0.901622
2 4.558013 9.416669 0.931311 742.644255 0.648648
3 4.558013 9.416669 0.931310 194.217982 0.824820
4 4.558013 9.416669 0.931311 186.672128 0.903305
.. ... ... ... ... ...
567 4.558013 9.416669 0.931310 1911.764755 0.696450
568 4.558013 9.416669 0.931310 847.019445 0.322726
569 4.558013 9.416669 0.931310 6586.721151 0.817416
570 4.558013 9.416669 0.931310 628.540995 0.221635
571 4.558013 9.416669 0.931311 869.107339 0.631821
[572 rows x 5 columns]