Skip to content

[newchem-cpp] query inj path names#479

Open
mabruzzo wants to merge 200 commits intograckle-project:newchem-cppfrom
mabruzzo:ncc/query_inj_path_names
Open

[newchem-cpp] query inj path names#479
mabruzzo wants to merge 200 commits intograckle-project:newchem-cppfrom
mabruzzo:ncc/query_inj_path_names

Conversation

@mabruzzo
Copy link
Collaborator

@mabruzzo mabruzzo commented Jan 1, 2026

This should be reviewed after PR #478 has been reviewed and merged


The size of the PR grew a little more than I initially anticipated.

Overview

This PR exposes information about the injection-pathway data to users through injection pathway information. Specifically users can query:

  • "inject_model_names" to get the list of strings naming each injection pathway (in the order that is internally assumed)
  • "inject_path_gas_yield_frac.C", "inject_path_gas_yield_frac.O", "inject_path_gas_yield_frac.Mg", ... to get yields for each metal nuclide that is initially in the gas-phase. For concreteness, let's consider the array associated with "inject_path_gas_yield_frac.C". Element i of that array holds the fraction of all injected non-primordial material corresponding to Carbon nuclides in the gas phase molecules.
  • "inject_path_grain_yield_frac.MgSiO3_dust", "inject_path_grain_yield_frac.AC_dust", ... to get yields for each relevant grain species. For concreteness, let's consider the array associated with "inject_path_grain_yield_frac.AC_dust". Element i of that array holds the fraction of all injected non-primordial material initially corresponding to amorphous carbon dust.

All other changes are effectively consequences

C++ Testing

I needed to update a bunch of the C++ tests to make sure that they worked properly since "inject_model_names" is the very first queryable-key that corresponds to an array of strings.

I also added a handful of tests to explicitly test queries of these new keys. Some examples include:

  • testing that all of these arrays have the same length
  • checking that all yields have a value $ 0 \leq x \leq 1$
  • that the sum of all yields is less than or approximately equal to 1 (this is performed separately for different injection pathways)

I did a little refactoring to try to make this all work nicely

gracklepy changes

I updated FluidContainer (and the supporting functions) to explicitly query the list of injection pathways from Grackle, rather than hardcoding the names of all of the injection pathways

  • this isn't a significant change, but I very much consider this to be a sign of things to come (i.e. reducing duplication of logic between the core library and the gracklepy layer)

I also added some experimental methods to access the yields from gracklepy. I don't think these are necessarily optimal, but I think its a useful short-term solution. Eventually (but not in this PR), we probably want to reuse this information to improve tests of multi-grain-species dust model so that it appropriately uses this information

pytest changes

I added a simple check of the new gracklepy changes (I think it will be a useful diagnostic tool if we make changes and forget to fully propagate the changes throughout the gracklepy)

The payoff

A major payoff to all of this effort is actually coming in the next PR.

There is some unforunate consequences, but if we don't do this you end
up with some pretty confusing looking code... (the confusion primarily
arises if new_FrozenKeyIdxBiMap or drop_FrozenKeyIdxBiMap has different
behavior from other functions with similar names). I really think it
would be better to make this into a simple C++ class with a constructor
and destructor, but thats a topic for another time
There's still a lot of work to be done (the type is incomplete and isn't
filled by anything at all)
We don't yet use the new format, but we are just about ready to start
doing so
@mabruzzo mabruzzo force-pushed the ncc/query_inj_path_names branch from c35f246 to 6b69e77 Compare January 1, 2026 23:15
@mabruzzo mabruzzo changed the title Ncc/query inj path names [newchem-cpp] query inj path names Jan 4, 2026
Also made a few assorted fixes
Both changes essentially affected 2 constants, which prior to this
commit were known as `keylen_max` & `invalid_val`.

The 2 contained constants are really just implementation details that
users of the inferface for `FrozenKeyIdxBiMap` shouldn't need to know
anything about
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

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant