API/Reference

Unitful

Unitful.jl works seamlessly with Cosmology.jl. In order to use its features, make sure it is installed and imported, along with UnitfulAstro.

pkg> add Unitful UnitfulAstro
julia> using Unitful, UnitfulAstro

Cosmological Models

Cosmology.cosmologyFunction
cosmology(;h = 0.69,
           Neff = 3.04,
           OmegaK = 0,
           OmegaM = 0.29,
           OmegaR = nothing,
           Tcmb = 2.7255,
           w0 = -1,
           wa = 0)

Parameters

  • h - Dimensionless Hubble constant
  • OmegaK - Curvature density (Ω_k)
  • OmegaM - Matter density (Ω_m)
  • OmegaR - Radiation density (Ω_r)
  • Tcmb - CMB temperature in Kelvin; used to compute Ω_γ
  • Neff - Effective number of massless neutrino species; used to compute Ω_ν
  • w0 - CPL dark energy equation of state; w = w0 + wa(1-a)
  • wa - CPL dark energy equation of state; w = w0 + wa(1-a)

Examples

julia> c = cosmology()
Cosmology.FlatLCDM{Float64}(0.69, 0.7099122024007928, 0.29, 8.77975992071536e-5)

julia> c = cosmology(OmegaK=0.1)
Cosmology.OpenLCDM{Float64}(0.69, 0.1, 0.6099122024007929, 0.29, 8.77975992071536e-5)

julia> c = cosmology(w0=-0.9, OmegaK=-0.1)
Cosmology.ClosedWCDM{Float64}(0.69, -0.1, 0.8099122024007929, 0.29, 8.77975992071536e-5, -0.9, 0.0)

Distances

Cosmology.angular_diameter_distFunction
angular_diameter_dist([u::Unitlike,] c::AbstractCosmology, [z₁,] z₂)

Ratio of the proper transverse size in Mpc of an object at redshift z₂ to its angular size in radians, as seen by an observer at z₁. Redshift z₁ defaults to 0 if omitted. Will convert to compatible unit u if provided.

Cosmology.comoving_radial_distFunction
comoving_radial_dist([u::Unitlike,] c::AbstractCosmology, [z₁,] z₂)

Comoving radial distance in Mpc at redshift z₂ as seen by an observer at z₁. Redshift z₁ defaults to 0 if omitted. Will convert to compatible unit u if provided.

Cosmology.luminosity_distFunction
luminosity_dist([u::Unitlike,] c::AbstractCosmology, z)

Bolometric luminosity distance in Mpc at redshift z. Will convert to compatible unit u if provided.

Cosmology.distmodFunction
distmod(c::AbstractCosmology, z)

Distance modulus in magnitudes at redshift z.

Examples

julia> c = cosmology(OmegaM=0.26)
Cosmology.FlatLCDM{Float64}(0.69, 0.7399122024007928, 0.26, 8.77975992071536e-5)

julia> angular_diameter_dist(c, 1.2)
1784.0089227105113 Mpc

julia> angular_diameter_dist(c, 0.7, 1.2)
606.6521737365097 Mpc

julia> luminosity_dist(c, 1.5)
11420.338287150073 Mpc

julia> luminosity_dist(u"Gpc", c, 1.5) # Can convert to appropriate unit
11.420338287150074 Gpc

Volumes

Cosmology.comoving_volume_elementFunction
comoving_volume_element([u::Unitlike,] c::AbstractCosmology, z)

Comoving volume element in Gpc out to redshift z. Will convert to compatible unit u if provided.

Cosmology.comoving_volumeFunction
comoving_volume([u::Unitlike,] c::AbstractCosmology, z)

Comoving volume in cubic Gpc out to redshift z. Will convert to compatible unit u if provided.

Examples

julia> c = cosmology(OmegaM=0.26)
Cosmology.FlatLCDM{Float64}(0.69, 0.7399122024007928, 0.26, 8.77975992071536e-5)

julia> comoving_volume_element(c, 2.1)
46.74459228888612 Gpc^3

julia> comoving_volume(c, 0.6)
49.3633436631307 Gpc^3

julia> comoving_volume(u"ly^3", c, 0.6)
1.7127035381753e30 ly^3

Times

Cosmology.ageFunction
age([u::Unitlike,] c::AbstractCosmology, z)

Age of the universe in Gyr at redshift z. Will convert to compatible unit u if provided.

Cosmology.lookback_timeFunction
lookback_time([u::Unitlike,] c::AbstractCosmology, z)

Difference between age at redshift 0 and age at redshift z in Gyr. Will convert to compatible unit u if provided.

Examples

julia> c = cosmology(OmegaM=0.26)
Cosmology.FlatLCDM{Float64}(0.69, 0.7399122024007928, 0.26, 8.77975992071536e-5)

julia> age(c, 1.2)
5.445600787626434 Gyr

julia> lookback_time(u"yr", c, 1.2)
8.761660748088268e9 yr