[newchem-cpp] light refactoring of solve_rate_cool#377
Merged
brittonsmith merged 36 commits intoAug 27, 2025
Merged
Conversation
The idea is for this struct to aggregate as many arguments for the time derivative as possible. This initial series of patches focuses on aggregating the non-evolved fields
The idea is to collect args that are forwarded to the time-derivative calculation and are effectively frozen between various calls I also converted some of the arguments passed into lookup_cool_rates0d to read from this pack of args. But, I haven't done it for the really large structs (e.g. my_chemistry). I think those will be easier to change later
…s0d from a struct Great effort was made to maintain consistency with historical behavior. Potential issues and ideas for refactoring were highlighted in comments
…ssed to lookup_cool_rate1d
…onsistency that needs to be addressed in the future
The idea is to reduce the number of arguments that we manually pass through
…re no longer needed)
…o gen2024transcribe/step_rate_newton_raphson-cleanup-1of2
…phson-cleanup-1of2
…phson-cleanup-1of2
…' into gen2024transcribe/solve_rate_cool-refactor
brittonsmith
approved these changes
Aug 27, 2025
brittonsmith
left a comment
Contributor
There was a problem hiding this comment.
I like this refactor. The logic of the itmasks and the use of a temp itmask always bothered me.
Comment on lines
+143
to
+144
| itmask_gs[i] = (!is_hi_dens) ? MASK_TRUE : MASK_FALSE; | ||
| itmask_nr[i] = (is_hi_dens) ? MASK_TRUE : MASK_FALSE; |
Contributor
There was a problem hiding this comment.
This is a borderline trivial comment, but would it make sense to make it clear that boolean-wise, itmask_gs should explicitly have the opposite value to itmask_nr? Doing a one-line statement like this that sets one itmask on the other may end up looking a bit clunky, so this might be the simplest after all.
| has_nr_coevolve_eint_prereqs && (ddom[i] > 1.e7) && (tgas[i] > 1650.0) | ||
| ); | ||
| // we don't care about imp_eng[i] where itmask_nr[i] == MASK_FALSE | ||
| imp_eng[i] = (nr_coevolve_energy) ? 1 : 0; |
Contributor
There was a problem hiding this comment.
Maybe this is in your stated plans and I missed it, but can we rename this variable? I've never liked it as it explains nothing about what its purpose is.
Collaborator
Author
There was a problem hiding this comment.
use nr_coevolve_energy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
originally proposed as brittonsmith#42
This PR must be reviewed after #375 is merged
This did a little bit of cleanup in
solve_rate_cool_g. I telegraphed in some comments a while back that I wanted to improve the mask behavior to make it a little more logical. We introduceitmask_gs, to replace the practice of temporarily overwritingitmaskand then reverting it later. I think the resulting code is a lot more logical.While I was doing this, I realized that I could slightly refactor the logic where we set the values of
itmask_gsanditmask_nr. This is more concise and I think the logic is a little more clean