Exemple #1
0
 def test_solid_angle(self):
     self.nn.targets = None
     for n in range(len(self.s)):
         angle = 0
         for nn in self.nn.get_voronoi_polyhedra(self.s, n).values():
             angle += nn['solid_angle']
         self.assertAlmostEqual(4 * np.pi, angle)
     self.assertEqual(solid_angle([0,0,0], [[1,0,0],[-1,0,0],[0,1,0]]), pi)
Exemple #2
0
 def test_solid_angle(self):
     self.nn.targets = None
     for n in range(len(self.s)):
         angle = 0
         for nn in self.nn.get_voronoi_polyhedra(self.s, n).values():
             angle += nn['solid_angle']
         self.assertAlmostEqual(4 * np.pi, angle)
     self.assertEqual(solid_angle([0, 0, 0], [[1, 0, 0], [-1, 0, 0], [0, 1, 0]]), pi)
Exemple #3
0
    def analyze_vol_interstice(center_coords, nn_coords, center_r,
                               nn_rs, convex_hull_simplices):
        """Analyze the volume interstices in the tetrahedra formed by center
        atom and neighbor convex hull triplets.
        Args:
            center_coords ([float]): Central atomic coordinates.
            nn_coords (array-like, shape (N, 3)): Nearest Neighbors' coordinates
            center_r (float): central atom's radius.
            nn_rs ([float]): Nearest Neighbors' radii.
            convex_hull_simplices (array-like, shape (M, 3)): Indices of points
                forming the simplicial facets of convex hull.
        Returns:
            volume_interstice_list ([float]): Volume interstice list.
        """
        volume_interstice_list = list()

        triplet_set = [(0, 1, 2), (1, 0, 2), (2, 0, 1)]
        for facet_indices in convex_hull_simplices:
            facet_coords = nn_coords[facet_indices]
            facet_rs = nn_rs[facet_indices]
            solid_angles = list()
            for triplet in triplet_set:
                s_a = solid_angle(facet_coords[triplet[0]],
                                  np.array([facet_coords[triplet[1]],
                                            facet_coords[triplet[2]],
                                            center_coords]))
                solid_angles.append(s_a)

            # calculate neighbors' packed volume in the tetrahedron
            packed_volume = 0
            for s_a, nn_r in zip(solid_angles, facet_rs):
                packed_volume += s_a / 3 * pow(nn_r, 3)

            # add center atom's volume in the tetrahedron
            center_solid_angle = solid_angle(center_coords, facet_coords)
            packed_volume += center_solid_angle / 3 * pow(center_r, 3)

            volume = vol_tetra(center_coords, *facet_coords)

            volume_interstice = 1 - packed_volume / volume
            volume_interstice_list.append(volume_interstice
                                          if volume_interstice > 0 else 0)
        return volume_interstice_list