diff --git a/rmgpy/reaction.py b/rmgpy/reaction.py index 7cd5511d14..a92c7f152c 100755 --- a/rmgpy/reaction.py +++ b/rmgpy/reaction.py @@ -192,10 +192,13 @@ def toChemkin(self, speciesList=None, kinetics=True): else: return rmgpy.chemkin.writeReactionString(self) - def toCantera(self, speciesList=None): + def toCantera(self, speciesList=None, useChemkinIdentifier = True): """ Converts the RMG Reaction object to a Cantera Reaction object with the appropriate reaction class. + + If useChemkinIdentifier is set to False, the species label is used + instead. Be sure that species' labels are unique when setting it False. """ from rmgpy.kinetics import Arrhenius, ArrheniusEP, MultiArrhenius, PDepArrhenius, MultiPDepArrhenius, Chebyshev, ThirdBody, Lindemann, Troe @@ -208,14 +211,20 @@ def toCantera(self, speciesList=None): # for initializing the cantera reaction object ctReactants = {} for reactant in self.reactants: - reactantName = reactant.toChemkin() # Use the chemkin name for the species + if useChemkinIdentifier: + reactantName = reactant.toChemkin() + else: + reactantName = reactant.label if reactantName in ctReactants: ctReactants[reactantName] += 1 else: ctReactants[reactantName] = 1 ctProducts = {} for product in self.products: - productName = product.toChemkin() # Use the chemkin name for the species + if useChemkinIdentifier: + productName = product.toChemkin() + else: + productName = product.label if productName in ctProducts: ctProducts[productName] += 1 else: diff --git a/rmgpy/species.py b/rmgpy/species.py index c627b38ee1..fe14c7467b 100644 --- a/rmgpy/species.py +++ b/rmgpy/species.py @@ -257,10 +257,13 @@ def toChemkin(self): from rmgpy.chemkin import getSpeciesIdentifier return getSpeciesIdentifier(self) - def toCantera(self): + def toCantera(self, useChemkinIdentifier = True): """ Converts the RMG Species object to a Cantera Species object with the appropriate thermo data. + + If useChemkinIdentifier is set to False, the species label is used + instead. Be sure that species' labels are unique when setting it False. """ import cantera as ct @@ -273,8 +276,10 @@ def toCantera(self): elementDict[symbol] = 1 else: elementDict[symbol] += 1 - - ctSpecies = ct.Species(self.toChemkin(), elementDict) + if useChemkinIdentifier: + ctSpecies = ct.Species(self.toChemkin(), elementDict) + else: + ctSpecies = ct.Species(self.label, elementDict) if self.thermo: try: ctSpecies.thermo = self.thermo.toCantera()