コード例 #1
0
ファイル: constraintsTest.py プロジェクト: z5476t4508/RMG-Py
    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))
コード例 #2
0
ファイル: constraintsTest.py プロジェクト: z5476t4508/RMG-Py
    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))
コード例 #3
0
ファイル: constraintsTest.py プロジェクト: cainja/RMG-Py
    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))
コード例 #4
0
ファイル: constraintsTest.py プロジェクト: z5476t4508/RMG-Py
    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))
コード例 #5
0
ファイル: constraintsTest.py プロジェクト: z5476t4508/RMG-Py
    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))
コード例 #6
0
ファイル: constraintsTest.py プロジェクト: z5476t4508/RMG-Py
    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))
コード例 #7
0
ファイル: constraintsTest.py プロジェクト: cainja/RMG-Py
    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))
コード例 #8
0
ファイル: constraintsTest.py プロジェクト: cainja/RMG-Py
    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))
コード例 #9
0
ファイル: constraintsTest.py プロジェクト: cainja/RMG-Py
    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))
コード例 #10
0
ファイル: constraintsTest.py プロジェクト: cainja/RMG-Py
    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))
コード例 #11
0
ファイル: constraintsTest.py プロジェクト: cainja/RMG-Py
    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))
コード例 #12
0
ファイル: constraintsTest.py プロジェクト: z5476t4508/RMG-Py
    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))
コード例 #13
0
ファイル: constraintsTest.py プロジェクト: cainja/RMG-Py
    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))
コード例 #14
0
ファイル: constraintsTest.py プロジェクト: z5476t4508/RMG-Py
    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))
コード例 #15
0
ファイル: constraintsTest.py プロジェクト: cainja/RMG-Py
    def testSpeciesInput(self):
        """
        Test that failsSpeciesConstraints can handle a Species object.
        """
        spc = Species().fromSMILES('C')

        self.assertFalse(failsSpeciesConstraints(spc))
コード例 #16
0
ファイル: constraintsTest.py プロジェクト: z5476t4508/RMG-Py
    def testSpeciesInput(self):
        """
        Test that failsSpeciesConstraints can handle a Species object.
        """
        spc = Species().fromSMILES('C')

        self.assertFalse(failsSpeciesConstraints(spc))
コード例 #17
0
ファイル: constraintsTest.py プロジェクト: z5476t4508/RMG-Py
    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))
コード例 #18
0
ファイル: constraintsTest.py プロジェクト: cainja/RMG-Py
    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))
コード例 #19
0
ファイル: constraintsTest.py プロジェクト: z5476t4508/RMG-Py
    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))
コード例 #20
0
ファイル: constraintsTest.py プロジェクト: cainja/RMG-Py
    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))
コード例 #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))
コード例 #22
0
ファイル: constraintsTest.py プロジェクト: cainja/RMG-Py
    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))
コード例 #23
0
ファイル: constraintsTest.py プロジェクト: cainja/RMG-Py
    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
コード例 #24
0
ファイル: constraintsTest.py プロジェクト: z5476t4508/RMG-Py
    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