rmgpy.data.kinetics.KineticsRules

class rmgpy.data.kinetics.KineticsRules(label='', name='', shortDesc='', longDesc='')

A class for working with a set of “rate rules” for a RMG kinetics family.

ancestors(node)

Returns all the ancestors of a node, climbing up the tree to the top.

areSiblings(node, nodeOther)

Return True if node and nodeOther have the same parent node. Otherwise, return False. Both node and nodeOther must be Entry types with items containing Group or LogicNode types.

calculateNormDistance(template, otherTemplate)

Calculate the norm distance squared between two rate rules with template and otherTemplate. The norm distance is a^2 + b^2 + c^2 .... when a is the distance between the nodes in the first tree, b is the distance between the nodes in the second tree, etc.

descendTree(structure, atoms, root=None, strict=False)

Descend the tree in search of the functional group node that best matches the local structure around atoms in structure.

If root=None then uses the first matching top node.

Returns None if there is no matching root.

Set strict to True if all labels in final matched node must match that of the structure. This is used in kinetics groups to find the correct reaction template, but not generally used in other GAVs due to species generally not being prelabeled.

descendants(node)

Returns all the descendants of a node, climbing down the tree to the bottom.

estimateKinetics(template, degeneracy=1)

Determine the appropriate kinetics for a reaction with the given template using rate rules.

Returns a tuple (kinetics, entry) where entry is the database entry used to determine the kinetics only if it is an exact match, and is None if some averaging or use of a parent node took place.

fillRulesByAveragingUp(rootTemplate, alreadyDone, verbose=False)

Fill in gaps in the kinetics rate rules by averaging child nodes. If verbose is set to True, then exact sources of kinetics are saved in the kinetics comments (warning: this uses up a lot of memory due to the extensively long comments)

generateOldTree(entries, level)

Generate a multi-line string representation of the current tree using the old-style syntax.

getAllRules(template)

Return all of the exact rate rules with the given template. Raises a ValueError if no corresponding entry exists.

getEntries()

Return a list of all of the entries in the rate rules database, sorted by index.

getEntriesToSave()

Return a sorted list of all of the entries in the rate rules database to save.

getRule(template)

Return the exact rate rule with the given template, or None if no corresponding entry exists.

getSpecies(path)

Load the dictionary containing all of the species in a kinetics library or depository.

hasRule(template)

Return True if a rate rule with the given template currently exists, or False otherwise.

load(path, local_context=None, global_context=None)

Load an RMG-style database from the file at location path on disk. The parameters local_context and global_context are used to provide specialized mapping of identifiers in the input file to corresponding functions to evaluate. This method will automatically add a few identifiers required by all data entries, so you don’t need to provide these.

loadOld(path, groups, numLabels)

Load a set of old rate rules for kinetics groups into this depository.

loadOldDictionary(path, pattern)

Parse an old-style RMG database dictionary located at path. An RMG dictionary is a list of key-value pairs of a one-line string key and a multi-line string value. Each record is separated by at least one empty line. Returns a dict object with the values converted to Molecule or Group objects depending on the value of pattern.

loadOldLibrary(path, numParameters, numLabels=1)

Parse an RMG database library located at path.

loadOldTree(path)

Parse an old-style RMG database tree located at path. An RMG tree is an n-ary tree representing the hierarchy of items in the dictionary.

matchNodeToChild(parentNode, childNode)

Return True if parentNode is a parent of childNode. Otherwise, return False. Both parentNode and childNode must be Entry types with items containing Group or LogicNode types. If parentNode and childNode are identical, the function will also return False.

matchNodeToNode(node, nodeOther)

Return True if node and nodeOther are identical. Otherwise, return False. Both node and nodeOther must be Entry types with items containing Group or LogicNode types.

matchNodeToStructure(node, structure, atoms, strict=False)

Return True if the structure centered at atom matches the structure at node in the dictionary. The structure at node should have atoms with the appropriate labels because they are set on loading and never change. However, the atoms in structure may not have the correct labels, hence the atoms parameter. The atoms parameter may include extra labels, and so we only require that every labeled atom in the functional group represented by node has an equivalent labeled atom in structure.

Matching to structure is more strict than to node. All labels in structure must be found in node. However the reverse is not true, unless strict is set to True.

Attribute Description
node Either an Entry or a key in the self.entries dictionary which has a Group or LogicNode as its Entry.item
structure A Group or a Molecule
atoms Dictionary of {label: atom} in the structure. A possible dictionary is the one produced by structure.getLabeledAtoms()
strict If set to True, ensures that all the node’s atomLabels are matched by in the structure
parseOldLibrary(path, numParameters, numLabels=1)

Parse an RMG database library located at path, returning the loaded entries (rather than storing them in the database). This method does not discard duplicate entries.

processOldLibraryEntry(data)

Process a list of parameters data as read from an old-style RMG thermo database, returning the corresponding kinetics object.

removeGroup(groupToRemove)

Removes a group that is in a tree from the database. In addition to deleting from self.entries, it must also update the parent/child relationships

Returns the removed group

save(path)

Save the current database to the file at location path on disk.

saveDictionary(path)

Extract species from all entries associated with a kinetics library or depository and save them to the path given.

saveEntry(f, entry)

Write the given entry in the thermo database to the file object f.

saveOld(path, groups)

Save a set of old rate rules for kinetics groups from this depository.

saveOldDictionary(path)

Save the current database dictionary to a text file using the old-style syntax.

saveOldLibrary(path)

Save the current database library to a text file using the old-style syntax.

saveOldTree(path)

Save the current database tree to a text file using the old-style syntax.