コード例 #1
0
    def test_nn_summaries_match(self):
        """Test nearest neighbour summary matching function."""
        sa = SiteAnalyzer(self.ba_n, use_symmetry_equivalent_sites=True)
        nn_a = sa.get_nearest_neighbors(0)
        nn_b = sa.get_nearest_neighbors(1)
        nn_c = sa.get_nearest_neighbors(4)

        self.assertTrue(nn_summaries_match(nn_a, nn_b))
        self.assertFalse(nn_summaries_match(nn_a, nn_c))

        # test bond dist tol works
        self.assertFalse(nn_summaries_match(nn_a, nn_b, bond_dist_tol=1e-10))

        # test not matching bond dists
        self.assertTrue(
            nn_summaries_match(nn_a, nn_b, bond_dist_tol=1e-10, match_bond_dists=False)
        )
コード例 #2
0
    def test_get_nearest_neighbors(self):
        """Check getting nearest neighbors."""
        sa = SiteAnalyzer(self.tin_dioxide)
        info = sa.get_nearest_neighbors(4)

        self.assertEqual(len(info), 3)
        self.assertEqual(info[0]["element"], "Sn4+")
        self.assertEqual(info[0]["inequiv_index"], 0)
        self.assertAlmostEqual(info[0]["dist"], 2.0922101061490546)

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

        # check different structure without oxi state
        sa = SiteAnalyzer(self.ba_n)
        info = sa.get_nearest_neighbors(0)
        self.assertEqual(len(info), 6)
        self.assertEqual(info[0]["element"], "N")
        self.assertEqual(info[0]["inequiv_index"], 0)
        self.assertAlmostEqual(info[0]["dist"], 1.2619877178483)