Skip to content

Integrate the photoionization cross sections once for each balance - #70

Merged
barrettp merged 1 commit into
mainfrom
speed
Oct 10, 2026
Merged

barrettp merged 1 commit into
mainfrom
speed

Conversation

@barrettp

Copy link
Copy Markdown
Member

Profiling a thick slab (one thread) showed that 57–64% of the time is in photoionization_integrals, and that the iteration of the electron fraction repeated it for every trial fraction.

  • RatesMemo: for ParPhotoIonize1/2/3 the photoionization rate is independent of the electron density and the recombination rate is proportional to it, so the later trials of ionization_balance scale the first result. The rate matrices agree with the uncached ones to rounding (H, He, O, Fe).
  • march_zones no longer computes line_emissivities twice when luminous=true (something(a, b) evaluated both).
one thread before after
thick slab, fixed T 73.8 s 51.6 s
thin slab, T iterated 166.6 s 133.3 s
balance of one zone 5.0 s 2.4 s

Results are unchanged (same He II to all digits; equilibrium T to 3e-10). Full suite passes on Julia 1.13 (987 tests). Further cost: record opacities, edge emissivities, heating and continuum opacity each still do a full photoionization pass per zone.

🤖 Generated with Claude Code

The photoionization rate does not depend on the electron density and the
recombination rate is proportional to it, so the iteration of the electron
fraction scales the first result (RatesMemo). The line emissivities are no
longer computed twice for the luminosities.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@barrettp
barrettp merged commit a8b86eb into main Oct 10, 2026
5 checks passed
@barrettp
barrettp deleted the speed branch October 10, 2026 10:39
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