Skip to content

transcribe lookup_cool_rates0d 2/2#33

Closed
mabruzzo wants to merge 691 commits into
brittonsmith:gen2024from
mabruzzo:gen2024transcribe/lookup_cool_rates0d_cleanup
Closed

transcribe lookup_cool_rates0d 2/2#33
mabruzzo wants to merge 691 commits into
brittonsmith:gen2024from
mabruzzo:gen2024transcribe/lookup_cool_rates0d_cleanup

Conversation

@mabruzzo

Copy link
Copy Markdown

This must be reviewed after PR #31


This PR finishes the transcription of lookup_cool_rates0d that I started back in #30

This PR can be broadly summarized as the following:

  1. I moved 1200+ lines of logic at the end of lookup_cool_rated0d into a function called species_density_derivatives_0d
    • getting the appropriate function signature took quite a bit of work
    • I needed to apply a bunch of transformations to the code as I worked through it. The commits applying these transformations are very atomic (there was a lot of search-and-replace)
    • as noted in PR transcribe lookup_cool_rates0d 1/2 #31 (and in the functions docstring), Gen seems to have copied a lot of logic from step_rate_g and then made a series of systematic changes. After we transcribe step_rate_g, I have some thoughts on how to reconcile the 2 implementation
    • this function was moved to the chemistry_solver_funcs.hpp file. The idea is to eventually store related logic from lookup_cool_rates1d_g, step_rate_g and rate_timestep_g within this file. The goal is to try to store chemistry-logic called here from the grackle solver. To the extent that it's possible, it would be nice to decouple this logic from the solver's underlying scheme (whether it's the classic partial updates with the backward-difference-formula OR newton-raphson OR something else)
  2. I fused lookup_cool_rates0d and time_deriv_0d::derivatives. The fused function is called time_deriv_0d::derivatives. This has been my intention for a while. The name now much more clearly conveys the purpose of the function (while it invokes lookup_cool_rates1d, the purpose of the function is much different).
  3. I started to pre-allocate a bunch of local variables corresponding to 1-element buffers
  4. I changed the data-structures used throughout time_deriv_0d::derivatives. This involved adding an ugly wrapper function that gets called by step_rate_newton_raphson. That is a short-term hack. My next intention is to finish cleaning up step_newton_raphson (I simply wanted to minimize the amount I changed that function in this PR)
  5. I removed a bunch more cleaning (mostly, I just removed a bunch of now unnecessary local variables)

Overall, I think the end result of this PR is a massive improvement over the original fortran routine (and it has much better documentation). While improvements are still possible,1 I think we're done with transcribing this function.

Future Thoughts

It also would make a lot of sense to refactor the function so that it can compute derivatives for multiple sets of conditions at once (i.e. so it's no longer 0d). Alternatively, it might more sense to more directly compute partial derivatives like $\frac{\partial }{\partial \rho_i} \dot{\rho}_i$ or $\frac{\partial }{\partial T} \dot{\rho}_i$. With a little refactoring that I want to do anyways, these calculations would be trivial

Misc

I have manually confirmed that all tests pass

Footnotes

  1. For example, now that I can see the full picture, I would make some different organizational choices. It also would make a lot of sense to refactor the function so that it can compute derivatives for multiple sets of conditions at once (i.e. so it's no longer 0d). Alternatively, it would might more sense to more directly compute $ \frac{\partial}{\partial \rho_i$ partial derivatives. With a little refactoring that I want to do anyways, this would become

@mabruzzo mabruzzo changed the base branch from master to gen2024 February 16, 2025 23:51
mabruzzo and others added 27 commits May 19, 2025 17:19
Originally one job ran the tests after building pygrackle as a
standalone package (i.e. the core Grackle is compiled as part of
pygrackle). The other job ran the tests with versions of pygrackle
where we explicitly built the core library (with both build-systems) as
a separate step from building pygrackle.
In these cases, we only run a subset of the test-suite (the much faster
component). This seems reasonable since we are already running the
answer-tests with the version of pygrackle configured that automatically
compiled the core-library as part of the build process. This should save
a lot of time
…sting-without-editable-install

Support running subset of pygrackle test without a an editable install
…tweak

cython does not need to be a runtime-dependency
…nstruction-tweaks

Pygrackle test instruction tweaks
…Warnings

Enable Compiler Warnings in a CI job
…lding_length_fix

H2 self shielding length scale factor fix
mabruzzo and others added 26 commits August 13, 2025 08:24
…o gen2024transcribe/step_rate_newton_raphson-cleanup-1of2
…e/internal_types_updates

[newchem-cpp] internal scratch-buffer interface update
…e/Implement-SpLUT-with-XMacros

[newchem-cpp] Refactor such that SpLUT is implemented with XMacros
…e/SpeciesLUTFieldAdaptor

[newchem-cpp] Introduce `SpeciesLutFieldAdaptor`
The *Great Renaming:* `gracklepy` edition
…e/initial-step_rate_newton_raphson

[newchem-cpp] initial transcription of `step_rate_newton_raphson`
…' into gen2024transcribe/lookup_cool_rates0d
@mabruzzo

mabruzzo commented Aug 20, 2025

Copy link
Copy Markdown
Author

superseded by grackle-project#379

@mabruzzo mabruzzo closed this Aug 20, 2025
@mabruzzo mabruzzo deleted the gen2024transcribe/lookup_cool_rates0d_cleanup branch September 11, 2025 14:15
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.

3 participants