Exemple #1
0
    def testRestartFileGenerationAndParsing(self):

        # react
        spc1 = Species().fromSMILES("[H]")
        spc2 = Species().fromSMILES("C=C=C=O")

        self.rmg.reactionModel.core.species.append(spc1)
        self.rmg.reactionModel.core.species.append(spc2)

        newReactions = []
        newReactions.extend(react((spc1, spc2)))

        # process newly generated reactions to make sure no duplicated reactions
        self.rmg.reactionModel.processNewReactions(newReactions, spc2, None)

        # save restart file
        restart_folder = os.path.join(os.path.dirname(rmgpy.__file__),
                                      'rmg/test_data/restartFile')
        if not os.path.exists(restart_folder):
            os.mkdir(restart_folder)

        restart_path = os.path.join(restart_folder, 'restart.pkl')
        saveRestartFile(restart_path, self.rmg)

        # load the generated restart file
        rmg_load = RMG()
        rmg_load.loadRestartFile(restart_path)

        core_species_num_orig = len(self.rmg.reactionModel.core.species)
        core_rxn_num_orig = len(self.rmg.reactionModel.core.reactions)
        core_species_num_load = len(rmg_load.reactionModel.core.species)
        core_rxn_num_load = len(rmg_load.reactionModel.core.reactions)

        edge_species_num_orig = len(self.rmg.reactionModel.edge.species)
        edge_rxn_num_orig = len(self.rmg.reactionModel.edge.reactions)
        edge_species_num_load = len(rmg_load.reactionModel.edge.species)
        edge_rxn_num_load = len(rmg_load.reactionModel.edge.reactions)

        self.assertEqual(core_species_num_orig, core_species_num_load)
        self.assertEqual(core_rxn_num_orig, core_rxn_num_load)

        self.assertEqual(edge_species_num_orig, edge_species_num_load)
        self.assertEqual(edge_rxn_num_orig, edge_rxn_num_load)

        import shutil
        shutil.rmtree(restart_folder)
Exemple #2
0
    def testRestartFileGenerationAndParsing(self):
        
        # react
        spc1 = Species().fromSMILES("[H]")
        spc2 = Species().fromSMILES("C=C=C=O")

        self.rmg.reactionModel.core.species.append(spc1)
        self.rmg.reactionModel.core.species.append(spc2)

        newReactions = []
        newReactions.extend(react((spc1,spc2)))

        # process newly generated reactions to make sure no duplicated reactions
        self.rmg.reactionModel.processNewReactions(newReactions, spc2, None)

        # save restart file
        restart_folder = os.path.join(os.path.dirname(rmgpy.__file__),'rmg/test_data/restartFile')
        if not os.path.exists(restart_folder):
            os.mkdir(restart_folder)

        restart_path = os.path.join(restart_folder, 'restart.pkl')
        saveRestartFile(restart_path, self.rmg)

        # load the generated restart file
        rmg_load = RMG()
        rmg_load.loadRestartFile(restart_path)

        core_species_num_orig = len(self.rmg.reactionModel.core.species)
        core_rxn_num_orig = len(self.rmg.reactionModel.core.reactions)
        core_species_num_load = len(rmg_load.reactionModel.core.species)
        core_rxn_num_load = len(rmg_load.reactionModel.core.reactions)

        edge_species_num_orig = len(self.rmg.reactionModel.edge.species)
        edge_rxn_num_orig = len(self.rmg.reactionModel.edge.reactions)
        edge_species_num_load = len(rmg_load.reactionModel.edge.species)
        edge_rxn_num_load = len(rmg_load.reactionModel.edge.reactions)

        self.assertEqual(core_species_num_orig, core_species_num_load)
        self.assertEqual(core_rxn_num_orig, core_rxn_num_load)

        self.assertEqual(edge_species_num_orig, edge_species_num_load)
        self.assertEqual(edge_rxn_num_orig, edge_rxn_num_load)

        import shutil
        shutil.rmtree(restart_folder)