φtorch.cosmology

The phytorch.cosmology module is modelled after AstroPy’s sub-package of the same name and provides routines for calculating cosmographic distances and related quantities in a FLRW cosmology.

The structure of the codebase is somewhat involved so as to be maximally composable and extensible. In a gist, classes can be abstract, concrete, or drivers. Hierarchies of abstract classes define the overall interface and implement shared functionalities. Concrete classes implement the details of concrete cosmological models, e.g. ΛCDM (with or without radiation, and/or flat), or with evolving dark energy. Drivers fill in the routines for calculating distances using, e.g. analytical formulae or numerical integration. Finally, user-facing classes must combine a concrete model with a driver to unlock the full functionality.

Concrete models

Concrete classes are located in the phytorch.cosmology.special.concrete sub-module. Currently, thee are five dark energy models implemented, each of which has four corresponding classes with/without radiation and with/without curvature:

  • (Flat)LambdaCDM(R): cosmological constant \(\Lambda \implies w = -1\);

  • (Flat)wCDM(R): constant equation of state \(w = w_0\);

  • (Flat)w0waCDM(R): linear evolution with scale factor:

    \[w(z) = w_0 + w_a (1-a) = w_0 + w_a \left(1 - \frac{1}{z+1}\right);\]
  • (Flat)wpwaCDM(R): pivoting equation of state:

    \[w(z) = w_p + w_a (a_p-a) = w_p + w_a \left(\frac{1}{z_p+1} - \frac{1}{z+1}\right);\]
  • (Flat)w0wzCDM(R): linear evolution with redshift: \(w(z) = w_0 + w_z z\).

Cosmography drivers

The driver sub-modules located under phytorch.cosmology.drivers provide implementations of cosmographic distance calculations for the models they support:

  • abstract: allows one to instantiate a concrete model without necessarily implementing distances (e.g. in order to calculate density evolutions). Supports all 20 concrete models (trivially).

  • odeint: calculates the distances using numerical integration with the torchdiffeq package. Supports all 20 concrete models but currently has trouble with batching.

  • analytic: implements analytic expressions based on Carlson’s elliptic integrals. Fully differentiable, batched, and awesome; however, only supports (Flat)LambdaCDM(R) models and requires compiling the Extensions.

    Todo

    Reference paper!

Converting to AstroPy

Todo

Add ability to convert from AstroPy.