def createOutput(self): """ Generate output html file from the path containing chemkin and dictionary files. """ import rmgpy.tools.generate_reactions as generate_reactions inputFile = self.input output_directory = self.getDirname() generate_reactions.execute(inputFile, output_directory)
def createOutput(self): """ Generate output html file from the path containing chemkin and dictionary files. """ import rmgpy.tools.generate_reactions as generate_reactions from rmgpy.rmg.main import initializeLog, RMG from rmgpy.chemkin import ChemkinWriter from rmgpy.rmg.output import OutputHTMLWriter inputFile = self.input output_directory = self.getDirname() rmg = RMG() # Add output listeners: rmg.attach(ChemkinWriter(output_directory)) rmg.attach(OutputHTMLWriter(output_directory)) generate_reactions.execute(rmg, inputFile, output_directory)
def test(self): folder = os.path.join(os.path.dirname(rmgpy.__file__), 'tools/data/generate') input_file = os.path.join(folder, 'input.py') rmg = RMG(input_file=input_file, output_directory=folder) rmg = execute(rmg) self.assertIsNotNone(rmg) self.assertIsNotNone(rmg.reaction_model.output_species_list) self.assertIsNotNone(rmg.reaction_model.output_reaction_list) shutil.rmtree(os.path.join(folder, 'pdep'))
def test_library_reaction_enters_core(self): """ Test that a reaction from a Reaction Library enters the core right after the initialization step if all the input species are present in that reaction. The following reaction from the Methylformate library HCjO + CH2O <=> Fmoml should appear in the model if HCjO, CH2O and Fmoml are all used as input species """ from rmgpy.reaction import Reaction from rmgpy.molecule import Molecule folder = os.path.join(os.path.dirname(rmgpy.__file__), 'tools/data/generate/libraryReaction') input_file = os.path.join(folder, 'input.py') rmg = RMG(input_file=input_file, output_directory=folder) rmg = execute(rmg) self.assertIsNotNone(rmg) # Assert that the flagged reaction occurs rxn_flagged = Reaction( reactants=[Molecule(smiles='[CH]=O'), Molecule(smiles='C=O')], products=[Molecule(smiles='[CH2]OC=O')]) count = 0 for reaction in rmg.reaction_model.core.reactions: if reaction.is_isomorphic(rxn_flagged): count += 1 self.assertEquals(count, 1) # Assert that the core only has 1 reaction self.assertEquals(len(rmg.reaction_model.core.reactions), 1) shutil.rmtree(os.path.join(folder, 'pdep'))
def test_duplicate_reaction(self): """ Test that the radical addition reaction HCJ=O + CH2O = [CH2]OC=O present in the reaction library "Methylformate", only appears once in the model. """ from rmgpy.reaction import Reaction from rmgpy.molecule import Molecule folder = os.path.join(os.path.dirname(rmgpy.__file__), 'tools/data/generate/duplicates') input_file = os.path.join(folder, 'input.py') rmg = RMG(input_file=input_file, output_directory=folder) rmg = execute(rmg) self.assertIsNotNone(rmg) rxn_flagged = Reaction( reactants=[Molecule(smiles='[CH]=O'), Molecule(smiles='C=O')], products=[Molecule(smiles='[CH2]OC=O')]) count = 0 for reaction in rmg.reaction_model.core.reactions: if reaction.is_isomorphic(rxn_flagged): count += 1 self.assertEquals(count, 1) shutil.rmtree(os.path.join(folder, 'pdep'))