From 501b5fd1f52360464e55a047b92473ca0a89686d Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Sat, 2 Dec 2017 14:03:03 -0500 Subject: [PATCH] [test/ck2cti] Add tests for negative reaction orders --- .../cython/cantera/test/test_convert.py | 15 ++++ test/data/negative-order.cti | 86 +++++++++++++++++++ test/data/negative-order.inp | 26 ++++++ 3 files changed, 127 insertions(+) create mode 100644 test/data/negative-order.cti create mode 100644 test/data/negative-order.inp diff --git a/interfaces/cython/cantera/test/test_convert.py b/interfaces/cython/cantera/test/test_convert.py index 2b3c70c57..934545a94 100644 --- a/interfaces/cython/cantera/test/test_convert.py +++ b/interfaces/cython/cantera/test/test_convert.py @@ -262,6 +262,21 @@ class chemkinConverterTest(utilities.CanteraTest): 'explicit-forward-order.cti') self.checkKinetics(ref, gas, [300, 800, 1450, 2800], [5e3, 1e5, 2e6]) + def test_negative_order(self): + with self.assertRaises(ck2cti.InputParseError): + convertMech(pjoin(self.test_data_dir, 'negative-order.inp'), + thermoFile=pjoin(self.test_data_dir, 'dummy-thermo.dat'), + outName=pjoin(self.test_work_dir, 'negative-order.cti'), quiet=True) + + def test_negative_order_permissive(self): + convertMech(pjoin(self.test_data_dir, 'negative-order.inp'), + thermoFile=pjoin(self.test_data_dir, 'dummy-thermo.dat'), + outName=pjoin(self.test_work_dir, 'negative-order.cti'), + quiet=True, permissive=True) + ref, gas = self.checkConversion(pjoin(self.test_data_dir, 'explicit-forward-order.xml'), + 'explicit-forward-order.cti') + self.checkKinetics(ref, gas, [300, 800, 1450, 2800], [5e3, 1e5, 2e6]) + def test_reaction_units(self): convertMech(pjoin(self.test_data_dir, 'units-default.inp'), thermoFile=pjoin(self.test_data_dir, 'dummy-thermo.dat'), diff --git a/test/data/negative-order.cti b/test/data/negative-order.cti new file mode 100644 index 000000000..065ad1901 --- /dev/null +++ b/test/data/negative-order.cti @@ -0,0 +1,86 @@ +units(length='cm', time='s', quantity='mol', act_energy='cal/mol') + +ideal_gas(name='gas', + elements="H C Ar", + species="""H AR R1A R1B P1""", + reactions='all', + initial_state=state(temperature=300.0, pressure=OneAtm)) + +#------------------------------------------------------------------------------- +# Species data +#------------------------------------------------------------------------------- + +species(name='H', + atoms='H:1', + thermo=(NASA([200.00, 1000.00], + [ 2.50000000E+00, 7.05332819E-13, -1.99591964E-15, + 2.30081632E-18, -9.27732332E-22, 2.54736599E+04, + -4.46682853E-01]), + NASA([1000.00, 3500.00], + [ 2.50000001E+00, -2.30842973E-11, 1.61561948E-14, + -4.73515235E-18, 4.98197357E-22, 2.54736599E+04, + -4.46682914E-01]))) + +species(name='AR', + atoms='Ar:1', + thermo=(NASA([300.00, 1000.00], + [ 2.50000000E+00, 0.00000000E+00, 0.00000000E+00, + 0.00000000E+00, 0.00000000E+00, -7.45375000E+02, + 4.36600000E+00]), + NASA([1000.00, 5000.00], + [ 2.50000000E+00, 0.00000000E+00, 0.00000000E+00, + 0.00000000E+00, 0.00000000E+00, -7.45375000E+02, + 4.36600000E+00])), + note='120186') + +species(name='R1A', + atoms='C:1 H:4', + thermo=(NASA([200.00, 1000.00], + [ 5.14987613E+00, -1.36709788E-02, 4.91800599E-05, + -4.84743026E-08, 1.66693956E-11, -1.02466476E+04, + -4.64130376E+00]), + NASA([1000.00, 3500.00], + [ 7.48514950E-02, 1.33909467E-02, -5.73285809E-06, + 1.22292535E-09, -1.01815230E-13, -9.46834459E+03, + 1.84373180E+01]))) + +species(name='R1B', + atoms='C:1 H:4', + thermo=(NASA([200.00, 1000.00], + [ 5.14987613E+00, -1.36709788E-02, 4.91800599E-05, + -4.84743026E-08, 1.66693956E-11, -1.02466476E+04, + -4.64130376E+00]), + NASA([1000.00, 3500.00], + [ 7.48514950E-02, 1.33909467E-02, -5.73285809E-06, + 1.22292535E-09, -1.01815230E-13, -9.46834459E+03, + 1.84373180E+01]))) + +species(name='P1', + atoms='C:2 H:7', + thermo=(NASA([200.00, 1000.00], + [ 5.14987613E+00, -1.36709788E-02, 4.91800599E-05, + -4.84743026E-08, 1.66693956E-11, -1.02466476E+04, + -4.64130376E+00]), + NASA([1000.00, 3500.00], + [ 7.48514950E-02, 1.33909467E-02, -5.73285809E-06, + 1.22292535E-09, -1.01815230E-13, -9.46834459E+03, + 1.84373180E+01]))) + +#------------------------------------------------------------------------------- +# Reaction data +#------------------------------------------------------------------------------- + +# Reaction 1 +reaction('R1A + R1B => H + P1', [1.000000e+12, 0.0, 20000.0], + order='R1A:2.5 R1B:-0.5', + options=['duplicate', 'negative_orders']) + +# Reaction 2 +reaction('H + P1 => R1A + R1B', [5.000000e+13, -2.0, 5000.0], + order='P1:-0.2', + options='negative_orders') + +# Reaction 3 +reaction('R1A + R1B => H + P1', [1.000000e+12, 0.0, 20000.0], + order='R1A:3.0 R1B:0.0', + options='duplicate') diff --git a/test/data/negative-order.inp b/test/data/negative-order.inp new file mode 100644 index 000000000..37644cc97 --- /dev/null +++ b/test/data/negative-order.inp @@ -0,0 +1,26 @@ +ELEMENTS +H C AR +END + +SPECIES +H +AR +R1A R1B P1 +END + +REACTIONS + +R1A+R1B=>H+P1 1e12 0.0 20000.0 + FORD / R1A 2.5 / + FORD / R1B -0.5 / + DUPLICATE + +H+P1=>R1A+R1B 5e13 -2.0 5000.0 + FORD / P1 -0.2 / + +R1A+R1B=>H+P1 1e12 0.0 20000.0 + FORD / R1A 3.0 / + FORD / R1B 0.0 / + DUPLICATE + +END