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 constantNeff
- Effective number of massless neutrino species; used to compute Ω_νOmegaK
- Curvature density (Ω_k)OmegaM
- Matter density (Ω_m)OmegaR
- Radiation density (Ω_r)Tcmb
- CMB temperature in Kelvin; 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 ($D_C$) 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.
It's calculated as $D_C = D_{H0} Z$, where $D_{H0}$ is the Hubble distance at the present epoch and, $Z = \int_{z_1}^{z_2} \frac{dz}{E(z)}$.
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
.
Cosmology.hubble_dist
— Functionhubble_dist(c::AbstractCosmology, z)
Hubble distance $D_H$, defined as the product of the speed of light and the Hubble time. That is, $D_H(z) = c / H(z)$.
See also
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.74459228888613 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.
Cosmology.hubble_time
— Functionhubble_time(c::AbstractCosmology, z)
Hubble time, defined as the inverse of the Hubble parameter. That is, $t_H(z) = 1/H(z)$.
See also
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.4454795007229455 Gyr
julia> lookback_time(u"yr", c, 1.2)
8.761465604385489e9 yr
Miscellaneous
Cosmology.H
— FunctionH(c::AbstractCosmology, z)
Hubble parameter at redshift z
.
Cosmology.scale_factor
— Functionscale_factor(z)
Return the scale factor $a(t)$ for a given redshift $z(t)$. According to the Friedmann–Lemaître–Robertson–Walker metric it's given as $a = 1/(1 + z)$ (Schneider 2015, p. 186).
A scale factor of 1, i.e., a redshift of 0, refers to the present epoch.
Bibliography
- Schneider, P. (2015). Extragalactic Astronomy and Cosmology: An Introduction. 2nd Edition (Springer, Berlin, Heidelberg).