Represent a reaction model constructed using a rate-based screening algorithm. The species and reactions in the model itself are called the core; the species and reactions identified as candidates for inclusion in the model are called the edge. The attributes are:
|core||The species and reactions of the current model core|
|edge||The species and reactions of the current model edge|
|networkDict||A dictionary of pressure-dependent reaction networks (
|networkList||A list of pressure-dependent reaction networks (
|networkCount||A counter for the number of pressure-dependent networks created|
|indexSpeciesDict||A dictionary with a unique index pointing to the species objects|
Add all species and reactions from reactionLibrary, a
KineticsPrimaryDatabase object, to the model edge.
Add all species and reactions from reactionLibrary, a
KineticsPrimaryDatabase object, to the output.
This does not bring any of the reactions or species into the core itself.
Add a reaction rxn to the reaction model core (and remove from edge if necessary). This function assumes rxn has already been checked to ensure it is supposed to be a core reaction (i.e. all of its reactants AND all of its products are in the list of core species).
Add a reaction rxn to the reaction model edge. This function assumes rxn has already been checked to ensure it is supposed to be an edge reaction (i.e. all of its reactants OR all of its products are in the list of core species, and the others are in either the core or the edge).
addReactionToUnimolecularNetworks(newReaction, newSpecies, network=None)¶
Given a newly-created
Reaction object newReaction, update the
corresponding unimolecular reaction network. If no network exists, a new
one is created. If the new reaction is an isomerization that connects two
existing networks, the two networks are merged. This function is called
whenever a new high-pressure limit edge reaction is created. Returns the
network containing the new reaction.
Add all species and reactions from seedMechanism, a
KineticsPrimaryDatabase object, to the model core. If react
True, then reactions will also be generated between the seed
species. For large seed mechanisms this can be prohibitively expensive,
so it is not done by default.
Add a species spec to the reaction model core (and remove from edge if necessary). This function also moves any reactions in the edge that gain core status as a result of this change in status to the core. If this are any such reactions, they are returned in a list.
Add a species spec to the reaction model edge.
Check to see if an existing reaction has the same reactants, products, and
family as rxn. Returns
False and the matched
reaction (if found).
First, a shortlist of reaction is retrieved that have the same reaction keys as the parameter reaction.
Next, the reaction ID containing an identifier (e.g. label) of the reactants and products is compared between the parameter reaction and the each of the reactions in the shortlist. If a match is found, the discovered reaction is returned.
If a match is not yet found, the Library (seed mechs, reaction libs) in the reaction database are iterated over to check if a reaction was overlooked (a reaction with a different “family” key as the parameter reaction).
Check to see if an existing species contains the same
molecule.Molecule as molecule. Returns
and the matched species (if found) or
None (if not found).
enlarge(newObject=None, reactEdge=False, unimolecularReact=None, bimolecularReact=None)¶
Enlarge a reaction model by processing the objects in the list newObject.
If newObject is a
rmg.species.Species object, then the species is moved from
the edge to the core and reactions generated for that species, reacting
with itself and with all other species in the model core. If newObject
rmg.unirxn.network.Network object, then reactions are
generated for the species in the network with the largest leak flux.
If the reactEdge flag is True, then no newObject is needed, and instead the algorithm proceeds to react the core species together to form edge reactions.
Generate best possible kinetics for the given reaction using the kinetics database.
Return lists of all of the species and reactions in the core and the edge.
Return the numbers of species and reactions in the model core and edge. Note that this is not necessarily equal to the lengths of the corresponding species and reaction lists.
Retrieve species object, by polling the index species dictionary.
Return the stoichiometry matrix for all generated species and reactions. The id of each species and reaction is the corresponding row and column, respectively, in the matrix.
Convert reactions from reactants/products that are referring to the core species index, to the respective Species objects.
Populates the core species dictionary
integer -> core Species
with the species that are currently in the core.
Make a new pressure-dependent reaction based on a list of reactants and a list of products. The reaction belongs to the specified network and has pressure-dependent kinetics given by kinetics.
No checking for existing reactions is made here. The returned PDepReaction object is not added to the global list of reactions, as that is intended to represent only the high-pressure-limit set. The reactionCounter is incremented, however, since the returned reaction can and will exist in the model edge and/or core.
Make a new reaction given a
Reaction object forward.
The reaction is added to the global list of reactions.
Returns the reaction in the direction that corresponds to the
estimated kinetics, along with whether or not the reaction is new to the
global reaction list.
The forward direction is determined using the “is_reverse” attribute of the reaction’s family. If the reaction family is its own reverse, then it is made such that the forward reaction is exothermic at 298K.
The forward reaction is appended to self.newReactionList if it is new.
makeNewSpecies(object, label='', reactive=True, checkForExisting=True)¶
Formally create a new species from the specified object, which can be
Molecule object or an
Check that all reactions that will appear the chemkin output have been checked as duplicates.
Call this if you’ve done something that may have introduced undetected duplicate reactions,
like add a reaction library or seed mechanism.
Anything added via the
expand() method should already be detected.
printEnlargeSummary(newCoreSpecies, newCoreReactions, newEdgeSpecies, newEdgeReactions, reactionsMovedFromEdge=None, reactEdge=False)¶
Output a summary of a model enlargement step to the log. The details of the enlargement are passed in the newCoreSpecies, newCoreReactions, newEdgeSpecies, and newEdgeReactions objects.
processNewReactions(newReactions, newSpecies, pdepNetwork=None)¶
Process a list of newly-generated reactions involving the new core species or explored isomer newSpecies in network pdepNetwork.
Makes a reaction and decides where to put it: core, edge, or PDepNetwork.
prune(reactionSystems, toleranceKeepInEdge, maximumEdgeSpecies, minSpeciesExistIterationsForPrune)¶
Remove species from the model edge based on the simulation results from the list of reactionSystems.
Adds the reaction to the reaction database.
The reaction database is structured as a multi-level dictionary, for efficient search and retrieval of existing reactions.
The database has two types of dictionary keys: - reaction family - reactant(s) keys
First, the keys are generated for the parameter reaction.
Next, it is checked whether the reaction database already contains similar keys. If not, a new container is created, either a dictionary for the family key and first reactant key, or a list for the second reactant key.
Finally, the reaction is inserted as the first element in the list.
Remove species spec from the reaction model edge.
retrieve(family_label, key1, key2)¶
Returns a list of reactions from the reaction database with the same keys as the parameters.
Returns an empty list when one of the keys could not be found.
Searches for the first reactant or product in the deflated reaction that is represented by an integer.
Such an object refers to a core species that was used to generate the reaction in the first place. Reactants or products represented by an object that is not an integer will be a newly-generated structure.
Searches through the reaction database for reactions with an identical reaction key as the key of the parameter reaction.
Both the reaction key based on the reactants as well as on the products is used to search for possible candidate reactions.
Iterate through all of the currently-existing unimolecular reaction networks, updating those that have been marked as invalid. In each update, the phenomonological rate coefficients \(k(T,P)\) are computed for each net reaction in the network, and the resulting reactions added or updated.