Mass conversion between different mass definitions ================================================== Mass conversion between spherical overdensity mass definitions -------------------------------------------------------------- In this notebook, we demonstrates how to convert the mass and concentration between various mass definitions (going from :math:`200m` to :math:`500c` in this example), and related functionalities, using both the object-oriented and functional interfaces of the code. .. code:: ipython3 import os os.environ[ "CLMM_MODELING_BACKEND" ] = "ccl" # here you may choose ccl, nc (NumCosmo) or ct (cluster_toolkit) import clmm import numpy as np import matplotlib.pyplot as plt We define a cosmology first: .. code:: ipython3 cosmo = clmm.Cosmology(H0=70.0, Omega_dm0=0.27 - 0.045, Omega_b0=0.045, Omega_k0=0.0) Create a ``CLMM`` Modeling object --------------------------------- Define a mass profile for a given SOD definition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We define halo parameters following the :math:`200m` overdensity definition: 1. the mass :math:`M_{200m}` 2. the concentration :math:`c_{200m}` .. code:: ipython3 # first SOD definition M1 = 1e14 c1 = 3 massdef1 = "mean" delta_mdef1 = 200 # cluster redshift z_cl = 0.4 .. code:: ipython3 # create a clmm Modeling object for each profile parametrisation nfw_def1 = clmm.Modeling(massdef=massdef1, delta_mdef=delta_mdef1, halo_profile_model="nfw") her_def1 = clmm.Modeling(massdef=massdef1, delta_mdef=delta_mdef1, halo_profile_model="hernquist") ein_def1 = clmm.Modeling(massdef=massdef1, delta_mdef=delta_mdef1, halo_profile_model="einasto") # set the properties of the profiles nfw_def1.set_mass(M1) nfw_def1.set_concentration(c1) nfw_def1.set_cosmo(cosmo) her_def1.set_mass(M1) her_def1.set_concentration(c1) her_def1.set_cosmo(cosmo) ein_def1.set_mass(M1) ein_def1.set_concentration(c1) ein_def1.set_cosmo(cosmo) Compute the enclosed mass in a given radius ------------------------------------------- Calculate the enclosed masses within r with the class method ``eval_mass_in_radius``. The calculation can also be done in the functional interface with ``compute_profile_mass_in_radius``. The enclosed mass is calculated as .. math:: M(<\text{r}) = M_{\Delta}\;\frac{f\left(\frac{\text{r}}{r_{\Delta}/c_{\Delta}}\right)}{f(c_{\Delta})}, where :math:`f(x)` for the different models are - :math:`\text{NFW}:\quad \ln(1+x)-\frac{x}{1+x}` - :math:`\text{Einasto}:\quad \gamma\left(\frac{3}{\alpha}, \frac{2}{\alpha}x^{\alpha}\right)\quad \; (\gamma\text{ is the lower incomplete gamma function},\; \alpha\text{ is the index of the Einasto profile})` - :math:`\text{Hernquist}:\quad \left(\frac{x}{1+x}\right)^2` .. code:: ipython3 r = np.logspace(-2, 0.4, 100) # object oriented nfw_def1_enclosed_oo = nfw_def1.eval_mass_in_radius(r3d=r, z_cl=z_cl) her_def1_enclosed_oo = her_def1.eval_mass_in_radius(r3d=r, z_cl=z_cl) ein_def1_enclosed_oo = ein_def1.eval_mass_in_radius(r3d=r, z_cl=z_cl) # functional nfw_def1_enclosed = clmm.compute_profile_mass_in_radius( r3d=r, redshift=z_cl, cosmo=cosmo, mdelta=M1, cdelta=c1, massdef=massdef1, delta_mdef=delta_mdef1, halo_profile_model="nfw", ) her_def1_enclosed = clmm.compute_profile_mass_in_radius( r3d=r, redshift=z_cl, cosmo=cosmo, mdelta=M1, cdelta=c1, massdef=massdef1, delta_mdef=delta_mdef1, halo_profile_model="hernquist", ) ein_def1_enclosed = clmm.compute_profile_mass_in_radius( r3d=r, redshift=z_cl, cosmo=cosmo, mdelta=M1, cdelta=c1, massdef=massdef1, delta_mdef=delta_mdef1, halo_profile_model="einasto", alpha=ein_def1.get_einasto_alpha(z_cl), ) Sanity check: comparison of the results given by the object-oriented and functional interface .. code:: ipython3 fig = plt.figure(figsize=(8, 6)) fig.gca().loglog(r, nfw_def1_enclosed, label=" NFW functional") fig.gca().loglog(r, nfw_def1_enclosed_oo, ls="--", label=" NFW object oriented") fig.gca().loglog(r, her_def1_enclosed, label="Hernquist functional") fig.gca().loglog(r, her_def1_enclosed_oo, ls="--", label="Hernquist object oriented") fig.gca().loglog(r, ein_def1_enclosed, label="Einasto functional") fig.gca().loglog(r, ein_def1_enclosed_oo, ls="--", label="Einasto object oriented") fig.gca().set_xlabel(r"$r\ [Mpc]$", fontsize=20) fig.gca().set_ylabel(r"$M(