sphalde 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. sphalde-1.1.0/CHANGELOG.md +61 -0
  2. sphalde-1.1.0/CITATION.cff +34 -0
  3. sphalde-1.1.0/LICENSE +78 -0
  4. sphalde-1.1.0/MANIFEST.in +3 -0
  5. sphalde-1.1.0/PKG-INFO +192 -0
  6. sphalde-1.1.0/README.md +153 -0
  7. sphalde-1.1.0/config/cosmology.yaml +79 -0
  8. sphalde-1.1.0/pyproject.toml +61 -0
  9. sphalde-1.1.0/setup.cfg +4 -0
  10. sphalde-1.1.0/sphalde/__init__.py +17 -0
  11. sphalde-1.1.0/sphalde/collapse/__init__.py +54 -0
  12. sphalde-1.1.0/sphalde/collapse/class_pk.py +82 -0
  13. sphalde-1.1.0/sphalde/collapse/equations.py +35 -0
  14. sphalde-1.1.0/sphalde/collapse/esscher.py +142 -0
  15. sphalde-1.1.0/sphalde/collapse/pdf_ldt_analytic.py +426 -0
  16. sphalde-1.1.0/sphalde/collapse/power_spectrum.py +90 -0
  17. sphalde-1.1.0/sphalde/collapse/solver.py +547 -0
  18. sphalde-1.1.0/sphalde/collapse/symbolic_pklin.py +405 -0
  19. sphalde-1.1.0/sphalde/collapse/variance.py +92 -0
  20. sphalde-1.1.0/sphalde/cosmology/__init__.py +4 -0
  21. sphalde-1.1.0/sphalde/cosmology/background.py +84 -0
  22. sphalde-1.1.0/sphalde/data/cosmology.yaml +79 -0
  23. sphalde-1.1.0/sphalde/mass_function/__init__.py +11 -0
  24. sphalde-1.1.0/sphalde/mass_function/press_schechter.py +319 -0
  25. sphalde-1.1.0/sphalde/mass_function/sheth_tormen.py +38 -0
  26. sphalde-1.1.0/sphalde/models/__init__.py +28 -0
  27. sphalde-1.1.0/sphalde/models/base_model.py +119 -0
  28. sphalde-1.1.0/sphalde/models/cpl.py +38 -0
  29. sphalde-1.1.0/sphalde/models/dynamic_base.py +194 -0
  30. sphalde-1.1.0/sphalde/models/eds.py +25 -0
  31. sphalde-1.1.0/sphalde/models/lcdm.py +19 -0
  32. sphalde-1.1.0/sphalde/models/nonabelian.py +134 -0
  33. sphalde-1.1.0/sphalde/models/wcdm.py +27 -0
  34. sphalde-1.1.0/sphalde/pipeline.py +715 -0
  35. sphalde-1.1.0/sphalde.egg-info/PKG-INFO +192 -0
  36. sphalde-1.1.0/sphalde.egg-info/SOURCES.txt +40 -0
  37. sphalde-1.1.0/sphalde.egg-info/dependency_links.txt +1 -0
  38. sphalde-1.1.0/sphalde.egg-info/entry_points.txt +2 -0
  39. sphalde-1.1.0/sphalde.egg-info/requires.txt +17 -0
  40. sphalde-1.1.0/sphalde.egg-info/top_level.txt +1 -0
  41. sphalde-1.1.0/tests/convergence.py +179 -0
  42. sphalde-1.1.0/tests/test_validation.py +216 -0
