From 735990bb69a4f25121c8fb1df43613666d4a63e9 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Sat, 17 Jul 2021 15:44:59 -0500 Subject: [PATCH] [Python] Expose rate coefficient and standard concentration units --- interfaces/cython/cantera/_cantera.pxd | 6 ++++++ interfaces/cython/cantera/reaction.pyx | 6 ++++++ interfaces/cython/cantera/thermo.pyx | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/interfaces/cython/cantera/_cantera.pxd b/interfaces/cython/cantera/_cantera.pxd index 4e45b527195..263379e4416 100644 --- a/interfaces/cython/cantera/_cantera.pxd +++ b/interfaces/cython/cantera/_cantera.pxd @@ -49,6 +49,10 @@ cdef extern from "cantera/base/xml.h" namespace "Cantera": XML_Node* findID(string) int nChildren() +cdef extern from "cantera/base/Units.h" namespace "Cantera": + cdef cppclass CxxUnits "Cantera::Units": + string str() + cdef extern from "cantera/base/AnyMap.h" namespace "Cantera": cdef cppclass CxxAnyValue "Cantera::AnyValue" @@ -207,6 +211,7 @@ cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera": size_t stateSize() void saveState(size_t, double*) except +translate_exception void restoreState(size_t, double*) except +translate_exception + CxxUnits standardConcentrationUnits() except +translate_exception # initialization void addUndefinedElements() except +translate_exception @@ -415,6 +420,7 @@ cdef extern from "cantera/kinetics/Reaction.h" namespace "Cantera": cbool allow_nonreactant_orders cbool allow_negative_orders cbool usesLegacy() + CxxUnits rate_units cdef cppclass CxxElementaryReaction2 "Cantera::ElementaryReaction2" (CxxReaction): CxxElementaryReaction2() diff --git a/interfaces/cython/cantera/reaction.pyx b/interfaces/cython/cantera/reaction.pyx index cd025c8587e..00bb8f3f6de 100644 --- a/interfaces/cython/cantera/reaction.pyx +++ b/interfaces/cython/cantera/reaction.pyx @@ -737,6 +737,12 @@ cdef class Reaction: def __get__(self): return self.reaction.usesLegacy() + property rate_coeff_units: + """Get string representation of reaction rate coefficient units""" + def __get__(self): + cdef CxxUnits rate_units = self.reaction.rate_units + return pystr(rate_units.str()) + cdef class Arrhenius: r""" diff --git a/interfaces/cython/cantera/thermo.pyx b/interfaces/cython/cantera/thermo.pyx index 26c9a0a2bb8..a90a6cc03b9 100644 --- a/interfaces/cython/cantera/thermo.pyx +++ b/interfaces/cython/cantera/thermo.pyx @@ -1570,6 +1570,12 @@ cdef class ThermoPhase(_SolutionBase): def __set__(self, double value): self.thermo.setElectricPotential(value) + property standard_concentration_units: + """Get standard concentration units for this phase.""" + def __get__(self): + cdef CxxUnits units = self.thermo.standardConcentrationUnits() + return pystr(units.str()) + cdef class InterfacePhase(ThermoPhase): """ A class representing a surface or edge phase"""