diff --git a/doc/sphinx/cython/kinetics.rst b/doc/sphinx/cython/kinetics.rst index ffffe4a48..46632c4f3 100644 --- a/doc/sphinx/cython/kinetics.rst +++ b/doc/sphinx/cython/kinetics.rst @@ -11,28 +11,28 @@ Reactions These classes contain the definition of a single reaction and its associated rate expression, indepenent of a specific `Kinetics` object. -.. autoclass:: Reaction +.. autoclass:: Reaction(reactants='', products='') :no-undoc-members: -.. autoclass:: ElementaryReaction +.. autoclass:: ElementaryReaction(reactants='', products='') :no-undoc-members: -.. autoclass:: ThirdBodyReaction +.. autoclass:: ThirdBodyReaction(reactants='', products='') :no-undoc-members: -.. autoclass:: FalloffReaction +.. autoclass:: FalloffReaction(reactants='', products='') :no-undoc-members: -.. autoclass:: ChemicallyActivatedReaction +.. autoclass:: ChemicallyActivatedReaction(reactants='', products='') :no-undoc-members: -.. autoclass:: PlogReaction +.. autoclass:: PlogReaction(reactants='', products='') :no-undoc-members: -.. autoclass:: ChebyshevReaction +.. autoclass:: ChebyshevReaction(reactants='', products='') :no-undoc-members: -.. autoclass:: InterfaceReaction +.. autoclass:: InterfaceReaction(reactants='', products='') :no-undoc-members: Auxilliary Reaction Data diff --git a/interfaces/cython/cantera/reaction.pyx b/interfaces/cython/cantera/reaction.pyx index 0e3451c25..5a262b04c 100644 --- a/interfaces/cython/cantera/reaction.pyx +++ b/interfaces/cython/cantera/reaction.pyx @@ -17,6 +17,11 @@ cdef class Reaction: A class which stores data about a reaction and its rate parameterization so that it can be added to a `Kinetics` object. + :param reactants: + Value used to set `reactants` + :param products: + Value used to set `products` + The static methods `listFromFile`, `listFromCti`, and `listFromXml` can be used to create lists of `Reaction` objects from existing definitions in the CTI or XML format. All of the following will produce a list of the 325 @@ -40,10 +45,14 @@ cdef class Reaction: """ reaction_type = 0 - def __cinit__(self, *args, init=True, **kwargs): + def __cinit__(self, reactants='', products='', init=True, **kwargs): if init: self._reaction.reset(newReaction(self.reaction_type)) self.reaction = self._reaction.get() + if reactants: + self.reactants = reactants + if products: + self.products = products cdef _assign(self, shared_ptr[CxxReaction] other): self._reaction = other diff --git a/interfaces/cython/cantera/test/test_kinetics.py b/interfaces/cython/cantera/test/test_kinetics.py index c4a830069..164527a02 100644 --- a/interfaces/cython/cantera/test/test_kinetics.py +++ b/interfaces/cython/cantera/test/test_kinetics.py @@ -645,9 +645,7 @@ class TestReaction(utilities.CanteraTest): self.assertEqual(eq1, eq2) def test_elementary(self): - r = ct.ElementaryReaction() - r.reactants = {'O':1, 'H2':1} - r.products = {'H':1, 'OH':1} + r = ct.ElementaryReaction({'O':1, 'H2':1}, {'H':1, 'OH':1}) r.rate = ct.Arrhenius(3.87e1, 2.7, 6260*1000*4.184) gas2 = ct.Solution(thermo='IdealGas', kinetics='GasKinetics', @@ -676,9 +674,7 @@ class TestReaction(utilities.CanteraTest): self.gas.net_rates_of_progress[1]) def test_falloff(self): - r = ct.FalloffReaction() - r.reactants = 'OH:2' - r.products = 'H2O2:1' + r = ct.FalloffReaction('OH:2', 'H2O2:1') r.high_rate = ct.Arrhenius(7.4e10, -0.37, 0.0) r.low_rate = ct.Arrhenius(2.3e12, -0.9, -1700*1000*4.184) r.falloff = ct.TroeFalloff((0.7346, 94, 1756, 5182))