PyCosmo

PyCosmo

As wide-​field surveys yield ever more precise measurements, cosmology has entered a phase of high precision requiring highly accurate and fast theoretical predictions. At the heart of most cosmological model predictions is a numerical solution of the Einstein-​Boltzmann equations governing the evolution of linear perturbations in the Universe. PyCosmo is a Python-​based framework to solve this set of equations and relies on the external sympy2c package for generation of optimized C/C++ code from SymPy symbolic expressions. The symbolic representation of the Einstein-​Boltzmann equation system in PyCosmo provides a convenient interface for implementing extended cosmological models. The PyCosmo framework can also be used as a general framework to compute cosmological quantities as well as observables for both interactive and high-​performance batch jobs applications.

PyCosmo Hub

PyCosmo is conceived as a multi-​purpose cosmology calculation tool in Python, and designed to be interactive and user-​friendly. In order to make its usage immediate to the users, we make PyCosmo publicly available on a hub platform, called PyCosmo Hub: https://pycosmohub.phys.ethz.ch/hub/login. The users accessing the Hub can follow tutorials showing how to use PyCosmo. Also, they have space to write their own notebooks, make their own calculations and save the results, without the need of installing any software.

Code release and documentation

If you are interested in installing the software, here you can find the latest public release: external page https://pypi.org/project/pycosmo/. The package can be installed using pip. This version of the code includes the Boltzmann Solver for standard ΛCDM cosmology and several extensions, and it is the same version currently installed on the PyCosmo Hub.
Future code releases will be linked on this page. For further information please contact pycosmo@lists.phys.ethz.ch.
Documentation about the software can be found at the link: https://cosmo-​docs.phys.ethz.ch/PyCosmo/. Tutorial notebooks are available on the PyCosmo Hub.

Publications

The first version of the code is described in Refregier et al., 2017 (external page https://arxiv.org/abs/1708.05177). This paper focuses on the implementation of the Boltzmann solver and shows its performance in computing cosmological transfer functions (see the figure below). Tarsitano et al., 2021 (external page https://arxiv.org/abs/2005.00543) focuses on the computation of cosmological quantities at the level of background, linear and non-​linear perturbations and observables. The accuracy of PyCosmo computations has been assessed through code comparison with other similar codes (external page CLASS, external page iCosmo, external page CCL, external page HMCode). Moser et al., 2021 (external page https://arxiv.org/abs/2112.08395) describes the re-implementation and extension of the Boltzmann solver, which now uses the external page sympy2c (Schmitt et al., in prep) package to generate optimized C/C++ code from symbolic expressions. The extensions include cosmological models (dark energy with a constant equation of state and massive neutrinos) and an approximation scheme (the Radiation Streaming Approximation). We compared PyCosmo with CLASS and found a good agreement both in terms of numerical accuracy and computing time.
Hitz et al., 2024 (external page https://arxiv.org/abs/2410.01694) describes the implementation of the dark matter halo model along with an adapted neutral hydrogen halo model to provide predictions for the non-linear power spectra. These predictions are designed for comparison with simulations of the halo distribution and are therefore adaptable to the simulated mass resolution.


If you use PyCosmo for your publications, please cite the papers above.

PyCosmo
Transfer function T(k) for the main perturbation fields at a = 1 as computed by PyCosmo. They were normalised such that T(k) → 1 as k → 0 and the reference accuracy setting for PyCosmo were used.

Public code releases