diff --git a/interfaces/cython/cantera/reaction.pyx b/interfaces/cython/cantera/reaction.pyx index 0cb527aa6..23d61bc26 100644 --- a/interfaces/cython/cantera/reaction.pyx +++ b/interfaces/cython/cantera/reaction.pyx @@ -297,6 +297,18 @@ cdef class ElementaryReaction(Reaction): cdef CxxElementaryReaction* r = self.reaction r.rate = deref(rate.rate) + property allow_negative_pre_exponential_factor: + """ + Get/Set whether the rate coefficient is allowed to have a negative + pre-exponential factor. + """ + def __get__(self): + cdef CxxElementaryReaction* r = self.reaction + return r.allow_negative_pre_exponential_factor + def __set__(self, allow): + cdef CxxElementaryReaction* r = self.reaction + r.allow_negative_pre_exponential_factor = allow + cdef class ThirdBodyReaction(ElementaryReaction): """ diff --git a/interfaces/cython/cantera/test/test_kinetics.py b/interfaces/cython/cantera/test/test_kinetics.py index 80d66dccd..560553c3a 100644 --- a/interfaces/cython/cantera/test/test_kinetics.py +++ b/interfaces/cython/cantera/test/test_kinetics.py @@ -657,6 +657,22 @@ class TestReaction(utilities.CanteraTest): self.assertNear(gas2.net_rates_of_progress[0], self.gas.net_rates_of_progress[2]) + def test_negative_A(self): + species = ct.Species.listFromFile('gri30.cti') + r = ct.ElementaryReaction('NH:1, NO:1', 'N2O:1, H:1') + r.rate = ct.Arrhenius(-2.16e13, -0.23, 0) + + self.assertFalse(r.allow_negative_pre_exponential_factor) + + with self.assertRaises(Exception): + gas = ct.Solution(thermo='IdealGas', kinetics='GasKinetics', + species=species, reactions=[r]) + + r.allow_negative_pre_exponential_factor = True + gas = ct.Solution(thermo='IdealGas', kinetics='GasKinetics', + species=species, reactions=[r]) + + def test_thirdbody(self): r = ct.ThirdBodyReaction() r.reactants = {'O':1, 'H':1}