Skip to content

Ability to inject initial conditions (only density field)#613

Merged
jordanflitter merged 10 commits intomainfrom
Nikos_branch
Feb 18, 2026
Merged

Ability to inject initial conditions (only density field)#613
jordanflitter merged 10 commits intomainfrom
Nikos_branch

Conversation

@jordanflitter
Copy link
Contributor

This PR implements two new more features.

The first one is the ability to inject hires_density_array to p21c.compute_initial_conditions. If a non-zero array is injected, then the usual Gaussian sampling in Fourier space is skipped, and then the rest of the computation continues. As before, this modified initial_conditions can then be used as an input to run_coeval (or run_lightcone) in order to make a "roundtrip test", something that could be useful for @nikos-triantafyllou's project.

The second new feature is the ability to run_global_evolution with delta_z0 which is not necessarily 0. This could be helpful in making (speedy) linear perturbation theory* with 21cmFAST.

*Note that this is a scale-independent perturbation theory, since we currently assume that the density field evolves in a scale-independent manner (as we simply multiply it by the scale-independent growth factor). This is actually not true in the dark ages, where the baryon density field evolves in a scale-dependent manner (unlike CDM, which roughly evolves in a scale-dependent manner), but this will wait for another PR

@jordanflitter jordanflitter added priority: medium Medium priority type: feature: ui New feature that adds functionality for the user labels Feb 16, 2026
@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.16%. Comparing base (943ca5f) to head (38582c8).
⚠️ Report is 14 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #613      +/-   ##
==========================================
+ Coverage   88.13%   88.16%   +0.03%     
==========================================
  Files          32       32              
  Lines        4729     4741      +12     
  Branches      796      800       +4     
==========================================
+ Hits         4168     4180      +12     
  Misses        401      401              
  Partials      160      160              

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

Copy link
Member

@steven-murray steven-murray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jordanflitter this is almost there, we discussed just now the following:

  • Changing the name of the hires_density_array parameter
  • Changing the with_value_not_computed to be private
  • Updating compute_xray_source_field to use your approach
  • Adding your paper (and others) to show_references()
  • Adding a small section to a new tutorial that promotes your new feature.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@jordanflitter
Copy link
Contributor Author

Thanks @steven-murray for your comments! I renamed some of the variable + function names, and I also updated the tutorials and the faq to give more information on the new features, as we discussed.

Unfortunately, we cannot at the moment get rid of the allow_already_computed hack in outputs.py and use "my approach" in compute_xray_source_field, I gave some details in #552.

As for your last two comments (include my paper in show_references() and promote it in the docs), I'll do it as part of #534.

@jordanflitter jordanflitter merged commit 47c4399 into main Feb 18, 2026
28 of 29 checks passed
@jordanflitter jordanflitter deleted the Nikos_branch branch February 18, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: medium Medium priority type: feature: ui New feature that adds functionality for the user

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants