diff --git a/interfaces/cython/cantera/ck2cti.py b/interfaces/cython/cantera/ck2cti.py index 214780ce0..4aa289320 100644 --- a/interfaces/cython/cantera/ck2cti.py +++ b/interfaces/cython/cantera/ck2cti.py @@ -955,6 +955,37 @@ class Parser(object): else: note = '' + # Normal method for specifying the elemental composition + composition = self.parseComposition(lines[0][24:44], 4, 5) + + # Chemkin-style extended elemental composition: additional lines + # indicated by '&' continuation character on preceding lines. Element + # names and abundances are separated by whitespace (not fixed width) + if lines[0].rstrip().endswith('&'): + complines = [] + for i in range(len(lines)-1): + if lines[i].rstrip().endswith('&'): + complines.append(lines[i+1]) + else: + break + lines = [lines[0]] + lines[i+1:] + comp = ' '.join(line.rstrip('&\n') for line in complines).split() + composition = {} + for i in range(0, len(comp), 2): + composition[comp[i].capitalize()] = int(comp[i+1]) + + # Non-standard extended elemental composition data may be located beyond + # column 80 on the first line of the thermo entry + if len(lines[0]) > 80: + elements = lines[0][80:] + composition2 = self.parseComposition(elements, len(elements)//10, 10) + composition.update(composition2) + + if not composition: + raise InputParseError("Error parsing elemental composition for " + "species '{0}'".format(species)) + + # Extract the NASA polynomial coefficients # Remember that the high-T polynomial comes first! Tmin = fortFloat(lines[0][45:55]) @@ -978,19 +1009,6 @@ class Parser(object): coeffs_high = coeffs_low - composition = self.parseComposition(lines[0][24:44], 4, 5) - - # Non-standard extended elemental composition data may be located beyond - # column 80 on the first line of the thermo entry - if len(lines[0]) > 80: - elements = lines[0][80:] - composition2 = self.parseComposition(elements, len(elements)//10, 10) - composition.update(composition2) - - if not composition: - raise InputParseError("Error parsing elemental composition for " - "species '{0}'".format(species)) - # Construct and return the thermodynamics model thermo = MultiNASA( @@ -1614,6 +1632,9 @@ class Parser(object): thermo = [] current = [] + elif thermo and thermo[-1].rstrip().endswith('&'): + # Include Chemkin-style extended elemental composition + thermo.append(line) line, comment = readline() elif tokens[0].upper().startswith('REAC'): diff --git a/test/data/soot-therm.dat b/test/data/soot-therm.dat index f4169da37..d328bfb73 100644 --- a/test/data/soot-therm.dat +++ b/test/data/soot-therm.dat @@ -36,11 +36,14 @@ BIN5 PYRENE C 0H 0 0 0G 300.000 5000.000 1401.000 01 3.65839677E+01 3.36764102E-02-1.16783938E-05 1.83077466E-09-1.06963777E-13 2 9.29809483E+03-1.81272070E+02-1.29758980E+01 1.63790064E-01-1.43851166E-04 3 6.31057915E-08-1.09568047E-11 2.48866399E+04 7.94950474E+01 4 -BIN6J PYRENEJ1 C 0H 0 0 0G 300.000 5000.000 1401.000 01C 778H 263 +BIN6J PYRENEJ1 C 0H 0 0 0G 300.000 5000.000 1401.000 01& +C 778 H 263 3.63345177E+01 3.13968020E-02-1.09044660E-05 1.71125597E-09-1.00056355E-13 2 4.05143093E+04-1.77494305E+02-1.20603441E+01 1.59247554E-01-1.41562602E-04 3 6.26071650E-08-1.09305161E-11 5.56473533E+04 7.68451211E+01 4 -BIN6 PYRENE C 0H 0 0 0G 300.000 5000.000 1401.000 01C 778H 264 +BIN6 PYRENE C 0H 0 0 0G 300.000 5000.000 1401.000 01& +C 778& +H 264 3.65839677E+01 3.36764102E-02-1.16783938E-05 1.83077466E-09-1.06963777E-13 2 9.29809483E+03-1.81272070E+02-1.29758980E+01 1.63790064E-01-1.43851166E-04 3 6.31057915E-08-1.09568047E-11 2.48866399E+04 7.94950474E+01 4