From 39079b93d1b308859ebd368cbbd2d4428961346c Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 21 Jun 2013 20:57:49 +0000 Subject: [PATCH] [ck2cti] Consider explicit third bodies in duplicate reaction check Reactions with the same reactants and products but different named third bodies are not considered duplicates and do not need to be marked as such. Normal third body reactions (with 'M' as the third body) are considered duplicates of reactions with specific third bodies if the efficiency for the specific third body is not zero. --- interfaces/python/ck2cti.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/interfaces/python/ck2cti.py b/interfaces/python/ck2cti.py index 60f25d344..be8d51bf9 100755 --- a/interfaces/python/ck2cti.py +++ b/interfaces/python/ck2cti.py @@ -312,6 +312,7 @@ class KineticsModel(object): self.Pmax = Pmax self.comment = comment self.parser = parser + self.efficiencies = {} def isPressureDependent(self): """ @@ -326,11 +327,8 @@ class KineticsModel(object): raise InputParseError('to_cti is not implemented for objects of class {0}'.format(self.__class__.__name__)) def efficiencyString(self): - if hasattr(self, 'efficiencies'): - return ' '.join('{0}:{1}'.format(mol, eff) - for mol,eff in self.efficiencies.items()) - else: - return '' + return ' '.join('{0}:{1}'.format(mol, eff) + for mol,eff in self.efficiencies.items()) class KineticsData(KineticsModel): @@ -1539,12 +1537,20 @@ class Parser(object): possible_duplicates = defaultdict(list) for r in self.reactions: - k = tuple(r.reactants), tuple(r.products), r.kinetics.isPressureDependent() + k = (tuple(r.reactants), tuple(r.products), r.kinetics.isPressureDependent()) possible_duplicates[k].append(r) for reactions in possible_duplicates.values(): for r1,r2 in itertools.combinations(reactions, 2): - if not r1.duplicate or not r2.duplicate: + if r1.duplicate and r2.duplicate: + pass # marked duplicate reaction + elif r1.thirdBody.upper() == 'M' and r1.kinetics.efficiencies.get(r2.thirdBody) == 0: + pass # explicit zero efficiency + elif r2.thirdBody.upper() == 'M' and r2.kinetics.efficiencies.get(r1.thirdBody) == 0: + pass # explicit zero efficiency + elif r1.thirdBody != r2.thirdBody: + pass # distinct third bodies + else: raise InputParseError(message.format(r1, r1.line_number, r2.line_number)) def parseTransportData(self, lines):