Add enthalpy_units optional argument to Reactant in Python API#66
Merged
markleader merged 2 commits intonasa:mainfrom Mar 23, 2026
Merged
Add enthalpy_units optional argument to Reactant in Python API#66markleader merged 2 commits intonasa:mainfrom
enthalpy_units optional argument to Reactant in Python API#66markleader merged 2 commits intonasa:mainfrom
Conversation
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.
Summary
Add explicit
enthalpy_unitssupport to the Pythoncea.ReactantAPI with a backward-compatible transition path.Current implicit behavior is preserved for now (
enthalpydefaults toJ/kg), but omission now emits a deprecation-styleFutureWarningand documentation/examples are updated to use explicit units. Thanks to @minh-dng for flagging the issue. Partial fix for #65.Changes
Python API (
source/bind/python/CEA.pyx)enthalpy_unitsargument toReactant(...).J/kg,kJ/kg,cal/kg,kcal/kgJ/mol,kJ/mol,cal/mol,kcal/mol/moland/molespellings accepted and normalized.enthalpyis provided andenthalpy_unitsis omitted:J/kg)FutureWarningrecommending explicitenthalpy_units.*/kg).Mixturereactant bridging logic to use per-reactant enthalpy units and conversion path:*/mole).Docs and examples
docs/source/interfaces/python_api.rstdocs/source/examples/equilibrium/example5.rstsource/bind/python/cea/samples/rp1311/example5.pyenthalpy_units.Tests (
source/bind/python/tests/test_rp1311_samples.py)enthalpy_units.enthalpy_unitswarning + behavior preservationTesting
ctest -R cea_core_test -Vpython -m pytestCompatibility / Numerical behavior
Expected behavior changes are API-facing (validation/warnings):
FutureWarningwhenReactant.enthalpyis given withoutenthalpy_units.ValueErrorwhen weight-based enthalpy units are used withoutmolecular_weight.J/kg).