示例#1
0
 def _has_mesh_symmetry(self):
     if self._rotations is None:
         return False
     m = self._mesh
     mesh_equiv = [m[1] == m[2], m[2] == m[0], m[0] == m[1]]
     lattice_equiv = get_lattice_vector_equivalence(
         [r.T for r in self._rotations])
     return np.extract(lattice_equiv, mesh_equiv).all()
示例#2
0
 def _has_mesh_symmetry(self):
     if self._rotations is None:
         return False
     m = self._mesh
     mesh_equiv = [m[1] == m[2], m[2] == m[0], m[0] == m[1]]
     lattice_equiv = get_lattice_vector_equivalence(
         [r.T for r in self._rotations])
     return np.extract(lattice_equiv, mesh_equiv).all()
示例#3
0
文件: mesh.py 项目: atztogo/phonopy
def length2mesh(length, lattice, rotations=None):
    """Convert length to mesh for q-point sampling

    This conversion for each reciprocal axis follows VASP convention by
        N = max(1, int(l * |a|^* + 0.5))
    'int' means rounding down, not rounding to nearest integer.

    Parameters
    ----------
    length : float
        Length having the unit of direct space length.
    lattice : array_like
        Basis vectors of primitive cell in row vectors.
        dtype='double', shape=(3, 3)
    rotations: array_like, optional
        Rotation matrices in real space. When given, mesh numbers that are
        symmetrically reasonable are returned. Default is None.
        dtype='intc', shape=(rotations, 3, 3)

    Returns
    -------
    array_like
        dtype=int, shape=(3,)

    """

    rec_lattice = np.linalg.inv(lattice)
    rec_lat_lengths = np.sqrt(np.diagonal(np.dot(rec_lattice.T, rec_lattice)))
    mesh_numbers = np.rint(rec_lat_lengths * length).astype(int)

    if rotations is not None:
        reclat_equiv = get_lattice_vector_equivalence(
            [r.T for r in np.array(rotations)])
        m = mesh_numbers
        mesh_equiv = [m[1] == m[2], m[2] == m[0], m[0] == m[1]]
        for i, pair in enumerate(([1, 2], [2, 0], [0, 1])):
            if reclat_equiv[i] and not mesh_equiv:
                m[pair] = max(m[pair])

    return np.maximum(mesh_numbers, [1, 1, 1])
示例#4
0
def length2mesh(length, lattice, rotations=None):
    """Convert length to mesh for q-point sampling

    This conversion for each reciprocal axis follows VASP convention by
        N = max(1, int(l * |a|^* + 0.5))
    'int' means rounding down, not rounding to nearest integer.

    Parameters
    ----------
    length : float
        Length having the unit of direct space length.
    lattice : array_like
        Basis vectors of primitive cell in row vectors.
        dtype='double', shape=(3, 3)
    rotations: array_like, optional
        Rotation matrices in real space. When given, mesh numbers that are
        symmetrically reasonable are returned. Default is None.
        dtype='intc', shape=(rotations, 3, 3)

    Returns
    -------
    array_like
        dtype=int, shape=(3,)

    """

    rec_lattice = np.linalg.inv(lattice)
    rec_lat_lengths = np.sqrt(np.diagonal(np.dot(rec_lattice.T, rec_lattice)))
    mesh_numbers = np.rint(rec_lat_lengths * length).astype(int)

    if rotations is not None:
        reclat_equiv = get_lattice_vector_equivalence(
            [r.T for r in np.array(rotations)])
        m = mesh_numbers
        mesh_equiv = [m[1] == m[2], m[2] == m[0], m[0] == m[1]]
        for i, pair in enumerate(([1, 2], [2, 0], [0, 1])):
            if reclat_equiv[i] and not mesh_equiv:
                m[pair] = max(m[pair])

    return np.maximum(mesh_numbers, [1, 1, 1])
示例#5
0
    mapping_table, grid_address = get_ir_reciprocal_mesh(
        mesh,
        cell,
        is_shift=is_shift)
    ir_grid_points = np.unique(mapping_table)
    primitive_vectors = np.linalg.inv(cell.get_cell())
    bz_grid_address, bz_map = relocate_BZ_grid_address(
        grid_address,
        mesh,
        np.linalg.inv(cell.get_cell()),
        is_shift=is_shift)

    bz_points = np.extract(bz_map > -1, bz_map)
    qpoints = (grid_address + is_shift / 2.0) / mesh
    qpoints -= (qpoints > 0.5001) * 1

    bz = BrillouinZone(primitive_vectors)
    bz.run(qpoints)
    sv = bz.get_shortest_qpoints()
    print("%d %d" % (len(bz_points), np.sum(len(x) for x in sv)))
    for q, vs in zip(qpoints, sv):
        if np.allclose(q, vs[0]):
            print(q)
        else:
            print("%s * %s" % (q, np.linalg.norm(np.dot(primitive_vectors, q))))
        for v in vs:
            print("%s %s" % (v, np.linalg.norm(np.dot(primitive_vectors, v))))

    rotations = symmetry.get_reciprocal_operations()
    print(get_lattice_vector_equivalence(rotations))
示例#6
0
    mapping_table, grid_address = get_ir_reciprocal_mesh(
        mesh,
        cell,
        is_shift=is_shift)
    ir_grid_points = np.unique(mapping_table)
    primitive_vectors = np.linalg.inv(cell.get_cell())
    bz_grid_address, bz_map = relocate_BZ_grid_address(
        grid_address,
        mesh,
        np.linalg.inv(cell.get_cell()),
        is_shift=is_shift)

    bz_points = np.extract(bz_map > -1, bz_map)
    qpoints = (grid_address + is_shift / 2.0) / mesh
    qpoints -= (qpoints > 0.5001) * 1

    bz = BrillouinZone(primitive_vectors)
    bz.run(qpoints)
    sv = bz.get_shortest_qpoints()
    print("%d %d" % (len(bz_points), np.sum(len(x) for x in sv)))
    for q, vs in zip(qpoints, sv):
        if np.allclose(q, vs[0]):
            print(q)
        else:
            print("%s * %s" % (q, np.linalg.norm(np.dot(primitive_vectors, q))))
        for v in vs:
            print("%s %s" % (v, np.linalg.norm(np.dot(primitive_vectors, v))))

    rotations = symmetry.get_reciprocal_operations()
    print(get_lattice_vector_equivalence(rotations))