Skip to content

[newchem-cpp] convert update_UVbackground_rates.{c->cpp}#431

Merged
brittonsmith merged 6 commits into
grackle-project:newchem-cppfrom
mabruzzo:ncc/cppify-update_UVbackground_rates
Jan 13, 2026
Merged

[newchem-cpp] convert update_UVbackground_rates.{c->cpp}#431
brittonsmith merged 6 commits into
grackle-project:newchem-cppfrom
mabruzzo:ncc/cppify-update_UVbackground_rates

Conversation

@mabruzzo

Copy link
Copy Markdown
Collaborator

To be reviewed after #430 is merged


This PR converts update_UVbackground_rates.c to C++. It also puts the update_UVbackground_rates function into our internal grackle::impl namespace.

I did a few other things as part of this PR:

  • I introduced a header file (so that we could stop forward-declaring the update_UVbackground_rates function every time we want to use it1
  • I replaced some of the unit-calculation logic with the internal_unit machinery (I don't think this will cause answer-tests to drift, but I'm not 100% sure and I haven't explicitly checked)
  • I made some tweaks to let us stop including grackle_macros.h2

Footnotes

  1. An argument could be made for making update_UVbackground_rates an inline function that is fully implemented in a header file.

  2. Broadly speaking, there are a handful of macros defined in that file that are unnecessary or problematic and I've been slowly working towards reducing the usage of grackle_macros.h to ultimately remove these macros

@mabruzzo mabruzzo added the refactor internal reorganization or code simplification with no behavior changes label Sep 29, 2025
@mabruzzo mabruzzo force-pushed the ncc/cppify-update_UVbackground_rates branch from a21b42f to d5f6f6b Compare September 30, 2025 14:28
@mabruzzo mabruzzo changed the base branch from newchem-cpp to main October 9, 2025 16:53
@mabruzzo mabruzzo changed the base branch from main to newchem-cpp October 9, 2025 16:53
@@ -73,79 +67,79 @@ int update_UVbackground_rates(chemistry_data *my_chemistry,
index++;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just making a note for myself. It has always bugged me that we do this to find the index for the redshift interpolation. All the tables we support are evenly spaced in log(1+z). At bare minimum we should bisection.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Issue #488

@brittonsmith brittonsmith changed the base branch from newchem-cpp to main January 13, 2026 13:21
@brittonsmith brittonsmith changed the base branch from main to newchem-cpp January 13, 2026 13:22

@brittonsmith brittonsmith left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks perfectly fine. I wish I understood the test failure.

@brittonsmith

Copy link
Copy Markdown
Contributor

Ok, I've looked at this. This happens for a constant density cooling model where we reach an equilibrium temperature and the cooling time becomes very long. The temperature itself is basically unchanged.
temperature
cooling_time

The bottom line is I interpret this as some sort of roundoff error behavior change and I think we can merge and move on.

@brittonsmith brittonsmith merged commit 4454194 into grackle-project:newchem-cpp Jan 13, 2026
4 of 5 checks passed
@mabruzzo mabruzzo deleted the ncc/cppify-update_UVbackground_rates branch January 13, 2026 17:18
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