Example #1
0
// OverdensityRadius calculates the radius at which h has an average density
// of rho.
func (h *Halo) OverdensityRadius(bt BiasType, rho float64) float64 {
	radiusToRho := func(r float64) float64 {
		m := h.MassEnclosed(bt, r)
		return haloDensity(r, m)
	}

	return num.FindEqualConst(radiusToRho, rho, h.Rs, h.Rs)
}
Example #2
0
func initSearching(h *Halo, cFunc num.Func1D, m, r float64) {
	rho200c := cosmo.RhoCritical(h.Z) * 200

	m200cToR := func(m200c float64) float64 {
		h.C200.R = haloRadius(m200c, rho200c)
		h.C200.C = cFunc(m200c)
		h.C200.M = m200c

		h.Rs = h.C200.R / h.C200.C

		return h.MassEnclosed(Corrected, r)
	}

	m200c := num.FindEqualConst(m200cToR, m, m, m)

	h.C200.R = haloRadius(m200c, rho200c)
	h.C200.C = cFunc(m200c)
	h.C200.M = m200c

	h.Rs = h.C200.R / h.C200.C
}