diff --git a/interfaces/cython/cantera/_cantera.pxd b/interfaces/cython/cantera/_cantera.pxd index a2ef26092..13368b452 100644 --- a/interfaces/cython/cantera/_cantera.pxd +++ b/interfaces/cython/cantera/_cantera.pxd @@ -1,6 +1,7 @@ from libcpp.vector cimport vector from libcpp.string cimport string from libcpp.map cimport map as stdmap +from libcpp.pair cimport pair from libcpp cimport bool as cbool from cpython cimport bool as pybool @@ -253,6 +254,12 @@ cdef extern from "cantera/kinetics/Reaction.h" namespace "Cantera": CxxThirdBody third_body shared_ptr[CxxFalloff] falloff + cdef cppclass CxxPlog "Cantera::Plog": + vector[pair[double,CxxArrhenius]] rates() + + cdef cppclass CxxPlogReaction "Cantera::PlogReaction" (CxxReaction): + CxxPlog rate + 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 947397a18..709d0fa97 100644 --- a/interfaces/cython/cantera/reaction.pyx +++ b/interfaces/cython/cantera/reaction.pyx @@ -68,9 +68,9 @@ cdef class Reaction: cdef class Arrhenius: - def __cinit__(self, init=True): + def __cinit__(self, A=0, b=0, E=0, init=True): if init: - self.rate = new CxxArrhenius() + self.rate = new CxxArrhenius(A, b, E) self.reaction = None def __dealloc__(self): @@ -96,6 +96,11 @@ cdef wrapArrhenius(CxxArrhenius* rate, Reaction reaction): r.reaction = reaction return r +cdef copyArrhenius(CxxArrhenius* rate): + r = Arrhenius(rate.preExponentialFactor(), rate.temperatureExponent(), + rate.activationEnergy_R()) + return r + cdef class ElementaryReaction(Reaction): property rate: @@ -183,6 +188,17 @@ cdef class ChemicallyActivatedReaction(FalloffReaction): pass +cdef class PlogReaction(Reaction): + property rates: + def __get__(self): + cdef CxxPlogReaction* r = self.reaction + rates = [] + cdef vector[pair[double,CxxArrhenius]] cxxrates = r.rate.rates() + cdef pair[double,CxxArrhenius] p_rate + for p_rate in cxxrates: + rates.append((p_rate.first,copyArrhenius(&p_rate.second))) + return rates + cdef Reaction wrapReaction(shared_ptr[CxxReaction] reaction): """ Wrap a C++ Reaction object with a Python object of the correct derived type. @@ -197,6 +213,8 @@ cdef Reaction wrapReaction(shared_ptr[CxxReaction] reaction): R = FalloffReaction(init=False) elif reaction_type == CHEMACT_RXN: R = ChemicallyActivatedReaction(init=False) + elif reaction_type == PLOG_RXN: + R = PlogReaction(init=False) else: R = Reaction(init=False)