Exemplo n.º 1
0
        def _evolve_single_system(f):
            try:
                # kstar, mass, orbital period (days), eccentricity, metaliccity, evolution time (millions of years)
                [tmp1,
                 tmp2] = _evolvebin.evolv2(f[0], f[1], f[2], f[3], f[4], f[5],
                                           f[6], f[7], f[8], f[9], f[10],
                                           f[11], f[12], f[13], f[14], f[15],
                                           f[16], f[17], f[18], f[19], f[20],
                                           f[21], f[22], f[23], f[24], f[25],
                                           f[26], f[27], f[28], f[29], f[30],
                                           f[31], f[32], f[33], f[34], f[36])

                bpp_tmp = tmp1[np.argwhere(tmp1[:, 0] > 0), :].squeeze(1)
                bcm_tmp = tmp2[np.argwhere(tmp2[:, 0] > 1), :].squeeze(1)

                bpp_tmp = pd.DataFrame(bpp_tmp,
                                       columns=bpp_columns,
                                       index=[int(f[35])] * len(bpp_tmp))
                bpp_tmp['bin_num'] = int(f[35])
                bpp_tmp.set_index('bin_num')

                bcm_tmp = pd.DataFrame(bcm_tmp,
                                       columns=bcm_columns,
                                       index=[int(f[35])] * len(bcm_tmp))
                bcm_tmp['bin_num'] = int(f[35])
                bcm_tmp.set_index('bin_num')

                return f, bpp_tmp, bcm_tmp

            except Exception as e:
                if nproc == 1:
                    raise
                else:
                    return f, e
Exemplo n.º 2
0
        def _evolve_single_system(f):
            try:
                # kstar, mass, orbital period (days), eccentricity, metaliccity, evolution time (millions of years)
                [bpp, bcm] = _evolvebin.evolv2(
                    f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], f[8], f[9],
                    f[10], f[11], f[12], f[13], f[14], f[15], f[16], f[17],
                    f[18], f[19], f[20], f[21], f[22], f[23], f[24], f[25],
                    f[26], f[27], f[28], f[29], f[30], f[31], f[32], f[33],
                    f[34], f[35], f[36], f[37], f[38], f[39], f[40], f[41],
                    f[42], f[43], f[44], f[45], f[46], f[47])

                try:
                    bpp = bpp[:np.argwhere(bpp[:, 0] == -1)[0][0]]
                    bcm = bcm[:np.argwhere(bcm[:, 0] == -1)[0][0]]
                except IndexError:
                    bpp = bpp[:np.argwhere(bpp[:, 0] > 0)[0][0]]
                    bcm = bcm[:np.argwhere(bcm[:, 0] > 0)[0][0]]
                    raise Warning('bpp overload: mass1 = {0}, mass2 = {1}, porb = {2}, ecc = {3}, tphysf = {4}, metallicity = {5}'\
                                   .format(f[2], f[3], f[4], f[5], f[7], f[6]))

                bpp_bin_numbers = np.atleast_2d(np.array([f[48]] * len(bpp))).T
                bcm_bin_numbers = np.atleast_2d(np.array([f[48]] * len(bcm))).T

                bpp = np.hstack((bpp, bpp_bin_numbers))
                bcm = np.hstack((bcm, bcm_bin_numbers))

                return f, bpp, bcm

            except Exception as e:
                raise
Exemplo n.º 3
0
def evolve(M1,
           M2,
           P_orb,
           ecc,
           v_kick_1,
           theta_kick_1,
           phi_kick_1,
           omega_kick_1,
           v_kick_2,
           theta_kick_2,
           phi_kick_2,
           omega_kick_2,
           time,
           metallicity,
           return_evolution = False,
           verbose_output = False,
           idum = None,
           dtp = 0.1,
           neta = 0.5,
           bwind = 0.0,
           hewind = 0.5,
           alpha1 = 1.0,
           lambda_ce = 0.5,
           ceflag = 0,
           cekickflag = 2,
           cemergeflag = 0,
           cehestarflag = 0,
           sigmadiv = -20,
           tflag = 1,
           windflag = 3,
           ifflag = 0,
           wdflag = 1,
           GRflag = 0,
           bhflag = 1,
           bhspinflag = 0,
           bhspinmag = 0.0,
           remnantflag = 3,
           mxns = 2.5,
           rejuvflag = 0,
           rejuv_fac = 1.0,
           pts1 = 0.005,
           pts2 = 0.01,
           pts3 = 0.02,
           sigma = 265.0,
           polar_kick_angle = 90.0,
           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],
           bhsigmafrac = 1.0,
           pisn = 45.0,
           ecsn = 2.5,
           ecsn_mlow = 1.4,
           aic = 1,
           ussn = 0,
           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],
           beta = 0.125,
           xi = 1.0,
           acc2 = 1.5,
           epsnov = 0.001,
           eddfac = 1.0,
           gamma = -2.0,
           qcflag = 4,
           ck = -1000,
           bconst = -3000,
           htpmb = 1,
           ST_cr = 1,
           ST_tide = 0,
           bdecayfac = 1,
           rembar_massloss = 0.5,
           kickflag = 0,
           f_acc = 1,
           don_lim = 0,
           acc_lim = -2,
           zsun = 0.014):

    if idum is None:
        random_data = os.urandom(4)
        idum = int.from_bytes(random_data, byteorder="big")

    # This is a stand in - the eccentric anomaly needs to be passed instead of pi/3 below
    # Unfortunately, this needs to be updated within cosmic to be the mean anomaly.
    natal_kick_array = [[v_kick_1, (np.pi/2-theta_kick_1) * 180/np.pi, phi_kick_1 * 180/np.pi, omega_kick_1, 0],
                        [v_kick_2, (np.pi/2-theta_kick_2) * 180/np.pi, phi_kick_2 * 180/np.pi, omega_kick_2, 0]]
    # natal_kick_array = [[-100.0, -100.0, -100.0, -100.0, 0.0], [-100.0, -100.0, -100.0, -100.0, 0.0]]
    kick_info = np.zeros((2,len(KICK_COLUMNS)-1))
    # kick_info[0,2] = v_kick_1
    # kick_info[0,3] = np.pi/2-theta_kick_1
    # kick_info[0,4] = phi_kick_1
    # kick_info[1,2] = v_kick_2
    # kick_info[1,3] = np.pi/2-theta_kick_2
    # kick_info[1,4] = phi_kick_2

    _evolvebin.windvars.neta = neta
    _evolvebin.windvars.bwind = bwind
    _evolvebin.windvars.hewind = hewind
    _evolvebin.cevars.alpha1 = alpha1
    _evolvebin.cevars.lambdaf = lambda_ce
    _evolvebin.ceflags.ceflag = ceflag
    _evolvebin.flags.tflag = tflag
    _evolvebin.flags.ifflag = ifflag
    _evolvebin.flags.wdflag = wdflag
    _evolvebin.snvars.pisn = pisn
    _evolvebin.flags.bhflag = bhflag
    # _evolvebin.flags.nsflag = nsflag
    _evolvebin.flags.remnantflag = remnantflag
    _evolvebin.ceflags.cekickflag = cekickflag
    _evolvebin.ceflags.cemergeflag = cemergeflag
    _evolvebin.ceflags.cehestarflag = cehestarflag
    _evolvebin.snvars.mxns = mxns
    _evolvebin.points.pts1 = pts1
    _evolvebin.points.pts2 = pts2
    _evolvebin.points.pts3 = pts3
    _evolvebin.snvars.ecsn = ecsn
    _evolvebin.snvars.ecsn_mlow = ecsn_mlow
    _evolvebin.flags.aic = aic
    _evolvebin.ceflags.ussn = ussn
    _evolvebin.snvars.sigma = sigma
    _evolvebin.snvars.sigmadiv = sigmadiv
    _evolvebin.snvars.bhsigmafrac = bhsigmafrac
    _evolvebin.snvars.polar_kick_angle = polar_kick_angle
    _evolvebin.snvars.natal_kick_array = natal_kick_array
    _evolvebin.cevars.qcrit_array = qcrit_array
    _evolvebin.windvars.beta = beta
    _evolvebin.windvars.xi = xi
    _evolvebin.windvars.acc2 = acc2
    _evolvebin.windvars.epsnov = epsnov
    _evolvebin.windvars.eddfac = eddfac
    _evolvebin.windvars.gamma = gamma
    _evolvebin.flags.bdecayfac = bdecayfac
    _evolvebin.flags.grflag = GRflag
    _evolvebin.magvars.bconst = bconst
    _evolvebin.magvars.ck = ck
    _evolvebin.flags.windflag = windflag
    _evolvebin.flags.qcflag = qcflag
    _evolvebin.flags.eddlimflag = eddlimflag
    _evolvebin.tidalvars.fprimc_array = fprimc_array
    _evolvebin.rand1.idum1 = idum
    _evolvebin.flags.bhspinflag = bhspinflag
    _evolvebin.snvars.bhspinmag = bhspinmag
    _evolvebin.mixvars.rejuv_fac = rejuv_fac
    _evolvebin.flags.rejuvflag = rejuvflag
    _evolvebin.flags.htpmb = htpmb
    _evolvebin.flags.st_cr = ST_cr
    _evolvebin.flags.st_tide = ST_tide
    _evolvebin.snvars.rembar_massloss = rembar_massloss
    _evolvebin.metvars.zsun = zsun
    _evolvebin.snvars.kickflag = kickflag
    _evolvebin.cmcpass.using_cmc = 0
    _evolvebin.windvars.f_acc = f_acc
    _evolvebin.windvars.don_lim = don_lim
    _evolvebin.windvars.acc_lim = acc_lim

    kstar_1 = 1
    kstar_2 = 1

    [bpp_index, bcm_index, kick_info_out] \
                       = _evolvebin.evolv2([kstar_1, kstar_2],
                                           [M1, M2],
                                           P_orb,
                                           ecc,
                                           metallicity,
                                           time,
                                           time,
                                           # dtp,
                                           [M1, M2],
                                           [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],
                                           [0.0, 0.0],
                                           [0.0, 0.0],
                                           [0.0, 0.0],
                                           [0.0, 0.0],
                                           [0.0, 0.0],
                                           0.0,
                                           np.zeros(20),
                                           kick_info)

    bcm = _evolvebin.binary.bcm[:bcm_index].copy()
    bpp = _evolvebin.binary.bpp[:bpp_index].copy()
    _evolvebin.binary.bpp[:bpp_index] = np.zeros(bpp.shape)
    _evolvebin.binary.bcm[:bcm_index] = np.zeros(bcm.shape)
    bcm = bcm.view(dtype=bcm_dtype)
    bpp = bpp.view(dtype=bpp_dtype)

    # If we want the entire evolution
    if return_evolution:
        return bcm, bpp

    kick = kick_info_out.ravel().view(dtype=kick_dtype)

    dtype = [('M1', 'f8'), ('M2', 'f8'), ('a', 'f8'), ('ecc', 'f8'), ('v_sys', 'f8'),
             ('mdot1', 'f8'), ('mdot2', 'f8'), ('t_SN1', 'f8'), ('t_SN2', 'f8'),
             ('R1', 'f8'), ('R2', 'f8'), ('Teff1', 'f8'), ('Teff2', 'f8'),
             ('L1', 'f8'), ('L2', 'f8'), ('k1','i8'), ('k2','i8')]

    output = np.zeros(1, dtype=dtype)

    if len(bcm) == 0: return output[0]

    V_sys_1 = np.sqrt(kick[0]['delta_vsysx_1']**2 + kick[0]['delta_vsysy_1']**2 + kick[0]['delta_vsysz_1']**2)
    V_sys_2 = np.sqrt(kick[1]['delta_vsysx_2']**2 + kick[1]['delta_vsysy_2']**2 + kick[1]['delta_vsysz_2']**2)


    output[0]['M1'] = bcm[-1]['mass_1']
    output[0]['M2'] = bcm[-1]['mass_2']
    output[0]['a'] = bcm[-1]['sep']
    output[0]['ecc'] = bcm[-1]['ecc']
    output[0]['v_sys'] = np.sqrt(V_sys_1**2 + V_sys_2**2)
    output[0]['mdot1'] = bcm[-1]['deltam_1']
    output[0]['mdot2'] = bcm[-1]['deltam_2']
    try:
        output[0]['t_SN1'] = bpp[bpp['evol_type'] == 15][0]['tphys']
    except:
        output[0]['t_SN1'] = 0.0
    try:
        output[0]['t_SN2'] = bpp[bpp['evol_type'] == 16][0]['tphys']
    except:
        output[0]['t_SN2'] = 0.0
    output[0]['R1'] = bcm[-1]['rad_1']
    output[0]['R2'] = bcm[-1]['rad_2']
    output[0]['Teff1'] = bcm[-1]['teff_1']
    output[0]['Teff2'] = bcm[-1]['teff_2']
    output[0]['L1'] = bcm[-1]['lum_1']
    output[0]['L2'] = bcm[-1]['lum_2']
    output[0]['k1'] = bcm[-1]['kstar_1']
    output[0]['k2'] = bcm[-1]['kstar_2']

    return output[0]
