예제 #1
0
    def test_multi_evolve_with_table(self):
        # Check that the sample_primary function samples mass correctly
        EvolvedBinaryBPP, EvolvedBinaryBCM, initCond, kick_info = Evolve.evolve(
            initialbinarytable=INIT_CONDITIONS, n_per_block=100)

        pd.testing.assert_frame_equal(EvolvedBinaryBPP, BPP_DF, check_dtype=False, check_exact=False, check_less_precise=True)
        pd.testing.assert_frame_equal(EvolvedBinaryBCM, BCM_DF, check_dtype=False, check_exact=False, check_less_precise=True)
예제 #2
0
    def test_single_evolve(self):
        # Check that the sample_primary function samples mass correctly
        EvolvedBinaryBPP, EvolvedBinaryBCM, initCond = Evolve.evolve(
            initialbinarytable=SINGLE_BINARY,
            BSEDict=BSEDict,
            idx=INIT_CONDITIONS[35])

        pd.testing.assert_frame_equal(EvolvedBinaryBPP, bppDF)
예제 #3
0
def evolve_merged_systems(merge_initial_conds, bin_num):
    
    merge_initial_conds['dtp']=0.1
    
    bpp, bcm, initC  = Evolve.evolve(initialbinarytable = merge_initial_conds)

    bpp.to_csv(path + "evolved_merger_tracks/" + str(bin_num) + "_evolved_bpp.csv")
    bcm.to_csv(path + "evolved_merger_tracks/" + str(bin_num) + "_evolved_bcm.csv")
    
    return
예제 #4
0
    def EvolveSingles(self):
        """Takes Initial (hard) binaries from above and evolves them"""
        #OLD COSMIC (on quest)
        #bpp, bcm, initC  = Evolve.evolve(initialbinarytable = self.InitialSingles, BSEDict = self.BSEDict)

        #COSMIC v3.3.0
        bpp, bcm, initC, kick_info = Evolve.evolve(
            initialbinarytable=self.InitialSingles, BSEDict=self.BSEDict)
        ##################
        #we need to grab only the final values at the age of the cluster
        ###############
        self.SinglesEvolved = bcm.loc[(bcm['tphys'] == self.age)]
예제 #5
0
def evolve_HMXB_systems(HMXB_initial_conds, bin_num):

    HMXB_initial_conds['dtp'] = 0.1

    HMXB_bpp, HMXB_bcm, HMXB_initC = Evolve.evolve(
        initialbinarytable=HMXB_initial_conds, )

    HMXB_bpp.to_csv(path + "evolved_tracks/" + str(bin_num) +
                    "_HMXB_evolved_bpp.csv")
    HMXB_bcm.to_csv(path + "evolved_tracks/" + str(bin_num) +
                    "_HMXB_evolved_bcm.csv")

    return
예제 #6
0
    def test_single_evolve(self):
        # Check that the sample_primary function samples mass correctly
        EvolvedBinaryBPP, EvolvedBinaryBCM, initCond = Evolve.evolve(
            initialbinarytable=INIT_CONDITIONS, BSEDict=BSEDict)

        pd.testing.assert_frame_equal(EvolvedBinaryBPP,
                                      BPP_DF,
                                      check_dtype=False,
                                      check_exact=False,
                                      check_less_precise=True)
        pd.testing.assert_frame_equal(EvolvedBinaryBCM,
                                      BCM_DF,
                                      check_dtype=False,
                                      check_exact=False,
                                      check_less_precise=True)
예제 #7
0
    def test_single_evolve_with_dict_and_table(self):
        EvolvedBinaryBPP, EvolvedBinaryBCM, initCond = Evolve.evolve(
            initialbinarytable=INIT_CONDITIONS,
            BSEDict=BSEDict,
            randomseed=523574)

        pd.testing.assert_frame_equal(EvolvedBinaryBPP,
                                      BPP_DF,
                                      check_dtype=False,
                                      check_exact=False,
                                      check_less_precise=True)
        pd.testing.assert_frame_equal(EvolvedBinaryBCM,
                                      BCM_DF,
                                      check_dtype=False,
                                      check_exact=False,
                                      check_less_precise=True)
예제 #8
0
    def test_single_evolve_with_inifile(self):
        EvolvedBinaryBPP, EvolvedBinaryBCM, initCond = Evolve.evolve(
            initialbinarytable=INIT_CONDITIONS_NO_BSE_COLUMNS,
            params=PARAMS_INI,
            randomseed=523574)

        pd.testing.assert_frame_equal(EvolvedBinaryBPP,
                                      BPP_DF,
                                      check_dtype=False,
                                      check_exact=False,
                                      check_less_precise=True)
        pd.testing.assert_frame_equal(EvolvedBinaryBCM,
                                      BCM_DF,
                                      check_dtype=False,
                                      check_exact=False,
                                      check_less_precise=True)
예제 #9
0
    def test_multi_evolve_with_dict(self):
        EvolvedBinaryBPP, EvolvedBinaryBCM, initCond = Evolve.evolve(
            initialbinarytable=INIT_CONDITIONS_NO_BSE_COLUMNS,
            BSEDict=BSEDict,
            randomseed=523574,
            n_per_block=100)

        pd.testing.assert_frame_equal(EvolvedBinaryBPP,
                                      BPP_DF,
                                      check_dtype=False,
                                      check_exact=False,
                                      check_less_precise=True)
        pd.testing.assert_frame_equal(EvolvedBinaryBCM,
                                      BCM_DF,
                                      check_dtype=False,
                                      check_exact=False,
                                      check_less_precise=True)
def cluster_bin_sampler(age, Nbin, Z, sigma, random_seed):
	"""Creates and evolves a set of binaries with given 
	age (to evolve to), number of binaries, metallicity, and velocity dispersion. 
	Will later loop through globular and open clusters and apply this for loop"""
	n_grid = Nbin

	# Initial (input) binares -- using sampler method from cosmic #1234 - random seed
	InitialBinaries, sampled_mass, n_sampled = InitialBinaryTable.sampler('multidim',\
	 [11], [11], random_seed, 1, 'delta_burst', age, Z, Nbin)#, porb_hi = [3])

	# Inclination and omega values
	inc = np.arccos(2.*np.random.uniform(0,1,Nbin) - 1.)
	omega = np.random.uniform(0,2*np.pi,Nbin)
	OMEGA = np.random.uniform(0,2*np.pi,Nbin)
	print(InitialBinaries)
# Making Input variables global (for plotting later)
	global p_i, m1_i, m2_i, ecc_i, tphysf_i, Z_i
	# Input binary params (for plotting later)
	p_i = InitialBinaries['porb']
	m1_i = InitialBinaries['mass1_binary']
	m2_i = InitialBinaries['mass2_binary']
	ecc_i = InitialBinaries['ecc']
	tphysf_i = InitialBinaries['tphysf']
	Z_i = InitialBinaries['metallicity']
	
	# Evolving input binaries
	bpp, bcm, initC  = Evolve.evolve(initialbinarytable=InitialBinaries, BSEDict=BSEDict)

	# Making returned variables global
	global p_f, m1_f, m2_f, ecc_f, tphysf_f, r1_f, r2_f, lum1_f, lum2_f, Teff1, Teff2
	# Evolved Binary Params (made global for plotting later, can )
	p_f = bcm['porb']
	m1_f = bcm['mass_1']
	m2_f = bcm['mass_2']
	ecc_f = bcm['ecc']
	tphysf_f = bcm['tphys']
	r1_f = bcm['rad_1']
	r2_f = bcm['rad_2']
	lum1_f = bcm['lumin_1']
	lum2_f = bcm['lumin_2']
	Teff1 = bcm['teff_1']#Effective temperature - just in case
	Teff2 = bcm['teff_2']



	return (InitialBinaries, bcm)
예제 #11
0
    def EvolveBinaries(self):
        """Takes Initial (hard) binaries from above and evolves them"""
        #OLD COSMIC (on quest)
        #bpp, bcm, initC  = Evolve.evolve(initialbinarytable = self.InitialBinaries, BSEDict = self.BSEDict)

        #COSMIC v3.3.0
        bpp, bcm, initC, kick_info = Evolve.evolve(
            initialbinarytable=self.InitialBinaries, BSEDict=self.BSEDict)
        self.bpp = bpp
        self.bcm = bcm
        ##################
        #we need to grab only the final values at the age of the cluster, and those that are still in binaries
        ###############
        self.bcmEvolved = self.bcm.loc[(self.bcm['tphys'] == self.age)
                                       & (self.bcm['bin_state'] == 0) &
                                       (self.bcm['mass_1'] > 0) &
                                       (self.bcm['mass_2'] > 0)]
        #reset index?
        self.bcmEvolved.reset_index(drop=True, inplace=True)
    def EvolveBinaries(self):
        """Takes Initial (hard) binaries from above and evolves them"""

        # BSE dictionary copied from cosmic's documentation (unchanged): https://cosmic-popsynth.github.io
        BSEDict = {'xi': 0.5, 'bhflag': 1, 'neta': 0.5, 'windflag': 3, 'wdflag': 0, 'alpha1': 1.0, \
        'pts1': 0.001, 'pts3': 0.02, 'pts2': 0.01, 'epsnov': 0.001, 'hewind': 1.0, 'ck': -1000, 'bwind': 0.0, 'lambdaf': 1.0, \
        'mxns': 3.0, 'beta': -1.0, 'tflag': 1, 'acc2': 1.5, 'nsflag': 3, 'ceflag': 0, 'eddfac': 1.0, 'merger': 0, 'ifflag': 0, \
        'bconst': -3000, 'sigma': 265.0, 'gamma': -2.0, 'ppsn': 1,\
         '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' : 0, \
          'cehestarflag' : 0, 'cemergeflag' : 0, 'ecsnp' : 2.5, 'ecsn_mlow' : 1.6, 'aic' : 1, 'sigmadiv' :-20.0}

        bpp, bcm, initC = Evolve.evolve(
            initialbinarytable=self.InitialBinaries, BSEDict=BSEDict)

        self.bpp = bpp
        self.bcm = bcm
        self.bcmEvolved = self.bcm.loc[self.bcm['tphys'] == self.age]
        print(self.bcmEvolved)
