API/Reference
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.cosmology
— Functioncosmology(;h = 0.69,
Neff = 3.04,
OmegaK = 0,
OmegaM = 0.29,
OmegaR = nothing,
Tcmb = 2.7255,
w0 = -1,
wa = 0)
Parameters
h
- Dimensionless Hubble constantOmegaK
- 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_dist
— Functionangular_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_dist
— Functioncomoving_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_dist
— Functionluminosity_dist([u::Unitlike,] c::AbstractCosmology, z)
Bolometric luminosity distance in Mpc at redshift z
. Will convert to compatible unit u
if provided.
Cosmology.distmod
— Functiondistmod(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_element
— Functioncomoving_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_volume
— Functioncomoving_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.age
— Functionage([u::Unitlike,] c::AbstractCosmology, z)
Age of the universe in Gyr at redshift z
. Will convert to compatible unit u
if provided.
Cosmology.lookback_time
— Functionlookback_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