Esempio n. 1
0
    def testSulfurConstraint(self):
        """
        Test that we can constrain the max number of sulfur atoms.
        """
        mol1 = Molecule(SMILES='CS')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='SCS')
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 2
0
    def testCarbonConstraint(self):
        """
        Test that we can constrain the max number of carbon atoms.
        """
        mol1 = Molecule(SMILES='CC')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='CCC')
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 3
0
    def testCarbonConstraint(self):
        """
        Test that we can constrain the max number of carbon atoms.
        """
        mol1 = Molecule(SMILES='CC')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='CCC')
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 4
0
    def testSiliconConstraint(self):
        """
        Test that we can constrain the max number of silicon atoms.
        """
        mol1 = Molecule(SMILES='[SiH4]')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='[SiH3][SiH3]')
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 5
0
    def testRadicalConstraint(self):
        """
        Test that we can constrain the max number of radical electrons.
        """
        mol1 = Molecule(SMILES='[CH2][CH2]')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='[CH2][CH][CH2]')
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 6
0
    def testHeavyConstraint(self):
        """
        Test that we can constrain the max number of heavy atoms.
        """
        mol1 = Molecule(SMILES='CCO')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='CCN=O')
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 7
0
    def testHeavyConstraint(self):
        """
        Test that we can constrain the max number of heavy atoms.
        """
        mol1 = Molecule(SMILES='CCO')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='CCN=O')
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 8
0
    def testRadicalConstraint(self):
        """
        Test that we can constrain the max number of radical electrons.
        """
        mol1 = Molecule(SMILES='[CH2][CH2]')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='[CH2][CH][CH2]')
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 9
0
    def testSulfurConstraint(self):
        """
        Test that we can constrain the max number of sulfur atoms.
        """
        mol1 = Molecule(SMILES='CS')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='SCS')
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 10
0
    def testSiliconConstraint(self):
        """
        Test that we can constrain the max number of silicon atoms.
        """
        mol1 = Molecule(SMILES='[SiH4]')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='[SiH3][SiH3]')
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 11
0
    def testNitrogenConstraint(self):
        """
        Test that we can constrain the max number of nitrogen atoms.
        """
        mol1 = Molecule(SMILES='CN')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='NCN')
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 12
0
    def testNitrogenConstraint(self):
        """
        Test that we can constrain the max number of nitrogen atoms.
        """
        mol1 = Molecule(SMILES='CN')
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule(SMILES='NCN')
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 13
0
    def testExplicitlyAllowedMolecules(self):
        """
        Test that we can explicitly allow molecules in species constraints.
        """
        mol = Molecule(SMILES='CCCC')
        self.assertTrue(failsSpeciesConstraints(mol))

        self.rmg.speciesConstraints['explicitlyAllowedMolecules'] = [Molecule(SMILES='CCCC')]
        self.assertFalse(failsSpeciesConstraints(mol))
Esempio n. 14
0
    def testExplicitlyAllowedMolecules(self):
        """
        Test that we can explicitly allow molecules in species constraints.
        """
        mol = Molecule(SMILES='CCCC')
        self.assertTrue(failsSpeciesConstraints(mol))

        self.rmg.speciesConstraints['explicitlyAllowedMolecules'] = [
            Molecule(SMILES='CCCC')
        ]
        self.assertFalse(failsSpeciesConstraints(mol))
Esempio n. 15
0
    def testSpeciesInput(self):
        """
        Test that failsSpeciesConstraints can handle a Species object.
        """
        spc = Species().fromSMILES('C')

        self.assertFalse(failsSpeciesConstraints(spc))
Esempio n. 16
0
    def testSpeciesInput(self):
        """
        Test that failsSpeciesConstraints can handle a Species object.
        """
        spc = Species().fromSMILES('C')

        self.assertFalse(failsSpeciesConstraints(spc))
