Skip to content

py-SP(k) Model#194

Open
jemme07 wants to merge 12 commits intocmbant:masterfrom
jemme07:spk
Open

py-SP(k) Model#194
jemme07 wants to merge 12 commits intocmbant:masterfrom
jemme07:spk

Conversation

@jemme07
Copy link
Copy Markdown

@jemme07 jemme07 commented Apr 19, 2026

Overview

This PR implements the SP(k) baryon-suppression model (Salcido et al. 2023) in CAMB.

Model references:

What is implemented

1. SP(k) non-linear wrapper

  • fortran/SPkNonLinear.f90 wraps a base non-linear model (e.g. HMCode/halofit) and applies SP(k) suppression multiplicatively.
  • Supports SP(k) relation modes exposed in the interface:
    • power-law
    • cosmology power-law
    • double power-law
  • Calibrated-range handling consistent with model limits:
    • outside calibrated z range, SP(k) correction is skipped
    • for k above calibrated limit, suppression evaluation is clamped at calibrated k_max
  • One-time runtime warnings (for FeedbackLevel > 0) are emitted for both out-of-range behaviors.

2. Python API path and integration coverage

  • SP(k) usage is validated through Python-side CAMB APIs, including class-selection.
  • camb/tests/camb_test.py includes coverage that set_classes(non_linear_model="SPkNonLinear") selects and runs correctly.

3. Dedicated SP(k) validation tests

  • camb/tests/spk_test.py adds dedicated SP(k) tests.
  • Tests compare CAMB SP(k) outputs directly against pyspk across supported relation modes.
  • Includes boundary-focused regression checks for high-k behavior and warning behavior.
  • Uses stable numerical tolerances and sampling choices for reproducible comparisons.

4. SP(k) demo notebook

  • Adds `docs/SPk_demo.ipynb
  • Notebook demonstrates:
    • baseline non-linear vs non-linear+SP(k)
    • CAMB-vs-pyspk suppression overlays
    • relative error diagnostics as a function of k and z
output

Supporting updates

  • pyproject.toml: adds pyspk>=2.0.0 to dev extras for validation workflows.

Validation run

  • Focused SP(k) suite:
    • python -m unittest camb.tests.spk_test
    • passing

Reviewer notes

  • The SP(k) formulas/behavior are anchored to the published model and cross-checked against the reference pyspk implementation.

jemme07 added 11 commits April 19, 2026 11:49
…erage

unignore and add SPk_demo.ipynb to the repo
add an end-to-end SP(k) demo comparing CAMB vs pyspk with relative-error diagnostics
make SP(k) unit references more stable with dense transfer sampling (k_per_logint=100)
tighten relation-match tolerances to 1e-6 / 1e-9
add a high-k boundary continuity regression test (k <= 12) to prevent cutoff artifacts
- Introduced warnings for redshift values outside the calibrated range,
  notifying users when SP(k) calculations are skipped.
- Added clamping warnings for input k values exceeding the calibrated maximum,
  ensuring users are informed when values are adjusted.
- Implemented logical flags to prevent repeated warnings during execution.
@jemme07
Copy link
Copy Markdown
Author

jemme07 commented Apr 28, 2026

Hi @cmbant ,

This PR is ready for review. Could you please assign some reviewers?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant