コード例 #1
0
 def load(self, path):
     """
     Load the solute library from the given path
     """
     Database.load(self,
                   path,
                   local_context={'SoluteData': SoluteData},
                   global_context={})
コード例 #2
0
    def load(self, path, local_context=None, global_context=None):
        import os
        Database.load(self, path, local_context, global_context)
        
        # Load the species in the kinetics library
        # Do not generate resonance structures, since training reactions may be written for a specific resonance form
        speciesDict = self.getSpecies(os.path.join(os.path.dirname(path),'dictionary.txt'), resonance=False)
        # Make sure all of the reactions draw from only this set
        entries = self.entries.values()
        for entry in entries:
            # Create a new reaction per entry
            rxn = entry.item
            rxn_string = entry.label
            # Convert the reactants and products to Species objects using the speciesDict
            reactants, products = rxn_string.split('=')
            reversible = True
            if '<=>' in rxn_string:
                reactants = reactants[:-1]
                products = products[1:]
            elif '=>' in rxn_string:
                products = products[1:]
                reversible = False
            assert reversible == rxn.reversible, "Reaction string reversibility (=>) and entry attribute `reversible` (set to `False`) must agree if reaction is irreversible."

            specificCollider = None
            collider = re.search('\(\+[^\)]+\)',reactants)
            if collider is not None:
                collider = collider.group(0) # save string value rather than the object
                assert collider == re.search('\(\+[^\)]+\)',products).group(0), "Third body colliders in reaction {0} in kinetics library {1} are not identical!".format(rxn_string, self.label)
                extraParenthesis = collider.count('(') -1
                for i in xrange(extraParenthesis):
                    collider += ')' # allow for species like N2(5) or CH2(T)(15) to be read as specific colliders, although currently not implemented in Chemkin. See RMG-Py #1070
                reactants = reactants.replace(collider,'')
                products = products.replace(collider,'')
                if collider.upper().strip() != "(+M)": # the collider is a specific species, not (+M) or (+m)
                    if collider.strip()[2:-1] not in speciesDict: # stripping spaces, '(+' and ')'
                        raise DatabaseError('Collider species {0} in kinetics library {1} is missing from its dictionary.'.format(collider.strip()[2:-1], self.label))
                    specificCollider = speciesDict[collider.strip()[2:-1]]

            for reactant in reactants.split('+'):
                reactant = reactant.strip()
                if reactant not in speciesDict:
                    raise DatabaseError('Species {0} in kinetics depository {1} is missing from its dictionary.'.format(reactant, self.label))
                # Depository reactions should have molecule objects because they are needed in order to descend the
                # tree using `getReactionTemplate()` later, but species objects work because `getReactionTemplate()`
                # will simply pick the first molecule object in `Species().molecule`.
                rxn.reactants.append(speciesDict[reactant])
            for product in products.split('+'):
                product = product.strip()
                if product not in speciesDict:
                    raise DatabaseError('Species {0} in kinetics depository {1} is missing from its dictionary.'.format(product, self.label))
                # Same comment about molecule vs species objects as above.
                rxn.products.append(speciesDict[product])
                
            if not rxn.isBalanced():
                raise DatabaseError('Reaction {0} in kinetics depository {1} was not balanced! Please reformulate.'.format(rxn, self.label))    
コード例 #3
0
ファイル: library.py プロジェクト: Asilvi/RMG-Py
 def load(self, path, local_context=None, global_context=None):
     Database.load(self, path, local_context, global_context)
     
     # Generate a unique set of the species in the kinetics library
     speciesDict = self.getSpecies()
     # Make sure all of the reactions draw from only this set
     entries = self.entries.values()
     for entry in entries:
         entry.item.reactants = [speciesDict[spec.label] for spec in entry.item.reactants]
         entry.item.products = [speciesDict[spec.label] for spec in entry.item.products]
         
     self.checkForDuplicates()
コード例 #4
0
    def load(self, path, local_context=None, global_context=None):
        Database.load(self, path, local_context, global_context)

        # Load a unique set of the species in the kinetics library
        speciesDict = self.getSpecies(
            os.path.join(os.path.dirname(path), 'dictionary.txt'))
        # Make sure all of the reactions draw from only this set
        entries = self.entries.values()
        for entry in entries:
            # Create a new reaction per entry
            rxn = entry.item
            rxn_string = entry.label
            # Convert the reactants and products to Species objects using the speciesDict
            reactants, products = rxn_string.split('=')
            reversible = True
            if '<=>' in rxn_string:
                reactants = reactants[:-1]
                products = products[1:]
            elif '=>' in rxn_string:
                products = products[1:]
                reversible = False
            assert reversible == rxn.reversible, "Reaction string reversibility (=>) and entry attribute `reversible` (set to `False`) must agree if reaction is irreversible."
            for reactant in reactants.split('+'):
                reactant = reactant.strip()
                if reactant not in speciesDict:
                    raise DatabaseError(
                        'Species {0} in kinetics library {1} is missing from its dictionary.'
                        .format(reactant, self.label))
                rxn.reactants.append(speciesDict[reactant])
            for product in products.split('+'):
                product = product.strip()
                if product not in speciesDict:
                    raise DatabaseError(
                        'Species {0} in kinetics library {1} is missing from its dictionary.'
                        .format(product, self.label))
                rxn.products.append(speciesDict[product])

            if not rxn.isBalanced():
                raise DatabaseError(
                    'Reaction {0} in kinetics library {1} was not balanced! Please reformulate.'
                    .format(rxn, self.label))

            if len(rxn.reactants) > 3:
                raise DatabaseError(
                    'RMG does not accept reactions with more than 3 reactants in its solver.  Reaction {0} in kinetics library {1} has {2} reactants.'
                    .format(rxn, self.label, len(rxn.reactants)))
            if len(rxn.products) > 3:
                raise DatabaseError(
                    'RMG does not accept reactions with more than 3 products in its solver.  Reaction {0} in kinetics library {1} has {2} reactants.'
                    .format(rxn, self.label, len(rxn.products)))

        self.checkForDuplicates()
コード例 #5
0
ファイル: depository.py プロジェクト: shamelmerchant/RMG-Py
    def load(self, path, local_context=None, global_context=None):
        import os

        Database.load(self, path, local_context, global_context)

        # Load the species in the kinetics library
        speciesDict = self.getSpecies(os.path.join(os.path.dirname(path), "dictionary.txt"))
        # Make sure all of the reactions draw from only this set
        entries = self.entries.values()
        for entry in entries:
            # Create a new reaction per entry
            rxn = entry.item
            rxn_string = entry.label
            # Convert the reactants and products to Species objects using the speciesDict
            reactants, products = rxn_string.split("=")
            reversible = True
            if "<=>" in rxn_string:
                reactants = reactants[:-1]
                products = products[1:]
            elif "=>" in rxn_string:
                products = products[1:]
                reversible = False
            assert reversible == rxn.reversible
            for reactant in reactants.split("+"):
                reactant = reactant.strip()
                if reactant not in speciesDict:
                    raise DatabaseError(
                        "Species {0} in kinetics depository {1} is missing from its dictionary.".format(
                            reactant, self.label
                        )
                    )
                # For some reason we need molecule objects in the depository rather than species objects
                rxn.reactants.append(speciesDict[reactant])
            for product in products.split("+"):
                product = product.strip()
                if product not in speciesDict:
                    raise DatabaseError(
                        "Species {0} in kinetics depository {1} is missing from its dictionary.".format(
                            product, self.label
                        )
                    )
                # For some reason we need molecule objects in the depository rather than species objects
                rxn.products.append(speciesDict[product])

            if not rxn.isBalanced():
                raise DatabaseError(
                    "Reaction {0} in kinetics depository {1} was not balanced! Please reformulate.".format(
                        rxn, self.label
                    )
                )
コード例 #6
0
ファイル: library.py プロジェクト: jabrownmit/RMG-Py
    def load(self, path, local_context=None, global_context=None):
        Database.load(self, path, local_context, global_context)

        # Generate a unique set of the species in the kinetics library
        speciesDict = self.getSpecies()
        # Make sure all of the reactions draw from only this set
        entries = self.entries.values()
        for entry in entries:
            entry.item.reactants = [
                speciesDict[spec.label] for spec in entry.item.reactants
            ]
            entry.item.products = [
                speciesDict[spec.label] for spec in entry.item.products
            ]

        self.checkForDuplicates()
コード例 #7
0
ファイル: base.py プロジェクト: davidfarinajr/AutoTST
    def load(self, path, local_context=None, global_context=None):

        Database.load(self, path, local_context, global_context)

        # Load the species in the kinetics library
        speciesDict = self.getSpecies(
            os.path.join(os.path.dirname(path), 'dictionary.txt'))
        # Make sure all of the reactions draw from only this set
        entries = list(self.entries.values())
        for entry in entries:
            # Create a new reaction per entry
            rxn = entry.item
            rxn_string = entry.label
            # Convert the reactants and products to Species objects using the
            # speciesDict
            reactants, products = rxn_string.split('=')
            reversible = True
            if '<=>' in rxn_string:
                reactants = reactants[:-1]
                products = products[1:]
            elif '=>' in rxn_string:
                products = products[1:]
                reversible = False
            assert reversible == rxn.reversible
            for reactant in reactants.split('+'):
                reactant = reactant.strip()
                if reactant not in speciesDict:
                    raise DatabaseError(
                        'RMGSpecies {0} in kinetics depository {1} is missing from its dictionary.'
                        .format(reactant, self.label))
                # For some reason we need molecule objects in the depository
                # rather than species objects
                rxn.reactants.append(speciesDict[reactant])
            for product in products.split('+'):
                product = product.strip()
                if product not in speciesDict:
                    raise DatabaseError(
                        'RMGSpecies {0} in kinetics depository {1} is missing from its dictionary.'
                        .format(product, self.label))
                # For some reason we need molecule objects in the depository
                # rather than species objects
                rxn.products.append(speciesDict[product])

            if not rxn.isBalanced():
                raise DatabaseError(
                    'Reaction {0} in kinetics depository {1} was not balanced! Please reformulate.'
                    .format(rxn, self.label))
コード例 #8
0
ファイル: library.py プロジェクト: Alborzi/RMG-Py
    def load(self, path, local_context=None, global_context=None):
        Database.load(self, path, local_context, global_context)
        
        # Load a unique set of the species in the kinetics library
        speciesDict = self.getSpecies(os.path.join(os.path.dirname(path),'dictionary.txt'))
        # Make sure all of the reactions draw from only this set
        entries = self.entries.values()
        for entry in entries:
            # Create a new reaction per entry
            rxn = entry.item
            rxn_string = entry.label
            # Convert the reactants and products to Species objects using the speciesDict
            reactants, products = rxn_string.split('=')
            reversible = True
            if '<=>' in rxn_string:
                reactants = reactants[:-1]
                products = products[1:]
            elif '=>' in rxn_string:
                products = products[1:]
                reversible = False
            assert reversible == rxn.reversible, "Reaction string reversibility (=>) and entry attribute `reversible` (set to `False`) must agree if reaction is irreversible."
            for reactant in reactants.split('+'):
                reactant = reactant.strip()
                if reactant not in speciesDict:
                    raise DatabaseError('Species {0} in kinetics library {1} is missing from its dictionary.'.format(reactant, self.label))
                rxn.reactants.append(speciesDict[reactant])
            for product in products.split('+'):
                product = product.strip()
                if product not in speciesDict:
                    raise DatabaseError('Species {0} in kinetics library {1} is missing from its dictionary.'.format(product, self.label))
                rxn.products.append(speciesDict[product])
                
            if not rxn.isBalanced():
                raise DatabaseError('Reaction {0} in kinetics library {1} was not balanced! Please reformulate.'.format(rxn, self.label))    

            if len(rxn.reactants) > 3: 
                raise DatabaseError('RMG does not accept reactions with more than 3 reactants in its solver.  Reaction {0} in kinetics library {1} has {2} reactants.'.format(rxn, self.label, len(rxn.reactants)))
            if len(rxn.products) > 3:
                raise DatabaseError('RMG does not accept reactions with more than 3 products in its solver.  Reaction {0} in kinetics library {1} has {2} reactants.'.format(rxn, self.label, len(rxn.products)))
            

            
        self.checkForDuplicates()
