Skip to content

[newchem-cpp] transcribe step_rate_g#425

Merged
brittonsmith merged 12 commits into
grackle-project:newchem-cppfrom
mabruzzo:ncc/transcribe_step_rate_gauss_seidel
Dec 17, 2025
Merged

[newchem-cpp] transcribe step_rate_g#425
brittonsmith merged 12 commits into
grackle-project:newchem-cppfrom
mabruzzo:ncc/transcribe_step_rate_gauss_seidel

Conversation

@mabruzzo

@mabruzzo mabruzzo commented Sep 14, 2025

Copy link
Copy Markdown
Collaborator

This PR should not be reviewed until after PR #416 has been merged


This PR attempts to transcribe step_rate_g

The transcribed function is called step_rate_gauss_seidel to mirror the naming convention of step_rate_newton_raphson.

The last 2 commits of this PR split the logic of step_rate_gauss_seidel between 2 helper functions (which are called by step_rate_gauss_seidel). These helper functions are named:

  1. grackle::impl::chemistry::species_density_updates_gauss_seidel (not touched in this PR)
    • this contains all of the logic for computing the evolved species densities.
    • this lives in the chemistry_solver_funcs.hpp file (alongside the grackle::impl::chemistry::species_density_derivatives_0d function)
    • logic in this function is similar enough to grackle::impl::chemistry::species_density_derivatives_0d (called by the newton-raphson solver) that we eventually want to refactor both functions so that the logic is shared (IMPORTANTLY, the logic in these functions should not evolve independently)
    • aside: clang-format was previously disabled for this file to make it easier for us to refactor this function in the future.
  2. grackle::impl::update_fields_from_tmpdens_gauss_seidel

Aside: while clang-format is temporarily disabled for the step_rate_gauss_seidel.hpp file in this PR, it is enabled by PR #434.

I don't think the act of splitting the transcribed logic between functions will make things any harder to review. But, let me know if you would prefer that I split those 2 commits into 2 PRs.

@mabruzzo mabruzzo added the refactor internal reorganization or code simplification with no behavior changes label Sep 14, 2025
The transcribed function is called step_rate_gauss_seidel to mirror the
naming convention of `step_rate_newton_raphson`.

I explicitly disabled clang-format to make it easier for us to factor
out common logic that is shared with `species_density_derivatives_0d`
- In slightly more detail, the logic is similar enough that we could
  definitely factor out a lot of common logic.
- The important thing is that we don't want the logic in each function
  to evolve independently
@mabruzzo mabruzzo force-pushed the ncc/transcribe_step_rate_gauss_seidel branch from 7ba4dbc to 586a480 Compare October 2, 2025 14:26
@mabruzzo mabruzzo changed the title [newchem-cpp] WIP: transcribe step_rate_g [newchem-cpp] transcribe step_rate_g Oct 2, 2025
@mabruzzo mabruzzo marked this pull request as ready for review October 2, 2025 14:34
@brittonsmith brittonsmith changed the base branch from newchem-cpp to main November 18, 2025 11:21
@brittonsmith brittonsmith changed the base branch from main to newchem-cpp November 18, 2025 11:21
@brittonsmith

Copy link
Copy Markdown
Contributor

@mabruzzo, just a heads-up. It looks like there is a merger conflict here now. Note sure where that came from.

HII(i,j,k) = std::fmax((gr_float)(species_tmpdens.data[SpLUT::HII][i] ), tiny_fortran_val);
HeI(i,j,k) = std::fmax((gr_float)(species_tmpdens.data[SpLUT::HeI][i] ), tiny_fortran_val);
HeII(i,j,k) = std::fmax((gr_float)(species_tmpdens.data[SpLUT::HeII][i] ), tiny_fortran_val);
HeIII(i,j,k) = std::fmax((gr_float)(species_tmpdens.data[SpLUT::HeIII][i] ), (gr_float)(1e-5)*tiny_fortran_val);

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 bugs me that we do things like this. I think it would be better if we defined the minimum value any given species is allowed to have.

@brittonsmith

Copy link
Copy Markdown
Contributor

This looks great and is surprisingly easy to read. After looking through it, I would be open to not keeping the manual stepping for the primordial networks unless it really is a huge slowdown.

@brittonsmith brittonsmith merged commit 579f546 into grackle-project:newchem-cpp Dec 17, 2025
5 checks passed
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