Skip to content

Conversation

@mabruzzo
Copy link
Collaborator

@mabruzzo mabruzzo commented Sep 10, 2025

To be reviewed after #415 is merged


The primary objective of this PR is to factor out heap allocations from the core loop. To accomplish this, this PR

  • pre-initializes the grid of ${\rm ln}\, (T_{\rm gas})$ and ${\rm ln}\, (T_{\rm dust})$ values that are used to interpolate h2dustS and h2dustC.
  • factors out some shielding logic, into ShieldFactorCalculator, so that we can avoid allocating the f_shieldH and f_shieldHe arrays)
  • we now pre-allocate the internal_dust_prop_buf instance

While I was doing this, I also factored out the H2-shielding logic into a helper function to try to improve readability (and make the code easier to reason about). I was also able to remove a bunch of logic where we were constructing Vlews from the body of lookup_cool_rate1d.

@mabruzzo mabruzzo changed the title [newchem-cpp] WIP: lookup_rate1d cleanup part 2 [newchem-cpp] WIP: lookup_cool_rate1d cleanup part 2 Sep 10, 2025
1. remove some unused variables (that I accidently copied)
2. prevent some implicit casts
@mabruzzo mabruzzo force-pushed the ncc/lookup_rate_1d_cleanup-scratch branch from 0047675 to 592dc98 Compare September 10, 2025 16:28
@mabruzzo mabruzzo changed the base branch from newchem-cpp to main September 12, 2025 15:53
@mabruzzo mabruzzo changed the base branch from main to newchem-cpp September 12, 2025 15:54
@mabruzzo mabruzzo added the refactor internal reorganization or code simplification with no behavior changes label Sep 12, 2025
@mabruzzo mabruzzo changed the title [newchem-cpp] WIP: lookup_cool_rate1d cleanup part 2 [newchem-cpp] lookup_cool_rate1d cleanup part 2 Sep 12, 2025
@mabruzzo mabruzzo marked this pull request as ready for review September 12, 2025 16:08
@mabruzzo
Copy link
Collaborator Author

@brittonsmith, this should be ready to go

@brittonsmith brittonsmith changed the base branch from newchem-cpp to main November 14, 2025 13:22
@brittonsmith brittonsmith changed the base branch from main to newchem-cpp November 14, 2025 13:22
Copy link
Contributor

@brittonsmith brittonsmith left a comment

Choose a reason for hiding this comment

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

This looks great. In the interest of progress, let's merge this now. The dust variable name can be changed any time.

Comment on lines +258 to +262
//H2 formation on dust grains with C and S compositions
if (
(add_h2dust_C_reaction_rate(&my_rates->h2dustC, kUnit, my_chemistry)
!= GR_SUCCESS) ||
(add_h2dust_S_reaction_rate(&my_rates->h2dustS, kUnit, my_chemistry)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe now is the time to right this wrong convert S to Si to denote this being silicon.

@brittonsmith brittonsmith merged commit f145e04 into grackle-project:newchem-cpp Nov 18, 2025
5 checks passed
@mabruzzo mabruzzo deleted the ncc/lookup_rate_1d_cleanup-scratch branch November 19, 2025 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor internal reorganization or code simplification with no behavior changes

Projects

Development

Successfully merging this pull request may close these issues.

2 participants