Ejemplo n.º 1
0
    def getKinetics(self):
        """
        Extracts the kinetic data from the chemkin file for plotting purposes.
        """
        from rmgpy.chemkin import loadChemkinFile
        from rmgpy.kinetics import ArrheniusEP, Chebyshev
        from rmgpy.reaction import Reaction
        from rmgpy.data.base import Entry

        kineticsDataList = []
        chemkinPath = self.path + "/chemkin/chem.inp"
        dictionaryPath = self.path + "RMG_Dictionary.txt"
        speciesList, reactionList = loadChemkinFile(chemkinPath, dictionaryPath)

        for reaction in reactionList:
            # If the kinetics are ArrheniusEP, replace them with Arrhenius
            if isinstance(reaction.kinetics, ArrheniusEP):
                reaction.kinetics = reaction.kinetics.toArrhenius(reaction.getEnthalpyOfReaction(298))

            reactants = " + ".join([moleculeToInfo(reactant) for reactant in reaction.reactants])
            arrow = "⇔" if reaction.reversible else "→"
            products = " + ".join([moleculeToInfo(reactant) for reactant in reaction.products])

            source = str(reaction).replace("<=>", "=")
            href = reaction.getURL()
            entry = Entry()
            entry.result = reactionList.index(reaction) + 1
            forwardKinetics = reaction.kinetics
            forward = True
            chemkin = reaction.toChemkin(speciesList)

            reverseKinetics = reaction.generateReverseRateCoefficient()
            reverseKinetics.comment = "Fitted reverse reaction. " + reaction.kinetics.comment

            rev_reaction = Reaction(reactants=reaction.products, products=reaction.reactants, kinetics=reverseKinetics)
            chemkin_rev = rev_reaction.toChemkin(speciesList)

            kineticsDataList.append(
                [
                    reactants,
                    arrow,
                    products,
                    entry,
                    forwardKinetics,
                    source,
                    href,
                    forward,
                    chemkin,
                    reverseKinetics,
                    chemkin_rev,
                ]
            )

        return kineticsDataList
Ejemplo n.º 2
0
    def getKinetics(self):
        """
        Extracts the kinetic data from the chemkin file for plotting purposes.
        """
        from rmgpy.chemkin import loadChemkinFile
        from rmgpy.kinetics import ArrheniusEP, Chebyshev
        from rmgpy.reaction import Reaction
        from rmgpy.data.base import Entry
        
        kineticsDataList = []    
        chemkinPath= self.path + '/chemkin/chem.inp'
        dictionaryPath = self.path + 'RMG_Dictionary.txt' 
        if self.Foreign:
            readComments = False
        else:
            readComments = True
        if os.path.exists(dictionaryPath):
            speciesList, reactionList = loadChemkinFile(chemkinPath, dictionaryPath, readComments=readComments)
        else:
            speciesList, reactionList = loadChemkinFile(chemkinPath, readComments=readComments)
            
        for reaction in reactionList:            
            # If the kinetics are ArrheniusEP, replace them with Arrhenius
            if isinstance(reaction.kinetics, ArrheniusEP):
                reaction.kinetics = reaction.kinetics.toArrhenius(reaction.getEnthalpyOfReaction(298))

            if os.path.exists(dictionaryPath):
                reactants = ' + '.join([moleculeToInfo(reactant) for reactant in reaction.reactants])
                arrow = '&hArr;' if reaction.reversible else '&rarr;'
                products = ' + '.join([moleculeToInfo(product) for product in reaction.products])
                href = reaction.getURL()
            else:
                reactants = ' + '.join([reactant.label for reactant in reaction.reactants])
                arrow = '&hArr;' if reaction.reversible else '&rarr;'
                products = ' + '.join([product.label for product in reaction.products])
                href = ''
                
            source = str(reaction).replace('<=>','=')
            entry = Entry()   
            entry.result = reactionList.index(reaction)+1
            forwardKinetics = reaction.kinetics     
            forward = True
            chemkin = reaction.toChemkin(speciesList)
            
            reverseKinetics = reaction.generateReverseRateCoefficient()
            reverseKinetics.comment = 'Fitted reverse reaction. ' + reaction.kinetics.comment
            
            rev_reaction = Reaction(reactants = reaction.products, products = reaction.reactants, kinetics = reverseKinetics)
            chemkin_rev = rev_reaction.toChemkin(speciesList)
            
            kineticsDataList.append([reactants, arrow, products, entry, forwardKinetics, source, href, forward, chemkin, reverseKinetics, chemkin_rev])

        return kineticsDataList