Exemplo n.º 4
0
        def _evolve_multi_system(f):
            try:
                res_bcm = np.zeros(f.shape[0],dtype=object)
                res_bpp = np.zeros(f.shape[0],dtype=object)
                for i in range(0,f.shape[0]):
                    # kstar, mass, orbital period (days), eccentricity, metaliccity, evolution time (millions of years)
                    _evolvebin.windvars.neta = f[i,37]
                    _evolvebin.windvars.bwind = f[i,38]
                    _evolvebin.windvars.hewind = f[i,39]
                    _evolvebin.cevars.alpha1 = f[i,40]
                    _evolvebin.cevars.lambdaf = f[i,41]
                    _evolvebin.ceflags.ceflag = f[i,42]
                    _evolvebin.flags.tflag = f[i,43]
                    _evolvebin.flags.ifflag = f[i,44]
                    _evolvebin.flags.wdflag = f[i,45]
                    _evolvebin.snvars.pisn = f[i,46]
                    _evolvebin.flags.bhflag = f[i,47]
                    _evolvebin.flags.nsflag = f[i,48]
                    _evolvebin.ceflags.cekickflag = f[i,49]
                    _evolvebin.ceflags.cemergeflag = f[i,50]
                    _evolvebin.ceflags.cehestarflag = f[i,51]
                    _evolvebin.windvars.mxns = f[i,52]
                    _evolvebin.points.pts1 = f[i,53]
                    _evolvebin.points.pts2 = f[i,54]
                    _evolvebin.points.pts3 = f[i,55]
                    _evolvebin.snvars.ecsn = f[i,56]
                    _evolvebin.snvars.ecsn_mlow = f[i,57]
                    _evolvebin.flags.aic = f[i,58]
                    _evolvebin.ceflags.ussn = f[i,59]
                    _evolvebin.snvars.sigma = f[i,60]
                    _evolvebin.snvars.sigmadiv = f[i,61]
                    _evolvebin.snvars.bhsigmafrac = f[i,62]
                    _evolvebin.snvars.polar_kick_angle = f[i,63]
                    _evolvebin.snvars.natal_kick_array = f[i,64]
                    _evolvebin.cevars.qcrit_array = f[i,65]
                    _evolvebin.windvars.beta = f[i,66]
                    _evolvebin.windvars.xi = f[i,67]
                    _evolvebin.windvars.acc2 = f[i,68]
                    _evolvebin.windvars.epsnov = f[i,69]
                    _evolvebin.windvars.eddfac = f[i,70]
                    _evolvebin.windvars.gamma = f[i,71]
                    _evolvebin.flags.bdecayfac = f[i,72]
                    _evolvebin.magvars.bconst = f[i,73]
                    _evolvebin.magvars.ck = f[i,74]
                    _evolvebin.flags.windflag = f[i,75]
                    _evolvebin.flags.qcflag = f[i,76]
                    _evolvebin.windvars.eddlimflag = f[i,77]
                    _evolvebin.tidalvars.fprimc_array = f[i,78]
                    _evolvebin.rand1.idum1 = f[i,80]
                    _evolvebin.flags.bhspinflag = f[i,81]
                    _evolvebin.snvars.bhspinmag = f[i,82]
                    _evolvebin.mixvars.rejuv_fac = f[i,83]
                    _evolvebin.flags.rejuvflag = f[i,84]
                    _evolvebin.flags.htpmb = f[i,85]
                    _evolvebin.flags.st_cr = f[i,86]
                    _evolvebin.flags.st_tide = f[i,87]
                    _evolvebin.cmcpass.using_cmc = 0 
                    [bpp, bcm] = _evolvebin.evolv2([f[i,0],f[i,1]], [f[i,2],f[i,3]], f[i,4], f[i,5], f[i,6], f[i,7], f[i,79],
                                                    [f[i,8],f[i,9]], [f[i,10],f[i,11]], [f[i,12],f[i,13]],
                                                    [f[i,14],f[i,15]], [f[i,16],f[i,17]], [f[i,18],f[i,19]],
                                                    [f[i,20],f[i,21]], [f[i,22],f[i,23]], [f[i,24],f[i,25]],
                                                    [f[i,26],f[i,27]], [f[i,28],f[i,29]], [f[i,30],f[i,31]],
                                                    [f[i,32],f[i,33]], [f[i,34],f[i,35]], f[i,36],
                                                    np.zeros(20),np.zeros(20))
                    try:
                        idx1 = np.argmax(bpp[:,0] == -1)
                        idx2 = np.argmax(bcm[:,0] == -1)
                        bpp = bpp[:idx1]
                        bcm = bcm[:idx2]
                    except IndexError:
                        bpp = bpp[:np.argwhere(bpp[:,0] > 0)[0][0]]
                        bcm = bcm[:np.argwhere(bcm[:,0] > 0)[0][0]]
                        raise Warning('bpp overload: mass1 = {0}, mass2 = {1}, porb = {2}, ecc = {3}, tphysf = {4}, metallicity = {5}'\
                                       .format(f[i,2], f[i,3], f[i,4], f[i,5], f[i,7], f[i,6]))
                    bpp_bin_numbers = np.atleast_2d(np.array([f[i,88]] * len(bpp))).T
                    bcm_bin_numbers = np.atleast_2d(np.array([f[i,88]] * len(bcm))).T

                    res_bpp[i] = np.hstack((bpp, bpp_bin_numbers))
                    res_bcm[i] = np.hstack((bcm, bcm_bin_numbers))

                return f, np.vstack(res_bpp), np.vstack(res_bcm)

            except Exception as e:
                raise
