From de1884db71b85ee90947d582831797f1d314af51 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Sun, 26 Apr 2015 14:36:46 -0400 Subject: [PATCH] [Python] Add access to interface reactions --- interfaces/cython/cantera/_cantera.pxd | 10 +++++++ interfaces/cython/cantera/reaction.pyx | 36 ++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/interfaces/cython/cantera/_cantera.pxd b/interfaces/cython/cantera/_cantera.pxd index 086d7603e..f88224f64 100644 --- a/interfaces/cython/cantera/_cantera.pxd +++ b/interfaces/cython/cantera/_cantera.pxd @@ -272,6 +272,16 @@ cdef extern from "cantera/kinetics/Reaction.h" namespace "Cantera": cdef cppclass CxxChebyshevReaction "Cantera::ChebyshevReaction": CxxChebyshevRate rate + cdef cppclass CxxCoverageDependency "Cantera::CoverageDependency": + double a + double E + double m + + cdef cppclass CxxInterfaceReaction "Cantera::InterfaceReaction" (CxxElementaryReaction): + stdmap[string, CxxCoverageDependency] coverage_deps + cbool is_sticking_coefficient + string sticking_species + cdef extern from "cantera/kinetics/Kinetics.h" namespace "Cantera": cdef cppclass CxxKinetics "Cantera::Kinetics": diff --git a/interfaces/cython/cantera/reaction.pyx b/interfaces/cython/cantera/reaction.pyx index 299278ce4..50136b19b 100644 --- a/interfaces/cython/cantera/reaction.pyx +++ b/interfaces/cython/cantera/reaction.pyx @@ -238,6 +238,40 @@ cdef class ChebyshevReaction(Reaction): return c.reshape((r.rate.nTemperature(), r.rate.nPressure())) +cdef class CoverageDepenency: + cdef public double a + cdef public double m + cdef public double E + + def __init__(self, a, m, E): + self.a = a + self.m = m + self.E = E + + +cdef class InterfaceReaction(ElementaryReaction): + property coverage_deps: + def __get__(self): + cdef CxxInterfaceReaction* r = self.reaction + print('ncov:', r.coverage_deps.size()) + deps = {} + cdef pair[string,CxxCoverageDependency] item + for item in r.coverage_deps: + deps[pystr(item.first)] = CoverageDepenency( + item.second.a, item.second.m, item.second.E * gas_constant) + return deps + + property is_sticking_coefficient: + def __get__(self): + cdef CxxInterfaceReaction* r = self.reaction + return r.is_sticking_coefficient + + property sticking_species: + def __get__(self): + cdef CxxInterfaceReaction* r = self.reaction + return pystr(r.sticking_species) + + cdef Reaction wrapReaction(shared_ptr[CxxReaction] reaction): """ Wrap a C++ Reaction object with a Python object of the correct derived type. @@ -256,6 +290,8 @@ cdef Reaction wrapReaction(shared_ptr[CxxReaction] reaction): R = PlogReaction(init=False) elif reaction_type == CHEBYSHEV_RXN: R = ChebyshevReaction(init=False) + elif reaction_type == INTERFACE_RXN: + R = InterfaceReaction(init=False) else: R = Reaction(init=False)