Skip to content

Commit

Permalink
[test] Add testing reaction orders import from cti
Browse files Browse the repository at this point in the history
  • Loading branch information
imitrichev committed Feb 26, 2016
1 parent b4c5ade commit aa83001
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
7 changes: 3 additions & 4 deletions interfaces/cython/cantera/ctml_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1138,11 +1138,10 @@ def __init__(self,
if self._order:
order = getPairs(self._order)
for o in order.keys():
if o in self._rxnorder:
self._rxnorder[o] = order[o]
if o not in self._rxnorder and 'nonreactant_orders' not in self._options:
raise CTI_Error("order specified for non-reactant: "+o+" and no \'nonreactant_orders\' option given")
else:
if 'nonreactant_orders' not in self._options:
raise CTI_Error("order specified for non-reactant: "+o)
self._rxnorder[o] = order[o]

self._kf = kf
self._igspecies = []
Expand Down
10 changes: 10 additions & 0 deletions interfaces/cython/cantera/test/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,13 @@ def test_noninteger_atomicity(self):
gas = ct.Solution('../data/noninteger-atomicity.cti')
self.assertNear(gas.molecular_weights[gas.species_index('CnHm')],
10.65*gas.atomic_weight('C') + 21.8*gas.atomic_weight('H'))

def test_reaction_orders(self):
gas = ct.Solution('../data/non-reactant-species.cti')
R=gas.reaction(0)
allow=R.allow_nonreactant_orders
self.assertEqual(allow, True)
self.assertNear(R.orders.get('OH'), 0.15)
allow=R.allow_negative_orders
self.assertEqual(allow, True)
self.assertNear(R.orders.get('H2'), -0.25)
23 changes: 23 additions & 0 deletions test/data/reaction-orders.cti
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Input file to test use of non-reactant species

units(length = "cm", time = "s", quantity = "mol", act_energy = "kJ/mol")

ideal_gas(name = "gas",
elements = " O H ",
species = """gri30: H2 O2 H2O OH """,
reactions = "all",
initial_state = state(temperature = 300.0,
pressure = OneAtm) )

#-------------------------------------------------------------------------------
# Reactions data
#-------------------------------------------------------------------------------

#test negative orders and non-reactant orders
reaction("2 H2 + O2 => 2 H2O", [1e13, 0.0, 0.0],
order="H2:-0.25 OH:0.15",
options=['negative_orders', 'nonreactant_orders'])

#if uncomment, should throw an error
#reaction("2 H2 + O2 => 2 H2O", [1e13, 0.0, 0.0],
# order="OH:0.15")

0 comments on commit aa83001

Please sign in to comment.