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.

Concrete Types

The following concrete types, representing specific types of cosmologies, are currently implemented:

Cosmology.FlatLCDMType
FlatLCDM(h::Real, Ω_Λ::Real, Ω_m::Real, Ω_b::Real, Tcmb0::Real, Neff::Real, m_ν)

Type for flat (Ω_k=0) ΛCDM cosmologies (w0=-1, wa=0).

source
Cosmology.OpenLCDMType
OpenLCDM(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).

source
Cosmology.ClosedLCDMType
ClosedLCDM(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).

source
Cosmology.FlatWCDMType
FlatWCDM(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).

source
Cosmology.OpenWCDMType
FlatWCDM(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).

source
Cosmology.ClosedWCDMType
FlatWCDM(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).

source

Convenience Constructors

Cosmology.cosmologyFunction
cosmology(;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 constant
  • OmegaK - Curvature density (Ω_k)
  • OmegaM - Matter density (Ω_m)
  • OmegaB - Baryon density (Ω_b)
  • OmegaG - Photon density (Ω_γ)
  • Tcmb0 - CMB temperature in Kelvin; used to compute Ω_γ if not provided
  • w0 - 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 to Int(floor(N_eff)) but this is not explicitly checked. If N_eff==0 then m_ν isn't used for anything.

Examples

Info

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.

Note

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.

source
Cosmology.WCDMFunction
WCDM(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.

source

Pre-Constructed Instances

These are constant instances that implement published cosmological results.

Note

These instances are not exported, so you must import them explicitly; e.g,

import Cosmology: Planck18
Planck18
Cosmology.FlatLCDM{Float64, 3}(0.6766, 0.6888463055445425, 0.30966, 0.04897, 2.7255, 3.046, (0.0, 0.0, 0.06))
Cosmology.Planck15Constant

The full Planck 15 cosmology (TT,TE,EE+lowP+lensing+ext; column 6 in Table 4 of Planck 2015 paper).

source

Retrieving Parameters

The parameters that define these types are accessed via the following unexported, internal methods.

Cosmology.hFunction
h(c::T) where T<:AbstractCosmology

Return "little h" for the cosmology, defined as the Hubble constant at present day (H0) divided by 100 km / s / Mpc.

source
Cosmology.partypeFunction
partype(c::T) where T<:AbstractCosmology

Return the type of the scalar fields in the AbstractCosmology object c.

source
Cosmology.m_nuFunction
m_nu(c::T) where T<:AbstractCosmology

Return the masses of the neutrino species in the cosmology c in eV.

source
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,)
source
Cosmology.NeffFunction
Neff(c::T) where T<:AbstractCosmology

Return the effective number of neutrino species in the cosmology c.

source
Cosmology.n_nuFunction
n_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)
3
source
Cosmology.w0Function
w0(c::Union{FlatWCDM,OpenWCDM,ClosedWCDM})

Return the present-day value of w for the CDL dark energy equation of state.

source
Cosmology.waFunction
wa(c::Union{FlatWCDM,OpenWCDM,ClosedWCDM})

Return the evolution parameter for the CDL dark energy equation of state.

source

Other parameters that have more complicated associated methods (e.g., parameters with redshift evolution like T_cmb) are given in the Methods section.