def test_nfw_density(): p = NFW_density_profile() r_s = 100*ytu.kpc rho_s = 1.0e8*ytu.Msun/ytu.kpc**3 p.set_param_values(r_s=r_s, rho_s=rho_s) x = r_yt/r_s assert_allclose(p(r_yt).v, (rho_s/(x*(1.+x)**2)).v) assert str(p(r_yt).units) == str(rho_s.units)
def test_nfw_density(): p = NFW_density_profile() r_s = 100 * ytu.kpc rho_s = 1.0e8 * ytu.Msun / ytu.kpc**3 p.set_param_values(r_s=r_s, rho_s=rho_s) x = r_yt / r_s assert_allclose(p(r_yt).v, (rho_s / (x * (1. + x)**2)).v) assert str(p(r_yt).units) == str(rho_s.units)
def test_mass_rescaling_astropy(): M = 6.0e14 * apu.Msun R = 1500.0 * apu.kpc pm = NFW_mass_profile() pd = NFW_density_profile() pd.set_param_values(r_s=350 * apu.kpc, rho_s=1.0 * apu.Msun / apu.kpc**3) rescale_profile_by_mass(pd, "rho_s", M, R) pm.set_param_values(**pd.param_values) assert_allclose(pm(R).to("Msun").value, M.value)
def test_mass_rescaling_yt(): M = 6.0e14 * ytu.Msun R = 1500.0 * ytu.kpc pm = NFW_mass_profile() pd = NFW_density_profile() pd.set_param_values(r_s=350 * ytu.kpc, rho_s=1.0 * ytu.Msun / ytu.kpc**3) rescale_profile_by_mass(pd, "rho_s", M, R) pm.set_param_values(**pd.param_values) assert_allclose(pm(R).in_units("Msun").v, M.v)
def test_mass_rescaling_astropy(): M = 6.0e14*apu.Msun R = 1500.0*apu.kpc pm = NFW_mass_profile() pd = NFW_density_profile() pd.set_param_values(r_s=350*apu.kpc, rho_s=1.0*apu.Msun/apu.kpc**3) rescale_profile_by_mass(pd, "rho_s", M, R) pm.set_param_values(**pd.param_values) assert_allclose(pm(R).to("Msun").value, M.value)
def test_mass_rescaling_yt(): M = 6.0e14*ytu.Msun R = 1500.0*ytu.kpc pm = NFW_mass_profile() pd = NFW_density_profile() pd.set_param_values(r_s=350*ytu.kpc, rho_s=1.0*ytu.Msun/ytu.kpc**3) rescale_profile_by_mass(pd, "rho_s", M, R) pm.set_param_values(**pd.param_values) assert_allclose(pm(R).in_units("Msun").v, M.v)
def test_latex(): pd = NFW_density_profile() lr = '\\frac{r_{s} \\rho_{s}}{r \\left(\\frac{r}{r_{s}} + 1\\right)^{2}}' assert pd.latex_representation() == lr