Issue |
A&A
Volume 695, March 2025
|
|
---|---|---|
Article Number | A170 | |
Number of page(s) | 21 | |
Section | Numerical methods and codes | |
DOI | https://doi.org/10.1051/0004-6361/202452770 | |
Published online | 19 March 2025 |
PySCo: A fast particle-mesh N-body code for modified gravity simulations in Python
1
Université Paris-Saclay, Université Paris Cité, CEA, CNRS, AIM,
91191,
Gif-sur-Yvette, France
2
Institute of Space Sciences (ICE, CSIC), Campus UAB,
Carrer de Can Magrans, s/n,
08193
Barcelona, Spain
3
Laboratoire Univers et Théorie, Observatoire de Paris, Université PSL, Université Paris Cité, CNRS,
92190
Meudon, France
★ Corresponding author; michel-andres.breton@cea.fr
Received:
27
October
2024
Accepted:
18
February
2025
We present PySCo, a fast and user-friendly Python library designed to run cosmological N-body simulations across various cosmological models, such as ΛCDM (Λ with cold dark matter) and w0waCDM, and alternative theories of gravity, including f (R), MOND (modified newtonian dynamics) and time-dependent gravitational constant parameterisations. PySCo employs particle-mesh solvers, using multigrid or fast Fourier transform (FFT) methods in their different variations. Additionally, PySCo can be easily integrated as an external library, providing utilities for particle and mesh computations. The library offers key features, including an initial condition generator based on up to third-order Lagrangian perturbation theory (LPT), power spectrum estimation, and computes the background and growth of density perturbations. In this paper, we detail PySCo’s architecture and algorithms and conduct extensive comparisons with other codes and numerical methods. Our analysis shows that, with sufficient small-scale resolution, the power spectrum at redshift z = 0 remains independent of the initial redshift at the 0.1% level for zini ≥ 125, 30, and 10 when using first, second, and third-order LPT, respectively. Moreover, we demonstrate that acceleration (or force) calculations should employ a configuration-space finite-difference stencil for central derivatives with at least five points, as three-point derivatives result in significant power suppression at small scales. Although the seven-point Laplacian method used in multigrid also leads to power suppression on small scales, this effect can largely be mitigated when computing ratios. In terms of performance, PySCo only requires approximately one CPU hour to complete a Newtonian simulation with 5123 particles (and an equal number of cells) on a laptop. Due to its speed and ease of use, PySCo is ideal for rapidly generating vast ensemble of simulations and exploring parameter spaces, allowing variations in gravity theories, dark energy models, and numerical approaches. This versatility makes PySCo a valuable tool for producing emulators, covariance matrices, or training datasets for machine learning.
Key words: methods: numerical / cosmology: miscellaneous / large-scale structure of Universe
© The Authors 2025
Open Access article, published by EDP Sciences, under the terms of the Creative Commons Attribution License (https://creativecommons.org/licenses/by/4.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.
This article is published in open access under the Subscribe to Open model. Subscribe to A&A to support open access publication.
Current usage metrics show cumulative count of Article Views (full-text article views including HTML views, PDF and ePub downloads, according to the available data) and Abstracts Views on Vision4Press platform.
Data correspond to usage on the plateform after 2015. The current usage metrics is available 48-96 hours after online publication and is updated daily on week days.
Initial download of the metrics may take a while.