示例#1
0
def getSimulationProperties(sim_name):

    if sim_name in sims:
        sim = SimulationProperties()
        sim.name = sim_name
        sim.cosmo_name = sims[sim_name]['cosmo']
        sim.box_size = sims[sim_name]['box_size']
        sim.Np = sims[sim_name]['Np']
        sim.epsilon = sims[sim_name]['epsilon']
        sim.folder = sims[sim_name]['folder']
        sim.Nfiles = sims[sim_name]['Nfiles']
        sim.Nsnapdigits = sims[sim_name]['Nsnapdigits']
        sim.code = sims[sim_name]['code']

    else:
        print("Invalid sim name, %s. Valid names are:" % sim_name)
        printBoxes()
        exit()

    try:
        previous_cosmo = cosmology.getCurrent()
    except Exception:
        previous_cosmo = None

    cosmo = cosmology.setCosmology(sim.cosmo_name)
    sim.mp = getParticleMass(sim.box_size, sim.Np, cosmo.Om0)

    if previous_cosmo is not None:
        cosmology.setCurrent(previous_cosmo)

    return sim
示例#2
0
def mass_function_rseppi(Mass):
    cosmo = cosmology.getCurrent()
    delta_c = peaks.collapseOverdensity(z=z)
    R = peaks.lagrangianR(Mass)
    sigma = cosmo.sigma(R=R, z=z)
    nu = delta_c / sigma
    nu2 = nu**2
    zp1 = 1.0 + z
    A = 0.333 * zp1**-0.11
    a = 0.788 * zp1**-0.01
    p = 0.807
    q = 1.795
    f = A * np.sqrt(2 / np.pi) * np.exp(
        -a * nu2 * 0.5) * (1.0 + (nu2 * a)**-p) * (nu * np.sqrt(a))**q

    d_ln_sigma_d_ln_R = cosmo.sigma(R, z, derivative=True)
    rho_Mpc = cosmo.rho_m(0.0) * 1E9
    mass_func_model = -1 / 3 * f * rho_Mpc / Mass * d_ln_sigma_d_ln_R
    return mass_func_model
示例#3
0
def matchCosmo():

    curcosmo = nfwutils.global_cosmology
    isMatch = False
    try:
        cur_ccosmo = cCosmo.getCurrent()

        isMatch = curcosmo.H0 == cur_ccosmo.H0 and \
                  curcosmo.omega_m == cur_ccosmo.Om0 and \
                  curcosmo.omega_l == cur_ccosmo.OL0
    except:
        pass

    if isMatch is False:

        cCosmo.setCosmology(
            'curCosmo',
            dict(H0=curcosmo.H0,
                 Om0=curcosmo.omega_m,
                 OL0=curcosmo.omega_l,
                 Ob0=0.049,
                 sigma8=0.9,
                 ns=0.95))
示例#4
0
def t_d(r, M, z, c, R, beta=beta_def):
    Menc = NFWM(r, M, z, c, R)
    t_dyn = 2. * np.pi * (r**3 / (G*Menc))**(1./2.) * km_per_kpc / (cosmology.getCurrent().H0 / 100.)
    return beta * t_dyn / s_per_Gyr / 2.
from colossus.cosmology import cosmology
from colossus.lss import bias

# Specify a set of concentration models for comparison.
models = [('cole89', 'NA'), ('sheth01', 'NA'), ('tinker10', '200c')]

# Build a range of halo masses at which to compute concentrations.
massLogarithmic = np.linspace(10.0, 15.0, 10)
mass = 10.0**massLogarithmic

# Specify redshifts.
redshifts = (0.0, 0.5, 1.0)

# Specify cosmology.
cosmology.setCosmology('planck15')
cosmo = cosmology.getCurrent()

# Iterate over models.
for model in models:

    outputFile = open(
        "testSuite/data/haloBiasesColossus/" + model[0] + "_" + model[1] +
        ".txt", "w")

    # Write cosmological parameters to file.
    outputFile.write("# OmegaMatter = " + str(cosmo.Om0) + "\n")
    outputFile.write("# OmegaDarkEnergy = " + str(cosmo.Ode0) + "\n")
    outputFile.write("# OmegaBaryon = " + str(cosmo.Ob0) + "\n")
    outputFile.write("# HubbleConstant = " + str(cosmo.H0) + "\n")
    outputFile.write("# sigma_8 = " + str(cosmo.sigma8) + "\n")
    outputFile.write("# index = " + str(cosmo.ns) + "\n")
示例#6
0
文件: cosmo.py 项目: abonaca/gd1_spur
def cm_relation():
    """"""

    cosmology.setCosmology('planck15')
    #for model_name in concentration.models:
    #print(model_name)

    #cosmology.setCosmology('bolshoi')
    csm = cosmology.getCurrent()
    M = 10**np.arange(5.0, 12.4, 0.1)
    z_ = 0
    rho_c = csm.rho_c(z_)
    h_ = csm.Hz(z_) * 1e-2
    delta = 200

    plt.close()
    fig, ax = plt.subplots(1, 1, figsize=(8, 5))

    models = ['ludlow16', 'diemer18']
    colors = [mpl.cm.Blues(0.5), mpl.cm.Blues(0.8)]
    #for model_name in concentration.models:
    for e, model_name in enumerate(models):
        c, mask = concentration.concentration(M,
                                              '200c',
                                              0.0,
                                              model=model_name,
                                              range_return=True)
        R = ((3 * M) / (4 * np.pi * delta * rho_c))**(1 / 3)
        rs = R / c * 1e3

        #plt.plot(M[mask]*h_, rs[mask]*h_, lw=2, label=model_name)
        plt.fill_between(M[mask] * h_,
                         rs[mask] * h_ * 0.84,
                         rs[mask] * h_ * 1.16,
                         lw=2,
                         label=model_name,
                         alpha=0.5,
                         color=colors[e])

    #rerkal = 1.05*1e3*np.sqrt(M*h_*1e-8)
    #plt.plot(M*h_, rerkal, 'r-')

    plt.axvline(1e6, ls=':', color='0.3')
    plt.axvline(1e7, ls=':', color='0.3')
    plt.axvline(1e8, ls=':', color='0.3')

    #plt.xlim(1E3, 4E15)
    #plt.ylim(2.0, 18.0)
    plt.xscale('log')
    plt.yscale('log')

    #plt.xlabel('$M_{200,c}$ [$M_\odot$ h$^{-1}$]')
    ##plt.ylabel('Concentration')
    #plt.ylabel('$r_s$ [kpc h$^{-1}$]')
    plt.xlabel('$M_{200,c}$ [$M_\odot$]')
    #plt.ylabel('Concentration')
    plt.ylabel('$r_s$ [pc]')
    plt.legend(fontsize='small', ncol=1, frameon=False, loc=4)

    plt.tight_layout()
    plt.savefig('../plots/rs_mass_cdm.png')