From 72e0d650b4d87185f909ebfe92623ac37e7debe0 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Thu, 26 Feb 2015 00:13:39 +0000 Subject: [PATCH] [ck2cti] Automatically add the 'negative_A' flag where necessary --- interfaces/cython/cantera/ck2cti.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/interfaces/cython/cantera/ck2cti.py b/interfaces/cython/cantera/ck2cti.py index 85121ccf2..ba24b4709 100644 --- a/interfaces/cython/cantera/ck2cti.py +++ b/interfaces/cython/cantera/ck2cti.py @@ -297,8 +297,16 @@ class Reaction(object): k_indent = ' ' * (kinstr.find('(') + 1) + options = self.kinetics.options() if self.duplicate: - kinstr = kinstr[:-1] + ",\n{0}options='duplicate')".format(k_indent) + options.append('duplicate') + if len(options) == 1: + optStr = repr(options[0]) + else: + optStr = repr(options) + + if self.duplicate: + kinstr = kinstr[:-1] + ",\n{0}options={1})".format(k_indent, optStr) if self.fwdOrders: order = ' '.join('{0}:{1}'.format(k,v) @@ -347,6 +355,9 @@ class KineticsModel(object): def to_cti(self, reactantstr, arrow, productstr): raise InputParseError('to_cti is not implemented for objects of class {0}'.format(self.__class__.__name__)) + def options(self): + return [] + def efficiencyString(self): return ' '.join('{0}:{1}'.format(mol, eff) for mol,eff in self.efficiencies.items()) @@ -427,6 +438,12 @@ class Arrhenius(KineticsModel): return '[{0}, {1}, {2}]'.format(A, self.b, Ea) + def options(self): + if self.A[0] < 0: + return ['negative_A'] + else: + return [] + def to_cti(self, reactantstr, arrow, productstr, indent=0): rxnstring = reactantstr + arrow + productstr return 'reaction({0!r}, {1})'.format(rxnstring, self.rateStr())