cmc
- class cosmic.sample.sampler.cmc.CMCSample
Bases:
Sample
- __doc__ = None
- __module__ = 'cosmic.sample.sampler.cmc'
- calc_porb_max(mass, vr, vt, binary_index, mass1_binary, mass2_binary, **kwargs)
- set_r_vr_vt(cluster_profile, **kwargs)
- class cosmic.sample.sampler.cmc.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.cmc.InitialCMCTable(data=None, index: Axes | None = None, columns: Axes | None = None, dtype: Dtype | None = None, copy: bool | None = None)
Bases:
DataFrame
- classmethod InitialCMCBinaries(index, id1, k1, m1, Reff1, id2, k2, m2, Reff2, a, e)
Create A Table of CMC Binaries
- Parameters:
- m1float
Primary mass [Msun]
- m2float
Secondary mass [Msun]
- porbfloat
Orbital period [days]
- eccfloat
Eccentricity
- 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
- Returns:
- InitialBinariesDataFrame
Single binary initial conditions
- classmethod InitialCMCSingles(id_idx, k, m, Reff, r, vr, vt, binind)
Create A Table of CMC Singles
- Parameters:
- m1float
Primary mass [Msun]
- m2float
Secondary mass [Msun]
- porbfloat
Orbital period [days]
- eccfloat
Eccentricity
- 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
- Returns:
- InitialBinariesDataFrame
Single binary initial conditions
- ScaleCentralBHMass(Mtotal)
Rescale the central BH mass; needed since this is a class attribute Parameters ———-
- Mtotalfloat
total mass of the cluster
- classmethod ScaleToNBodyUnits(Singles, Binaries, virial_radius=1, central_bh=0, scale_with_central_bh=False)
- Rescale the single masses, radii, and velocities into N-body units
- i.e. sum m = M = 1
Kinetic Energy = 0.25 Potential Energy = -0.5
Note that this is already done for r, vr, and vt from the profile generators. However, after the stellar masses are assigned we need to redo it, and the stellar radii and seperations need to be converted from RSUN to code units
- Parameters:
- SinglesDataFrame
Pandas DataFrame from the InitialCMCSingles function
- BinariesDataFrame
Pandas DataFrame from the InitialCMCSingles function
- virial_radiusfloat
Virial radius of the cluster in parsec (default 1pc)
- Returns:
- None: Pandas dataframes are modified in place
- __annotations__ = {'_AXIS_LEN': 'int', '_AXIS_ORDERS': "list[Literal['index', 'columns']]", '_AXIS_TO_AXIS_NUMBER': 'dict[Axis, int]', '__array_priority__': 'int', '__hash__': 'ClassVar[None]', '_accessors': 'set[str]', '_attrs': 'dict[Hashable, Any]', '_cache': 'dict[str, Any]', '_constructor_sliced': 'Callable[..., Series]', '_hidden_attrs': 'frozenset[str]', '_info_axis_name': "Literal['columns']", '_info_axis_number': 'Literal[1]', '_internal_names': 'list[str]', '_internal_names_set': 'set[str]', '_is_copy': 'weakref.ReferenceType[NDFrame] | str | None', '_metadata': 'list[str]', '_mgr': 'BlockManager | ArrayManager', '_typ': 'str'}
- __doc__ = None
- __module__ = 'cosmic.sample.initialcmctable'
- _mgr: BlockManager | ArrayManager
- central_bh = 0.0
- mass_of_cluster = None
- metallicity = None
- classmethod read(filename)
Read Singles and Binaries to HDF5 or FITS file
- Parameters:
- filename(str)
Must end in “.fits” or “.hdf5/h5”
- Returns:
- SinglesDataFrame
Pandas DataFrame from the InitialCMCSingles function
- BinariesDataFrame
Pandas DataFrame from the InitialCMCBinaries function
- 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(InitialCMCTable.sampler(‘independent’) to see the arguments necessary for the independent sample
- The available named formats are:
- ============== …
Format …
- ============== …
cmc …
- cmc_point_mass …
- ============== …
- scale_with_central_bh = False
- scaled_to_nbody_units = False
- tidal_radius = None
- virial_radius = None
- classmethod write(Singles, Binaries, filename='input.hdf5', **kwargs)
Save Singles and Binaries to HDF5 or FITS file
- Parameters:
- SinglesDataFrame
Pandas DataFrame from the InitialCMCSingles function
- BinariesDataFrame
Pandas DataFrame from the InitialCMCBinaries function
- filename(str)
Must end in “.fits” or “.hdf5/h5”
- Returns:
- None:
- class cosmic.sample.sampler.cmc.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 or Offner et al.(2022) in fig 1
- Parameters:
- primary_massarray
Mass that determines the binary fraction
- binfrac_modelstr or float
vanHaaften - primary mass dependent and ONLY VALID up to 100 Msun
offner22 - primary mass dependent
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, porb_max=None, size=None, **kwargs)
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
- porb_modelstr or dict
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 raghavan10 : log normal orbital periods in days with mean_logP = 4.9 and sigma_logP = 2.3 between 0 < log10(P/day) < 9 following Raghavan+2010 <https://ui.adsabs.harvard.edu/abs/2010ApJS..190….1R/abstract>_ moe19 : log normal orbital periods in days with mean_logP = 4.9 and sigma_logP = 2.3 between 0 < log10(P/day) < 9 following Raghavan+2010 <https://ui.adsabs.harvard.edu/abs/2010ApJS..190….1R/abstract>_ but with different close binary fractions following Moe+2019 <https://ui.adsabs.harvard.edu/abs/2019ApJ…875…61M/abstract>_ Custom power law distribution defined with a dictionary with keys “min”, “max”, and “slope” (e.g. porb_model={“min”: 0.15, “max”: 0.55, “slope”: -0.55}) would reproduce the Sana+2012 distribution.
- metfloat
metallicity of the population
- 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, q_power_law=0, **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.cmc.get_cmc_point_mass_sampler(cluster_profile, size, **kwargs)
Generates an CMC cluster model according to user-specified model. Note here that masses will all be unity (with total cluster normalized accordingly)
- Parameters:
- cluster_profilestr
Model to use for the cluster profile (i.e. sampling of the placement of objects in the cluster and their velocity within the cluster) Options include: ‘plummer’ : Standard Plummer sphere.
Additional parameters: ‘r_max’ : float
the maximum radius (in virial radii) to sample the clsuter
- ‘elson’EFF 1987 profile. Generalization of Plummer that better fits young massive clusters
Additional parameters: ‘gamma’ : float
steepness paramter for Elson profile; note that gamma=4 is same is Plummer
- ‘r_max’float
the maximum radius (in virial radii) to sample the clsuter
- ‘king’King profile
- ‘w_0’float
King concentration parameter
- ‘r_max’float
the maximum radius (in virial radii) to sample the clsuter
- sizeint
Size of the population to sample
- Returns:
- Singles: pandas.DataFrame
DataFrame of Single objects in the format of the InitialCMCTable
- Binaries: pandas.DataFrame
DataFrame of Single objects in the format of the InitialCMCTable
- cosmic.sample.sampler.cmc.get_cmc_sampler(cluster_profile, primary_model, ecc_model, porb_model, binfrac_model, met, size, **kwargs)
Generates an initial cluster sample according to user specified models
- Parameters:
- cluster_profilestr
Model to use for the cluster profile (i.e. sampling of the placement of objects in the cluster and their velocity within the cluster) Options include: ‘plummer’ : Standard Plummer sphere.
Additional parameters: ‘r_max’ : float
the maximum radius (in virial radii) to sample the clsuter
- ‘elson’EFF 1987 profile. Generalization of Plummer that better fits young massive clusters
Additional parameters: ‘gamma’ : float
steepness paramter for Elson profile; note that gamma=4 is same is Plummer
- ‘r_max’float
the maximum radius (in virial radii) to sample the clsuter
- ‘king’King profile
- ‘w_0’float
King concentration parameter
- ‘r_max’float
the maximum radius (in virial radii) to sample the clsuter
- 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
- msortfloat
Stars with M>msort can have different pairing and sampling of companions
- pairfloat
Sets the pairing of stars M>msort only with stars with M>msort
- binfrac_modelstr or float
Model for binary fraction; choices include: vanHaaften, offner22, or a fraction where 1.0 is 100% binaries
- binfrac_model_msortstr or float
Same as binfrac_model for M>msort
- 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
- m2_minfloat
kwarg which sets the minimum secondary mass for sampling the secondary as uniform in mass_2 between m2_min and mass_1
- qmin_msortfloat
Same as qmin for M>msort; only applies if qmin is supplied
- 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:
- Singles: pandas.DataFrame
DataFrame of Single objects in the format of the InitialCMCTable
- Binaries: pandas.DataFrame
DataFrame of Single objects in the format of the InitialCMCTable
- cosmic.sample.sampler.cmc.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