コード例 #1
0
    def test_get_next_nearest_neighbors(self):
        """Check getting next nearest neighbors."""
        sa = SiteAnalyzer(self.tin_dioxide)
        info = sa.get_next_nearest_neighbors(5)

        self.assertEqual(len(info), 14)
        self.assertEqual(info[0]["element"], "O2-")
        self.assertEqual(info[0]["connectivity"], "edge")
        self.assertEqual(info[0]["geometry"]["type"], "trigonal planar")
        self.assertEqual(info[0]["inequiv_index"], 2)

        info = sa.get_next_nearest_neighbors(0,
                                             inc_inequivalent_site_index=False)
        self.assertTrue('inequiv_index' not in info[0])

        info = sa.get_next_nearest_neighbors(0)
        self.assertEqual(info[0]["element"], 'Sn4+')
        self.assertEqual(info[0]["connectivity"], "edge")
        self.assertEqual(info[0]["geometry"]["type"], "octahedral")
        self.assertEqual(len(info[0]['angles']), 2)
        self.assertAlmostEqual(info[0]['angles'][0], 101.62287790513848)

        # check different structure without oxi state
        sa = SiteAnalyzer(self.ba_n)
        info = sa.get_next_nearest_neighbors(0)
        self.assertEqual(len(info), 36)
        self.assertEqual(info[5]["element"], "N")
        self.assertEqual(info[5]["connectivity"], "edge")
        self.assertEqual(info[5]["geometry"]["type"], "6-coordinate")
        self.assertEqual(len(info[5]['angles']), 2)
        self.assertAlmostEqual(info[5]['angles'][0], 83.91397867959587)
コード例 #2
0
    def test_get_next_nearest_neighbors(self):
        """Check getting next nearest neighbors."""
        sa = SiteAnalyzer(self.tin_dioxide)
        info = sa.get_next_nearest_neighbors(5)

        self.assertEqual(len(info), 14)
        idx = [i for i, s in enumerate(info) if s["connectivity"] == "edge"][0]
        self.assertEqual(info[idx]["element"], "O2-")
        self.assertEqual(info[idx]["connectivity"], "edge")
        self.assertEqual(info[idx]["geometry"]["type"], "trigonal planar")
        self.assertEqual(info[idx]["inequiv_index"], 2)

        info = sa.get_next_nearest_neighbors(0, inc_inequivalent_site_index=False)
        self.assertTrue("inequiv_index" not in info[0])

        info = sa.get_next_nearest_neighbors(0)
        self.assertEqual(info[0]["element"], "Sn4+")
        self.assertEqual(info[0]["connectivity"], "edge")
        self.assertEqual(info[0]["geometry"]["type"], "octahedral")
        self.assertEqual(len(info[0]["angles"]), 2)
        self.assertAlmostEqual(info[0]["angles"][0], 101.62287790513848)
        self.assertAlmostEqual(info[0]["distance"], 3.24322132)

        # check different structure without oxi state
        sa = SiteAnalyzer(self.ba_n)
        info = sa.get_next_nearest_neighbors(0)
        self.assertEqual(len(info), 36)
        self.assertEqual(info[5]["element"], "N")
        self.assertEqual(info[5]["connectivity"], "edge")
        self.assertEqual(info[5]["geometry"]["type"], "6-coordinate")
        self.assertEqual(len(info[5]["angles"]), 2)
        self.assertAlmostEqual(info[5]["angles"][0], 83.91397867959587)
        self.assertAlmostEqual(info[5]["distance"], 3.549136232944574)
コード例 #3
0
    def test_nnn_summaries_match(self):
        """Test nearest neighbour summary matching function."""
        sa = SiteAnalyzer(self.ba_n, use_symmetry_equivalent_sites=True)
        nnn_a = sa.get_next_nearest_neighbors(0)
        nnn_b = sa.get_next_nearest_neighbors(3)
        nnn_c = sa.get_next_nearest_neighbors(4)

        self.assertTrue(nnn_summaries_match(nnn_a, nnn_b))
        self.assertFalse(nnn_summaries_match(nnn_a, nnn_c))

        # test not matching bond angles
        self.assertTrue(
            nnn_summaries_match(nnn_a,
                                nnn_b,
                                bond_angle_tol=1e-10,
                                match_bond_angles=False))