From b26f9f4ee24fe2a8d823a2fde79aae3b33782253 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 15 Aug 2012 15:14:08 +0000 Subject: [PATCH] Fixed handling of rate coefficient units in ck2cti.py Units specified on the REACTIONS line were not being handled correctly, causing the units(...) directive of the resulting .cti file to always have the default units of 'cal/mol' and 'mol', but without correcting the values. --- interfaces/python/ck2cti.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/interfaces/python/ck2cti.py b/interfaces/python/ck2cti.py index 0977ee7b3..39671c3b7 100755 --- a/interfaces/python/ck2cti.py +++ b/interfaces/python/ck2cti.py @@ -60,6 +60,7 @@ UNIT_OPTIONS = {'CAL/': 'cal/mol', 'MOLEC': 'molec', 'MOLECULES': 'molec'} +PROCESSED_UNITS = False ENERGY_UNITS = 'cal/mol' QUANTITY_UNITS = 'mol' @@ -1220,8 +1221,16 @@ def loadChemkinFile(path, speciesList=None): except IndexError: pass - ENERGY_UNITS = UNIT_OPTIONS[energyUnits] - QUANTITY_UNITS = UNIT_OPTIONS[moleculeUnits] + global PROCESSED_UNITS, ENERGY_UNITS, UNIT_OPTIONS + if not PROCESSED_UNITS: + PROCESSED_UNITS = True + ENERGY_UNITS = UNIT_OPTIONS[energyUnits] + QUANTITY_UNITS = UNIT_OPTIONS[moleculeUnits] + else: + if (ENERGY_UNITS != UNIT_OPTIONS[energyUnits] or + QUANTITY_UNITS != UNIT_OPTIONS[moleculeUnits]): + raise InputParseError("Multiple REACTIONS sections with " + "different units are not supported.") kineticsList = [] commentsList = []