def generate_reactions_from_library(self,
                                        library,
                                        reactants,
                                        products=None):
        """
        Find all reactions from the specified kinetics library involving the
        provided `reactants`, which can be either :class:`Molecule` objects or
        :class:`Species` objects.
        """
        ensure_species(reactants)

        reaction_list = []
        for entry in library.entries.values():
            if entry.item.matchesSpecies(reactants, products=products):
                reaction = LibraryReaction(
                    reactants=entry.item.reactants[:],
                    products=entry.item.products[:],
                    specificCollider=entry.item.specificCollider,
                    degeneracy=entry.item.degeneracy,
                    reversible=entry.item.reversible,
                    duplicate=entry.item.duplicate,
                    kinetics=deepcopy(entry.data),
                    library=library,
                    entry=entry,
                )
                reaction_list.append(reaction)

        return reaction_list
Exemple #2
0
 def generateReactionsFromLibrary(self, reactants, products, library):
     """
     Generate all reactions between the provided list of one or two
     `reactants`, which should be :class:`Molecule` objects. This method
     searches the depository.
     """
     reactionList = []
     for entry in library.entries.values():
         if entry.item.matchesMolecules(reactants):
             reaction = LibraryReaction(
                 reactants = entry.item.reactants[:],
                 products = entry.item.products[:],
                 degeneracy = entry.item.degeneracy,
                 reversible = entry.item.reversible,
                 duplicate = entry.item.duplicate,
                 kinetics = deepcopy(entry.data),
                 library = library,
                 entry = entry,
             )
             reactionList.append(reaction)
     if products:
         reactionList = filterReactions(reactants, products, reactionList)
     return reactionList
Exemple #3
0
    print('Loading RMG-Py database...')
    database = RMGDatabase()
    database.load(settings['database.directory'],
                  kinetics_families='all',
                  kinetics_depositories='all')

    print('Loading {0} library'.format(library_name))
    kinetic_library = database.kinetics.libraries[library_name]

    reaction_list = []
    for index, entry in kinetic_library.entries.items():
        reaction = entry.item
        reaction.kinetics = entry.data
        library_reaction = LibraryReaction(index=reaction.index,
                                           reactants=reaction.reactants,
                                           products=reaction.products,
                                           reversible=reaction.reversible,
                                           kinetics=reaction.kinetics,
                                           library=library_name)
        reaction_list.append(library_reaction)

    species_list = []
    index = 0
    species_dict = kinetic_library.get_species(
        os.path.join(settings['database.directory'], 'kinetics', 'libraries',
                     library_name, 'dictionary.txt'))
    for spec in list(species_dict.values()):
        index = index + 1
        species = Species(molecule=spec.molecule)
        species.get_thermo_data()
        species.index = index
        species_list.append(species)