예제 #13
0
def cosmic_run(cluster_age, Nbin):
    n_grid = Nbin
    m1 = np.random.uniform(0.5, 2, 1000)
    m2 = np.random.uniform(0.5, 2, 1000)
    metal = np.ones(n_grid)
    porb = np.random.uniform(0, 1000, 1000)
    ecc = np.random.random(1000)
    k1 = np.ones(n_grid)
    k2 = np.ones(n_grid)
    t_p = np.ones(n_grid) * cluster_age

    # Initial grid of binaries (input parameters)
    binary_grid = InitialBinaryTable.MultipleBinary(m1=m1, m2=m2, \
    porb=porb, ecc=ecc, tphysf=t_p,\
     kstar1=k1, kstar2=k2, metallicity=metal)
    # Setting up variables drawn from initial binary table (binary_grid)
    p_i = binary_grid['porb']
    m1_i = binary_grid['mass1_binary']
    m2_i = binary_grid['mass2_binary']
    ecc_i = binary_grid['ecc']
    tphysf_i = binary_grid['tphysf']
    Z_i = binary_grid['metallicity']

    # Using this class to evolve the binaries taken from the initial binary grid
    bpp, bcm, initC = Evolve.evolve(initialbinarytable=binary_grid,
                                    BSEDict=BSEDict)

    # Setting up variables from evolved binaries (bcm - certain times)
    p_f = bcm['porb']
    m1_f = bcm['mass_1']
    m2_f = bcm['mass_2']
    ecc_f = bcm['ecc']
    tphysf_f = bcm['tphys']
    r1_f = bcm['rad_1']
    r2_f = bcm['rad_2']

    return bcm
예제 #14
0
# Can print initial binaries if needed
# print('Initial Binaries:')
# print(binary_grid)
# print(' ')

# Setting up variables drawn from initial binary table (binary_grid)
p_i = binary_grid['porb']
m1_i = binary_grid['mass1_binary']
m2_i = binary_grid['mass2_binary']
ecc_i = binary_grid['ecc']
tphysf_i = binary_grid['tphysf']
Z_i = binary_grid['metallicity']

# Using this class to evolve the binaries taken from the initial binary grid
bpp, bcm, initC = Evolve.evolve(initialbinarytable=binary_grid,
                                BSEDict=BSEDict)

# Printing Evolved binaries
# print('Evolved Binaries:')
# print(bpp, bcm, initC)
print(np.size(bcm))

# Setting up variables from evolved binaries (bcm - certain times)
p_f = bcm['porb']
m1_f = bcm['mass_1']
m2_f = bcm['mass_2']
ecc_f = bcm['ecc']
tphysf_f = bcm['tphys']
r1_f = bcm['rad_1']
r2_f = bcm['rad_2']
print(bcm['radc_1'])
예제 #15
0
 def EvolveBinaries(cls):
     bpp, bcm, initC = Evolve.evolve(initialbinarytable=cls.InitialBinaries,
                                     BSEDict=BSEDict)
예제 #16
0
final_kstar2 = [10]

# Sampling initial binaries - pulled from cosmic's documentation
InitialBinaries, sampled_mass, n_sampled = InitialBinaryTable.sampler('multidim', [0,14], [0,14], \
                            2,1, SFH_model='delta_burst', \
                            component_age=13000.0, met=0.02, size=60000)

# Initial Binary Period Histogram
f, ax = plt.subplots(figsize=(8, 5))
ax.hist(np.log10(p_i), bins=50, color='#CF0A2C')
ax.set_xlabel('Input Periods (log-days)')
ax.grid(None)
f.savefig('/projects/p30137/abowen/CEB/cosmic/plots/InputBinaryHist-60k.png')