Exemplo n.º 5
0
        def _evolve_single_system(f):
            try:
                # kstar, mass, orbital period (days), eccentricity, metaliccity, evolution time (millions of years)
                _evolvebin.windvars.neta = f[37]
                _evolvebin.windvars.bwind = f[38]
                _evolvebin.windvars.hewind = f[39]
                _evolvebin.cevars.alpha1 = f[40]
                _evolvebin.cevars.lambdaf = f[41]
                _evolvebin.ceflags.ceflag = f[42]
                _evolvebin.flags.tflag = f[43]
                _evolvebin.flags.ifflag = f[44]
                _evolvebin.flags.wdflag = f[45]
                _evolvebin.snvars.pisn = f[46]
                _evolvebin.flags.bhflag = f[47]
                _evolvebin.flags.nsflag = f[48]
                _evolvebin.ceflags.cekickflag = f[49]
                _evolvebin.ceflags.cemergeflag = f[50]
                _evolvebin.ceflags.cehestarflag = f[51]
                _evolvebin.windvars.mxns = f[52]
                _evolvebin.points.pts1 = f[53]
                _evolvebin.points.pts2 = f[54]
                _evolvebin.points.pts3 = f[55]
                _evolvebin.snvars.ecsn = f[56]
                _evolvebin.snvars.ecsn_mlow = f[57]
                _evolvebin.flags.aic = f[58]
                _evolvebin.ceflags.ussn = f[59]
                _evolvebin.snvars.sigma = f[60]
                _evolvebin.snvars.sigmadiv = f[61]
                _evolvebin.snvars.bhsigmafrac = f[62]
                _evolvebin.snvars.polar_kick_angle = f[63]
                _evolvebin.snvars.natal_kick_array = f[64]
                _evolvebin.cevars.qcrit_array = f[65]
                _evolvebin.windvars.beta = f[66]
                _evolvebin.windvars.xi = f[67]
                _evolvebin.windvars.acc2 = f[68]
                _evolvebin.windvars.epsnov = f[69]
                _evolvebin.windvars.eddfac = f[70]
                _evolvebin.windvars.gamma = f[71]
                _evolvebin.flags.bdecayfac = f[72]
                _evolvebin.magvars.bconst = f[73]
                _evolvebin.magvars.ck = f[74]
                _evolvebin.flags.windflag = f[75]
                _evolvebin.flags.qcflag = f[76]
                _evolvebin.windvars.eddlimflag = f[77]
                _evolvebin.tidalvars.fprimc_array = f[78]
                _evolvebin.rand1.idum1 = f[80]
                _evolvebin.flags.bhspinflag = f[81]
                _evolvebin.snvars.bhspinmag = f[82]
                _evolvebin.mixvars.rejuv_fac = f[83]
                _evolvebin.flags.rejuvflag = f[84]
                _evolvebin.flags.htpmb = f[85]
                _evolvebin.flags.st_cr = f[86]
                _evolvebin.flags.st_tide = f[87]
                _evolvebin.cmcpass.using_cmc = 0

                [bpp, bcm] = _evolvebin.evolv2([f[0],f[1]], [f[2],f[3]], f[4], f[5], f[6], f[7], f[79],
                                                [f[8],f[9]], [f[10],f[11]], [f[12],f[13]],
                                                [f[14],f[15]], [f[16],f[17]], [f[18],f[19]],
                                                [f[20],f[21]], [f[22],f[23]], [f[24],f[25]],
                                                [f[26],f[27]], [f[28],f[29]], [f[30],f[31]],
                                                [f[32],f[33]], [f[34],f[35]], f[36],
                                                np.zeros(20),np.zeros(20))

                try:
                    bpp = bpp[:np.argwhere(bpp[:,0] == -1)[0][0]]
                    bcm = bcm[:np.argwhere(bcm[:,0] == -1)[0][0]]
                except IndexError:
                    bpp = bpp[:np.argwhere(bpp[:,0] > 0)[0][0]]
                    bcm = bcm[:np.argwhere(bcm[:,0] > 0)[0][0]]
                    raise Warning('bpp overload: mass1 = {0}, mass2 = {1}, porb = {2}, ecc = {3}, tphysf = {4}, metallicity = {5}'\
                                   .format(f[2], f[3], f[4], f[5], f[7], f[6]))

                bpp_bin_numbers = np.atleast_2d(np.array([f[88]] * len(bpp))).T
                bcm_bin_numbers = np.atleast_2d(np.array([f[88]] * len(bcm))).T

                bpp = np.hstack((bpp, bpp_bin_numbers))
                bcm = np.hstack((bcm, bcm_bin_numbers))

                return f, bpp, bcm

            except Exception as e:
                raise
Exemplo n.º 6
0
def evolve(mass1,
           mass2,
           orbital_period,
           ecc,
           v_kick1,
           theta_kick1,
           phi_kick1,
           v_kick2,
           theta_kick2,
           phi_kick2,
           tphysf,
           metallicity,
           verbose=False,
           xi=1.0,
           bhflag=1,
           neta=0.5,
           windflag=3,
           wdflag=1,
           alpha1=1.0,
           pts1=0.001,
           pts3=0.02,
           pts2=0.01,
           epsnov=0.001,
           hewind=0.5,
           ck=-1000,
           bwind=0.0,
           lambdaf=0.5,
           mxns=2.5,
           beta=0.125,
           tflag=1,
           acc2=1.5,
           nsflag=3,
           ceflag=0,
           eddfac=1.0,
           ifflag=0,
           bconst=-3000,
           sigma=265.0,
           gamma=-1.0,
           pisn=45.0,
           natal_kick_array=[-100.0, -100.0, -100.0, -100.0, -100.0, -100.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=2,
           eddlimflag=0,
           idum1=None,
           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):

    natal_kick_array = [
        v_kick1, v_kick2, theta_kick1, theta_kick2, phi_kick1, phi_kick2
    ]

    if idum1 is None:
        idum1 = -np.random.randint(
            np.iinfo(np.int32).min, np.iinfo(np.int32).max, size=1)

    # Set input variables
    _evolvebin.windvars.neta = neta
    _evolvebin.windvars.bwind = bwind
    _evolvebin.windvars.hewind = hewind
    _evolvebin.cevars.alpha1 = alpha1
    _evolvebin.cevars.lambdaf = lambdaf
    _evolvebin.ceflags.ceflag = ceflag
    _evolvebin.flags.tflag = tflag
    _evolvebin.flags.ifflag = ifflag
    _evolvebin.flags.wdflag = wdflag
    _evolvebin.snvars.pisn = pisn
    _evolvebin.flags.bhflag = bhflag
    _evolvebin.flags.nsflag = nsflag
    _evolvebin.ceflags.cekickflag = cekickflag
    _evolvebin.ceflags.cemergeflag = cemergeflag
    _evolvebin.ceflags.cehestarflag = cehestarflag
    _evolvebin.windvars.mxns = mxns
    _evolvebin.points.pts1 = pts1
    _evolvebin.points.pts2 = pts2
    _evolvebin.points.pts3 = pts3
    _evolvebin.snvars.ecsn = ecsn
    _evolvebin.snvars.ecsn_mlow = ecsn_mlow
    _evolvebin.flags.aic = aic
    _evolvebin.ceflags.ussn = ussn
    _evolvebin.snvars.sigma = sigma
    _evolvebin.snvars.sigmadiv = sigmadiv
    _evolvebin.snvars.bhsigmafrac = bhsigmafrac
    _evolvebin.snvars.polar_kick_angle = polar_kick_angle
    _evolvebin.snvars.natal_kick_array = natal_kick_array
    _evolvebin.cevars.qcrit_array = qcrit_array
    _evolvebin.windvars.beta = beta
    _evolvebin.windvars.xi = xi
    _evolvebin.windvars.acc2 = acc2
    _evolvebin.windvars.epsnov = epsnov
    _evolvebin.windvars.eddfac = eddfac
    _evolvebin.windvars.gamma = gamma
    _evolvebin.flags.bdecayfac = bdecayfac
    _evolvebin.magvars.bconst = bconst
    _evolvebin.magvars.ck = ck
    _evolvebin.flags.windflag = windflag
    _evolvebin.flags.qcflag = qcflag
    _evolvebin.windvars.eddlimflag = eddlimflag
    _evolvebin.tidalvars.fprimc_array = fprimc_array
    _evolvebin.rand1.idum1 = idum1
    _evolvebin.flags.bhspinflag = bhspinflag
    _evolvebin.snvars.bhspinmag = bhspinmag
    _evolvebin.mixvars.rejuv_fac = rejuv_fac
    _evolvebin.flags.rejuvflag = rejuvflag
    _evolvebin.flags.htpmb = htpmb
    _evolvebin.flags.st_cr = ST_cr
    _evolvebin.flags.st_tide = ST_tide
    _evolvebin.cmcpass.using_cmc = 0

    # 0 k1,
    # 1 k2,
    # 2 m1,
    # 3 m2,
    # 4 porb,
    # 5 ecc,
    # 6 metallicity,
    # 7 tphysf,
    # 8 mass0_1,
    # 9 mass0_2,
    # 10 rad1,
    # 11 rad2,
    # 12 lumin1,
    # 13 lumin2,
    # 14 massc1,
    # 15 massc2,
    # 16 radc1,
    # 17 radc2,
    # 18 menv1,
    # 19 menv2,
    # 20 renv1,
    # 21 renv2,
    # 22 ospin1,
    # 23 ospin2,
    # 24 b_0_1,
    # 25 b_0_2,
    # 26 bacc1,
    # 27 bacc2,
    # 28 tacc1,
    # 29 tacc2,
    # 30 epoch1,
    # 31 epoch2,
    # 32 tms1,
    # 33 tms2,
    # 34 bhspin1,
    # 35 bhspin2,
    # 36 tphys,
    # 37 binfrac

    print(_evolvebin.windvars.neta, _evolvebin.windvars.bwind,
          _evolvebin.windvars.hewind, _evolvebin.cevars.alpha1,
          _evolvebin.cevars.lambdaf, _evolvebin.ceflags.ceflag,
          _evolvebin.flags.tflag, _evolvebin.flags.ifflag,
          _evolvebin.flags.wdflag, _evolvebin.snvars.pisn,
          _evolvebin.flags.bhflag, _evolvebin.flags.nsflag,
          _evolvebin.ceflags.cekickflag, _evolvebin.ceflags.cemergeflag,
          _evolvebin.ceflags.cehestarflag, _evolvebin.windvars.mxns,
          _evolvebin.points.pts1, _evolvebin.points.pts2,
          _evolvebin.points.pts3, _evolvebin.snvars.ecsn,
          _evolvebin.snvars.ecsn_mlow, _evolvebin.flags.aic,
          _evolvebin.ceflags.ussn, _evolvebin.snvars.sigma,
          _evolvebin.snvars.sigmadiv, _evolvebin.snvars.bhsigmafrac,
          _evolvebin.snvars.polar_kick_angle,
          _evolvebin.snvars.natal_kick_array, _evolvebin.cevars.qcrit_array,
          _evolvebin.windvars.beta, _evolvebin.windvars.xi,
          _evolvebin.windvars.acc2, _evolvebin.windvars.epsnov,
          _evolvebin.windvars.eddfac, _evolvebin.windvars.gamma,
          _evolvebin.flags.bdecayfac, _evolvebin.magvars.bconst,
          _evolvebin.magvars.ck, _evolvebin.flags.windflag,
          _evolvebin.flags.qcflag, _evolvebin.windvars.eddlimflag,
          _evolvebin.tidalvars.fprimc_array, _evolvebin.rand1.idum1,
          _evolvebin.flags.bhspinflag, _evolvebin.snvars.bhspinmag,
          _evolvebin.mixvars.rejuv_fac, _evolvebin.flags.rejuvflag,
          _evolvebin.flags.htpmb, _evolvebin.flags.st_cr,
          _evolvebin.flags.st_tide, _evolvebin.cmcpass.using_cmc)

    [bpp, bcm] = _evolvebin.evolv2(
        [1, 1],
        [mass1, mass2],
        orbital_period,
        ecc,
        metallicity,
        tphysf,
        tphysf,  # dtp,
        [mass1, mass2],
        [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],
        # [mass0_1, mass0_2],
        # [rad1, rad2],
        # [lumin1, lumin2],
        # [massc1, massc2],
        # [radc1, radc2],
        # [menv1, menv2],
        # [renv1, renv2],
        # [ospin1, ospin2],
        # [b_0_1, b_0_2],
        # [bacc1, bacc2],
        # [tacc1, tacc2],
        # [epoch1, epoch2],
        # [tms1, tms2],
        # [bhspin1, bhspin2],
        0.0,
        np.zeros(20),
        np.zeros(20))

    print(
        [1, 1],
        [mass1, mass2],
        orbital_period,
        ecc,
        metallicity,
        tphysf,
        tphysf,  # dtp,
        [mass1, mass2],
        [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],
        # [mass0_1, mass0_2],
        # [rad1, rad2],
        # [lumin1, lumin2],
        # [massc1, massc2],
        # [radc1, radc2],
        # [menv1, menv2],
        # [renv1, renv2],
        # [ospin1, ospin2],
        # [b_0_1, b_0_2],
        # [bacc1, bacc2],
        # [tacc1, tacc2],
        # [epoch1, epoch2],
        # [tms1, tms2],
        # [bhspin1, bhspin2],
        0.0,
        np.zeros(20),
        np.zeros(20))

    return bcm, bpp
Exemplo n.º 7
0
def _evolve_single_system(f):
    try:
        f["kick_info"] = np.zeros((2, len(KICK_COLUMNS) - 1))
        # determine if we already have a compact object, if yes than one SN has already occured
        if (f["kstar_1"] in range(10, 15)) or (f["kstar_2"] in range(10, 15)):
            f["kick_info"][0, 0] = 1
        # kstar, mass, orbital period (days), eccentricity, metaliccity, evolution time (millions of years)
        _evolvebin.windvars.neta = f["neta"]
        _evolvebin.windvars.bwind = f["bwind"]
        _evolvebin.windvars.hewind = f["hewind"]
        _evolvebin.cevars.alpha1 = f["alpha1"]
        _evolvebin.cevars.lambdaf = f["lambdaf"]
        _evolvebin.ceflags.ceflag = f["ceflag"]
        _evolvebin.flags.tflag = f["tflag"]
        _evolvebin.flags.ifflag = f["ifflag"]
        _evolvebin.flags.wdflag = f["wdflag"]
        _evolvebin.snvars.pisn = f["pisn"]
        _evolvebin.flags.bhflag = f["bhflag"]
        _evolvebin.flags.remnantflag = f["remnantflag"]
        _evolvebin.ceflags.cekickflag = f["cekickflag"]
        _evolvebin.ceflags.cemergeflag = f["cemergeflag"]
        _evolvebin.ceflags.cehestarflag = f["cehestarflag"]
        _evolvebin.flags.grflag = f["grflag"]
        _evolvebin.flags.bhms_coll_flag = f["bhms_coll_flag"]
        _evolvebin.snvars.mxns = f["mxns"]
        _evolvebin.points.pts1 = f["pts1"]
        _evolvebin.points.pts2 = f["pts2"]
        _evolvebin.points.pts3 = f["pts3"]
        _evolvebin.snvars.ecsn = f["ecsn"]
        _evolvebin.snvars.ecsn_mlow = f["ecsn_mlow"]
        _evolvebin.flags.aic = f["aic"]
        _evolvebin.ceflags.ussn = f["ussn"]
        _evolvebin.snvars.sigma = f["sigma"]
        _evolvebin.snvars.sigmadiv = f["sigmadiv"]
        _evolvebin.snvars.bhsigmafrac = f["bhsigmafrac"]
        _evolvebin.snvars.polar_kick_angle = f["polar_kick_angle"]
        _evolvebin.snvars.natal_kick_array = f["natal_kick_array"]
        _evolvebin.cevars.qcrit_array = f["qcrit_array"]
        _evolvebin.mtvars.don_lim = f["don_lim"]
        _evolvebin.mtvars.acc_lim = f["acc_lim"]
        _evolvebin.windvars.beta = f["beta"]
        _evolvebin.windvars.xi = f["xi"]
        _evolvebin.windvars.acc2 = f["acc2"]
        _evolvebin.windvars.epsnov = f["epsnov"]
        _evolvebin.windvars.eddfac = f["eddfac"]
        _evolvebin.windvars.gamma = f["gamma"]
        _evolvebin.flags.bdecayfac = f["bdecayfac"]
        _evolvebin.magvars.bconst = f["bconst"]
        _evolvebin.magvars.ck = f["ck"]
        _evolvebin.flags.windflag = f["windflag"]
        _evolvebin.flags.qcflag = f["qcflag"]
        _evolvebin.flags.eddlimflag = f["eddlimflag"]
        _evolvebin.tidalvars.fprimc_array = f["fprimc_array"]
        _evolvebin.rand1.idum1 = f["randomseed"]
        _evolvebin.flags.bhspinflag = f["bhspinflag"]
        _evolvebin.snvars.bhspinmag = f["bhspinmag"]
        _evolvebin.mixvars.rejuv_fac = f["rejuv_fac"]
        _evolvebin.flags.rejuvflag = f["rejuvflag"]
        _evolvebin.flags.htpmb = f["htpmb"]
        _evolvebin.flags.st_cr = f["ST_cr"]
        _evolvebin.flags.st_tide = f["ST_tide"]
        _evolvebin.snvars.rembar_massloss = f["rembar_massloss"]
        _evolvebin.metvars.zsun = f["zsun"]
        _evolvebin.snvars.kickflag = f["kickflag"]
        _evolvebin.cmcpass.using_cmc = 0

        [bpp_index, bcm_index, kick_info] = _evolvebin.evolv2(
            [f["kstar_1"], f["kstar_2"]], [f["mass_1"], f["mass_2"]],
            f["porb"], f["ecc"], f["metallicity"], f["tphysf"], f["dtp"],
            [f["mass0_1"], f["mass0_2"]], [f["rad_1"], f["rad_2"]],
            [f["lum_1"], f["lum_2"]], [f["massc_1"], f["massc_2"]],
            [f["radc_1"], f["radc_2"]], [f["menv_1"], f["menv_2"]],
            [f["renv_1"], f["renv_2"]], [f["omega_spin_1"], f["omega_spin_2"]],
            [f["B_1"], f["B_2"]], [f["bacc_1"], f["bacc_2"]],
            [f["tacc_1"], f["tacc_2"]], [f["epoch_1"], f["epoch_2"]],
            [f["tms_1"], f["tms_2"]], [f["bhspin_1"], f["bhspin_2"]],
            f["tphys"], np.zeros(20), np.zeros(20), f["kick_info"])
        bcm = _evolvebin.binary.bcm[:bcm_index].copy()
        bpp = _evolvebin.binary.bpp[:bpp_index].copy()
        _evolvebin.binary.bpp[:bpp_index] = np.zeros(bpp.shape)
        _evolvebin.binary.bcm[:bcm_index] = np.zeros(bcm.shape)

        bpp = np.hstack((bpp, np.ones((bpp.shape[0], 1)) * f["bin_num"]))
        bcm = np.hstack((bcm, np.ones((bcm.shape[0], 1)) * f["bin_num"]))
        kick_info = np.hstack((kick_info, np.ones(
            (kick_info.shape[0], 1)) * f["bin_num"]))

        return f, bpp, bcm, kick_info, _evolvebin.snvars.natal_kick_array.copy(
        )

    except Exception as e:
        print(e)
        raise