Skip to content

Class v33#17

Open
elikrause wants to merge 3 commits into
masterfrom
class_v33
Open

Class v33#17
elikrause wants to merge 3 commits into
masterfrom
class_v33

Conversation

@elikrause
Copy link
Copy Markdown
Contributor

modified cosmo3D.c to support CLASS v3.3

  • cosmo3Dc: adapt free_class_structs, run_class, CLASS_sigma8,
    get_class_s8, get_class_As, and p_class to support CLASS v3.3 API
    (struct fourier/harmonic/thermodynamics/perturbations/transfer,
    input_read_from_file, fourier_pk_at_k_and_z) via #if CLASS_V33 / #else
    guards; the else branch covers both CLASS_V29 and unversioned class
  • cosmo3D_v33.c: fix sigma8 shooting bugs visible in v33: read sigma8
    before free_class_structs in get_class_s8; free between double
    run_class calls in get_class_As
  • cosmo3D_v33.c: add HMCode runmode variants (HMcode2020,
    HMcode2016, HMcode2020_baryonic_feedback, etc.) routing to P_type=4;
    class/CLASS runmodes call halofit; pass hmcode_version and
    log10T_heat_hmcode (t_agn) to CLASS parser
  • structs.c: add t_agn field to pdeltapara for log10T_heat_hmcode

I tested that this is fully backward compatible, defaults to the class version that's shipped with cosmolike_core, and that changes at the data vector level are typically < 0.1% between different class versions (all with halofit) if the amplitude is specified in terms of A_s. This difference is slightly larger is sigma_8 is specified, due to updates to the sigma_8 shooting algorithm.

I also checked that class structures are freed completely between difference calls and did not see any indication of memory leaks in a short MCMC with 10000 samples.

image

elikrause and others added 3 commits May 19, 2026 10:41
- cosmo3D_v33.c: adapt free_class_structs, run_class, CLASS_sigma8,
  get_class_s8, get_class_As, and p_class to support CLASS v3.3 API
  (struct fourier/harmonic/thermodynamics/perturbations/transfer,
  input_read_from_file, fourier_pk_at_k_and_z) via #if CLASS_V33 / #else
  guards; the else branch covers both CLASS_V29 and unversioned class
- cosmo3D_v33.c: fix sigma8 shooting bugs visible in v33: read sigma8
  before free_class_structs in get_class_s8; free between double
  run_class calls in get_class_As
- cosmo3D_v33.c: add HMCode runmode variants (HMcode2020,
  HMcode2016, HMcode2020_baryonic_feedback, etc.) routing to P_type=4;
  class/CLASS runmodes call halofit; pass hmcode_version and
  log10T_heat_hmcode (t_agn) to CLASS parser
- structs.c: add t_agn field to pdeltapara for log10T_heat_hmcode

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
distortions_free guards on has_distortions so it is a no-op for mPk
runs, but omitting it would leak if distortions are ever enabled.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@elikrause
Copy link
Copy Markdown
Contributor Author

elikrause commented May 19, 2026

Note that makefiles for v33 requires linking C++ standard library - add "-lc++" to your project Makefile. Here's a minimal example

CLASS33_DIR := ../cosmolike_core/class_v33

opt_home_CLASS33 := -std=c99 -Wno-missing-braces -Wno-missing-field-initializers
-I/usr/local/include
-I$(CLASS33_DIR)/include
-I$(CLASS33_DIR)/external/RecfastCLASS
-I$(CLASS33_DIR)/external/HyRec2020
-I$(CLASS33_DIR)/external/heating
-L/usr/local/lib -L$(CLASS33_DIR)
-g -std=gnu99 -lgsl -lfftw3 -lgslcblas -lclass -lc++ -lm -DCLASS_V33

class_v33:
gcc like_test.c -o ./test_desy3 $(cfftlog) $(cfastpt) $(opt_home_CLASS33)

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