independent

class cosmic.sample.sampler.independent.InitialBinaryTable

Bases: object

classmethod InitialBinaries(m1, m2, porb, ecc, tphysf, kstar1, kstar2, metallicity, **kwargs)

Create single binary

Parameters
m1float

Primary mass [Msun]

m2float

Secondary mass [Msun]

porbfloat

Orbital period [days]

eccfloat

Eccentricity

tphysffloat

Time to evolve the binary [Myr]

kstar1array

0-14 Initial stellar type of the larger object; main sequence stars are 0 if m < 0.7 Msun and 1 otherwise

kstar2array

0-14 Initial stellar type of the smaller object; main sequence stars are 0 if m < 0.7 Msun and 1 otherwise

metallicityfloat

Metallicity of the binaries; Z_sun = 0.02

**kwargs
binfracfloat

System-specific probability of the primary star being in a binary

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

Returns
InitialBinariesDataFrame

Single binary initial conditions

__annotations__ = {}
__dict__ = mappingproxy({'__module__': 'cosmic.sample.initialbinarytable', 'InitialBinaries': <classmethod(<function InitialBinaryTable.InitialBinaries>)>, 'sampler': <classmethod(<function InitialBinaryTable.sampler>)>, '__dict__': <attribute '__dict__' of 'InitialBinaryTable' objects>, '__weakref__': <attribute '__weakref__' of 'InitialBinaryTable' objects>, '__doc__': None, '__annotations__': {}})
__doc__ = None
__module__ = 'cosmic.sample.initialbinarytable'
__weakref__

list of weak references to the object (if defined)

classmethod sampler(format_, *args, **kwargs)

Fetch a method to generate an initial binary sample

Parameters
formatstr

the method name; Choose from ‘independent’ or ‘multidim’

*args

the arguments necessary for the registered sample method; see help(InitialBinaryTable.sampler(‘independent’) to see the arguments necessary for the independent sample

The available named formats are:
=========== …

Format …

=========== …
independent …

multidim …

=========== …
class cosmic.sample.sampler.independent.Sample

Bases: object

__annotations__ = {}
__dict__ = mappingproxy({'__module__': 'cosmic.sample.sampler.independent', 'sample_primary': <function Sample.sample_primary>, 'sample_secondary': <function Sample.sample_secondary>, 'binary_select': <function Sample.binary_select>, 'sample_porb': <function Sample.sample_porb>, 'sample_ecc': <function Sample.sample_ecc>, 'sample_SFH': <function Sample.sample_SFH>, 'set_kstar': <function Sample.set_kstar>, 'set_reff': <function Sample.set_reff>, '__dict__': <attribute '__dict__' of 'Sample' objects>, '__weakref__': <attribute '__weakref__' of 'Sample' objects>, '__doc__': None, '__annotations__': {}})
__doc__ = None
__module__ = 'cosmic.sample.sampler.independent'
__weakref__

list of weak references to the object (if defined)

binary_select(primary_mass, binfrac_model=0.5, **kwargs)

Select which primary masses will have a companion using either a binary fraction specified by a float or a primary-mass dependent binary fraction following van Haaften et al.(2009) in appdx

Parameters
primary_massarray

Mass that determines the binary fraction

binfrac_modelstr or float

vanHaaften - primary mass dependent and ONLY VALID up to 100 Msun float - fraction of binaries; 0.5 means 2 in 3 stars are a binary pair while 1 means every star is in a binary pair

Optional kwargs are defined in `get_independent_sampler`
Returns
stars_in_binaryarray

primary masses that will have a binary companion

stars_in_singlearray

primary masses that will be single stars

binary_fractionarray

system-specific probability of being in a binary

binaryIdxarray

Idx of stars in binary

sample_SFH(SF_start=13700.0, SF_duration=0.0, met=0.02, size=None)

Sample an evolution time for each binary based on a user-specified time at the start of star formation and the duration of star formation. The default is a burst of star formation 13,700 Myr in the past.

Parameters
SF_startfloat

Time in the past when star formation initiates in Myr

SF_durationfloat

Duration of constant star formation beginning from SF_Start in Myr

metfloat

metallicity of the population [Z_sun = 0.02] Default: 0.02

sizeint, optional

number of evolution times to sample NOTE: this is set in cosmic-pop call as Nstep

Returns
tphysarray

array of evolution times of size=size

metallicityarray

array of metallicities

sample_ecc(aRL_over_a, ecc_model='sana12', size=None)

Sample the eccentricity according to a user specified model

Parameters
ecc_modelstring

‘thermal’ samples from a thermal eccentricity distribution following Heggie (1975) ‘uniform’ samples from a uniform eccentricity distribution ‘sana12’ samples from the eccentricity distribution from Sana+2012 <https://ui.adsabs.harvard.edu/abs/2012Sci…337..444S/abstract>_ ‘circular’ assumes zero eccentricity for all systems DEFAULT = ‘sana12’

aRL_over_aratio of the minimum seperation (where RL overflow starts)

to the sampled semi-major axis. Use this to truncate the eccentricitiy

sizeint, optional

number of eccentricities to sample this is set in cosmic-pop call as Nstep

Returns
eccarray

array of sampled eccentricities with size=size

sample_porb(mass1, mass2, rad1, rad2, porb_model='sana12', porb_max=None, size=None)

Sample the orbital period according to the user-specified model

Parameters
mass1array

primary masses

mass2array

secondary masses

rad1array

radii of the primaries.

rad2array

radii of the secondaries

modelstring

selects which model to sample orbital periods, choices include: log_uniform : semi-major axis flat in log space from RRLO < 0.5 up to 1e5 Rsun according to Abt (1983) and consistent with Dominik+2012,2013 and then converted to orbital period in days using Kepler III sana12 : power law orbital period between 0.15 < log(P/day) < 5.5 following Sana+2012 <https://ui.adsabs.harvard.edu/abs/2012Sci…337..444S/abstract>_ renzo19 : power law orbital period for m1 > 15Msun binaries from Sana+2012 <https://ui.adsabs.harvard.edu/abs/2012Sci…337..444S/abstract>_ following the implementation of Renzo+2019 <https://ui.adsabs.harvard.edu/abs/2019A%26A…624A..66R/abstract>_ and flat in log otherwise

Returns
porbarray

orbital period with array size equalling array size of mass1 and mass2 in units of days

aRL_over_a: array

ratio of radius where RL overflow starts to the sampled seperation used to truncate the eccentricitiy distribution

sample_primary(primary_model='kroupa01', size=None, **kwargs)

Sample the primary mass (always the most massive star) from a user-selected model

kroupa93 follows Kroupa (1993), normalization comes from Hurley 2002 between 0.08 and 150 Msun salpter55 follows Salpeter (1955) between 0.08 and 150 Msun kroupa01 follows Kroupa (2001) <https://arxiv.org/abs/astro-ph/0009005> between 0.08 and 100 Msun

Parameters
primary_modelstr, optional
model for mass distribution; choose from:
kroupa93 follows Kroupa (1993), normalization comes from
`Hurley 2002 <https://arxiv.org/abs/astro-ph/0201220>`_
valid for masses between 0.1 and 100 Msun
salpter55 follows
`Salpeter (1955) <http://adsabs.harvard.edu/abs/1955ApJ…121..161S>`_
valid for masses between 0.1 and 100 Msun
kroupa01 follows Kroupa (2001), normalization comes from
`Hurley 2002 <https://arxiv.org/abs/astro-ph/0009005>`_
valid for masses between 0.1 and 100 Msun
custom is a generic piecewise power law that takes in the power
law slopes and break points given in the optional input lists (alphas, mcuts)
default alphas and mcuts yield an IMF identical to kroupa01
Default kroupa01
sizeint, optional
number of initial primary masses to sample
NOTE: this is set in cosmic-pop call as Nstep
alphasarray, optional
absolute values of the power law slopes for primary_model = ‘custom’
Default [-1.3,-2.3,-2.3] (identical to slopes for primary_model = ‘kroupa01’)
mcutsarray, optional, units of Msun
break points separating the power law ‘pieces’ for primary_model = ‘custom’
Default [0.08,0.5,1.0,150.] (identical to breaks for primary_model = ‘kroupa01’)
Optional kwargs are defined in `get_independent_sampler`
Returns
a_0array
Sampled primary masses
np.sum(a_0)float
Total amount of mass sampled
sample_secondary(primary_mass, **kwargs)

Sample a secondary mass using draws from a uniform mass ratio distribution motivated by Mazeh et al. (1992) and Goldberg & Mazeh (1994)

NOTE: the lower lim is set by either qmin or m2_min which are passed as kwargs

Parameters
primary_massarray

sets the maximum secondary mass (for a maximum mass ratio of 1)

Optional kwargs are defined in `get_independent_sampler`
Returns
secondary_massarray

sampled secondary masses with array size matching size of primary_mass

set_kstar(mass)

Initialize stellar types according to BSE classification kstar=1 if M>=0.7 Msun; kstar=0 if M<0.7 Msun

Parameters
massarray

array of masses

Returns
kstararray

array of initial stellar types

set_reff(mass, metallicity, zsun=0.02)

Better way to set the radii from BSE, by calling it directly

takes masses and metallicities, and returns the radii

Note that the BSE function is hard-coded to go through arrays of length 10^5. If your masses are more than that, you’ll need to divide it into chunks

cosmic.sample.sampler.independent.get_independent_sampler(final_kstar1, final_kstar2, primary_model, ecc_model, porb_model, SF_start, SF_duration, binfrac_model, met, size, **kwargs)

Generates an initial binary sample according to user specified models

Parameters
final_kstar1int or list

Int or list of final kstar1

final_kstar2int or list

Int or list of final kstar2

primary_modelstr

Model to sample primary mass; choices include: kroupa93, kroupa01, salpeter55, custom if ‘custom’ is selected, must also pass arguemts: alphas : array

list of power law indicies

mcutsarray

breaks in the power laws.

e.g. alphas=[-1.3,-2.3,-2.3],mcuts=[0.08,0.5,1.0,150.] reproduces standard Kroupa2001 IMF

ecc_modelstr

Model to sample eccentricity; choices include: thermal, uniform, sana12

porb_modelstr

Model to sample orbital period; choices include: log_uniform, sana12

qminfloat

kwarg which sets the minimum mass ratio for sampling the secondary where the mass ratio distribution is flat in q if q > 0, qmin sets the minimum mass ratio q = -1, this limits the minimum mass ratio to be set such that the pre-MS lifetime of the secondary is not longer than the full lifetime of the primary if it were to evolve as a single star

m_maxfloat

kwarg which sets the maximum primary and secondary mass for sampling NOTE: this value changes the range of the IMF and should not be used

as a means of selecting certain kstar types!

m1_minfloat

kwarg which sets the minimum primary mass for sampling NOTE: this value changes the range of the IMF and should not be used

as a means of selecting certain kstar types!

m2_minfloat

kwarg which sets the minimum secondary mass for sampling the secondary as uniform in mass_2 between m2_min and mass_1

msortfloat

Stars with M>msort can have different pairing and sampling of companions

qmin_msortfloat

Same as qmin for M>msort

m2_min_msortfloat

Same as m2_min for M>msort

SF_startfloat

Time in the past when star formation initiates in Myr

SF_durationfloat

Duration of constant star formation beginning from SF_Start in Myr

binfrac_modelstr or float

Model for binary fraction; choices include: vanHaaften or a fraction where 1.0 is 100% binaries

binfrac_model_msortstr or float

Same as binfrac_model for M>msort

metfloat

Sets the metallicity of the binary population where solar metallicity is zsun

sizeint

Size of the population to sample

zsunfloat

optional kwarg for setting effective radii, default is 0.02

Returns
InitialBinaryTablepandas.DataFrame

DataFrame in the format of the InitialBinaryTable

mass_singlesfloat

Total mass in single stars needed to generate population

mass_binariesfloat

Total mass in binaries needed to generate population

n_singlesint

Number of single stars needed to generate a population

n_binariesint

Number of binaries needed to generate a population

cosmic.sample.sampler.independent.register_sampler(data_format, data_class, function, force=False, usage=None)

Register a new method to InitialBinaryTable.sampler() for a given format

Parameters
data_formatstr

name of the format to be registered

data_classtype

the class that the sampler returns

functioncallable

the method to call from InitialBinaryTable.sampler()

forcebool, optional

overwrite existing registration for data_format if found, default: False