From e8ab4dda286fb86db42aa5e9b8a95d1c4d16056e Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 8 Jul 2013 01:35:20 +0000 Subject: [PATCH] [ck2cti] Fix handling of thermo entries with end-of-line comments --- interfaces/python/ck2cti.py | 11 +++++------ test/data/dummy-thermo.dat | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/interfaces/python/ck2cti.py b/interfaces/python/ck2cti.py index 5d80c6d0c..572900a1e 100755 --- a/interfaces/python/ck2cti.py +++ b/interfaces/python/ck2cti.py @@ -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'): diff --git a/test/data/dummy-thermo.dat b/test/data/dummy-thermo.dat index ed613ad28..ac64b7d0f 100644 --- a/test/data/dummy-thermo.dat +++ b/test/data/dummy-thermo.dat @@ -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