Skip to content

Refactor logT precalculation#535

Open
mabruzzo wants to merge 71 commits into
grackle-project:newchem-cppfrom
mabruzzo:ncc/LnTPreparer
Open

Refactor logT precalculation#535
mabruzzo wants to merge 71 commits into
grackle-project:newchem-cppfrom
mabruzzo:ncc/LnTPreparer

Conversation

@mabruzzo
Copy link
Copy Markdown
Collaborator

@mabruzzo mabruzzo commented Apr 20, 2026

To be reviewed after #543 has been merged.


This PR refactors the calculations of ln(T). It factors out all of the logic so that it is now performed by the newly created LnTPreparer class1. I don't actually think that it's an ideal abstraction, but I think it's a huge improvement over what we had. Before we try to come up with a better abstraction, I think we need to decide how to resolve a bunch of inconsistencies that are described in the docstring of LnTPreparer (maybe that discussion should be moved to an issue?).

Hoisting logic out of cool1d_multi_g and lookup_cool_rates1d

As part of this PR, I pulled the logic pertaining to LnTPreparer class out of cool1d_multi_g and lookup_cool_rates1d. This does 2 things: (i) we can stop passing iteration count to cool1d_multi_g and (ii) it paves the way for us to directly reuse the computed ln(T) values for both cool1d_multi_g and lookup_cool_rates1d (note the values are still recomputed in this PR -- we start reusing values in PR #537).

At a glance, the logic might look a little more complex. However, this complexity has always been present; I've just made it more explicit. I think this is definitely a step in the right direction.

Gold Standard

In any case, I tried to take a lot of care to avoid breaking the gold-standard. At the end something changed, and I don't totally understand why. It's a small enough change that I'm content to probably just update the gold-standard.

I have deferred a small handful of (related) changes to PR #537, where there will be a significant change in the gold-standard.

Footnotes

  1. This was made as a slightly more traditional C++ class with a true constructor and attached methods to gauge how people feel about moving towards this sort of approach. I'm happy convert it to the more classic C-style logic on request.

mabruzzo added 30 commits April 19, 2026 09:40
This switches to using GRIMPL_NAMESPACE_DECL and puts all the helper
function into the namespace
The result is definitely not bitwise identical, but that's not going to
make tests fail (since the logic is not tested)
@mabruzzo mabruzzo marked this pull request as ready for review April 23, 2026 12:13
@mabruzzo mabruzzo changed the title WIP: refactor logT precalculation Refactor logT precalculation Apr 23, 2026
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.

2 participants