[Python] Implement 'allow_negative_pre_exponential_factor' property

This commit is contained in:
Ray Speth 2015-05-11 16:26:32 -04:00
parent f5b2fc37df
commit 946b7abfc5
2 changed files with 28 additions and 0 deletions

View file

@ -297,6 +297,18 @@ cdef class ElementaryReaction(Reaction):
cdef CxxElementaryReaction* r = <CxxElementaryReaction*>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 = <CxxElementaryReaction*>self.reaction
return r.allow_negative_pre_exponential_factor
def __set__(self, allow):
cdef CxxElementaryReaction* r = <CxxElementaryReaction*>self.reaction
r.allow_negative_pre_exponential_factor = allow
cdef class ThirdBodyReaction(ElementaryReaction):
"""

View file

@ -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}