{"title":"PySCo: A fast particle-mesh N-body code for modified gravity simulations in Python","authors":"Michel-Andrès Breton","doi":"10.1051/0004-6361/202452770","DOIUrl":null,"url":null,"abstract":"We present PySCo, a fast and user-friendly Python library designed to run cosmological <i>N<i/>-body simulations across various cosmological models, such as ΛCDM (Λ with cold dark matter) and <i>w<i/><sub>0<sub/><i>w<i/><sub><i>a<i/><sub/>CDM, and alternative theories of gravity, including <i>f<i/> (<i>R<i/>), 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 <i>z<i/> = 0 remains independent of the initial redshift at the 0.1% level for <i>z<i/><sub>ini<sub/> ≥ 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 512<sup>3<sup/> 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.","PeriodicalId":8571,"journal":{"name":"Astronomy & Astrophysics","volume":"70 1","pages":""},"PeriodicalIF":5.8000,"publicationDate":"2025-03-19","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Astronomy & Astrophysics","FirstCategoryId":"101","ListUrlMain":"https://doi.org/10.1051/0004-6361/202452770","RegionNum":2,"RegionCategory":"物理与天体物理","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q1","JCRName":"ASTRONOMY & ASTROPHYSICS","Score":null,"Total":0}
引用次数: 0
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 (Λ 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.
我们介绍了PySCo,一个快速且用户友好的Python库,旨在跨各种宇宙学模型(如ΛCDM (Λ with cold dark matter)和w0waCDM)运行宇宙学n体模拟,以及引力的替代理论,包括f (R), MOND(修正牛顿动力学)和时间相关的引力常数参数化。PySCo采用粒子网格求解器,在不同的变体中使用多网格或快速傅里叶变换(FFT)方法。此外,PySCo可以很容易地集成为一个外部库,为粒子和网格计算提供实用工具。该库提供了关键功能,包括基于三阶拉格朗日摄动理论(LPT)的初始条件生成器,功率谱估计,并计算密度摄动的背景和增长。在本文中,我们详细介绍了PySCo的架构和算法,并与其他代码和数值方法进行了广泛的比较。我们的分析表明,在足够的小尺度分辨率下,当zini≥125、30和10时,分别使用一阶、二阶和三阶LPT时,红移z = 0处的功率谱仍然独立于0.1%水平下的初始红移。此外,我们证明加速度(或力)计算应该使用至少有五个点的中心导数的构型空间有限差分模板,因为三点导数在小尺度下会导致显着的功率抑制。虽然在多网格中使用的七点拉普拉斯方法在小尺度上也会导致功率抑制,但在计算比率时,这种影响可以在很大程度上得到缓解。在性能方面,PySCo只需要大约一个CPU小时就可以在笔记本电脑上完成5123个粒子(和相同数量的细胞)的牛顿模拟。由于它的速度和易用性,PySCo是快速生成大量模拟集合和探索参数空间的理想选择,允许重力理论,暗能量模型和数值方法的变化。这种多功能性使PySCo成为生成模拟器、协方差矩阵或用于机器学习的训练数据集的宝贵工具。
期刊介绍:
Astronomy & Astrophysics is an international Journal that publishes papers on all aspects of astronomy and astrophysics (theoretical, observational, and instrumental) independently of the techniques used to obtain the results.