Ejemplo n.º 3
0
    def getKinetics(self):
        """
        Extracts the kinetic data from the chemkin file for plotting purposes.
        """
        from rmgpy.chemkin import loadChemkinFile
        from rmgpy.kinetics import ArrheniusEP, Chebyshev
        from rmgpy.reaction import Reaction
        from rmgpy.data.base import Entry
        
        kineticsDataList = []    
        chemkinPath= os.path.join(self.path, 'chemkin','chem.inp')
        dictionaryPath = os.path.join(self.path, 'RMG_Dictionary.txt' )
        if self.Foreign:
            readComments = False
        else:
            readComments = True
        if os.path.exists(dictionaryPath):
            speciesList, reactionList = loadChemkinFile(chemkinPath, dictionaryPath, readComments=readComments)
        else:
            speciesList, reactionList = loadChemkinFile(chemkinPath, readComments=readComments)
            
        for reaction in reactionList:            
            # If the kinetics are ArrheniusEP, replace them with Arrhenius
            if isinstance(reaction.kinetics, ArrheniusEP):
                reaction.kinetics = reaction.kinetics.toArrhenius(reaction.getEnthalpyOfReaction(298))

            if os.path.exists(dictionaryPath):
                reactants = ' + '.join([moleculeToInfo(reactant) for reactant in reaction.reactants])
                arrow = '&hArr;' if reaction.reversible else '&rarr;'
                products = ' + '.join([moleculeToInfo(product) for product in reaction.products])
                href = reaction.getURL()
            else:
                reactants = ' + '.join([reactant.label for reactant in reaction.reactants])
                arrow = '&hArr;' if reaction.reversible else '&rarr;'
                products = ' + '.join([product.label for product in reaction.products])
                href = ''
                
            source = str(reaction).replace('<=>','=')
            entry = Entry()   
            entry.result = reactionList.index(reaction)+1
            forwardKinetics = reaction.kinetics     
            forward = True
            chemkin = reaction.toChemkin(speciesList)
            
            reverseKinetics = reaction.generateReverseRateCoefficient()
            reverseKinetics.comment = 'Fitted reverse reaction. ' + reaction.kinetics.comment
            
            rev_reaction = Reaction(reactants = reaction.products, products = reaction.reactants, kinetics = reverseKinetics)
            chemkin_rev = rev_reaction.toChemkin(speciesList)
            
            kineticsDataList.append([reactants, arrow, products, entry, forwardKinetics, source, href, forward, chemkin, reverseKinetics, chemkin_rev])

        return kineticsDataList
Ejemplo n.º 4
0
    def getKinetics(self):
        """
        Extracts the kinetic data from the chemkin file for plotting purposes.
        """
        from rmgpy.chemkin import load_chemkin_file
        from rmgpy.kinetics import ArrheniusEP, ArrheniusBM
        from rmgpy.reaction import Reaction
        from rmgpy.data.base import Entry

        kinetics_data_list = []
        chem_file = os.path.join(self.path, 'chemkin', 'chem.inp')
        dict_file = os.path.join(self.path, 'RMG_Dictionary.txt')
        if self.foreign:
            read_comments = False
        else:
            read_comments = True
        if os.path.exists(dict_file):
            spc_list, rxn_list = load_chemkin_file(chem_file,
                                                   dict_file,
                                                   read_comments=read_comments)
        else:
            spc_list, rxn_list = load_chemkin_file(chem_file,
                                                   read_comments=read_comments)

        for reaction in rxn_list:
            # If the kinetics are ArrheniusEP and ArrheniusBM, replace them with Arrhenius
            if isinstance(reaction.kinetics, (ArrheniusEP, ArrheniusBM)):
                reaction.kinetics = reaction.kinetics.to_arrhenius(
                    reaction.get_enthalpy_of_reaction(298))

            if os.path.exists(dict_file):
                reactants = ' + '.join([
                    moleculeToInfo(reactant) for reactant in reaction.reactants
                ])
                arrow = '&hArr;' if reaction.reversible else '&rarr;'
                products = ' + '.join(
                    [moleculeToInfo(product) for product in reaction.products])
                href = reaction.get_url()
            else:
                reactants = ' + '.join(
                    [reactant.label for reactant in reaction.reactants])
                arrow = '&hArr;' if reaction.reversible else '&rarr;'
                products = ' + '.join(
                    [product.label for product in reaction.products])
                href = ''

            source = str(reaction).replace('<=>', '=')
            entry = Entry()
            entry.result = rxn_list.index(reaction) + 1
            forward_kinetics = reaction.kinetics
            forward = True
            chemkin = reaction.to_chemkin(spc_list)

            rev_kinetics = reaction.generate_reverse_rate_coefficient()
            rev_kinetics.comment = 'Fitted reverse reaction. ' + reaction.kinetics.comment

            rev_reaction = Reaction(reactants=reaction.products,
                                    products=reaction.reactants,
                                    kinetics=rev_kinetics)
            chemkin_rev = rev_reaction.to_chemkin(spc_list)

            kinetics_data_list.append([
                reactants, arrow, products, entry, forward_kinetics, source,
                href, forward, chemkin, rev_kinetics, chemkin_rev
            ])

        return kinetics_data_list