Skip to content

added C and Python support for custom reactant data#53

Merged
markleader merged 5 commits intonasa:mainfrom
markleader:feat/custom-reactants
Mar 3, 2026
Merged

added C and Python support for custom reactant data#53
markleader merged 5 commits intonasa:mainfrom
markleader:feat/custom-reactants

Conversation

@markleader
Copy link
Contributor

Summary

Add custom-reactant support to the C and Python interfaces so RP-1311 Example 5 style workflows (including reactants not present in thermo.lib, e.g. CHOS-Binder) are available outside the legacy main interface, while keeping existing Mixture([...]) behavior backward compatible.

Changes

  • C API:
    • Added additive constructors in source/bind/c/cea.h:
      • cea_mixture_create_products_from_input_reactants(...)
      • cea_mixture_create_products_from_input_reactants_w_ions(...)
  • Fortran C shim (source/bind/c/bindc.F90):
    • Implemented the new product-constructor APIs.
    • Added shared parser helper for cea_reactant_input -> ReactantInput to remove duplicated parsing/validation logic.
  • Python bindings:
    • Extended source/bind/python/cea_def.pxd with cea_reactant_input and new function declarations.
    • Added cea.Reactant in source/bind/python/CEA.pyx.
    • Updated Mixture(...) to accept str, Reactant, and mixed lists.
    • Added dispatch to input-reactant creation paths (including product generation from input reactants).
    • Enforced SI-only Python Reactant inputs:
      • temperature in K
      • enthalpy in J/kg (converted internally for core input)
  • Examples:
    • Added C sample: source/bind/c/samples/rp1311_example5.c
    • Implemented Python sample: source/bind/python/cea/samples/rp1311/example5.py
    • Registered C sample in source/bind/c/CMakeLists.txt as cea_bindc_rp1311_ex5
  • Tests/docs:
    • Added RP-1311 example 5 Python regression coverage in source/bind/python/tests/test_rp1311_samples.py
    • Removed bytes-mixture test in source/bind/python/tests/test_strings.py (bytes inputs no longer supported)
    • Updated Python API docs in docs/source/interfaces/python_api.rst to document cea.Reactant and SI expectations.

Testing

  • Ran:
    • ctest -R cea_core_test -V
    • python -m pytest

Compatibility / Numerical behavior

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

@markleader markleader merged commit 4c1cb82 into nasa:main Mar 3, 2026
23 checks passed
@markleader markleader deleted the feat/custom-reactants branch March 3, 2026 20:56
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