Skip to content

Commit

Permalink
[ck2cti] Detect badly formatted values of 4th Troe coefficient
Browse files Browse the repository at this point in the history
Fixes #499
  • Loading branch information
speth committed Feb 8, 2018
1 parent 70016b9 commit bde6e05
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
5 changes: 1 addition & 4 deletions interfaces/cython/cantera/ck2cti.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,10 +1390,7 @@ def parseExpression(expression, dest):
alpha = float(tokens[0].strip())
T3 = float(tokens[1].strip())
T1 = float(tokens[2].strip())
try:
T2 = float(tokens[3].strip())
except (IndexError, ValueError):
T2 = None
T2 = float(tokens[3].strip()) if len(tokens) > 3 else None

falloff = Troe(
alpha=(alpha,''),
Expand Down
6 changes: 6 additions & 0 deletions interfaces/cython/cantera/test/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ def test_negative_order_permissive(self):
'explicit-forward-order.cti')
self.checkKinetics(ref, gas, [300, 800, 1450, 2800], [5e3, 1e5, 2e6])

def test_bad_troe_value(self):
with self.assertRaises(ValueError):
convertMech(pjoin(self.test_data_dir, 'bad-troe.inp'),
thermoFile=pjoin(self.test_data_dir, 'dummy-thermo.dat'),
outName=pjoin(self.test_work_dir, 'bad-troe.cti'), quiet=True)

def test_reaction_units(self):
convertMech(pjoin(self.test_data_dir, 'units-default.inp'),
thermoFile=pjoin(self.test_data_dir, 'dummy-thermo.dat'),
Expand Down
13 changes: 13 additions & 0 deletions test/data/bad-troe.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ELEMENTS
H C
END

SPECIES
H R1A R1B P1
END

REACTIONS
R1A+R1B(+M) <=> H+P1(+M) 1e12 0.0 20000.0
LOW / 1.040E+26 -2.760 1600.00/
TROE/ .5620 91.00 5836.00 1.00000+100/
END

0 comments on commit bde6e05

Please sign in to comment.