diff --git a/interfaces/cython/cantera/ck2cti.py b/interfaces/cython/cantera/ck2cti.py index 5b86763ea..6815bdb92 100644 --- a/interfaces/cython/cantera/ck2cti.py +++ b/interfaces/cython/cantera/ck2cti.py @@ -1676,7 +1676,6 @@ class Parser(object): elif tokens[0].upper().startswith('THER') and contains(line, 'NASA9'): inHeader = False - entryPosition = 0 entryLength = None entry = [] while line is not None and not get_index(line, 'END') == 0: @@ -1704,20 +1703,16 @@ class Parser(object): except (IndexError, ValueError): pass - if entryPosition == 0: - entry.append(line) - elif entryPosition == 1: + entry.append(line) + if len(entry) == 2: entryLength = 2 + 3 * int(line.split()[0]) - entry.append(line) - elif entryPosition < entryLength: - entry.append(line) - if entryPosition == entryLength-1: + if len(entry) == entryLength: label, thermo, comp, note = self.readNasa9Entry(entry) + entry = [] if label not in self.speciesDict: if skipUndeclaredSpecies: logging.info('Skipping unexpected species "{0}" while reading thermodynamics entry.'.format(label)) - thermo = [] continue else: # Add a new species entry @@ -1736,11 +1731,6 @@ class Parser(object): species.composition = comp species.note = note - entryPosition = -1 - entry = [] - - entryPosition += 1 - elif tokens[0].upper().startswith('THER'): # List of thermodynamics (hopefully one per species!) inHeader = False diff --git a/interfaces/cython/cantera/test/test_convert.py b/interfaces/cython/cantera/test/test_convert.py index 13ba1ba60..de8aa81f7 100644 --- a/interfaces/cython/cantera/test/test_convert.py +++ b/interfaces/cython/cantera/test/test_convert.py @@ -204,6 +204,16 @@ class chemkinConverterTest(utilities.CanteraTest): 'nasa9_test.cti') self.checkThermo(ref, gas, [300, 500, 1200, 5000]) + def test_nasa9_subset(self): + convertMech(pjoin(self.test_data_dir, 'nasa9-test-subset.inp'), + thermoFile=pjoin(self.test_data_dir, 'nasa9-test-therm.dat'), + outName=pjoin(self.test_work_dir, 'nasa9-test-subset.cti'), + quiet=True) + + ref, gas = self.checkConversion(pjoin(self.test_data_dir, 'nasa9-test-subset.xml'), + 'nasa9-test-subset.cti') + self.checkThermo(ref, gas, [300, 500, 1200, 5000]) + def test_sri_falloff(self): convertMech(pjoin(self.test_data_dir, 'sri-falloff.inp'), thermoFile=pjoin(self.test_data_dir, 'dummy-thermo.dat'), diff --git a/test/data/nasa9-test-subset.inp b/test/data/nasa9-test-subset.inp new file mode 100644 index 000000000..720607ad5 --- /dev/null +++ b/test/data/nasa9-test-subset.inp @@ -0,0 +1,10 @@ +! +! +! +! +ELEMENTS +O H Al Cl E Ar +END +SPECIES +ALCL3 AR +END diff --git a/test/data/nasa9-test-subset.xml b/test/data/nasa9-test-subset.xml new file mode 100644 index 000000000..22e56e130 --- /dev/null +++ b/test/data/nasa9-test-subset.xml @@ -0,0 +1,56 @@ + + + + + + + O H Al Cl E Ar + ALCL3 AR + + 300.0 + 101325.0 + + + + + + + + + + + + Al:1 Cl:3 + Gurvich,1996a pt1 p173 pt2 p134. [tpis96] + + + + 7.750600970E+04, -1.440779717E+03, 1.401744141E+01, -6.381631240E-03, + 5.871674720E-06, -2.908872278E-09, 5.994050890E-13, -6.579343180E+04, + -4.494017799E+01 + + + + -1.378630916E+05, -5.579207290E+01, 1.004190387E+01, -1.682165339E-05, + 3.724664660E-09, -4.275526780E-13, 1.982341329E-17, -7.343407470E+04, + -2.045130429E+01 + + + + + + + Ar:1 + Ref-Elm. Moore,1971. Gordon,1999.. [g 3/98] + + + + 0.000000000E+00, 0.000000000E+00, 2.500000000E+00, 0.000000000E+00, + 0.000000000E+00, 0.000000000E+00, 0.000000000E+00, -7.453750000E+02, + 4.379674910E+00 + + + + + +