Author: Svetlin V. Tassev
This repository accompanies the paper Dominated-Convergence Failure in
Cosmological Perturbation Theory and a Numerical Foundation for BBGKY+ZA.
It contains the C++ pipeline that evaluates the Zel'dovich phase-space
two-point kernel sec:corrZA, the Python helpers that prepare its cosmology input,
and the Python figure scripts that produced the numerical-results panels
of Section sec:Pnumresults and Appendix app:asympt.
The kernel
| Path | Role |
|---|---|
makefile |
Builds the nine maintained executables (seven FINALP_exp lane + two FINALP cross-check lane) |
*.cpp, *.h, *.hpp |
C++ sources of the angular, radial, merge and contraction stages |
Compute_*.sh, Merge_*.sh, Run_*.sh |
Shell wrappers for the maintained pipeline stages |
Python/ |
Cosmology-input generation and HDF5 comparison helpers (Python) |
analyze/CLM_check/ |
Python scripts that produce the figures of the paper from the HDF5 outputs |
data/ |
Runtime input/cache directory, kept in git via .gitkeep |
DOCUMENTATION.md |
Detailed code, file-format, and code-to-paper reference |
FIGURES.md |
Provenance of every paper figure that this repository produces |
LICENSE |
GNU GPL v3 license text |
The executables are intended to be run from the repository root so that
the relative runtime directory data/ resolves correctly.
The code stores quantities under names that differ from those in the paper by historical convention. The mapping is:
| Paper symbol (tex) | Code symbol / file | Notes |
|---|---|---|
mathcalP |
the kernel of eq. (Pcurly), eqs. (FINALP_exp,FINALP) |
|
mathcalC_LM2D (HEALPix-sampled) |
cosmology-independent angular polynomial, eq. (CLM_FINAL) |
|
mathcalC_coeff_LM2D (coefficient table) |
CLM_ab_def) |
|
mathcalG (merged files) |
radial Hankel transform piece, eq. (Glmn); stored scaled by |
|
inner integrand of compute_mathcalG_noSumN.cpp
|
eq. (Hlmn) |
|
|
|
zeta, gamma (in read_cosmo.cpp, data/zeta_gamma.txt) |
cosmological inputs, derived from |
sigmav2 |
velocity-dispersion scalar | |
pk_zeldovich, pk_zeldovich_standard (in power_spectra.h5) |
Zel'dovich density power spectrum, Appendix app:PZ
|
|
pk (in cosmology_input.h5) |
linear matter power spectrum | |
Psub_def) |
P_powers axis) |
substituted angular variable |
Psub_def) |
Q_powers axis) |
substituted angular variable |
reference slice mathcalP_PQ_coefficients
|
eq. (Pstar_def) |
The translation P_code = X_paper, Q_code = Z_paper is centralized in
init_pq_linear_substitution() inside C_LM_PQ.cpp. The HDF5 datasets
P_powers[i] and Q_powers[j] carry the integer exponents stored along
the third and fourth axes of mathcalC_coeff_LM2D and
mathcalP_PQ_coefficients, so the reconstruction reads
with
One subtlety to keep in mind. The code's substitution (eq. Psub_def)
Pexp_XZ) of the paper writes the same kernel as
The paper's truncation of the FINALP_exp) is
exposed at run time via the environment variables MATHCAL_MAX_L and
MATHCAL_MAX_M, with maintained defaults 30/100. The numerical
tiering of Appendix app:numerics —
The kernel i_LM
The four stages and their outputs are:
-
Angular stage. Either
ComputeMathcalC_LM2D(paper's HEALPix-sampled$\mathcal{C}_{LM}(s,t,\mu_{lm})$ via eq. (SLM1)) orComputeMathcalC_LM_PQ(paper's$(X,Z)$ -substituted$\mathcal{C}_{LM,ab}(\mu_{lm})$ via eq. (CLM_ab_def)). Cosmology-independent. Produces one HDF5 file permu_lmgrid point on the linear grid$\mu_{lm}=\cos(\pi\,\mathrm{NUM}/100)$ with$\mathrm{NUM}\in[0,100]$ . -
Radial stage.
ComputeMathcalG_noSumNevaluates the Hankel transform in eq. (Glmn) atbias = -0.9andbias = +0.9using FFTLog. Produces one raw HDF5 file peri_LMper bias. -
Merge stage.
MergeMathcalGsstitches the two biases onto a single$k$ grid using the matched-derivative criterion described in Appendixapp:numerics. Produces one merged HDF5 file peri_LM. -
Contraction stage.
ComputeMathcalP_noSumN(HEALPix lane) orComputeMathcalP_QP(coefficient lane) contracts the angular and merged radial files into$\mathcal{P}$ . The figures of the paper are produced from the coefficient-lane outputmathcalP_PQ_i.h5.
The figures of the paper come from the coefficient-lane (PQ) outputs
mathcalP_PQ_<i_LM>.h5. The HEALPix-lane outputs P_<i_LM>.h5 are
retained as a fully resummed reference and are cross-checked against the
PQ reconstruction by Compare_healpix_PQ.sh (see also
analyze/CLM_check/plot_mathcalP_healpix_vs_PQ.py).
ExportPowerSpectra is optional and writes a 1D diagnostic file
power_spectra.h5 tied to Appendix app:PZ; it is not consumed by any
of the four stages above.
A second, independent representation of FINALP) of
the paper, the fully separated
-
ComputeMathcalE(driven byCompute_MathcalE.sh): the radial stage that sums over the explicit-$N$ index inside the Hankel transform. Writes onemathcalE_LMN_scaled_by_2pi_over_k_to_3_halves_LM_<LM>_MaxL_10_MaxM_100_MaxN_100.h5file perLM=l*mvalue from a hard-coded list of discreteLMpoints ({1e-10, ..., 3.5}incompute_mathcalE.cpp::main()). -
ComputeMathcalP_E_LMN(driven byCompute_MathcalP_E_LMN.sh): a single-pixel HEALPix contraction that pairs onemathcalE_LMN_*.h5file with onemathcalC_LM2D_<NUM>_<DEN>.h5slice and prints the contracted$\mathcal{P}$ to stdout at a hard-coded test point$(l,m,I_{\rm pixel})=(4,4,N_{\rm pixels}-1)$ .
This is the FINALP-vs-FINALP_exp cross-check that Section sec:Pnumerics
of the paper refers to. The production figures use the FINALP_exp
(LM list, edit the hard-coded
values in compute_mathcalE.cpp::main() and
compute_mathcalP_E_LMN.cpp::main().
g++and GNUmake(the source warns thatclangwas not reliable for this code path)- HDF5 with C++ headers and libraries
- FFTW3 (with OpenMP support;
fftw3lifUSE_LONG_DOUBLE=1) - FLINT / ARB / ACB (for the arbitrary-precision angular and FLINT-path radial branches)
- GSL
- OpenMP
- HEALPix C++ (only required by the HEALPix-sampled angular stage and the HEALPix-lane contraction)
- Python 3 with
numpy,scipy,matplotlib,h5py,pyccl(for the cosmology generator and the figure scripts)
The figure-production Python scripts in analyze/CLM_check/ additionally
use matplotlib's LaTeX backend (text.usetex = True) at run time;
install a working texlive if you want to reproduce the rendered
panels exactly.
A working, least-fragile setup is a dedicated conda environment from
conda-forge:
conda create -n vlasov-2pt -c conda-forge python=3.12 pyccl numpy scipy matplotlib h5py
conda init zsh
exec zsh
conda activate vlasov-2ptIf activation is not available in the current shell, use:
eval "$(conda shell.zsh hook)"
conda activate vlasov-2ptFor one-off runs, skip activation and prefix commands with
conda run -n vlasov-2pt.
From the repository root:
# 1. write data/cosmology_input.h5 from pyccl
conda run -n vlasov-2pt python3 Python/calculate_cosmology_input.py --no-show
# 2. build all nine maintained executables
make
mkdir -p output/mathcalC_coeff output/mathcalG output/mathcalP_PQ
# 3. angular stage (coefficient lane)
MATHCALC_COEFF_DIR=output/mathcalC_coeff ./Compute_MathcalC_LM_PQ.sh
# 4. radial stage (writes two raw biases per i_LM into MATHCALG_DIR)
RADIAL_OUTPUT_DIR=output/mathcalG ./Compute_MathcalRadial.sh
# 5. merge the two bias branches per i_LM in place
MATHCALG_DIR=output/mathcalG ./Merge_MathcalGs.sh
# 6. contract into mathcalP_PQ_<i_LM>.h5
MATHCALC_COEFF_DIR=output/mathcalC_coeff \
MATHCALG_DIR=output/mathcalG \
OUTPUT_DIR=output/mathcalP_PQ \
./Compute_MathcalP_QP.shThe HEALPix lane uses the same data preparation, radial, and merge
stages, and substitutes Compute_MathcalC_LM2D.sh and
Compute_MathcalP.sh (writing P_<i_LM>.h5) for stages 3 and 6.
By default the four stages use the maintained truncation
(MATHCAL_MAX_L, MATHCAL_MAX_M) = (30, 100). The paper's tiered
production uses (10, 50), (30, 100), and (50, 120) across three
MaxL_<L>_MaxM_<M> filename suffix so the maintained
and custom lanes do not collide.
The shared-cache wrappers Run_mathcalP_PQ_shared_RESULTS.sh,
Run_mathcalP_PQ_shared_RESULTS_range.sh, and
Run_mathcalP_Healpix_shared_RESULTS.sh codify the production layout
used to produce the figures of the paper. They default the shared
runtime/output root to /run/media/user/SEAGATE/RESULTS; export
OUTPUT_ROOT=<your path> before invocation, or edit the
OUTPUT_ROOT="${OUTPUT_ROOT:-...}" line at the top of each script, to
run them on a different host.
The provenance of every figure that this repository produces is
documented in FIGURES.md. In short, the figures of
Section sec:Pnumresults are produced by Python scripts in
analyze/CLM_check/ from mathcalP_PQ_<i_LM>.h5 files; the appendix
asymptotic figures (Figs. fig:pz_asympt_late_D_low_k and
fig:pz_asympt_late_D_high_k) and the angular reference figures
(Figs. fig:L=1,fig:L=3,fig:L=10) are produced externally
(Mathematica) and not from this repository's Python code.
- All stage wrappers are resumable. Each one skips outputs that already exist; set the corresponding
FORCE_RECOMPUTE_*environment variable (seeDOCUMENTATION.mdfor the full list) to overwrite. Compute_MathcalC_LM2D.shandCompute_MathcalC_LM_PQ.shacceptMATHCALC_PARALLEL_JOBS=<N>and use per-output lock directories so that two processes do not compute the sameNUM/DENfile at once.Compute_MathcalRadial.shacceptsMATHCALG_PARALLEL_JOBS=<N>and launches separate bias runs in isolated worker directories.Merge_MathcalGs.shpreserves the raw bias-split inputs by default; setDELETE_RAW_MATHCALG=1to delete them after a successful merge. If a merge attempt fails for a giveni_LMthe wrapper retries with thresholds enlarged by1.5xup to three times before skipping thati_LM.- Set
TARGET_I_LM=<i>to makeCompute_MathcalRadial.sh,Merge_MathcalGs.sh,Compute_MathcalP.sh, andCompute_MathcalP_QP.shwork on onei_LMvalue instead of their default ranges. - Set
FAST_MATHCALP=1to keep the same convergence/error calculation while switching themathcalPcontraction to a faster plaindoubleaccumulator (the default uses Neumaier-compensatedlong double). Compute_MathcalP.shassumes the fullNUM = 0..100angular grid exists.
Full details of all wrapper environment variables, HDF5 file schemas,
the merge logic, and the convergence flag are in
DOCUMENTATION.md.
If you use this code, please cite the accompanying paper.
This software is distributed under the terms of the GNU General Public
License version 3 or later. See LICENSE for the full text.
Note: the documentation files in this repository (README.md,
DOCUMENTATION.md, FIGURES.md) were generated automatically by
inspection of the source code and the accompanying paper. They are
intended to be code-first: where the documentation and the source
disagree, the source is authoritative.