Skip to content

JICF cleanup: remove MIB dead code and mesh dependence (#98, #99)#106

Open
jjhans wants to merge 2 commits into
95-generalize-and-improve-jicf-modelfrom
jicf-cleanup-deadcode-and-mesh
Open

JICF cleanup: remove MIB dead code and mesh dependence (#98, #99)#106
jjhans wants to merge 2 commits into
95-generalize-and-improve-jicf-modelfrom
jicf-cleanup-deadcode-and-mesh

Conversation

@jjhans

@jjhans jjhans commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Cleanup work under the JICF umbrella (#95), covering two sub-issues.

#99 — Remove unused mixed-is-burned (MIB) model

The MIB progress-variable / chemical-energy profiles were computed and stored but never used at runtime. Removed JICModel.calc_MIB_profile, C_E_CHEM_avg_MIB, FuelInjector.get_MIB_profiles, the load_MIB_profile flag and its handling, and the corresponding example arguments (~118 lines).

#98 — Remove mesh dependence of Z profiles; consolidate to HDF5

  • Store the generation mesh with Z_avg_profile / Z_var_profile and build the interpolators on that stored mesh (with linear extrapolation for out-of-range query points such as ghost cells), decoupling the model from the simulation grid — no more full regeneration when the mesh changes.
  • Replace the collection of per-array .npy cache files and the three load_* boolean flags with a single HDF5 file (jicf_model.h5), auto-detecting cached groups (Z_3D, Z_profiles, chemical_sources) and computing any that are missing. Examples pass datadir instead of the removed flags.

Verification

  • ruff + py_compile clean; the jicf package imports fine.
  • Mechanism test: querying the profile interpolator on a different (206-pt, extended) mesh now returns finite values instead of the previous 200-vs-206 shape-mismatch crash; the HDF5 write/detect/read round-trips.

Not included (separate blocker)

Full end-to-end verification of the HyShot FPV run is still blocked by the injector-origin divide-by-zero in profile.py (AnalyticJICF), which poisons Z_3D with NaN — see #105. That lives in the analytic model (arguably #104 territory), not this mesh/HDF5 cleanup.

Note: examples/04_jicf_heat_release_profile has a pre-existing JICModel signature mismatch (passes fuel=, omits phi_inj) unrelated to this PR.

Relates to #95, #98, #99.

jjhans added 2 commits July 2, 2026 18:18
The MIB progress-variable / chemical-energy profiles were computed and
stored but never used at runtime. Removes the dead code:

- JICModel.calc_MIB_profile and C_E_CHEM_avg_MIB (generate.py)
- the load_MIB_profile flag and its __init__ handling
- FuelInjector.get_MIB_profiles (source.py)
- the corresponding load_MIB_profile arguments in the HyShot II and
  04_jicf_heat_release_profile examples
The Z_avg/Z_var profiles were generated on the simulation mesh and their
interpolators rebuilt against `self.xc`, forcing a full regeneration
whenever the mesh changed. Now the generation mesh is stored with the
profiles and the interpolators are built on that stored mesh (with linear
extrapolation for out-of-range query points such as ghost cells), so the
model is decoupled from the simulation grid.

Also replaces the collection of per-array `.npy` cache files and the three
`load_*` boolean flags with a single HDF5 file (`jicf_model.h5`). Cached
tables are auto-detected per group (Z_3D, Z_profiles, chemical_sources)
and any missing tables are computed and written. Examples updated to pass
`datadir` instead of the removed load flags.
@jjhans jjhans force-pushed the jicf-cleanup-deadcode-and-mesh branch from 7bd1cd6 to c529835 Compare July 3, 2026 01:20

@TimothyEDawson TimothyEDawson left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks great, thank you! Just two minor adjustments and then I'd be happy to merge it in.

if self.xc[i] > self.x_noz:
# Record the mesh the profiles are generated on so the interpolators can
# be rebuilt independently of the simulation mesh.
self.x_profile = np.asarray(self.xc, dtype=float)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This works, but it would also be nice to have some control over what mesh is being used. We could even use the stretched grid already present in self.x_3D_data. Can you try that?

self.alpha = alpha if alpha is not None else 1e6
self.datadir = Path(datadir)
self.datadir.mkdir(exist_ok=True)
self.model_file = (

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Defaulting to None and using this sort of ternary logic is a good pattern, but in this case we now have an unused datadir which can point to a different location than the model_file. Instead, let's make the model_file input a str with default value of "jicf_model.h5", then on this line make self.model_file = self.datadir / model_file.

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.

2 participants