Skip to content

Improve input parsing backwards-compatibility#48

Merged
markleader merged 3 commits intonasa:mainfrom
markleader:fix/input-enthalpy
Feb 27, 2026
Merged

Improve input parsing backwards-compatibility#48
markleader merged 3 commits intonasa:mainfrom
markleader:fix/input-enthalpy

Conversation

@markleader
Copy link
Copy Markdown
Contributor

Summary

Improve reac input compatibility with legacy CEA2 behavior, fix #25 so that user-provided reactant enthalpy overrides so they are honored at runtime.

Changes

  • source/input.f90

    • Hardened read_input/read_problem flow to avoid EOF/trailing-line parsing crash.
    • Switched read_problem to subroutine-style output and adjusted read_input handling accordingly.
    • Replaced overlapping problems = problems(1:n-1) shrink with allocate/copy/move_alloc.
    • Expanded reac parsing compatibility:
      • case-insensitive token handling for reactant keywords and amount tokens,
      • den... density alias support in addition to rho...,
      • default density units to g/cc when omitted,
      • molecular-weight token support (wt/mol, wt/mole, molwt, mwt, mw) with unit conversion/validation,
      • exploded formula parsing with implicit coefficient 1.0,
      • allow omitted amounts for name reactants,
      • reject mixed mole/weight amount bases in one reac dataset.
    • Fixed formula-token precedence so element tokens (e.g., H, O) are not misclassified as enthalpy tokens.
  • source/main.f90

    • Added apply_reactant_thermo_overrides and applied it after reactant mixture creation in all relevant execution paths.
    • Ensures user-provided reactant enthalpy input (h,...) overrides thermo-fit reference values, including for database species.
    • Fixed per-reactant temperature indexing bug in compute_reactant_enthalpy (prob%reactants(i) instead of always index 1).
    • Added defensive defaulting in named-reactant weight assembly when amounts are missing (equal basis with warning).
  • source/input_test.pf

    • Added parser regressions for:
      • custom reactant formula + enthalpy + molecular weight,
      • molecular-weight aliases,
      • missing named-reactant amount,
      • density alias/default density units,
      • implicit formula coefficients,
      • case-insensitive reac keywords/tokens.

Testing

  • ctest -R cea_core_test -V
  • python test_main.py

Compatibility / Numerical behavior

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

Expected numerical/output changes are limited to inputs that explicitly rely on new/changed behavior:

  • cases with user-specified reactant enthalpy overrides now honor that input (instead of being overwritten by thermo fits),
  • cases with previously invalid/ambiguous reac forms (e.g., missing named-reactant amounts, den alias, molecular-weight aliases, implicit formula coefficients, case variants) now parse/behave in a CEA2-compatible way.

@markleader markleader merged commit 3bbe516 into nasa:main Feb 27, 2026
23 checks passed
@markleader markleader deleted the fix/input-enthalpy branch February 27, 2026 21:41
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.

[bug] Custom reactant enthalpy is overwritten

1 participant