[ck2cti] Fix for support of unterminated thermo sections
Fixes the case where the next section header contains a modifier, e.g. 'thermo all' or 'reactions <units>'. Based on a patch provided by Bryan Weber. See Issue 199. Cherry-pick of trunk r2662.
This commit is contained in:
parent
a23eac62d8
commit
0590c6c1a3
3 changed files with 50 additions and 0 deletions
|
|
@ -1385,6 +1385,11 @@ class Parser(object):
|
|||
'next section on line {0}.'.format(self.line_number))
|
||||
advance = False
|
||||
tokens.pop()
|
||||
# Fix the case where there THERMO ALL or REAC UNITS
|
||||
# ends the species section
|
||||
if (tokens[-1].upper().startswith('THER') or
|
||||
tokens[-1].upper().startswith('REAC')):
|
||||
tokens.pop()
|
||||
break
|
||||
|
||||
line, comment = readline()
|
||||
|
|
|
|||
31
test/data/unterminated-sections2.inp
Normal file
31
test/data/unterminated-sections2.inp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
Elements
|
||||
H C
|
||||
|
||||
SPECIES
|
||||
foo bar baz
|
||||
|
||||
|
||||
thermo All
|
||||
300.000 1000.000 5000.000
|
||||
foo C 1H 4 G 200.000 3500.000 1000.000 1
|
||||
7.48514950E-02 1.33909467E-02-5.73285809E-06 1.22292535E-09-1.01815230E-13 2
|
||||
-9.46834459E+03 1.84373180E+01 5.14987613E+00-1.36709788E-02 4.91800599E-05 3
|
||||
-4.84743026E-08 1.66693956E-11-1.02466476E+04-4.64130376E+00 4
|
||||
bar C 1H 4 G 200.000 3500.000 1000.000 1
|
||||
7.48514950E-02 1.33909467E-02-5.73285809E-06 1.22292535E-09-1.01815230E-13 2
|
||||
-9.46834459E+03 1.84373180E+01 5.14987613E+00-1.36709788E-02 4.91800599E-05 3
|
||||
-4.84743026E-08 1.66693956E-11-1.02466476E+04-4.64130376E+00 4
|
||||
baz C 1H 4 G 200.000 3500.000 1000.000 1
|
||||
7.48514950E-02 1.33909467E-02-5.73285809E-06 1.22292535E-09-1.01815230E-13 2
|
||||
-9.46834459E+03 1.84373180E+01 5.14987613E+00-1.36709788E-02 4.91800599E-05 3
|
||||
-4.84743026E-08 1.66693956E-11-1.02466476E+04-4.64130376E+00 4
|
||||
|
||||
reactions cal/mol
|
||||
foo + bar = 2 baz 1.2345e12 1.0 200.0
|
||||
2foo + baz = 3bar 5.4321e10 1.0 500.0
|
||||
|
||||
transport
|
||||
foo 2 357.000 5.180 0.000 0.000 1.000
|
||||
bar 2 266.800 4.982 0.000 0.000 1.000
|
||||
baz 2 266.800 4.982 0.000 0.000 1.000
|
||||
! some comment
|
||||
|
|
@ -160,6 +160,20 @@ class chemkinConverterTest(utilities.CanteraTest):
|
|||
self.assertEqual(gas.nSpecies(), 3)
|
||||
self.assertEqual(gas.nReactions(), 2)
|
||||
|
||||
def test_unterminatedSections2(self):
|
||||
self.assertRaises(ck2cti.InputParseError,
|
||||
lambda: convertMech('../data/unterminated-sections2.inp',
|
||||
outName='unterminated-sections2.cti',
|
||||
quiet=True))
|
||||
|
||||
convertMech('../data/unterminated-sections2.inp',
|
||||
outName='unterminated-sections2.cti',
|
||||
quiet=True, permissive=True)
|
||||
|
||||
gas = ct.IdealGasMix('unterminated-sections2.cti')
|
||||
self.assertEqual(gas.nSpecies(), 3)
|
||||
self.assertEqual(gas.nReactions(), 2)
|
||||
|
||||
def test_nasa9(self):
|
||||
convertMech('../data/nasa9-test.inp',
|
||||
thermoFile='../data/nasa9-test-therm.dat',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue