Search arXivSearch

arXiv · 2410.20501

PySCo: A fast Particle-Mesh $N$-body code for modified gravity simulations in Python

Abstract

We present PySCo, a fast and user-friendly Python library designed to run cosmological $N$-body simulations across various cosmological models, such as $Λ$CDM and $w_0w_a$CDM, and alternative theories of gravity, including $f(R)$, MOND 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 $z_{\rm ini} \geq$ 125, 30, and 10 when using first, second, and third-order LPT, respectively. 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 $512^3$ 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.

Explore related subjects

Keep this discovery

Explore connections, maps & timelines

BibTeXRIS

Michel-Andrès Breton. 2026-01-07. PySCo: A fast Particle-Mesh $N$-body code for modified gravity simulations in Python. https://doi.org/10.1051/0004-6361%2F202452770

Cite the original work for its findings. Save a collection to share your selection of sources.

KEEP EXPLORING

Related papers

From quantum fluctuations to galaxy power spectrum multipoles

These notes trace large-scale structure from primordial curvature perturbations generated by inflationary quantum fluctuations to galaxy power-spectrum multipoles. Three core lectures develop the linear matter power spectrum, spherical and anisotropic collapse, galaxy bias, redshift-space distortions, the Kaiser model, and multipole estimators with Gaussian covariance. The extension develops nonlinear bias and the one-loop effective field theory model used in full-shape analyses. Derivations are explicit; appendices collect longer calculations and solutions. The core lectures assume undergraduate-level cosmology; the extension assumes familiarity with perturbation theory.

astro-ph.CO

A universal connection between lens density profiles and low-frequency wave optics in gravitational-wave lensing

We investigate the low-frequency behavior of the amplification factor in gravitational lensing and explore how it encodes information about the density profile of the lensing object. We derive the low-frequency expansion of the amplification factor under the Born approximation for a broad class of projected density profiles. For spherically symmetric profiles that decay faster than any power law at large distances, we derive a systematic expansion of the amplification factor in powers of frequency, with the logarithmic dependence appearing only in the leading term, and show that each expansion coefficient is determined by a finite set of moments of the density profile. We then extend the analysis to profiles with power-law tails and demonstrate that such profiles induce additional non-analytic frequency dependences, including fractional powers and logarithmic terms, which directly reflect the asymptotic behavior of the density distribution. Furthermore, we investigate the effects of non-sphericity and show that contributions from the quadrupole moment appear only as higher-order corrections relative to the spherically symmetric component in the low-frequency regime. Finally, we investigate the validity of the Born approximation in the low-frequency expansion. We derive a criterion for the maximum order of the low-frequency expansion up to which the Born approximation remains dominant over the post-Born corrections.

astro-ph.CO

Initial clustering of primordial black holes: A general formulation for arbitrary local non-Gaussianity

Initial spatial clustering of primordial black holes (PBHs) induced by local-type non-Gaussianity (LNG) can substantially modify cosmological constraints on PBH abundance. Several inflationary scenarios that enhance curvature perturbations at small scales relevant to PBH formation predict LNG that is not necessarily perturbative. Therefore, it is crucial to establish a theoretical framework capable of investigating the initial clustering induced by arbitrary LNG. Here, we present a general analytical formulation for the PBH two-point correlation function applicable to arbitrary LNGs in the alternative approach. Under the assumptions that PBHs form only at the large peaks of perturbations, and that large-scale modes weakly modulate the local variance of small-scale perturbations, we derive an analytic expression for the PBH bias parameter, directly connecting initial clustering to the primordial trispectrum in the collapsed limit. We demonstrate the versatility of our formula by computing the bias parameters in the ultra-slow-roll inflation, curvaton, and modulated reheating scenarios. We also formally generalize the framework to broad power spectra to account for correlations across different PBH mass scales. Because our formulation does not rely on weak or perturbative non-Gaussianity assumptions, our result provides a universal theoretical basis for evaluating initial clustering impact on PBH observables.

astro-ph.CO