Skip to content

Local primordial non-Gaussianities in initial conditions#631

Draft
jordanflitter wants to merge 1 commit intorelease-v4.2from
f_NL
Draft

Local primordial non-Gaussianities in initial conditions#631
jordanflitter wants to merge 1 commit intorelease-v4.2from
f_NL

Conversation

@jordanflitter
Copy link
Copy Markdown
Contributor

This PR includes the ability to have local PNGs in the initial conditions. At this moment, it only works with POWER_SPECTRUM!=CLASS, which is why it's in a draft state. The CLASS transfer function, being defined differently than the other transfer functions, requires a different implementation, so this PR will be in a draft state until there's also a support with having POWER_SPECTRUM=CLASS and PRIMORDIAL_NON_GAUSSIANITIES=True.

Some notes:

  • According to this paper, https://arxiv.org/pdf/1304.8049, it is not enough to simply change the initial conditions, but it's also necessary to modify EPS (eq. 5). This requires computing analytically the 3-point function in linear theory. This is much harder and will be done in a future PR.
  • I added an output called hires_Phi, just to be able to see directly how the primordial gravitational field is modified due to PNGs. It is only allocated when PRIMORDIAL_NON_GAUSSIANITIES=True, and it's a single (high-resolution) box in the initial conditions (unlike output boxes that we make at each node_redshift), so I'm not sure if users should be concerned about this extra memory allocation.
  • I added some functions in InitialConditions.c like add_pngs_to_delta_box, add_pngs_to_Phi_box, multiply_by_factor_in_Fourier_space and Poisson_factor. I am not entirely sure that the last two functions should indeed be placed in InitialConditions.c. There is a lot of resemblance between filter_box and multiply_by_factor_in_Fourier_space, and I actually think that we could use the latter to perform the former (since filtering is actually multiplying the box in Fourier space by a k-dependent factor, this is exactly what multiply_by_factor_in_Fourier_space does). I am not sure this PR is the best place to do this, but I do think it worths of making an issue.

@jordanflitter jordanflitter added type: feature: physical New feature that adds new analysis/physical model Science Project Something that we can write a paper on labels Mar 9, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.23%. Comparing base (02ed909) to head (009268d).
⚠️ Report is 17 commits behind head on release-v4.2.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/py21cmfast/wrapper/outputs.py 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           release-v4.2     #631      +/-   ##
================================================
+ Coverage         88.01%   88.23%   +0.22%     
================================================
  Files                32       32              
  Lines              4755     4760       +5     
  Branches            803      804       +1     
================================================
+ Hits               4185     4200      +15     
+ Misses              410      399      -11     
- Partials            160      161       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@steven-murray
Copy link
Copy Markdown
Member

This looks cool @jordanflitter!

I will refrain from a full review since it's in draft state, but I will note that I think hires_Phi is a bad name :--) Phi is a symbol name, not a physically meaningful name.

Otherwise, I agree in spirit with all your notes!

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

Labels

Science Project Something that we can write a paper on type: feature: physical New feature that adds new analysis/physical model

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants