ClusterMonteCarlo SamplingΒΆ

New in COSMIC 3.4, you can now use COSMIC to sample initial conditions that can be used in the simulation of a Globular Cluster (GC), using the ClusterMonteCarlo (CMC) software package. To create these initial conditions, and save them in a format readable by CMC, you can do the following.

In [1]: from cosmic.sample.initialcmctable import InitialCMCTable

In [2]: from cosmic.sample.sampler import cmc

To see the arguments necessary to call the CMC sampler use the help function:

In [3]: help(cmc.get_cmc_sampler)
Help on function get_cmc_sampler in module 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_profile : `str`
        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_model : `str`
        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
        mcuts : `array`
            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_model : `str`
        Model to sample eccentricity; choices include: thermal, uniform, sana12
    
    porb_model : `str`
        Model to sample orbital period; choices include: log_uniform, sana12
    
    msort : `float`
        Stars with M>msort can have different pairing and sampling of companions
    
    pair : `float`
        Sets the pairing of stars M>msort only with stars with M>msort
    
    binfrac_model : `str or float`
        Model for binary fraction; choices include: vanHaaften, offner22, or a fraction where 1.0 is 100% binaries
    
    binfrac_model_msort : `str or float`
        Same as binfrac_model for M>msort
    
    qmin : `float`
        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_min : `float`
        kwarg which sets the minimum secondary mass for sampling
        the secondary as uniform in mass_2 between m2_min and mass_1
    
    qmin_msort : `float`
        Same as qmin for M>msort; only applies if qmin is supplied
    
    met : `float`
        Sets the metallicity of the binary population where solar metallicity is zsun 
    
    size : `int`
        Size of the population to sample
    
    zsun : `float`
        optional kwarg for setting effective radii, default is 0.02
    
    Optional Parameters
    -------------------
    virial_radius : `float`
        the initial virial radius of the cluster, in parsecs
        Default -- 1 pc
    
    tidal_radius : `float`
        the initial tidal radius of the cluster, in units of the virial_radius
        Default -- 1e6 rvir
    
    central_bh : `float`
        Put a central massive black hole in the cluster
        Default -- 0 MSUN
        
    scale_with_central_bh : `bool`
        If True, then the potential from the central_bh is included when scaling the radii.
        Default -- False
    
    seed : `float`
        seed to the random number generator, for reproducability
    
    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
In [4]: from cosmic.sample import InitialCMCTable

In [5]: Singles, Binaries = InitialCMCTable.sampler('cmc', binfrac_model=0.2, primary_model='kroupa01', ecc_model='sana12', porb_model='sana12', qmin=-1.0, cluster_profile='plummer', met=0.014, size=40000, params='../examples/Params.ini', gamma=4, r_max=100)

In [6]: InitialCMCTable.write(Singles, Binaries, filename="input.hdf5")

In [7]: InitialCMCTable.write(Singles, Binaries, filename="input.fits")