[ck2cti] Fix handling of thermo entries with end-of-line comments

This commit is contained in:
Ray Speth 2013-07-08 01:35:20 +00:00
parent ceeea2ed21
commit e8ab4dda28
2 changed files with 7 additions and 8 deletions

View file

@ -892,15 +892,14 @@ class Parser(object):
units = '1' + units
return units
def readThermoEntry(self, entry, TintDefault):
def readThermoEntry(self, lines, TintDefault):
"""
Read a thermodynamics `entry` for one species in a Chemkin-format file
Read a thermodynamics entry for one species in a Chemkin-format file
(consisting of two 7-coefficient NASA polynomials). Returns the label of
the species, the thermodynamics model as a :class:`MultiNASA` object, the
elemental composition of the species, and the comment/note associated with
the thermo entry.
"""
lines = entry.splitlines()
identifier = lines[0][0:24].split()
species = identifier[0].strip()
@ -1412,10 +1411,10 @@ class Parser(object):
line, comment = readline()
if not contains(line, 'END'):
TintDefault = float(line.split()[1])
thermo = ''
thermo = []
while not contains(line, 'END'):
if len(line) >= 80 and line[79] in ['1', '2', '3', '4']:
thermo += line
thermo.append(line)
if line[79] == '4':
label, thermo, comp, note = self.readThermoEntry(thermo, TintDefault)
try:
@ -1424,7 +1423,7 @@ class Parser(object):
self.speciesDict[label].note = note
except KeyError:
logging.info('Skipping unexpected species "{0}" while reading thermodynamics entry.'.format(label))
thermo = ''
thermo = []
line, comment = readline()
elif contains(line, 'REACTIONS'):

View file

@ -23,7 +23,7 @@ P1 C 2H 7 G 200.000 3500.000 1000.000 1
-4.84743026E-08 1.66693956E-11-1.02466476E+04-4.64130376E+00 4
R2 C 2H 7 G 200.000 3500.000 1000.000 1
7.48514950E-02 1.33909467E-02-5.73285809E-06 1.22292535E-09-1.01815230E-13 2
7.48514950E-02 1.33909467E-02-5.73285809E-06 1.22292535E-09-1.01815230E-13 2 ! an end-of line comment that should be automatically discarded
-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
P2A C 1H 4 G 200.000 3500.000 1000.000 1
@ -34,7 +34,7 @@ P2B 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
! a comment between entries that should also be discarded
R3 C 2H 7 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