Skip to content

Commit

Permalink
[Python] Expose rate coefficient and standard concentration units
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Jul 17, 2021
1 parent 94733b1 commit 735990b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions interfaces/cython/cantera/_cantera.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions interfaces/cython/cantera/reaction.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
6 changes: 6 additions & 0 deletions interfaces/cython/cantera/thermo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit 735990b

Please sign in to comment.