Ejemplo n.º 1
0
 def setUpClass(cls):
     """
     A method that is run before all unit tests in this class.
     """
     cls.maxDiff = None
     cls.rmgdb = rmgdb.make_rmg_database_object()
     rmgdb.load_families_only(cls.rmgdb)
     cls.rxn1 = ARCReaction(reactants=['CH4', 'OH'],
                            products=['CH3', 'H2O'])
     cls.rxn1.rmg_reaction = Reaction(reactants=[
         Species().fromSMILES(str('C')),
         Species().fromSMILES(str('[OH]'))
     ],
                                      products=[
                                          Species().fromSMILES(
                                              str('[CH3]')),
                                          Species().fromSMILES(str('O'))
                                      ])
     cls.rxn2 = ARCReaction(reactants=['C2H5', 'OH'],
                            products=['C2H4', 'H2O'])
     cls.rxn2.rmg_reaction = Reaction(reactants=[
         Species().fromSMILES(str('C[CH2]')),
         Species().fromSMILES(str('[OH]'))
     ],
                                      products=[
                                          Species().fromSMILES(str('C=C')),
                                          Species().fromSMILES(str('O'))
                                      ])
     cls.rxn3 = ARCReaction(reactants=['CH3CH2NH'], products=['CH2CH2NH2'])
     cls.rxn3.rmg_reaction = Reaction(
         reactants=[Species().fromSMILES(str('CC[NH]'))],
         products=[Species().fromSMILES(str('[CH2]CN'))])
Ejemplo n.º 2
0
    def test_determine_family(self):
        """Test the determine_family() function."""
        rxn = ARCReaction(r_species=[ARCSpecies(label='CH2CH2CH3', smiles='[CH2]CC')],
                          p_species=[ARCSpecies(label='CH3CHCH3', smiles='C[CH]C')])
        self.assertIsNone(rxn.family)
        rmgdb.determine_family(rxn, db=None)
        self.assertEqual(rxn.family.label, 'intra_H_migration')

        rxn = ARCReaction(r_species=[ARCSpecies(label='C2H6', smiles='CC'),
                                     ARCSpecies(label='OH', smiles='[OH]')],
                          p_species=[ARCSpecies(label='water', smiles='O'),
                                     ARCSpecies(label='C2H5', smiles='[CH2]C')])
        self.assertIsNone(rxn.family)
        rmgdb.determine_family(rxn, db=self.rmgdb)
        self.assertEqual(rxn.family.label, 'H_Abstraction')

        r_1 = ARCSpecies(label='C3H6O', smiles='CCC=O')
        r_2 = ARCSpecies(label='C4H9O', smiles='[CH2]C(C)CO')
        p_1 = ARCSpecies(label='C3H5O', smiles='CC=C[O]')  # This is the "wrong" resonance structure on purpose.
        p_2 = ARCSpecies(label='C4H10O', smiles='CC(C)CO')
        rxn = ARCReaction(reactants=['C3H6O', 'C4H9O'], products=['C3H5O', 'C4H10O'],
                          r_species=[r_1, r_2], p_species=[p_1, p_2])
        self.assertIsNone(rxn.family)
        rmgdb.determine_family(rxn, db=self.rmgdb)
        self.assertEqual(rxn.family.label, 'H_Abstraction')
Ejemplo n.º 3
0
 def test_rmg_reaction_to_str(self):
     """Test the rmg_reaction_to_str() method and the reaction label generated"""
     spc1 = Species().fromSMILES(str('CON=O'))
     spc1.label = str('CONO')
     spc2 = Species().fromSMILES(str('C[N+](=O)[O-]'))
     spc2.label = str('CNO2')
     rmg_reaction = Reaction(reactants=[spc1], products=[spc2])
     rxn = ARCReaction(rmg_reaction=rmg_reaction)
     rxn_str = rxn.rmg_reaction_to_str()
     self.assertEqual(rxn_str, 'CON=O <=> [O-][N+](=O)C')
     self.assertEqual(rxn.label, 'CONO <=> CNO2')
Ejemplo n.º 4
0
 def test_from_dict(self):
     """Test Species.from_dict()"""
     rxn_dict = self.rxn1.as_dict()
     rxn = ARCReaction(reaction_dict=rxn_dict)
     self.assertEqual(rxn.label, 'CH4 + OH <=> CH3 + H2O')
     self.assertEqual(rxn.ts_methods,
                      [tsm.lower() for tsm in default_ts_methods])