From 52bb3a6cfcd12e76aea4257e5aafd4486e4e027c Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Sun, 30 Jun 2024 12:48:03 -0400 Subject: [PATCH] [Input] Add ck2yaml test for non-reactant order handling --- test/data/nonreactant-order.inp | 8 ++++ test/data/nonreactant-order.yaml | 73 ++++++++++++++++++++++++++++++++ test/python/test_convert.py | 9 ++++ 3 files changed, 90 insertions(+) create mode 100644 test/data/nonreactant-order.inp create mode 100644 test/data/nonreactant-order.yaml diff --git a/test/data/nonreactant-order.inp b/test/data/nonreactant-order.inp new file mode 100644 index 000000000..e520f2f9b --- /dev/null +++ b/test/data/nonreactant-order.inp @@ -0,0 +1,8 @@ +ELEMENTS H C END +SPECIES H R1A R1B P1 P2A END + +REACTIONS +R1A+R1B=>H+P1 1e12 0.0 20000.0 + FORD / R1A 1.5 / + FORD / P2A 0.5 / +END diff --git a/test/data/nonreactant-order.yaml b/test/data/nonreactant-order.yaml new file mode 100644 index 000000000..739c7819b --- /dev/null +++ b/test/data/nonreactant-order.yaml @@ -0,0 +1,73 @@ +generator: ck2yaml +input-files: [err-nonreactant-order.inp, dummy-thermo.dat] +cantera-version: 3.1.0a2 +date: Fri, 28 Jun 2024 13:10:15 -0400 + +units: {length: cm, time: s, quantity: mol, activation-energy: cal/mol} + +phases: +- name: gas + thermo: ideal-gas + elements: [H, C] + species: [H, R1A, R1B, P1, P2A] + kinetics: gas + state: {T: 300.0, P: 1 atm} + +species: +- name: H + composition: {H: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [2.5, 7.05332819e-13, -1.99591964e-15, 2.30081632e-18, -9.27732332e-22, + 2.54736599e+04, -0.446682853] + - [2.50000001, -2.30842973e-11, 1.61561948e-14, -4.73515235e-18, 4.98197357e-22, + 2.54736599e+04, -0.446682914] + note: 'NOTE: All of this thermo data is bogus' +- name: R1A + composition: {C: 1, H: 4} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [5.14987613, -0.0136709788, 4.91800599e-05, -4.84743026e-08, 1.66693956e-11, + -1.02466476e+04, -4.64130376] + - [0.074851495, 0.0133909467, -5.73285809e-06, 1.22292535e-09, -1.0181523e-13, + -9468.34459, 18.437318] +- name: R1B + composition: {C: 1, H: 4} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [5.14987613, -0.0136709788, 4.91800599e-05, -4.84743026e-08, 1.66693956e-11, + -1.02466476e+04, -4.64130376] + - [0.074851495, 0.0133909467, -5.73285809e-06, 1.22292535e-09, -1.0181523e-13, + -9468.34459, 18.437318] +- name: P1 + composition: {C: 2, H: 7} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [5.14987613, -0.0136709788, 4.91800599e-05, -4.84743026e-08, 1.66693956e-11, + -1.02466476e+04, -4.64130376] + - [0.074851495, 0.0133909467, -5.73285809e-06, 1.22292535e-09, -1.0181523e-13, + -9468.34459, 18.437318] +- name: P2A + composition: {C: 1, H: 4} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 3500.0] + data: + - [5.14987613, -0.0136709788, 4.91800599e-05, -4.84743026e-08, 1.66693956e-11, + -1.02466476e+04, -4.64130376] + - [0.074851495, 0.0133909467, -5.73285809e-06, 1.22292535e-09, -1.0181523e-13, + -9468.34459, 18.437318] + +reactions: +- equation: R1A + R1B => H + P1 # Reaction 1 + rate-constant: {A: 1.0e+12, b: 0.0, Ea: 2.0e+04} + orders: {R1A: 1.5, P2A: 0.5} + nonreactant-orders: true diff --git a/test/python/test_convert.py b/test/python/test_convert.py index b575df8ef..056c9f5c6 100644 --- a/test/python/test_convert.py +++ b/test/python/test_convert.py @@ -259,6 +259,15 @@ class ck2yamlTest(utilities.CanteraTest): ref, gas = self.checkConversion("negative-order.yaml", output) self.checkKinetics(ref, gas, [300, 800, 1450, 2800], [5e3, 1e5, 2e6]) + def test_nonreactant_order(self): + with pytest.raises(ck2yaml.InputError, match="Non-reactant order for reaction"): + self.convert("nonreactant-order.inp", thermo="dummy-thermo.dat") + + output = self.convert("nonreactant-order.inp", thermo="dummy-thermo.dat", + permissive=True) + ref, gas = self.checkConversion("nonreactant-order.yaml", output) + self.checkKinetics(ref, gas, [300, 800, 1450, 2800], [5e3, 1e5, 2e6]) + def test_negative_A_factor(self): output = self.convert('negative-rate.inp', thermo='dummy-thermo.dat') gas = ct.Solution(output) # Validate the mechanism