diff --git a/interfaces/cython/cantera/ck2cti.py b/interfaces/cython/cantera/ck2cti.py index 0264b7dc28..812b44cdb0 100644 --- a/interfaces/cython/cantera/ck2cti.py +++ b/interfaces/cython/cantera/ck2cti.py @@ -1549,7 +1549,8 @@ def readline(): tokens = tokens[1:] while line is not None and not contains(line, 'END'): # Grudging support for implicit end of section - if line.strip()[:4].upper() == 'SPEC': + start = line.strip().upper().split() + if start and start[0] in ('SPEC', 'SPECIES'): self.warn('"ELEMENTS" section implicitly ended by start of ' 'next section on line {0}.'.format(self.line_number)) advance = False @@ -1572,7 +1573,9 @@ def readline(): inHeader = False while line is not None and not contains(line, 'END'): # Grudging support for implicit end of section - if line.strip()[:4].upper() in ('REAC', 'TRAN', 'THER'): + start = line.strip().upper().split() + if start and start[0] in ('REAC', 'REACTIONS', 'TRAN', + 'TRANSPORT', 'THER', 'THERMO'): self.warn('"SPECIES" section implicitly ended by start of ' 'next section on line {0}.'.format(self.line_number)) advance = False @@ -1620,7 +1623,9 @@ def readline(): inHeader = False while line is not None and not contains(line, 'END'): # Grudging support for implicit end of section - if line.strip()[:4].upper() in ('REAC', 'THER'): + start = line.strip().upper().split() + if start and start[0] in ('REAC', 'REACTIONS', 'THER', + 'THERMO'): self.warn('"SITE" section implicitly ended by start of ' 'next section on line {0}.'.format(self.line_number)) advance = False @@ -1659,7 +1664,8 @@ def readline(): entry = [] while line is not None and not get_index(line, 'END') == 0: # Grudging support for implicit end of section - if line.strip()[:4].upper() in ('REAC', 'TRAN'): + start = line.strip().upper().split() + if start and start[0] in ('REAC', 'REACTIONS', 'TRAN', 'TRANSPORT'): self.warn('"THERMO" section implicitly ended by start of ' 'next section on line {0}.'.format(self.line_number)) advance = False @@ -1728,7 +1734,8 @@ def readline(): current = [] while line is not None and not contains(line, 'END'): # Grudging support for implicit end of section - if line.strip()[:4].upper() in ('REAC', 'TRAN'): + start = line.strip().upper().split() + if start and start[0] in ('REAC', 'REACTIONS', 'TRAN', 'TRANSPORT'): self.warn('"THERMO" section implicitly ended by start of ' 'next section on line {0}.'.format(self.line_number)) advance = False @@ -1819,7 +1826,8 @@ def readline(): reactions = self.reactions while line is not None and not contains(line, 'END'): # Grudging support for implicit end of section - if line.strip()[:4].upper() == 'TRAN': + start = line.strip().upper().split() + if start and start[0] in ('TRAN', 'TRANSPORT'): self.warn('"REACTIONS" section implicitly ended by start of ' 'next section on line {0}.'.format(self.line_number)) advance = False @@ -1878,7 +1886,8 @@ def readline(): transport_start_line = self.line_number while line is not None and not contains(line, 'END'): # Grudging support for implicit end of section - if line.strip()[:4].upper() == 'REAC': + start = line.strip().upper().split() + if start and start[0] in ('REAC', 'REACTIONS'): self.warn('"TRANSPORT" section implicitly ended by start of ' 'next section on line {0}.'.format(self.line_number)) advance = False diff --git a/interfaces/cython/cantera/test/test_convert.py b/interfaces/cython/cantera/test/test_convert.py index 359aefc1e5..39879fef9e 100644 --- a/interfaces/cython/cantera/test/test_convert.py +++ b/interfaces/cython/cantera/test/test_convert.py @@ -142,7 +142,7 @@ def test_pathologicalSpeciesNames(self): outName=pjoin(self.test_work_dir, 'species-names.cti'), quiet=True) gas = ct.Solution('species-names.cti') - self.assertEqual(gas.n_species, 7) + self.assertEqual(gas.n_species, 8) self.assertEqual(gas.species_name(0), '(Parens)') self.assertEqual(gas.species_name(1), '@#$%^-2') self.assertEqual(gas.species_index('co:lons:'), 2) @@ -151,18 +151,19 @@ def test_pathologicalSpeciesNames(self): self.assertEqual(gas.species_name(5), 'eq=uals') self.assertEqual(gas.species_name(6), 'plus') - self.assertEqual(gas.n_reactions, 10) + self.assertEqual(gas.n_reactions, 11) nu = gas.product_stoich_coeffs() - gas.reactant_stoich_coeffs() - self.assertEqual(list(nu[:,0]), [-1, -1, 0, 2, 0, 0, 0]) - self.assertEqual(list(nu[:,1]), [-2, 3, 0, -1, 0, 0, 0]) - self.assertEqual(list(nu[:,2]), [-1, 0, 0, 0, 1, 0, 0]) - self.assertEqual(list(nu[:,3]), [3, 0, 0, 0, -2, -1, 0]) - self.assertEqual(list(nu[:,4]), [2, 0, 0, 0, -1, 0, -1]) - self.assertEqual(list(nu[:,5]), [1, 0, 0, 0, 1, -1, -1]) - self.assertEqual(list(nu[:,6]), [2, 0, -1, 0, 0, -1, 0]) - self.assertEqual(list(nu[:,7]), [0, 0, 0, 0, -1, 1, 0]) - self.assertEqual(list(nu[:,8]), [0, 0, 0, 0, -1, 1, 0]) - self.assertEqual(list(nu[:,9]), [0, 0, 0, 0, -1, 1, 0]) + self.assertEqual(list(nu[:,0]), [-1, -1, 0, 2, 0, 0, 0, 0]) + self.assertEqual(list(nu[:,1]), [-2, 3, 0, -1, 0, 0, 0, 0]) + self.assertEqual(list(nu[:,2]), [-1, 0, 0, 0, 1, 0, 0, 0]) + self.assertEqual(list(nu[:,3]), [3, 0, 0, 0, -2, -1, 0, 0]) + self.assertEqual(list(nu[:,4]), [2, 0, 0, 0, -1, 0, -1, 0]) + self.assertEqual(list(nu[:,5]), [1, 0, 0, 0, 1, -1, -1, 0]) + self.assertEqual(list(nu[:,6]), [2, 0, -1, 0, 0, -1, 0, 0]) + self.assertEqual(list(nu[:,7]), [0, 0, 0, 0, -1, 1, 0, 0]) + self.assertEqual(list(nu[:,8]), [0, 0, 0, 0, -1, 1, 0, 0]) + self.assertEqual(list(nu[:,9]), [0, 0, 0, 0, -1, 1, 0, 0]) + self.assertEqual(list(nu[:,10]), [0, 0, -1, 0, 2, 0, 0, -1]) def test_unterminatedSections(self): with self.assertRaises(ck2cti.InputParseError): diff --git a/test/data/species-names.inp b/test/data/species-names.inp index 8c0ff5d6c7..6e97053703 100644 --- a/test/data/species-names.inp +++ b/test/data/species-names.inp @@ -2,7 +2,7 @@ Elements H C End SPEC -(Parens) @#$%^-2 co:lons: [xy2]*{.} plus+ eq=uals plus +(Parens) @#$%^-2 co:lons: [xy2]*{.} plus+ eq=uals plus trans_butene end thermo @@ -23,6 +23,10 @@ co:lons: 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 +trans_butene 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 plus+ 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 @@ -51,5 +55,6 @@ plus+ (+(Parens)) = eq=uals (+(Parens)) 9.999e9 9.9 999.9 LOW / 8.888e8 8.8 888.8 / plus+ (+plus+) = eq=uals (+plus+) 9.999e9 9.9 999.9 LOW / 8.888e8 8.8 888.8 / +trans_butene + co:lons: = 2 plus+ 9.999e9 9.9 999.9 end