Пример #1
0
 def test_qdelaunay(self):
     data = [[0, 0], [-0.5, -0.5], [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5]]
     self.assertEqual(['4', '3 0 1', '0 2 1', '4 0 3', '0 4 2'],
                      qdelaunay("i", data))
     self.assertEqual(qdelaunay("n", data), [
         '4', '4', '-0 -0.8944271909999159 -0.4472135954999579      0',
         '-0.8944271909999159      0 -0.4472135954999579     -0',
         '0.8944271909999159      0 -0.4472135954999579     -0',
         '-0 0.8944271909999159 -0.4472135954999579     -0'
     ])
     self.assertEqual(qdelaunay("i n", data), [
         '4', '3 0 1', '0 2 1', '4 0 3', '0 4 2', '4', '4',
         '-0 -0.8944271909999159 -0.4472135954999579      0',
         '-0.8944271909999159      0 -0.4472135954999579     -0',
         '0.8944271909999159      0 -0.4472135954999579     -0',
         '-0 0.8944271909999159 -0.4472135954999579     -0'
     ])
Пример #2
0
 def test_qdelaunay(self):
     data = [[0,0], [-0.5, -0.5], [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5]]
     self.assertEqual(['4', '3 0 1', '0 2 1', '4 0 3', '0 4 2'],
                      qdelaunay("i", data))
     self.assertEqual(qdelaunay("n", data),
                      ['4', '4',
                       '-0 -0.8944271909999159 -0.4472135954999579      0',
                       '-0.8944271909999159      0 -0.4472135954999579     -0',
                       '0.8944271909999159      0 -0.4472135954999579     -0',
                       '-0 0.8944271909999159 -0.4472135954999579     -0']
     )
     self.assertEqual(qdelaunay("i n", data),
                      ['4', '3 0 1', '0 2 1', '4 0 3', '0 4 2',
                       '4', '4',
                       '-0 -0.8944271909999159 -0.4472135954999579      0',
                       '-0.8944271909999159      0 -0.4472135954999579     -0',
                       '0.8944271909999159      0 -0.4472135954999579     -0',
                       '-0 0.8944271909999159 -0.4472135954999579     -0']
     )
Пример #3
0
    def __init__(self, points, joggle=False):
        """
        Initializes a DelaunayTri from points.

        Args:
            points ([[float]]): All the points as a sequence of sequences.
                e.g., [[-0.5, -0.5], [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5]]
            joggle (bool): Use qhull option to joggle inputs until simplical
                result is obtained instead of merging facets.
        """
        self.points = points
        dim = [len(i) for i in self.points]
        if max(dim) != min(dim):
            raise ValueError("Input points must all have the same dimension!")
        self.dim = dim[0]
        if joggle:
            options = "i QJ"
        else:
            options = "i Qt"
        output = qdelaunay(options, points)
        output.pop(0)
        self.vertices = [[int(i)for i in row.strip().split()] for row in output]
Пример #4
0
 def __init__(self, points, joggle=False):
     """
     Args:
         points:
             All the points as a sequence of sequences. e.g., [[-0.5, -0.5],
             [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5]]
         joggle:
             Use qhull option to joggle inputs until simplical result is 
             obtained instead of merging facets.
     """
     self.points = points
     dim = map(len, self.points)
     if max(dim) != min(dim):
         raise ValueError("Input points must all have the same dimension!")
     self.dim = dim[0]
     if joggle:
         options = "i QJ"
     else:
         options = "i Qt"
     output = qdelaunay(options, points)
     output.pop(0)
     self.vertices = [map(int, row.strip().split()) for row in output]
Пример #5
0
 def __init__(self, points, joggle=False):
     """
     Args:
         points:
             All the points as a sequence of sequences. e.g., [[-0.5, -0.5],
             [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5]]
         joggle:
             Use qhull option to joggle inputs until simplical result is 
             obtained instead of merging facets.
     """
     self.points = points
     dim = map(len, self.points)
     if max(dim) != min(dim):
         raise ValueError("Input points must all have the same dimension!")
     self.dim = dim[0]
     if joggle:
         options = "i QJ"
     else:
         options = "i Qt"
     output = qdelaunay(options, points)
     output.pop(0)
     self.vertices = [map(int, row.strip().split()) for row in output]
Пример #6
0
    def __init__(self, points, joggle=False):
        """
        Initializes a DelaunayTri from points.

        Args:
            points ([[float]]): All the points as a sequence of sequences.
                e.g., [[-0.5, -0.5], [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5]]
            joggle (bool): Use qhull option to joggle inputs until simplical
                result is obtained instead of merging facets.
        """
        self.points = points
        dim = [len(i) for i in self.points]
        if max(dim) != min(dim):
            raise ValueError("Input points must all have the same dimension!")
        self.dim = dim[0]
        if joggle:
            options = "i QJ"
        else:
            options = "i Qt"
        output = qdelaunay(options, points)
        output.pop(0)
        self.vertices = [[int(i) for i in row.strip().split()]
                         for row in output]
Пример #7
0
def triang_inds(pts_w_imgs, gb1_inds, inds_arr):
    """
    Function finds the indices of atoms which make tetrahedrons with at least one GB atom.

    Parameters
    -------------
    pts_w_imgs :
        The position of atoms which are inside the main box and within rCut to the main box.
    gb1_inds :
        Indices of the GB atoms
    inds_arr : 
        The atom indices of the initial unit cell with no replicates.

    Returns
    ------------
    tri_vertices :
        Tetrahedrons with at least one corner in the GB region.
    gb_tri_inds1 :
        The indices of atoms which make tri_vertices tetrahedrons.
    """
    tri_simplices = qdelaunay("i Qt", pts_w_imgs)
    num_tri = int(tri_simplices[0])
    tri_vertices = np.zeros((num_tri, 4), dtype='int')
    for ct1 in range(num_tri):
        tri_vertices[ct1, :] = np.array(
            [int(i) for i in str.split(tri_simplices[ct1 + 1])])

    inds1 = (inds_arr[tri_vertices])
    inds2 = np.copy(inds1)
    inds2.sort(axis=1)
    tarr1 = np.zeros((np.shape(pts_w_imgs)[0], ))
    tarr1[gb1_inds] = 1
    gb_tri_inds = np.where(np.sum(tarr1[tri_vertices], axis=1))[0]
    i1, ia = np.unique(gb_tri_inds, return_index=True, axis=0)
    gb_tri_inds1 = gb_tri_inds[ia]

    return tri_vertices, gb_tri_inds1