@@ -0,0 +1,61 @@
1
+ # Changelog
2
+
3
+ All notable changes to SPHALDE are listed here. Versions follow
4
+ [semantic versioning](https://semver.org).
5
+
6
+ ## [1.1.0] - 2026-11-27
7
+
8
+ ### Changed
9
+ - The default CPL model is now the best fit of DESI DR2 BAO + CMB + DES-Y5
10
+ supernovae, (w0, wa) = (−0.752, −0.86) (DESI Collaboration 2025,
11
+ arXiv:2503.14738), in `CPL()`, the configuration file, the notebooks and the
12
+ pyLDT-cosmo comparison script.
13
+ - The driver moved from `run.py` to the module `sphalde.pipeline`; `run.py`
14
+ remains as a thin wrapper for clones of the repository, so
15
+ `python run.py ...` works as before.
16
+
17
+ ### Added
18
+ - Installation from PyPI: `pip install sphalde`, with the `sphalde` command
19
+ (same options as `run.py`) and the default configuration shipped with the
20
+ package (`sphalde --write-config` copies it; `--config` selects another file).
21
+ - Initial conditions of the non-Abelian model as constructor parameters
22
+ (`omega_i`, `x_i`, `y_i`, `zeta_i`, `Omega_ri`, `alpha`, `z_ini`); the default
23
+ is still `omega_i = 0`. `omega_i` is the mass parameter m²/H² of Guarnizo et
24
+ al. (2020, Eq. 22), as in their figures; the normalized mass term starts at
25
+ zeta_i·sqrt(omega_i). They can be set from Python, the configuration file,
26
+ `--param NonAbelian.omega_i=...` or the shortcut `--omega-i`. Notebook 01
27
+ uses the value of Guarnizo et al. (2020, Eq. 74), `omega_i = 5e-29`.
28
+ - `NonAbelian(mass_force=False, N_ini=...)`, for comparison only, reproduces
29
+ the Mathematica notebook behind Fig. 12 of Guarnizo et al. (2020), which
30
+ omits the mass-term force +w²/zeta in the x' equation and starts each curve
31
+ at a different e-fold; notebook 01 compares it with the published equations.
32
+ - Dynamical models integrate their background into the future, up to `a_max`
33
+ (default 10, i.e. 1 + z = 0.1); `model.w_z(z)` gives w_DE for any z >= z_min
34
+ (z = -0.9 for 1 + z = 0.1), with NaN outside the integrated range instead of
35
+ an extrapolation. Present-day values are still read at a = 1.
36
+ - A clear error when the background system of a dynamical model cannot be
37
+ integrated up to a = 1 (and a warning if it stops between a = 1 and a_max).
38
+ - `sphalde --version`; GitHub workflow that publishes each release to PyPI.
39
+ - Notebook cells that print the rows of Tables III and V of the paper; the halo
40
+ figure of notebook 01 uses the redshift step of the driver (Δln a = 0.01).
41
+
42
+ ## [1.0.0] - 2026-11-25
43
+
44
+ First public release of SPHALDE (Spherical collapse, halos and LDT density PDF for Dark Energy), accompanying the SPHALDE paper.
45
+
46
+ ### Features
47
+ - Spherical collapse in homogeneous dark energy models: δ_c(z), Δ_vir(z) with the dark energy virial correction, D(z) and f(z), with Mészáros initial conditions when radiation is present.
48
+ - Press–Schechter and Sheth–Tormen mass functions, σ8 normalization by the ratio of δ_c(0), and full-sky cluster counts.
49
+ - Backscaling solver for the nonlinear mapping ρ(τ; z) and the critical value τ_c(z).
50
+ - LDT matter-density PDF with analytic derivatives of the rate function; normalization by rescaling of ρ (default) or Esscher tilt.
51
+ - Linear P(k) from the symbolic expression of Bartlett et al. (2023), rescaled with the model's growth from z_i = 19; optional CLASS input.
52
+ - Models: EdS, ΛCDM, wCDM, CPL and the massive non-Abelian SU(2) model.
53
+ - Command-line driver `run.py` with a YAML configuration and parallel execution over redshifts and values of τ.
54
+ - Validation tests, numerical convergence tests and a comparison with pyLDT-cosmo.
55
+
56
+ ### Installation
57
+ git clone https://github.com/MrPI07/sphalde.git
58
+ cd sphalde
59
+ python -m pip install -e .
60
+
61
+ Requires Python ≥ 3.10, numpy, scipy, matplotlib and pyyaml. Released under the MIT license.
@@ -0,0 +1,34 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use SPHALDE, please cite the SPHALDE paper and the archived version of the software."
3
+ title: "SPHALDE: Spherical collapse, halos and LDT density PDF for Dark Energy"
4
+ type: software
5
+ version: 1.1.0
6
+ date-released: 2026-11-27
7
+ license: MIT
8
+ repository-code: "https://github.com/MrPI07/sphalde"
9
+ authors:
10
+ - family-names: "Ibarbo-Perlaza"
11
+ given-names: "Pedro M."
12
+ affiliation: "Departamento de Física, Universidad del Valle, 760032 Cali, Colombia"
13
+ orcid: "https://orcid.org/0000-0001-7374-7613"
14
+ email: "pedro.ibarbo@correounivalle.edu.co"
15
+ - family-names: "Orjuela-Quintana"
16
+ given-names: "J. Bayron"
17
+ affiliation: "Departamento de Física, Universidad del Valle, 760032 Cali, Colombia"
18
+ orcid: "https://orcid.org/0000-0001-5090-2860"
19
+ - family-names: "Valenzuela-Toledo"
20
+ given-names: "César A."
21
+ affiliation: "Departamento de Física, Universidad del Valle, 760032 Cali, Colombia"
22
+ orcid: "https://orcid.org/0000-0002-6380-2778"
23
+ keywords:
24
+ - cosmology
25
+ - dark energy
26
+ - spherical collapse
27
+ - halo mass function
28
+ - large deviation theory
29
+ # preferred-citation: # add when the paper has a reference
30
+ # type: article
31
+ # title: "..."
32
+ # authors: [...]
33
+ # journal: "..."
34
+ # year: 2026
sphalde-1.1.0/LICENSE ADDED
@@ -0,0 +1,78 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pedro M. Ibarbo-Perlaza, J. Bayron Orjuela-Quintana and César A. Valenzuela-Toledo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ -------------------------------------------------------------------------------
24
+ Third-party code
25
+
26
+ sphalde/collapse/symbolic_pklin.py is adapted from symbolic_pofk
27
+ (https://github.com/DeaglanBartlett/symbolic_pofk), distributed under the
28
+ following license:
29
+
30
+ MIT License
31
+
32
+ Copyright (c) 2024 Deaglan J. Bartlett
33
+
34
+ Permission is hereby granted, free of charge, to any person obtaining a copy
35
+ of this software and associated documentation files (the "Software"), to deal
36
+ in the Software without restriction, including without limitation the rights
37
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
38
+ copies of the Software, and to permit persons to whom the Software is
39
+ furnished to do so, subject to the following conditions:
40
+
41
+ The above copyright notice and this permission notice shall be included in all
42
+ copies or substantial portions of the Software.
43
+
44
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
47
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
48
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
49
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
50
+ SOFTWARE.
51
+
52
+ -------------------------------------------------------------------------------
53
+
54
+ comparison/pyldt/pyldt_nojulia/ transcribes to numpy the ordinary differential
55
+ equations that pyLDT-cosmo (https://github.com/mcataneo/pyLDT-cosmo) defines in
56
+ Julia. pyLDT-cosmo is distributed under the following license:
57
+
58
+ MIT License
59
+
60
+ Copyright (c) 2020 Matteo Cataneo
61
+
62
+ Permission is hereby granted, free of charge, to any person obtaining a copy
63
+ of this software and associated documentation files (the "Software"), to deal
64
+ in the Software without restriction, including without limitation the rights
65
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
66
+ copies of the Software, and to permit persons to whom the Software is
67
+ furnished to do so, subject to the following conditions:
68
+
69
+ The above copyright notice and this permission notice shall be included in all
70
+ copies or substantial portions of the Software.
71
+
72
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
73
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
74
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
75
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
76
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
77
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
78
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ include config/cosmology.yaml
2
+ include CHANGELOG.md CITATION.cff
3
+ recursive-include tests *.py
sphalde-1.1.0/PKG-INFO ADDED
@@ -0,0 +1,192 @@
1
+ Metadata-Version: 2.4
2
+ Name: sphalde
3
+ Version: 1.1.0
4
+ Summary: Spherical collapse, halos and LDT density PDF for Dark Energy
5
+ Author: J. Bayron Orjuela-Quintana, César A. Valenzuela-Toledo
6
+ Author-email: "Pedro M. Ibarbo-Perlaza" <pedro.ibarbo@correounivalle.edu.co>
7
+ License-Expression: MIT
8
+ Project-URL: Repository, https://github.com/MrPI07/sphalde
9
+ Project-URL: Documentation, https://github.com/MrPI07/sphalde#readme
10
+ Project-URL: Changelog, https://github.com/MrPI07/sphalde/blob/main/CHANGELOG.md
11
+ Keywords: cosmology,dark energy,spherical collapse,halo mass function,large deviation theory,large-scale structure
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Intended Audience :: Science/Research
20
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
21
+ Classifier: Topic :: Scientific/Engineering :: Physics
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: numpy>=1.24
26
+ Requires-Dist: scipy>=1.10
27
+ Requires-Dist: matplotlib>=3.7
28
+ Requires-Dist: pyyaml>=6.0
29
+ Provides-Extra: class
30
+ Requires-Dist: classy; extra == "class"
31
+ Provides-Extra: colossus
32
+ Requires-Dist: colossus; extra == "colossus"
33
+ Provides-Extra: notebooks
34
+ Requires-Dist: jupyter; extra == "notebooks"
35
+ Requires-Dist: colossus; extra == "notebooks"
36
+ Provides-Extra: test
37
+ Requires-Dist: pytest>=7; extra == "test"
38
+ Dynamic: license-file
39
+
40
+ # SPHALDE
41
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24756256.svg)](https://doi.org/10.5281/zenodo.24756256)
42
+ [![tests](https://github.com/MrPI07/sphalde/actions/workflows/tests.yml/badge.svg)](https://github.com/MrPI07/sphalde/actions/workflows/tests.yml)
43
+
44
+ **Spherical collapse, halos and LDT density PDF for Dark Energy**
45
+
46
+ SPHALDE is a Python code for nonlinear spherical collapse in homogeneous dark
47
+ energy models. From a single description of the background expansion it
48
+ computes
49
+
50
+ - the collapse threshold δ_c(z), the virial overdensity Δ_vir(z) (with the
51
+ dark energy correction to the virial theorem) and the linear growth D(z), f(z);
52
+ - Press–Schechter and Sheth–Tormen halo mass functions and full-sky cluster
53
+ counts, per mass bin and above a mass threshold;
54
+ - the matter-density PDF in spheres from Large Deviation Theory, using the
55
+ full nonlinear mapping ρ(τ; z) of each model obtained by backscaling.
56
+
57
+ Radiation is part of every model's background. δ_c and the halo statistics
58
+ follow the standard convention and are computed without it; the backscaling
59
+ always includes it, because it dominates at the initial scale factor
60
+ a_ini = 1e-4.
61
+
62
+ Models included: Einstein–de Sitter (analytic test), ΛCDM, wCDM, CPL and the
63
+ massive non-Abelian SU(2) model. The default CPL model is the best fit of DESI
64
+ DR2 BAO + CMB + DES-Y5 supernovae, (w0, wa) = (−0.752, −0.86)
65
+ ([DESI Collaboration 2025](https://arxiv.org/abs/2503.14738)). A new model needs
66
+ only w(a) or, for a dynamical model, its background equations (see
67
+ `sphalde/models/`).
68
+
69
+ ## Installation
70
+
71
+ Python 3.10 or newer.
72
+
73
+ ```bash
74
+ pip install sphalde # numpy, scipy, matplotlib, pyyaml
75
+ pip install "sphalde[colossus]" # adds COLOSSUS (comparison of mass functions)
76
+ ```
77
+
78
+ To run the notebooks and tests, or to modify the code, install from a clone:
79
+
80
+ ```bash
81
+ git clone https://github.com/MrPI07/sphalde.git
82
+ cd sphalde
83
+ python -m pip install -e ".[test,notebooks]" # adds pytest, jupyter and colossus
84
+ ```
85
+
86
+ The linear power spectrum comes by default from the symbolic expression of
87
+ Bartlett et al. (2023), so neither CLASS nor CAMB is required. CLASS (`classy`)
88
+ can be used instead with `pdf.pk_source: class` in the configuration.
89
+
90
+ ## Quick start
91
+
92
+ The `sphalde` command runs the whole calculation with the default
93
+ configuration, which ships with the package:
94
+
95
+ ```bash
96
+ sphalde --list-models
97
+ sphalde --models LCDM CPL --quick # coarse grids, a few minutes
98
+ sphalde --write-config my_config.yaml # copy the default configuration
99
+ sphalde --config my_config.yaml # everything in your configuration
100
+ ```
101
+
102
+ Common options:
103
+
104
+ ```bash
105
+ sphalde --models CPL --param CPL.w0=-0.752 --param CPL.wa=-0.86
106
+ sphalde --models wCDM --w0 -0.8
107
+ sphalde --models NonAbelian --omega-i 5e-29 # initial omega = m^2/H^2 of the non-Abelian model
108
+ sphalde --tasks collapse halos --workers 6
109
+ sphalde --tasks pdf --pdf-z 0 1 --pdf-R 10 20
110
+ ```
111
+
112
+ From a clone of the repository, `python run.py` is equivalent to `sphalde`
113
+ and reads `config/cosmology.yaml`; `python tests/test_validation.py` runs the
114
+ validation tests (about 15 s).
115
+
116
+ Each model writes its tables and plots to `outputs/<model>/`, and
117
+ `outputs/run_summary.json` records the configuration, σ8, timings and
118
+ software versions.
119
+
120
+ From Python:
121
+
122
+ ```python
123
+ import numpy as np
124
+ from sphalde import get_model, FlatFLRW
125
+ from sphalde.collapse import SphericalCollapseSolver
126
+
127
+ cosmo = FlatFLRW(67.66, get_model("CPL")) # w0 = -0.752, wa = -0.86
128
+ res = SphericalCollapseSolver(cosmo, n_workers=4).compute_all(np.array([0.0, 1.0, 2.0]))
129
+ print(res["delta_c"], res["Delta_vir"])
130
+ ```
131
+
132
+ Dynamical models take their initial conditions as arguments, e.g.
133
+ `get_model("NonAbelian", omega_i=5e-29)`, with `omega_i` = m²/H² at the initial
134
+ redshift (Guarnizo et al. 2020); the default `omega_i = 0` switches off the
135
+ mass term. `model.w_z(z)` gives w_DE down to 1 + z = 0.1 (z = -0.9).
136
+
137
+ The whole pipeline is also available from Python:
138
+
139
+ ```python
140
+ from sphalde.pipeline import load_config, run_model
141
+ res = run_model(load_config(), "CPL", tasks=["collapse", "halos"])
142
+ ```
143
+
144
+ The LDT PDF is computed in two stages: `prepare_epoch_setup` (once per model
145
+ and redshift) and `pdf_at_R` (once per radius). See
146
+ `notebooks/02_backscaling_ldt_pdf.ipynb` for a complete example.
147
+
148
+ ## Repository layout
149
+
150
+ ```
151
+ sphalde/
152
+ models/ dark energy models (DarkEnergyModel, DynamicDEModel)
153
+ cosmology/ flat FLRW background
154
+ collapse/ collapse and backscaling solvers, linear P(k), variance, LDT PDF
155
+ mass_function/ Press–Schechter, Sheth–Tormen, sigma(M), cluster counts
156
+ pipeline.py driver of the full calculation (the `sphalde` command)
157
+ data/ default configuration (copy of config/cosmology.yaml)
158
+ run.py command-line driver for a clone of the repository
159
+ config/ cosmology.yaml (all settings)
160
+ tests/ test_validation.py (pytest), convergence.py
161
+ notebooks/ examples that also produce the paper figures
162
+ comparison/pyldt/ comparison with pyLDT-cosmo (Cataneo et al. 2022)
163
+ ```
164
+
165
+ ## Tests
166
+
167
+ `tests/test_validation.py` checks the code against analytic results and
168
+ independent calculations: δ_c, Δ_vir and the growth factor in EdS, the
169
+ ΛCDM limits of wCDM and CPL, the closure and Hubble rate of the non-Abelian
170
+ model, the radiation rule, the derivatives of σ(M), the Press–Schechter mass
171
+ fraction, the comoving volume element and a lognormal test of the PDF
172
+ pipeline. Run it with `pytest` or `python tests/test_validation.py`.
173
+
174
+ `tests/convergence.py` changes one numerical parameter at a time (integrator
175
+ tolerances, collapse threshold, initial scale factor, τ and ρ grids) and
176
+ reports how much δ_c, Δ_vir, τ_c and the PDF move:
177
+
178
+ ```bash
179
+ python tests/convergence.py --quick # about 2 minutes
180
+ python tests/convergence.py # 10-20 minutes
181
+ ```
182
+
183
+ ## Citation
184
+
185
+ If you use SPHALDE, please cite the paper and the version of the code archived
186
+ in Zenodo. See `CITATION.cff`.
187
+
188
+ ## License
189
+
190
+ MIT; see `LICENSE`. `sphalde/collapse/symbolic_pklin.py` is adapted from
191
+ [symbolic_pofk](https://github.com/DeaglanBartlett/symbolic_pofk)
192
+ (MIT, © 2024 Deaglan J. Bartlett).
@@ -0,0 +1,153 @@
1
+ # SPHALDE
2
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24756256.svg)](https://doi.org/10.5281/zenodo.24756256)
3
+ [![tests](https://github.com/MrPI07/sphalde/actions/workflows/tests.yml/badge.svg)](https://github.com/MrPI07/sphalde/actions/workflows/tests.yml)
4
+
5
+ **Spherical collapse, halos and LDT density PDF for Dark Energy**
6
+
7
+ SPHALDE is a Python code for nonlinear spherical collapse in homogeneous dark
8
+ energy models. From a single description of the background expansion it
9
+ computes
10
+
11
+ - the collapse threshold δ_c(z), the virial overdensity Δ_vir(z) (with the
12
+ dark energy correction to the virial theorem) and the linear growth D(z), f(z);
13
+ - Press–Schechter and Sheth–Tormen halo mass functions and full-sky cluster
14
+ counts, per mass bin and above a mass threshold;
15
+ - the matter-density PDF in spheres from Large Deviation Theory, using the
16
+ full nonlinear mapping ρ(τ; z) of each model obtained by backscaling.
17
+
18
+ Radiation is part of every model's background. δ_c and the halo statistics
19
+ follow the standard convention and are computed without it; the backscaling
20
+ always includes it, because it dominates at the initial scale factor
21
+ a_ini = 1e-4.
22
+
23
+ Models included: Einstein–de Sitter (analytic test), ΛCDM, wCDM, CPL and the
24
+ massive non-Abelian SU(2) model. The default CPL model is the best fit of DESI
25
+ DR2 BAO + CMB + DES-Y5 supernovae, (w0, wa) = (−0.752, −0.86)
26
+ ([DESI Collaboration 2025](https://arxiv.org/abs/2503.14738)). A new model needs
27
+ only w(a) or, for a dynamical model, its background equations (see
28
+ `sphalde/models/`).
29
+
30
+ ## Installation
31
+
32
+ Python 3.10 or newer.
33
+
34
+ ```bash
35
+ pip install sphalde # numpy, scipy, matplotlib, pyyaml
36
+ pip install "sphalde[colossus]" # adds COLOSSUS (comparison of mass functions)
37
+ ```
38
+
39
+ To run the notebooks and tests, or to modify the code, install from a clone:
40
+
41
+ ```bash
42
+ git clone https://github.com/MrPI07/sphalde.git
43
+ cd sphalde
44
+ python -m pip install -e ".[test,notebooks]" # adds pytest, jupyter and colossus
45
+ ```
46
+
47
+ The linear power spectrum comes by default from the symbolic expression of
48
+ Bartlett et al. (2023), so neither CLASS nor CAMB is required. CLASS (`classy`)
49
+ can be used instead with `pdf.pk_source: class` in the configuration.
50
+
51
+ ## Quick start
52
+
53
+ The `sphalde` command runs the whole calculation with the default
54
+ configuration, which ships with the package:
55
+
56
+ ```bash
57
+ sphalde --list-models
58
+ sphalde --models LCDM CPL --quick # coarse grids, a few minutes
59
+ sphalde --write-config my_config.yaml # copy the default configuration
60
+ sphalde --config my_config.yaml # everything in your configuration
61
+ ```
62
+
63
+ Common options:
64
+
65
+ ```bash
66
+ sphalde --models CPL --param CPL.w0=-0.752 --param CPL.wa=-0.86
67
+ sphalde --models wCDM --w0 -0.8
68
+ sphalde --models NonAbelian --omega-i 5e-29 # initial omega = m^2/H^2 of the non-Abelian model
69
+ sphalde --tasks collapse halos --workers 6
70
+ sphalde --tasks pdf --pdf-z 0 1 --pdf-R 10 20
71
+ ```
72
+
73
+ From a clone of the repository, `python run.py` is equivalent to `sphalde`
74
+ and reads `config/cosmology.yaml`; `python tests/test_validation.py` runs the
75
+ validation tests (about 15 s).
76
+
77
+ Each model writes its tables and plots to `outputs/<model>/`, and
78
+ `outputs/run_summary.json` records the configuration, σ8, timings and
79
+ software versions.
80
+
81
+ From Python:
82
+
83
+ ```python
84
+ import numpy as np
85
+ from sphalde import get_model, FlatFLRW
86
+ from sphalde.collapse import SphericalCollapseSolver
87
+
88
+ cosmo = FlatFLRW(67.66, get_model("CPL")) # w0 = -0.752, wa = -0.86
89
+ res = SphericalCollapseSolver(cosmo, n_workers=4).compute_all(np.array([0.0, 1.0, 2.0]))
90
+ print(res["delta_c"], res["Delta_vir"])
91
+ ```
92
+
93
+ Dynamical models take their initial conditions as arguments, e.g.
94
+ `get_model("NonAbelian", omega_i=5e-29)`, with `omega_i` = m²/H² at the initial
95
+ redshift (Guarnizo et al. 2020); the default `omega_i = 0` switches off the
96
+ mass term. `model.w_z(z)` gives w_DE down to 1 + z = 0.1 (z = -0.9).
97
+
98
+ The whole pipeline is also available from Python:
99
+
100
+ ```python
101
+ from sphalde.pipeline import load_config, run_model
102
+ res = run_model(load_config(), "CPL", tasks=["collapse", "halos"])
103
+ ```
104
+
105
+ The LDT PDF is computed in two stages: `prepare_epoch_setup` (once per model
106
+ and redshift) and `pdf_at_R` (once per radius). See
107
+ `notebooks/02_backscaling_ldt_pdf.ipynb` for a complete example.
108
+
109
+ ## Repository layout
110
+
111
+ ```
112
+ sphalde/
113
+ models/ dark energy models (DarkEnergyModel, DynamicDEModel)
114
+ cosmology/ flat FLRW background
115
+ collapse/ collapse and backscaling solvers, linear P(k), variance, LDT PDF
116
+ mass_function/ Press–Schechter, Sheth–Tormen, sigma(M), cluster counts
117
+ pipeline.py driver of the full calculation (the `sphalde` command)
118
+ data/ default configuration (copy of config/cosmology.yaml)
119
+ run.py command-line driver for a clone of the repository
120
+ config/ cosmology.yaml (all settings)
121
+ tests/ test_validation.py (pytest), convergence.py
122
+ notebooks/ examples that also produce the paper figures
123
+ comparison/pyldt/ comparison with pyLDT-cosmo (Cataneo et al. 2022)
124
+ ```
125
+
126
+ ## Tests
127
+
128
+ `tests/test_validation.py` checks the code against analytic results and
129
+ independent calculations: δ_c, Δ_vir and the growth factor in EdS, the
130
+ ΛCDM limits of wCDM and CPL, the closure and Hubble rate of the non-Abelian
131
+ model, the radiation rule, the derivatives of σ(M), the Press–Schechter mass
132
+ fraction, the comoving volume element and a lognormal test of the PDF
133
+ pipeline. Run it with `pytest` or `python tests/test_validation.py`.
134
+
135
+ `tests/convergence.py` changes one numerical parameter at a time (integrator
136
+ tolerances, collapse threshold, initial scale factor, τ and ρ grids) and
137
+ reports how much δ_c, Δ_vir, τ_c and the PDF move:
138
+
139
+ ```bash
140
+ python tests/convergence.py --quick # about 2 minutes
141
+ python tests/convergence.py # 10-20 minutes
142
+ ```
143
+
144
+ ## Citation
145
+
146
+ If you use SPHALDE, please cite the paper and the version of the code archived
147
+ in Zenodo. See `CITATION.cff`.
148
+
149
+ ## License
150
+
151
+ MIT; see `LICENSE`. `sphalde/collapse/symbolic_pklin.py` is adapted from
152
+ [symbolic_pofk](https://github.com/DeaglanBartlett/symbolic_pofk)
153
+ (MIT, © 2024 Deaglan J. Bartlett).
@@ -0,0 +1,79 @@
1
+ # ===================================================================
2
+ # SPHALDE — configuration file
3
+ # Units: masses in h^-1 M_sun, lengths in h^-1 Mpc.
4
+ # ===================================================================
5
+
6
+ cosmology:
7
+ H0: 67.66 # km/s/Mpc
8
+ Om_m: 0.3103 # present matter density (injected into every model
9
+ # that accepts Om_m, unless the model sets its own)
10
+ sigma8: 0.8083 # sigma8 of the reference LCDM model
11
+ n_s: 0.9665
12
+ radiation: true # master switch for radiation (Omega_r0 from T_CMB =
13
+ # 2.7255 K and N_eff; Om_de = 1 - Om_m - Om_r). If false,
14
+ # no stage uses it. Per-stage settings below.
15
+ N_eff: 3.046
16
+
17
+ # Models to run. "params" are passed to the model constructor.
18
+ # Available: EdS, LCDM, wCDM, CPL, NonAbelian (see sphalde/models/)
19
+ models:
20
+ - name: LCDM
21
+ - name: wCDM
22
+ params: {w0: -0.9}
23
+ - name: CPL # DESI DR2 BAO + CMB + DES-Y5 best fit (arXiv:2503.14738)
24
+ params: {w0: -0.752, wa: -0.86}
25
+ # Dynamical model; its initial conditions can be changed, e.g.
26
+ # - name: NonAbelian
27
+ # params: {omega_i: 5.0e-29} # omega_i = m^2/H^2 at z_ini; default 0 (no mass term)
28
+
29
+ # Stages to run: background, collapse, halos, pdf
30
+ # (halos needs collapse; it is added automatically)
31
+ tasks: [background, collapse, halos, pdf]
32
+
33
+ n_workers: null # null -> all cores; 1 -> serial (debugging)
34
+
35
+ collapse:
36
+ z_max: 10.4 # collapse-redshift grid, uniform in ln a
37
+ dlna: 0.01
38
+ meszaros_ic: true # growing-mode IC with radiation (= f=1 if Om_r=0)
39
+ radiation: false # standard convention for delta_c and halo statistics:
40
+ # no radiation, so delta_c(z) -> 1.68647 (EdS) at high z.
41
+ # true: radiation included (delta_c ~ 1.688 at z = 10).
42
+ # Applies to EVERY model (dynamical ones too: their
43
+ # Omega_r0 goes into Omega_DE0).
44
+
45
+ halos:
46
+ mass_functions: [PS, ST]
47
+ sigma_method: pk # pk: sigma(M) from P(k) (same variance as
48
+ # the PDF module); fit: Viana & Liddle 1996
49
+ sigma8_normalization: delta_c_ratio
50
+ # delta_c_ratio: sigma8_mod = sigma8 dc_mod(0)/dc_LCDM(0)
51
+ # (same cluster abundance today)
52
+ # fixed: same sigma8 for every model
53
+ mass_bins:
54
+ - [1.0e13, 1.0e14]
55
+ - [1.0e14, 1.0e15]
56
+ - [1.0e15, 1.0e16]
57
+ M_inf_limits: [1.0e13, 1.0e14, 1.0e15]
58
+ M_max: 1.0e16
59
+ z_max_counts: 4.0 # maximum redshift for N^bin(z) and N(z,>M)
60
+ dndM_redshifts: [0.0, 0.5, 1.0, 2.0]
61
+ dndM_mass_range: [1.0e12, 1.0e16, 200]
62
+
63
+ pdf:
64
+ z_eval: [0.0, 1.0]
65
+ radii: [10.0, 15.0, 20.0, 25.0, 30.0]
66
+ a_ini: 1.0e-4 # initial scale factor of the backscaling
67
+ z_ini: 19.0 # redshift of the reference P_L(k)
68
+ pk_source: symbolic # symbolic (Bartlett et al. 2023) | class
69
+ margin: 0.999 # keep tau < margin * tau_c(z)
70
+ normalization: rescale # rescale (Uhlemann et al. 2016, pyLDT) | esscher
71
+ radiation: true # radiation dominates at a_ini = 1e-4: keep it
72
+ # (with the Meszaros initial condition) for
73
+ # EVERY model, also those whose constructor
74
+ # does not take Om_r
75
+
76
+ output:
77
+ dir: outputs
78
+ save_data: true
79
+ plots: true
@@ -0,0 +1,61 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sphalde"
7
+ version = "1.1.0"
8
+ description = "Spherical collapse, halos and LDT density PDF for Dark Energy"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.10"
13
+ authors = [
14
+ { name = "Pedro M. Ibarbo-Perlaza", email = "pedro.ibarbo@correounivalle.edu.co" },
15
+ { name = "J. Bayron Orjuela-Quintana" },
16
+ { name = "César A. Valenzuela-Toledo" },
17
+ ]
18
+ keywords = ["cosmology", "dark energy", "spherical collapse", "halo mass function",
19
+ "large deviation theory", "large-scale structure"]
20
+ classifiers = [
21
+ "Development Status :: 5 - Production/Stable",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Operating System :: OS Independent",
28
+ "Intended Audience :: Science/Research",
29
+ "Topic :: Scientific/Engineering :: Astronomy",
30
+ "Topic :: Scientific/Engineering :: Physics",
31
+ ]
32
+ dependencies = [
33
+ "numpy>=1.24",
34
+ "scipy>=1.10",
35
+ "matplotlib>=3.7",
36
+ "pyyaml>=6.0",
37
+ ]
38
+
39
+ [project.optional-dependencies]
40
+ class = ["classy"]
41
+ colossus = ["colossus"]
42
+ notebooks = ["jupyter", "colossus"]
43
+ test = ["pytest>=7"]
44
+
45
+ [project.scripts]
46
+ sphalde = "sphalde.pipeline:cli"
47
+
48
+ [project.urls]
49
+ Repository = "https://github.com/MrPI07/sphalde"
50
+ Documentation = "https://github.com/MrPI07/sphalde#readme"
51
+ Changelog = "https://github.com/MrPI07/sphalde/blob/main/CHANGELOG.md"
52
+
53
+ [tool.setuptools.packages.find]
54
+ include = ["sphalde*"]
55
+
56
+ [tool.setuptools.package-data]
57
+ sphalde = ["data/*.yaml"]
58
+
59
+ [tool.pytest.ini_options]
60
+ testpaths = ["tests"]
61
+ python_files = ["test_*.py"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+