Skip to content

Smooth-gate transport-species screening for trace species - #144

Open
djkees wants to merge 1 commit into
nasa:mainfrom
djkees:up/transport-species-smooth-gate
Open

djkees wants to merge 1 commit into
nasa:mainfrom
djkees:up/transport-species-smooth-gate

Conversation

@djkees

@djkees djkees commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Transport-species screening in compute_transport_properties used a hardcoded, always-hard-zero cutoff to decide whether to revive a trace gas species for the transport-species list, ignoring smooth_truncation entirely and drifting out of sync with a custom trace value. This replaces it with the same tsize/esize threshold and compute_nj_effective smooth gate used everywhere else in the solve.

djkees#11

Changes

  • source/equilibrium.f90: replaced the hardcoded transport_log_cutoff = 25.328436d0 constant and its hard nj(i) <= 0.0d0 step check with gas_amount_ln_threshold (ion-aware, using tsize/esize) and compute_nj_effective (respects smooth_truncation/truncation_width), matching the pattern used at every other activity-threshold check in this file. Added a comment noting why this loop rarely has anything to revive in the common converged path (species are already screened by the far more permissive log_min floor before this loop runs) and when it actually matters (the singular-matrix fallback path, or a future tighter/configurable reporting floor).
  • source/equilibrium_test.pf: strengthened the existing test_equilibrium_transport_ch4_o2_smooth_truncation stub with transport-property assertions; added test_equilibrium_transport_ionized_smooth_truncation (ions + transport + smooth_truncation together, not otherwise covered); added test_transport_screening_smooth_gate_at_threshold, which isolates the changed loop directly by calling compute_transport_properties twice on the same converged solution with one species pinned exactly at its activity threshold — once with smooth_truncation off, once on.

Testing

  • cmake --build build-dev --target cea_core_test -j4 && ./build-dev/source/cea_core_test.exe — full 124-test suite (122 pre-existing + 2 new) passes.
  • Verified test_transport_screening_smooth_gate_at_threshold actually isolates this change: temporarily reverted just equilibrium.f90 (keeping the new test) and reran — that one test failed as expected (equilibrium_test.pf:4184, the smooth-mode revival assertion), with every other test still passing. Restored the fix and reconfirmed all 124 pass.
  • Ran the same CH4/O2 and ionized Li/F2 chamber-state cases end-to-end with smooth_truncation on vs. off through the Python bindings: converged results agree to 1e-8–1e-16 relative (ordinary solve-path noise, not a discrepancy), with a ~4-45% per-solve timing overhead for smooth mode depending on mixture size, consistent with it being an opt-in, numerically-smoother reformulation rather than a different physical model.

Compatibility / Numerical behavior

  • No expected changes to numerical results
  • Expected changes (explain and provide validation)

For default settings (no custom trace, smooth_truncation off), behavior is unchanged: tsize equals the old hardcoded constant's value by coincidence at convergence, and the full pre-existing test suite (including several exact-reference-value regression tests) passes unmodified. Real behavior changes are scoped to: (1) a custom trace value, which the old code silently ignored for this one loop; (2) ionized mixtures, which now get the same looser esize threshold used everywhere else instead of a flat cutoff; (3) smooth_truncation=True runs, where deep-trace species (near the log_min reporting floor) are now revived to a small nonzero amount instead of an exact hard zero — validated directly by the new isolated test, and shown not to meaningfully affect aggregate transport properties in two realistic end-to-end cases.


Drafted with Claude's assistance.

  • The root cause (a hardcoded constant that happens to equal the default xsize, and a smooth_truncation flag ignored entirely by this one loop) was found by direct reading of equilibrium.f90 and tracing where eq_soln%nj is populated before this loop runs (compute_reported_nj / log_min), not taken from the issue text alone.
  • Numerical claims were independently verified: full existing test suite reruns, an isolated Fortran-level test that was checked to fail against the pre-fix code and pass against the fix, and end-to-end Python-binding comparisons (CH4/O2 and ionized Li/F2 cases) with on/off timing and per-species nj diffs, not just aggregate outputs.

Suggested changelog entry (for CHANGELOG.md, left to the maintainer to place)

Fixed

  • Transport-species screening in compute_transport_properties now uses the same tsize/esize activity threshold and smooth_truncation gate as the rest of the equilibrium solve, instead of a hardcoded cutoff that only coincidentally matched the default trace setting and always applied a hard zero/nonzero step. Results are unchanged for default settings; a custom trace value or ionized mixtures may now include slightly different trace species in transport-property output, and smooth_truncation=True runs revive trace species continuously instead of via a step.

Replaces the hardcoded transport-species revival cutoff in
compute_transport_properties with the same tsize/esize threshold and
smooth_truncation gate used elsewhere in the solve, so it stays
consistent (and correct under a custom trace value) whether or not
smooth_truncation is enabled.

(cherry picked from commit 7202b68)

This branch has not been deployed

No deployments
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.

1 participant