# Evolving the binaries
bpp, bcm, initC = Evolve.evolve(initialbinarytable=InitialBinaries,
                                BSEDict=BSEDict)

# Defining initial and final periods
p_i = InitialBinaries['porb']
p_f = bcm['porb']

# Evolved Binary Histogram - Period

f, ax = plt.subplots(figsize=(8, 5))
ax.hist(np.log10(p_f), bins=50, color='black')
ax.set_xlabel('Evolved periods (log-days)')
ax.grid(None)
f.savefig('/projects/p30137/abowen/CEB/cosmic/plots/EvolvedBinaryHist-60k.png')

# Making copy of bcm for later
EvolvedBinaries = bcm
예제 #17
0
    for bpp_met, initC_met in zip(bpp_mets, initC_mets):

        ## true/false params for the binary
        this_BBH = False
        this_BBHm = False
        this_HMXB = False

        sample_bpp = bpps.iloc[np.where(bpps['metallicity'] == bpp_met)[0]]

        sample_initC = initCs.iloc[np.where(
            initCs['metallicity'] == initC_met)[0]]
        if (sample_initC.shape[0] > 1):
            sample_initC = sample_initC.iloc[:-1]

        bpp, bcm, initC, kick_info = Evolve.evolve(
            initialbinarytable=sample_initC,
            timestep_conditions=timestep_conditions)

        merger_type = int(bcm['merger_type'].iloc[-1])
        bin_state = bcm['bin_state'].iloc[-1]

        z_f = sample_bpp['redshift'].iloc[-1]
        d_L = (1 + z_f) * cosmo.comoving_distance(z_f).to(
            u.cm).value  ## luminosity distance, in cm for flux calculation

        ## "cosmological weight" of the system using comoving volume element
        dVdz = cosmo.differential_comoving_volume(z_f)
        p_cosmic = dVdz * (1 + z_f)**-1

        ## get ZAMS masses for the binary
        ZAMS_mass_k1 = bpp['mass_1'].iloc[0]
예제 #18
0
파일: sim.py 프로젝트: sarahthiele/CTA200
final_kstar1 = [10, 11, 12]
final_kstar2 = [10, 11, 12]
prim_mod = 'kroupa01'
ecc_mod = 'uniform'
porb_mod = 'sana12'
SF_st = 13700.0
SF_d = 0.0
Z = 0.017
num = 10000

InitBin, mass_singles, mass_binaries, n_singles, n_binaries = InitialBinaryTable.sampler(
    'independent',
    final_kstar1,
    final_kstar2,
    binfrac_model=0.5,
    primary_model=prim_mod,
    ecc_model=ecc_mod,
    porb_model=porb_mod,
    SF_start=SF_st,
    SF_duration=SF_d,
    met=Z,
    size=num)

bpp, bcm, initC, kick = Evolve.evolve(initialbinarytable=InitBin,
                                      BSEDict=BSEDict,
                                      n=8)
bpp.to_hdf('datafile.hdf', key='bpp')
bcm.to_hdf('datafile.hdf', key='bcm')
initC.to_hdf('datafile.hdf', key='bcm')
예제 #19
0
파일: RunBSESN.py 프로젝트: shrujal123/LMXB
        B = f.create_group('BSEDict')

        for key in BSEDict.keys():
            f['BSEDict'][key] = BSEDict[key]

        f.attrs['COSMIC_git_hash'] = commit_cosmic
        f.attrs['LMXB_git_hash'] = commit_lmxb

        f.attrs['Nbse'] = run_config.Nbse
        f.attrs['Mexp'] = run_config.Mexp

    InitialTable = initialize_binary_table(BSE_input)
    call('rm ' + BSE_input)

    bpp, bcm, initC = Evolve.evolve(initialbinarytable=InitialTable,
                                    BSEDict=BSEDict,
                                    nproc=args.ncores,
                                    idx=int(args.i) * run_config.Nbse)

    iloc = np.where((((
        (bpp.evol_type == 15) | (bpp.evol_type == 15.5)) & (bpp.kstar_2 < 13))
                     | (((bpp.evol_type == 16) | (bpp.evol_type == 16.5)) &
                        (bpp.kstar_1 < 13))) & (bpp.sep > 0))[0]
    bpp_preSN = bpp.iloc[iloc]

    bin_num = bpp.iloc[iloc].index
    initC = initC.set_index('bin_num')
    initC_preSN = initC.loc[bin_num]
    initC_preSN.to_hdf(INITC_input, key='initC')

    preSNbinaries = construct_bse_output(bpp_preSN, initC_preSN)