コード例 #9
0
 def load(self, path):
     """
     Load the metal library from the given path
     """
     Database.load(self, path, local_context={}, global_context={})
コード例 #10
0
    def load(self, path, local_context=None, global_context=None):
        Database.load(self, path, local_context, global_context)

        # Load a unique set of the species in the kinetics library
        speciesDict = self.getSpecies(
            os.path.join(os.path.dirname(path), 'dictionary.txt'))
        # Make sure all of the reactions draw from only this set
        entries = self.entries.values()
        for entry in entries:
            # Create a new reaction per entry
            rxn = entry.item
            rxn_string = entry.label
            # Convert the reactants and products to Species objects using the speciesDict
            reactants, products = rxn_string.split('=>')
            reversible = True
            if '<=>' in rxn_string:
                reactants = reactants[:-1]
                products = products[1:]
            elif '=>' in rxn_string:
                products = products[1:]
                reversible = False
            assert reversible == rxn.reversible, "Reaction string reversibility (=>) and entry attribute `reversible` (set to `False`) must agree if reaction is irreversible."

            collider = re.search('\(\+[^\)]+\)', reactants)
            if collider is not None:
                collider = collider.group(
                    0)  # save string value rather than the object
                assert collider == re.search('\(\+[^\)]+\)',products).group(0), "Third body colliders in reaction {0} in kinetics library {1} are missing" \
                                                                                " from products or are not identical!".format(rxn_string, self.label)
                extraParenthesis = collider.count('(') - 1
                for i in xrange(extraParenthesis):
                    collider += ')'  # allow for species like N2(5) or CH2(T)(15) to be read as specific colliders, although currently not implemented in Chemkin. See RMG-Py #1070
                reactants = reactants.replace(collider, '', 1)
                products = products.replace(collider, '', 1)
                if collider.upper().strip(
                ) != "(+M)":  # the collider is a specific species, not (+M) or (+m)
                    if collider.strip(
                    )[2:
                      -1] not in speciesDict:  # stripping spaces, '(+' and ')'
                        raise DatabaseError(
                            'Collider species {0} in kinetics library {1} is missing from its dictionary.'
                            .format(collider.strip()[2:-1], self.label))
                    rxn.specificCollider = speciesDict[collider.strip()[2:-1]]
            # verify there's no more than one specificCollider:
            collider = re.search('\(\+[^\)]+\)', reactants)
            if collider is not None:
                raise DatabaseError(
                    "Found TWO specific third body colliders, {0} and {1}, in reaction {2} in kinetics library {3), expecting no more than one!"
                    .format(rxn.specificCollider, collider.group(0),
                            rxn_string, self.label))

            for reactant in reactants.split('+'):
                reactant = reactant.strip()
                if reactant not in speciesDict:
                    raise DatabaseError(
                        'Species {0} in kinetics library {1} is missing from its dictionary.'
                        .format(reactant, self.label))
                rxn.reactants.append(speciesDict[reactant])
            for product in products.split('+'):
                product = product.strip()
                if product not in speciesDict:
                    raise DatabaseError(
                        'Species {0} in kinetics library {1} is missing from its dictionary.'
                        .format(product, self.label))
                rxn.products.append(speciesDict[product])

            if not rxn.isBalanced():
                raise DatabaseError(
                    'Reaction {0} in kinetics library {1} was not balanced! Please reformulate.'
                    .format(rxn, self.label))

            if len(rxn.reactants) > 3:
                raise DatabaseError(
                    'RMG does not accept reactions with more than 3 reactants in its solver.  Reaction {0} in kinetics library {1} has {2} reactants.'
                    .format(rxn, self.label, len(rxn.reactants)))
            if len(rxn.products) > 3:
                raise DatabaseError(
                    'RMG does not accept reactions with more than 3 products in its solver.  Reaction {0} in kinetics library {1} has {2} reactants.'
                    .format(rxn, self.label, len(rxn.products)))

        self.checkForDuplicates()