Cosmology
cosmology
Cosmology sub-package.
Re-exports the FRW utilities from :mod:jaxlatt.core.cosmology.frw so that
existing import sites from jaxlatt.core.cosmology import … keep working
unchanged.
FRWUniverse
Bases: Module
FLRW universe parameters in conformal time.
Attributes:
| Name | Type | Description |
|---|---|---|
a |
Array
|
Scale factor (dimensionless, typically normalized to \(a(\tau_0) = 1\)) |
adot |
Array
|
Conformal time derivative \(da/d\tau\) (same units as a/time) |
tau |
Array
|
Conformal time coordinate \(\tau\) |
M_pl |
float
|
Reduced Planck mass in simulation units (sets gravity strength) |
Derived quantities:
- \(H = a'/a\): Conformal Hubble parameter
- \(\rho_{\mathrm{crit}} = 3M_{\mathrm{pl}}^2 H^2\): Critical density
H
property
Compute the conformal Hubble parameter.
Returns:
| Type | Description |
|---|---|
float
|
Value of \(H = a'/a\) for the current universe state. |
rho_crit
property
Compute the critical density.
Returns:
| Type | Description |
|---|---|
float
|
Critical density computed from |
copy()
Create a copy of the universe state.
Returns:
| Type | Description |
|---|---|
|
New |
replace(**kwargs)
Create a new universe with selected fields replaced.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Fields to override (a, adot, tau). |
{}
|
Returns:
| Type | Description |
|---|---|
FRWUniverse
|
New |
Source code in jaxlatt/core/cosmology/frw.py
create_frw_universe(a_initial=1.0, rho_initial=1.0, M_pl=1.0, *, w=1.0 / 3.0)
Initialize a generic FRW universe for a perfect fluid with equation of state \(p = w \rho\).
The first Friedmann equation in conformal time,
fixes the initial \(a'\) from \(\rho\) and \(a\) alone — \(w\) does not enter
the initial conditions. Pass the matching pressure function to
coupled_evolve_expanding to realize the intended dynamics:
- \(w = 1/3\) (radiation): use
make_radiation_pressure - \(w = 0\) (matter): use
make_matter_pressure - arbitrary: use
make_eos_pressure(w)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a_initial
|
float
|
Initial scale factor. |
1.0
|
rho_initial
|
float
|
Initial energy density. |
1.0
|
M_pl
|
float
|
Reduced Planck mass. |
1.0
|
w
|
float
|
Equation-of-state parameter \(p/\rho\). Does not affect the returned object; provided for call-site documentation. |
1.0 / 3.0
|
Returns:
| Type | Description |
|---|---|
FRWUniverse
|
Initialized |
Source code in jaxlatt/core/cosmology/frw.py
create_matter_universe(a_initial=1.0, rho_initial=1.0, M_pl=1.0)
Initialize FRW universe in matter-dominated era (\(w = 0\)).
See create_frw_universe for full documentation.
Pass make_matter_pressure to coupled_evolve_expanding for matter dynamics.
Source code in jaxlatt/core/cosmology/frw.py
create_radiation_universe(a_initial=1.0, rho_initial=1.0, M_pl=1.0)
Initialize FRW universe in radiation-dominated era (\(w = 1/3\)).
See create_frw_universe for full documentation.
Pass make_radiation_pressure to coupled_evolve_expanding for radiation dynamics.
Source code in jaxlatt/core/cosmology/frw.py
friedmann_acceleration(rho, p, M_pl, a)
Compute conformal acceleration \(a''\) from Friedmann equation.
In conformal time \(\tau\) (related to cosmic time \(t\) by \(dt = a(\tau)d\tau\)), the second Friedmann equation is:
where:
- \(a'' = d^2a/d\tau^2\)
- \(G = 1/M_{\mathrm{pl}}^2\) (gravitational constant)
- \(\rho\) = energy density
- \(p\) = pressure
Special cases:
- Radiation (\(p = \rho/3\)): \(a'' = 0\) \(\Rightarrow\) \(a(\tau)\) linear in \(\tau\)
- Matter (\(p = 0\)): \(a'' = \frac{4\pi G}{3} a^3 \rho\) \(\Rightarrow\) \(a(\tau) \propto \tau^2\)
References
- Dodelson & Schmidt, "Modern Cosmology" (2nd ed.), Eq. (2.26)
- Mukhanov, "Physical Foundations of Cosmology", Eq. (2.18)
- Baumann, "Cosmology", Eq. (2.35)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
float
|
Total energy density |
required |
p
|
float
|
Total pressure |
required |
M_pl
|
float
|
Reduced Planck mass (default: 1.0 in natural units) |
required |
a
|
float
|
Current scale factor |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Conformal acceleration \(a''\) (second derivative with respect to \(\tau\)) |
Source code in jaxlatt/core/cosmology/frw.py
friedmann_step_leapfrog(universe, rho_func, pressure_func, dt)
Advance scale factor using leapfrog integration (symplectic).
Leapfrog for \(a(\tau)\):
This preserves symplectic structure if rho_func and pressure_func are Hamiltonian.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
universe
|
FRWUniverse
|
Current FRWUniverse state |
required |
rho_func
|
Callable[[float], float]
|
Function computing \(\rho(a)\) |
required |
pressure_func
|
Callable[[float], float]
|
Function computing \(p(a)\) |
required |
dt
|
float
|
Conformal timestep \(d\tau\) |
required |
Returns:
| Type | Description |
|---|---|
FRWUniverse
|
Updated |
Source code in jaxlatt/core/cosmology/frw.py
friedmann_step_predictor_corrector(universe, rho_func, pressure_func, dt)
Advance scale factor by one timestep using predictor-corrector.
This uses a 2nd-order accurate predictor-corrector scheme:
- Predictor: Euler step to estimate \(a(\tau + d\tau)\)
- Corrector: Trapezoidal rule using predicted value
The energy density \(\rho\) and pressure \(p\) are computed from field values via
rho_func and pressure_func, which may depend on \(a\) (for rescaled fields).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
universe
|
FRWUniverse
|
Current FRWUniverse state |
required |
rho_func
|
Callable[[float], float]
|
Function computing total energy density from scale factor.
Signature: |
required |
pressure_func
|
Callable[[float], float]
|
Function computing total pressure from scale factor.
Signature: |
required |
dt
|
float
|
Conformal timestep \(d\tau\) |
required |
Returns:
| Type | Description |
|---|---|
FRWUniverse
|
Updated |
Source code in jaxlatt/core/cosmology/frw.py
friedmann_step_predictor_corrector_from_state(universe, rho_p_callable, dt)
Advance scale factor using predictor-corrector with state-dependent ρ, p.
More general than :func:friedmann_step_predictor_corrector: instead of
separate rho_func(a) and pressure_func(a) callables, it accepts a
single rho_p_callable(universe) → (rho, p). Because the callable
receives the whole universe rather than just a, it can close over
lattice field state, which is what makes self-consistent field-sourced
expansion possible: the fields set ρ and p, which drive a(τ), which in turn
evolves the fields.
friedmann_step_predictor_corrector is a thin wrapper around this
function, so the two share one integrator and cannot drift apart.
The predictor-corrector scheme is identical to
:func:friedmann_step_predictor_corrector; the difference is purely in
how ρ and p are evaluated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
universe
|
FRWUniverse
|
Current FRWUniverse state. |
required |
rho_p_callable
|
Callable[[FRWUniverse], tuple]
|
Callable |
required |
dt
|
float
|
Conformal timestep. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Updated |
FRWUniverse
|
class: |
Source code in jaxlatt/core/cosmology/frw.py
make_eos_pressure(w, rho_func)
Create pressure function for equation of state \(p = w\rho\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
w
|
float
|
Equation of state parameter |
required |
rho_func
|
Callable[[float], float]
|
Energy density function \(\rho(a)\) |
required |
Returns:
| Type | Description |
|---|---|
|
Function \(p(a) = w\rho(a)\) |
Source code in jaxlatt/core/cosmology/frw.py
make_matter_pressure(a=None)
Create matter pressure function \(p = 0\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Scale factor (unused, for API consistency) |
None
|
Returns:
| Type | Description |
|---|---|
|
Function \(p(a) = 0\) for matter |
Source code in jaxlatt/core/cosmology/frw.py
make_radiation_pressure(rho_initial, a_initial)
Create radiation pressure function \(p = \rho/3\) with \(\rho \propto a^{-4}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho_initial
|
float
|
Initial energy density |
required |
a_initial
|
float
|
Initial scale factor |
required |
Returns:
| Type | Description |
|---|---|
|
Function \(p(a)\) for radiation |
Source code in jaxlatt/core/cosmology/frw.py
make_radiation_rho(rho_initial, a_initial)
Create a radiation-era density function with \(\rho(a) \propto a^{-4}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho_initial
|
float
|
Reference density at |
required |
a_initial
|
float
|
Reference scale factor. |
required |
Returns:
| Type | Description |
|---|---|
|
Callable |
Source code in jaxlatt/core/cosmology/frw.py
matter_scaling_check(a_initial, a_final, rho_initial, rho_final)
Check if energy density scales as matter (\(\rho \propto a^{-3}\)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a_initial
|
float
|
Initial scale factor. |
required |
a_final
|
float
|
Final scale factor. |
required |
rho_initial
|
float
|
Initial energy density. |
required |
rho_final
|
float
|
Final energy density. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Tuple |
float
|
measured exponent \(n\) in \(\rho \propto a^{-n}\) and |
tuple[float, float]
|
the deviation from \(n = 3\). |
Source code in jaxlatt/core/cosmology/frw.py
radiation_scaling_check(a_initial, a_final, rho_initial, rho_final)
Check if energy density scales as radiation (\(\rho \propto a^{-4}\)).
For pure radiation:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a_initial
|
float
|
Initial scale factor. |
required |
a_final
|
float
|
Final scale factor. |
required |
rho_initial
|
float
|
Initial energy density. |
required |
rho_final
|
float
|
Final energy density. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Tuple |
float
|
measured exponent \(n\) in \(\rho \propto a^{-n}\) and |
tuple[float, float]
|
the deviation from \(n = 4\). |