Esempio n. 17
0
    def testCarbeneConstraint(self):
        """
        Test that we can constrain the max number of singlet carbenes.
        """
        mol1 = Molecule().fromAdjacencyList("""
1 C u0 p1 c0 {2,S} {3,S}
2 H u0 p0 c0 {1,S}
3 H u0 p0 c0 {1,S}
""")
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule().fromAdjacencyList("""
1 C u0 p1 c0 {2,S} {3,S}
2 H u0 p0 c0 {1,S}
3 C u0 p1 c0 {1,S} {4,S}
4 H u0 p0 c0 {3,S}
""")
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 18
0
    def testCarbeneConstraint(self):
        """
        Test that we can constrain the max number of singlet carbenes.
        """
        mol1 = Molecule().fromAdjacencyList("""
1 C u0 p1 c0 {2,S} {3,S}
2 H u0 p0 c0 {1,S}
3 H u0 p0 c0 {1,S}
""")
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule().fromAdjacencyList("""
1 C u0 p1 c0 {2,S} {3,S}
2 H u0 p0 c0 {1,S}
3 C u0 p1 c0 {1,S} {4,S}
4 H u0 p0 c0 {3,S}
""")
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 19
0
    def testCarbeneRadicalConstraint(self):
        """
        Test that we can constrain the max number of radical electrons with a carbene.
        """
        mol1 = Molecule().fromAdjacencyList("""
1 C u0 p1 c0 {2,S} {3,S}
2 H u0 p0 c0 {1,S}
3 H u0 p0 c0 {1,S}
""")
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule().fromAdjacencyList("""
1 C u0 p1 c0 {2,S} {3,S}
2 H u0 p0 c0 {1,S}
3 C u1 p0 c0 {1,S} {4,S} {5,S}
4 H u0 p0 c0 {3,S}
5 H u0 p0 c0 {3,S}
""")
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 20
0
    def testCarbeneRadicalConstraint(self):
        """
        Test that we can constrain the max number of radical electrons with a carbene.
        """
        mol1 = Molecule().fromAdjacencyList("""
1 C u0 p1 c0 {2,S} {3,S}
2 H u0 p0 c0 {1,S}
3 H u0 p0 c0 {1,S}
""")
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule().fromAdjacencyList("""
1 C u0 p1 c0 {2,S} {3,S}
2 H u0 p0 c0 {1,S}
3 C u1 p0 c0 {1,S} {4,S} {5,S}
4 H u0 p0 c0 {3,S}
5 H u0 p0 c0 {3,S}
""")
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 21
0
    def testIsotopeConstraint(self):
        """
        Test that we can constrain the max number of isotopic atoms.
        """
        mol1 = Molecule().fromAdjacencyList("""
1 C u0 p0 c0 {2,S} {3,S} {4,S} {5,S}
2 D u0 p0 c0 {1,S}
3 D u0 p0 c0 {1,S}
4 H u0 p0 c0 {1,S}
5 H u0 p0 c0 {1,S}
""")
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule().fromAdjacencyList("""
1 C u0 p0 c0 {2,S} {3,S} {4,S} {5,S}
2 D u0 p0 c0 {1,S}
3 D u0 p0 c0 {1,S}
4 D u0 p0 c0 {1,S}
5 H u0 p0 c0 {1,S}
""")
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 22
0
    def testIsotopeConstraint(self):
        """
        Test that we can constrain the max number of isotopic atoms.
        """
        mol1 = Molecule().fromAdjacencyList("""
1 C u0 p0 c0 {2,S} {3,S} {4,S} {5,S}
2 D u0 p0 c0 {1,S}
3 D u0 p0 c0 {1,S}
4 H u0 p0 c0 {1,S}
5 H u0 p0 c0 {1,S}
""")
        self.assertFalse(failsSpeciesConstraints(mol1))

        mol2 = Molecule().fromAdjacencyList("""
1 C u0 p0 c0 {2,S} {3,S} {4,S} {5,S}
2 D u0 p0 c0 {1,S}
3 D u0 p0 c0 {1,S}
4 D u0 p0 c0 {1,S}
5 H u0 p0 c0 {1,S}
""")
        self.assertTrue(failsSpeciesConstraints(mol2))
Esempio n. 23
0
    def testConstraintsNotLoaded(self, mock_logging):
        """
        Test what happens when constraints are not loaded.
        """
        # Reset module level rmg variable in rmgpy.rmg.input
        rmgpy.rmg.input.rmg = None

        mol = Molecule(SMILES='C')

        self.assertFalse(failsSpeciesConstraints(mol))

        mock_logging.debug.assert_called_with('Species constraints could not be found.')

        # Restore module level rmg variable in rmgpy.rmg.input
        rmgpy.rmg.input.rmg = self.rmg
Esempio n. 24
0
    def testConstraintsNotLoaded(self, mock_logging):
        """
        Test what happens when constraints are not loaded.
        """
        # Reset module level rmg variable in rmgpy.rmg.input
        rmgpy.rmg.input.rmg = None

        mol = Molecule(SMILES='C')

        self.assertFalse(failsSpeciesConstraints(mol))

        mock_logging.debug.assert_called_with(
            'Species constraints could not be found.')

        # Restore module level rmg variable in rmgpy.rmg.input
        rmgpy.rmg.input.rmg = self.rmg