Defined Types
Abstract Types
The highest level type defined in this package is the abstract type Cosmology.AbstractCosmology, which all other cosmology objects are subtyped from. Below these are Cosmology.AbstractFlatCosmology, Cosmology.AbstractOpenCosmology, and Cosmology.AbstractClosedCosmology.
Cosmology.AbstractCosmology — TypeAbstractCosmology is the base type for all cosmologies.
Cosmology.AbstractFlatCosmology — TypeAbstractFlatCosmology is the base type for all flat cosmologies (Ω_k=0).
Cosmology.AbstractOpenCosmology — TypeAbstractOpenCosmology is the base type for all open cosmologies (Ω_k<0).
Cosmology.AbstractClosedCosmology — TypeAbstractClosedCosmology is the base type for all closed cosmologies (Ω_k<0).
Concrete Types
The following concrete types, representing specific types of cosmologies, are currently implemented:
Cosmology.FlatLCDM — TypeFlatLCDM(h::Real, Ω_Λ::Real, Ω_m::Real, Ω_b::Real, Tcmb0::Real, Neff::Real, m_ν)Type for flat (Ω_k=0) ΛCDM cosmologies (w0=-1, wa=0).
Cosmology.OpenLCDM — TypeOpenLCDM(h::Real, Ω_k::Real, Ω_Λ::Real, Ω_m::Real, Ω_b::Real, Tcmb0::Real, Neff::Real, m_ν)Type for open (Ω_k>0) ΛCDM cosmologies (w0=-1, wa=0).
Cosmology.ClosedLCDM — TypeClosedLCDM(h::Real, Ω_k::Real, Ω_Λ::Real, Ω_m::Real, Ω_b::Real, Tcmb0::Real, Neff::Real, m_ν)Type for closed (Ω_k<0) ΛCDM cosmologies (w0=-1, wa=0).
Cosmology.FlatWCDM — TypeFlatWCDM(h::Real, Ω_k::Real, Ω_Λ::Real, Ω_m::Real, Ω_b::Real, Tcmb0::Real, Neff::Real, m_ν, w0::Real, wa::Real)Flat cosmology with the w0wa dark energy equation of state,
\[w(z) = w_0 + w_a \, \frac{z}{1+z} = w_0 + w_a \, (1-a)\]
(Equations 6 and 7 in Linder 2003).
Cosmology.OpenWCDM — TypeFlatWCDM(h::Real, Ω_k::Real, Ω_Λ::Real, Ω_m::Real, Ω_b::Real, Tcmb0::Real, Neff::Real, m_ν, w0::Real, wa::Real)Open cosmology with the w0wa dark energy equation of state,
\[w(z) = w_0 + w_a \, \frac{z}{1+z} = w_0 + w_a \, (1-a)\]
(Equations 6 and 7 in Linder 2003).
Cosmology.ClosedWCDM — TypeFlatWCDM(h::Real, Ω_k::Real, Ω_Λ::Real, Ω_m::Real, Ω_b::Real, Tcmb0::Real, Neff::Real, m_ν, w0::Real, wa::Real)Closed cosmology with the w0wa dark energy equation of state,
\[w(z) = w_0 + w_a \, \frac{z}{1+z} = w_0 + w_a \, (1-a)\]
(Equations 6 and 7 in Linder 2003).
Convenience Constructors
Cosmology.cosmology — Functioncosmology(;h = 0.6766, OmegaK = 0, OmegaM = 0.30966, OmegaB = 0.04897, OmegaG = nothing, Tcmb0 = 2.7255, w0 = -1, wa = 0, N_eff = 3.046, m_ν=(0.0,0.0,0.06))Constructs the proper AbstractCosmology type depending on the passed parameters. To specify the photon density of the cosmology, either OmegaG or Tcmb0 can be provided; if OmegaG is provided, it takes precedence over Tcmb0. To turn neutrinos off, you can set N_eff=nothing, m_ν=nothing; then OmegaG==OmegaR, all radiation is in the form of photons.
Parameters
h- Dimensionless Hubble constantOmegaK- Curvature density (Ω_k)OmegaM- Matter density (Ω_m)OmegaB- Baryon density (Ω_b)OmegaG- Photon density (Ω_γ)Tcmb0- CMB temperature in Kelvin; used to compute Ω_γ if not providedw0- CPL dark energy equation of state;w = w0 + wa(1-a)wa- CPL dark energy equation of state;w = w0 + wa(1-a)N_eff- Effective number of massless neutrino species; used to compute Ω_νm_ν- Neutrino masses; should have length equal toInt(floor(N_eff))but this is not explicitly checked. IfN_eff==0thenm_νisn't used for anything.
Examples
This function is not type-stable; it will return different concrete subtypes of AbstractCosmology depending on the parameters you pass. This incurs a performance penalty. If you want to, you can access constructors of the concrete types directly; this can make creation of new instances much faster. For example, c=cosmology() takes ~300 ns, while FlatLCDM(c.h,c.Ω_Λ,c.Ω_m,c.Ω_b,c.Tcmb0,c.Neff,c.m_nu) takes ~1 ns. If you REALLY need this speed, you should use the basic constructors.
Inclusion of massive neutrinos is expensive. For example, for the default massive neutrino parameters c=cosmology(), the evaluation of E(c, 0.8) takes 114.613 ns, while E( cosmology(m_ν=(0.0,),N_eff=3.046), 0.8) takes 6.986 ns and E( cosmology(m_ν=(0.0,),N_eff=0), 0.8) takes 6.095 ns. This makes a significant difference in methods that involve integrations (e.g., comoving_radial_dist). If speed is a concern, consider if you can neglect neutrinos for your calculation.
Cosmology.WCDM — FunctionWCDM(h::Real, Ω_k::Real, Ω_Λ::Real, Ω_m::Real, Ω_b::Real, Tcmb0::Real, Neff::Real, m_ν, w0::Real, wa::Real)Constructs a cosmology with the w0wa dark energy equation of state,
\[w(z) = w_0 + w_a \, \frac{z}{1+z} = w_0 + w_a \, (1-a)\]
and returns one of FlatWCDM, OpenWCDM, ClosedWCDM depending the value of Ω_k. This function is type-unstable by design.
Pre-Constructed Instances
These are constant instances that implement published cosmological results.
These instances are not exported, so you must import them explicitly; e.g,
import Cosmology: Planck18
Planck18Cosmology.FlatLCDM{Float64, 3}(0.6766, 0.6888463055445425, 0.30966, 0.04897, 2.7255, 3.046, (0.0, 0.0, 0.06))Cosmology.Planck18 — ConstantThe full Planck 18 cosmology (best fit with BAO; column 6).
Cosmology.Planck15 — ConstantThe full Planck 15 cosmology (TT,TE,EE+lowP+lensing+ext; column 6 in Table 4 of Planck 2015 paper).
Cosmology.Planck15_only — ConstantThe conservative Planck 15 cosmology (TT+lowP+lensing; column 2 in Table 4 of Planck 2015 paper).
Cosmology.Planck13 — ConstantThe full Planck 13 cosmology.
Cosmology.WMAP9 — ConstantThe full WMAP 9 cosmology.
Cosmology.WMAP7 — ConstantThe full WMAP 7 cosmology.
Cosmology.WMAP5 — ConstantThe full WMAP 5 cosmology.
Retrieving Parameters
The parameters that define these types are accessed via the following unexported, internal methods.
Cosmology.h — Functionh(c::T) where T<:AbstractCosmologyReturn "little h" for the cosmology, defined as the Hubble constant at present day (H0) divided by 100 km / s / Mpc.
Cosmology.partype — Functionpartype(c::T) where T<:AbstractCosmologyReturn the type of the scalar fields in the AbstractCosmology object c.
Cosmology.m_nu — Functionm_nu(c::T) where T<:AbstractCosmologyReturn the masses of the neutrino species in the cosmology c in eV.
m_nu(x::AbstractArray)
m_nu(x::AbstractArray{<:Unitful.Energy})
m_nu(x::AbstractArray{<:Unitful.Mass})
m_nu(x::Tuple)
m_nu(x::NTuple)
m_nu(x::NTuple{N,T}) where {N,T<:u.Energy}
m_nu(x::NTuple{N,T}) where {N,T<:u.Mass}
m_nu(x::Number)
m_nu(x::Nothing)Converts various forms of m_nu to NTuples so they can be stored in the cosmology structs. Currently mixed units in a Tuple is not supported. If providing units in the argument, they should all be the same.
Examples
julia> x=[0.0,0.0,0.06];
julia> m_nu(x)
(0.0, 0.0, 0.06)
julia> x=[0.0,0.0,0.06]*Unitful.eV;
julia> m_nu(x)
(0.0, 0.0, 0.06)
julia> x=(0.0,0.0,0.06);
julia> m_nu(x) === x
true
julia> x=(0.0,0.0,0.06) .* Unitful.eV;
julia> m_nu(x)
(0.0, 0.0, 0.06)
julia> m_nu(0.06)
(0.06,)
julia> m_nu(nothing)
(0,)
Cosmology.Neff — FunctionNeff(c::T) where T<:AbstractCosmologyReturn the effective number of neutrino species in the cosmology c.
Cosmology.n_nu — Functionn_nu(c::AbstractCosmology)
n_nu(Neff::Real)Return the number of discrete neutrinos in the cosmology, defined as Int(floor(Neff(c))); see Neff.
Examples
julia> Cosmology.n_nu(Cosmology.Planck18)
3
julia> Cosmology.n_nu(3.046)
3Cosmology.w0 — Functionw0(c::Union{FlatWCDM,OpenWCDM,ClosedWCDM})Return the present-day value of w for the CDL dark energy equation of state.
Cosmology.wa — Functionwa(c::Union{FlatWCDM,OpenWCDM,ClosedWCDM})Return the evolution parameter for the CDL dark energy equation of state.
Other parameters that have more complicated associated methods (e.g., parameters with redshift evolution like T_cmb) are given in the Methods section.