def kinetics_checkChildParentRelationships(self, family_name): """ This test checks that groups' parent-child relationships are correct in the database. """ from rmgpy.data.base import Database originalFamily = self.database.kinetics.families[family_name] family = Database() family.entries = originalFamily.groups.entries for nodeName, childNode in family.entries.iteritems(): #top nodes and product nodes don't have parents by definition, so they get an automatic pass: if childNode in originalFamily.groups.top or childNode in originalFamily.forwardTemplate.products: continue parentNode = childNode.parent # Check whether the node has proper parents unless it is the top reactant or product node # The parent should be more general than the child nose.tools.assert_true( family.matchNodeToChild(parentNode, childNode), "In {family} family, group {parent} is not a proper parent of its child {child}." .format(family=family_name, parent=parentNode, child=nodeName)) #check that parentNodes which are LogicOr do not have an ancestor that is a Group #If it does, then the childNode must also be a child of the ancestor if isinstance(parentNode, LogicOr): ancestorNode = childNode while ancestorNode not in originalFamily.groups.top and isinstance( ancestorNode, LogicOr): ancestorNode = ancestorNode.parent if isinstance(ancestorNode, Group): nose.tools.assert_true( family.matchNodeToChild(ancestorNode, childNode), "In {family} family, group {ancestor} is not a proper ancestor of its child {child}." .format(family=family_name, ancestor=ancestorNode, child=nodeName))
def kinetics_checkSiblingsForParents(self, family_name): """ This test checks that siblings in a tree are not actually parent/child """ from rmgpy.data.base import Database originalFamily = self.database.kinetics.families[family_name] family = Database() family.entries = originalFamily.groups.entries for nodeName, node in family.entries.iteritems(): #Some families also construct a 2-level trees for the products #(root with all entries down one level) We don't care about this #tree as it is not used in searching, so we ignore products if node in originalFamily.forwardTemplate.products: continue for index, child1 in enumerate(node.children): for child2 in node.children[index + 1:]: #Don't check a node against itself if child1 is child2: continue nose.tools.assert_false( family.matchNodeToChild(child1, child2), "In family {0}, node {1} is written as a sibling of {2}, when it is actually a parent." .format(family_name, child1, child2)) nose.tools.assert_false( family.matchNodeToChild(child2, child1), "In family {0}, node {1} is written as a sibling of {2}, when it is actually a parent." .format(family_name, child2, child1))
def apply_LSRs(self, delta_atomic_adsoprtion_energies): self.rmg_spcs = Database().get_species(self.dictionary_filename, resonance=False) for species in self.surf.species(): rmg_spcs = self.rmg_spcs[species.name] self._correct_binding_energy(rmg_spcs, delta_atomic_adsoprtion_energies, False)
def kinetics_checkGroupsNonidentical(self, family_name): """ This test checks that the groups are non-identical. """ from rmgpy.data.base import Database originalFamily = self.database.kinetics.families[family_name] family = Database() family.entries = originalFamily.groups.entries entriesCopy = copy(family.entries) for nodeName, nodeGroup in family.entries.iteritems(): del entriesCopy[nodeName] for nodeNameOther, nodeGroupOther in entriesCopy.iteritems(): nose.tools.assert_false(family.matchNodeToNode(nodeGroup, nodeGroupOther), "Group {group} in {family} family was found to be identical to group {groupOther}".format(group=nodeName, family=family_name, groupOther=nodeNameOther))
def save_pictures(git_path="", species_path="", overwrite=False): """ Save a folder full of molecule pictures, needed for the pretty dot files. Saves them in the results directory, in a subfolder "species_pictures". Unless you set overwrite=True, it'll leave alone files that are already there. """ dictionary_filename = git_path + "/base/chemkin/species_dictionary.txt" specs = Database().get_species(dictionary_filename, resonance=False) images_dir = os.path.join(species_path) os.makedirs(images_dir, exist_ok=True) for name, species in specs.items(): filepath = os.path.join(images_dir, name + ".png") if not overwrite and os.path.exists(filepath): continue species.molecule[0].draw(filepath)
self.delEa = delEa self.A = A self.n = n self.Ea_old = Ea_old self.Ea_new = Ea_new def setParam(self, A, n, Ea): self.A = A self.n = n self.Ea_old = Ea def setModEa(self, Ea): self.Ea_new = Ea database = Database() species_dict = database.getSpecies( '/home/slakman.b/Code/mech_C8_EF_paper/V3/RMG_Dictionary.txt') reaction_list = [] family_list = ['H_Abstraction', 'intra_H_migration'] with open('/home/slakman.b/Code/mech_C8_EF_paper/V3/chem.inp', 'r') as mech_file: for line in mech_file: if line.strip().startswith('REACTIONS'): break for line in mech_file: if line.strip().startswith('!'): break if 'H_Abstraction' in line or 'intra_H_migration' in line: reaction_list.append(line.strip())
def setUp(self): """ A function run before each unit test in this class. """ # Set up a dummy database self.database = Database()