[Input] Improve error message for Chemkin files with unrecognized sections
This commit is contained in:
parent
cbe763836e
commit
4d5cd502a2
3 changed files with 24 additions and 0 deletions
|
|
@ -1908,6 +1908,9 @@ class Parser(object):
|
|||
else:
|
||||
transportLines.append(line)
|
||||
line, comment = readline()
|
||||
elif line.strip():
|
||||
raise InputParseError('Section starts with unrecognized keyword.'
|
||||
'\n"""\n{0}\n"""'.format(line.rstrip()))
|
||||
|
||||
if advance:
|
||||
line, comment = readline()
|
||||
|
|
|
|||
|
|
@ -195,6 +195,13 @@ class chemkinConverterTest(utilities.CanteraTest):
|
|||
self.assertEqual(gas.n_species, 3)
|
||||
self.assertEqual(gas.n_reactions, 2)
|
||||
|
||||
def test_unrecognized_section(self):
|
||||
with self.assertRaisesRegex(ck2cti.InputParseError, 'SPAM'):
|
||||
convertMech(pjoin(self.test_data_dir, 'unrecognized-section.inp'),
|
||||
thermoFile=pjoin(self.test_data_dir, 'dummy-thermo.dat'),
|
||||
outName=pjoin(self.test_work_dir, 'unrecognized-section.cti'),
|
||||
quiet=True, permissive=True)
|
||||
|
||||
def test_nasa9(self):
|
||||
convertMech(pjoin(self.test_data_dir, 'nasa9-test.inp'),
|
||||
thermoFile=pjoin(self.test_data_dir, 'nasa9-test-therm.dat'),
|
||||
|
|
|
|||
14
test/data/unrecognized-section.inp
Normal file
14
test/data/unrecognized-section.inp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
Elements
|
||||
H C
|
||||
|
||||
SPECIES
|
||||
R1A R1B H P1
|
||||
END
|
||||
|
||||
SPAM
|
||||
R1A + R1B = H + P1 1.2345e12 1.0 200.0
|
||||
END
|
||||
|
||||
reactions cal/mol
|
||||
R1A + R1B = H + P1 1.2345e12 1.0 200.0
|
||||
R1A + R1A = H + P1 5.4321e10 1.0 500.0
|
||||
Loading…
Add table
Reference in a new issue