Beispiel #1
0
def test_GridPoints_NaCl_with_rotations_fit_BZ(ph_nacl):
    rec_lat = np.linalg.inv(ph_nacl.primitive.cell)
    rotations = ph_nacl.primitive_symmetry.get_pointgroup_operations()
    mesh = [5, 5, 5]
    gpf = GridPoints(mesh, rec_lat, rotations=rotations,
                     fit_in_BZ=False)
    gpt = GridPoints(mesh, rec_lat, rotations=rotations,
                     fit_in_BZ=True)
    np.testing.assert_allclose(
        gpf.qpoints,
        [[0.0, 0.0, 0.0],
         [0.2, 0.0, 0.0],
         [0.4, 0.0, 0.0],
         [0.2, 0.2, 0.0],
         [0.4, 0.2, 0.0],
         [-0.4, 0.2, 0.0],
         [-0.2, 0.2, 0.0],
         [0.4, 0.4, 0.0],
         [-0.4, 0.4, 0.0],
         [-0.4, 0.4, 0.2]], atol=1e-8)
    np.testing.assert_allclose(
        gpt.qpoints,
        [[0.0, 0.0, 0.0],
         [0.2, 0.0, 0.0],
         [0.4, 0.0, 0.0],
         [0.2, 0.2, 0.0],
         [0.4, 0.2, 0.0],
         [-0.4, 0.2, 0.0],
         [-0.2, 0.2, 0.0],
         [0.4, 0.4, 0.0],
         [-0.4, -0.6, 0.0],
         [0.6, 0.4, 0.2]], atol=1e-8)
Beispiel #2
0
    def __init__(
            self,
            dynamical_matrix,
            mesh,
            shift=None,
            is_time_reversal=True,
            is_mesh_symmetry=True,
            with_eigenvectors=False,
            is_gamma_center=False,
            rotations=None,  # Point group operations in real space
            factor=VaspToTHz):
        self._mesh = np.array(mesh, dtype='intc')
        self._with_eigenvectors = with_eigenvectors
        self._factor = factor
        self._cell = dynamical_matrix.get_primitive()
        self._dynamical_matrix = dynamical_matrix

        self._gp = GridPoints(self._mesh,
                              np.linalg.inv(self._cell.get_cell()),
                              q_mesh_shift=shift,
                              is_gamma_center=is_gamma_center,
                              is_time_reversal=(is_time_reversal
                                                and is_mesh_symmetry),
                              rotations=rotations,
                              is_mesh_symmetry=is_mesh_symmetry)

        self._qpoints = self._gp.qpoints
        self._weights = self._gp.weights

        self._frequencies = None
        self._eigenvectors = None

        self._q_count = 0
Beispiel #3
0
def test_GridPoints_NaCl_with_rotations(ph_nacl):
    rec_lat = np.linalg.inv(ph_nacl.primitive.cell)
    rotations = ph_nacl.primitive_symmetry.get_pointgroup_operations()
    gp = GridPoints([4, 4, 4], rec_lat, rotations=rotations)
    np.testing.assert_array_equal(
        gp.ir_grid_points, [0, 1, 2, 5, 6, 7, 10, 27])
    np.testing.assert_array_equal(gp.weights, [1, 8, 4, 6, 24, 12, 3, 6])
    np.testing.assert_array_equal(
        gp.grid_mapping_table,
        [0, 1, 2, 1, 1, 5, 6, 7, 2, 6,
         10, 6, 1, 7, 6, 5, 1, 5, 6, 7,
         5, 1, 7, 6, 6, 7, 6, 27, 7, 6,
         27, 6, 2, 6, 10, 6, 6, 7, 6, 27,
         10, 6, 2, 6, 6, 27, 6, 7, 1, 7,
         6, 5, 7, 6, 27, 6, 6, 27, 6, 7,
         5, 6, 7, 1])
    np.testing.assert_allclose(
        gp.qpoints,
        [[0.0, 0.0, 0.0],
         [0.25, 0.0, 0.0],
         [0.5, 0.0, 0.0],
         [0.25, 0.25, 0.0],
         [0.5, 0.25, 0.0],
         [-0.25, 0.25, 0.0],
         [0.5, 0.5, 0.0],
         [-0.25, 0.5, 0.25]], atol=1e-8)
Beispiel #4
0
def test_GridPoints_SnO2_with_rotations_MP(ph_sno2):
    rec_lat = np.linalg.inv(ph_sno2.primitive.cell)
    rotations = ph_sno2.primitive_symmetry.get_pointgroup_operations()
    gp = GridPoints([4, 4, 4], rec_lat, rotations=rotations,
                    is_gamma_center=False)
    np.testing.assert_array_equal(
        gp.ir_grid_points, [0, 1, 5, 16, 17, 21])
    np.testing.assert_array_equal(gp.weights, [8, 16, 8, 8, 16, 8])
    np.testing.assert_array_equal(
        gp.grid_mapping_table,
        [0, 1, 1, 0, 1, 5, 5, 1, 1, 5,
         5, 1, 0, 1, 1, 0, 16, 17, 17, 16,
         17, 21, 21, 17, 17, 21, 21, 17, 16, 17,
         17, 16, 16, 17, 17, 16, 17, 21, 21, 17,
         17, 21, 21, 17, 16, 17, 17, 16, 0, 1,
         1, 0, 1, 5, 5, 1, 1, 5, 5, 1,
         0, 1, 1, 0])
    np.testing.assert_allclose(
        gp.qpoints,
        [[0.125, 0.125, 0.125],
         [0.375, 0.125, 0.125],
         [0.375, 0.375, 0.125],
         [0.125, 0.125, 0.375],
         [0.375, 0.125, 0.375],
         [0.375, 0.375, 0.375]], atol=1e-8)
Beispiel #5
0
 def testGridPoints(self):
     gp = GridPoints([11, 11, 11], [[-1, 1, 1], [1, -1, 1], [1, 1, -1]])
     self.assertTrue((gp.grid_address == gp.get_grid_address()).all())
     self.assertTrue((gp.ir_grid_points == gp.get_ir_grid_points()).all())
     np.testing.assert_allclose(gp.qpoints, gp.get_ir_qpoints())
     self.assertTrue((gp.weights == gp.get_ir_grid_weights()).all())
     self.assertTrue(
         (gp.grid_mapping_table == gp.get_grid_mapping_table()).all())
Beispiel #6
0
def test_GridPoints():
    """Test of GridPoints."""
    gp = GridPoints([2, 3, 4], [[-1, 1, 1], [1, -1, 1], [1, 1, -1]])

    assert gp.ir_grid_points.dtype == np.dtype("int_")
    assert gp.weights.dtype == np.dtype("int_")
    assert gp.grid_mapping_table.dtype == np.dtype("int_")
    assert gp.grid_address.dtype == np.dtype("intc")
    assert gp.mesh_numbers.dtype == np.dtype("intc")
    assert gp.reciprocal_lattice.dtype == np.dtype("double")
    assert gp.qpoints.dtype == np.dtype("double")

    np.testing.assert_array_equal(gp.grid_address, ga234)
Beispiel #7
0
    def __init__(self,
                 dynamical_matrix,
                 cell,
                 mesh,
                 shift=None,
                 is_time_reversal=False,
                 is_mesh_symmetry=True,
                 is_eigenvectors=False,
                 is_band_connection=False,
                 is_gamma_center=False,
                 group_velocity=None,
                 factor=VaspToTHz,
                 symprec=1e-5):
        self._mesh = np.array(mesh)
        self._is_band_connection=is_band_connection
        self._band_order = None
        self._is_eigenvectors = is_eigenvectors
        self._factor = factor
        self._cell = cell
        self._dynamical_matrix = dynamical_matrix
        # self._qpoints, self._weights = get_qpoints(self._mesh,
        #                                            self._cell,
        #                                            shift,
        #                                            is_gamma_center,
        #                                            is_time_reversal,
        #                                            symprec,
        #                                            is_symmetry)
        rotations  = Symmetry(self._cell).get_pointgroup_operations()
        self._gp = GridPoints(self._mesh,
                              np.linalg.inv(self._cell.get_cell()),
                              q_mesh_shift=shift,
                              is_gamma_center=is_gamma_center,
                              is_time_reversal=is_time_reversal,
                              rotations=rotations,
                              is_mesh_symmetry=is_mesh_symmetry)
        self._qpoints = self._gp.get_ir_qpoints()
        self._weights = self._gp.get_ir_grid_weights()

        self._eigenvalues = None
        self._eigenvectors = None
        self._set_eigenvalues()
        if self._is_band_connection:
            self._set_band_connection()

        self._group_velocities = None
        if group_velocity is not None:
            self._set_group_velocities(group_velocity)
Beispiel #8
0
def test_GridPoints_NaCl_with_rotations_fit_BZ(ph_nacl: Phonopy, fit_in_BZ):
    """Test of GridPoints with rotations from NaCl and fit_in_BZ."""
    rec_lat = np.linalg.inv(ph_nacl.primitive.cell)
    rotations = ph_nacl.primitive_symmetry.pointgroup_operations
    mesh = [5, 5, 5]
    gpts = GridPoints(mesh, rec_lat, rotations=rotations, fit_in_BZ=fit_in_BZ)
    if fit_in_BZ:
        np.testing.assert_allclose(
            gpts.qpoints,
            [
                [0.0, 0.0, 0.0],
                [0.2, 0.0, 0.0],
                [0.4, 0.0, 0.0],
                [0.2, 0.2, 0.0],
                [0.4, 0.2, 0.0],
                [-0.4, 0.2, 0.0],
                [-0.2, 0.2, 0.0],
                [0.4, 0.4, 0.0],
                [-0.4, -0.6, 0.0],
                [0.6, 0.4, 0.2],
            ],
            atol=1e-8,
        )
    else:
        np.testing.assert_allclose(
            gpts.qpoints,
            [
                [0.0, 0.0, 0.0],
                [0.2, 0.0, 0.0],
                [0.4, 0.0, 0.0],
                [0.2, 0.2, 0.0],
                [0.4, 0.2, 0.0],
                [-0.4, 0.2, 0.0],
                [-0.2, 0.2, 0.0],
                [0.4, 0.4, 0.0],
                [-0.4, 0.4, 0.0],
                [-0.4, 0.4, 0.2],
            ],
            atol=1e-8,
        )
Beispiel #9
0
    def __init__(
            self,
            dynamical_matrix,
            mesh,
            shift=None,
            is_time_reversal=True,
            is_mesh_symmetry=True,
            is_eigenvectors=False,
            is_gamma_center=False,
            group_velocity=None,
            rotations=None,  # Point group operations in real space
            factor=VaspToTHz,
            use_lapack_solver=False):

        self._mesh = np.array(mesh, dtype='intc')
        self._is_eigenvectors = is_eigenvectors
        self._factor = factor
        self._cell = dynamical_matrix.get_primitive()
        self._dynamical_matrix = dynamical_matrix
        self._use_lapack_solver = use_lapack_solver

        self._gp = GridPoints(self._mesh,
                              np.linalg.inv(self._cell.get_cell()),
                              q_mesh_shift=shift,
                              is_gamma_center=is_gamma_center,
                              is_time_reversal=is_time_reversal,
                              rotations=rotations,
                              is_mesh_symmetry=is_mesh_symmetry)

        self._qpoints = self._gp.get_ir_qpoints()
        self._weights = self._gp.get_ir_grid_weights()

        self._frequencies = None
        self._eigenvalues = None
        self._eigenvectors = None
        self._set_phonon()

        self._group_velocities = None
        if group_velocity is not None:
            self._set_group_velocities(group_velocity)
Beispiel #10
0
def test_GridPoints_SnO2_with_rotations(ph_sno2):
    rec_lat = np.linalg.inv(ph_sno2.primitive.cell)
    rotations = ph_sno2.primitive_symmetry.get_pointgroup_operations()
    gp = GridPoints([4, 4, 4], rec_lat, rotations=rotations)
    np.testing.assert_array_equal(
        gp.ir_grid_points,
        [0, 1, 2, 5, 6, 10, 16, 17, 18, 21, 22, 26, 32, 33, 34, 37, 38, 42])
    np.testing.assert_array_equal(
        gp.weights,
        [1, 4, 2, 4, 4, 1, 2, 8, 4, 8, 8, 2, 1, 4, 2, 4, 4, 1])
    np.testing.assert_array_equal(
        gp.grid_mapping_table,
        [0, 1, 2, 1, 1, 5, 6, 5, 2, 6,
         10, 6, 1, 5, 6, 5, 16, 17, 18, 17,
         17, 21, 22, 21, 18, 22, 26, 22, 17, 21,
         22, 21, 32, 33, 34, 33, 33, 37, 38, 37,
         34, 38, 42, 38, 33, 37, 38, 37, 16, 17,
         18, 17, 17, 21, 22, 21, 18, 22, 26, 22,
         17, 21, 22, 21])
    np.testing.assert_allclose(
        gp.qpoints,
        [[0.0, 0.0, 0.0],
         [0.25, 0.0, 0.0],
         [0.5, 0.0, 0.0],
         [0.25, 0.25, 0.0],
         [0.5, 0.25, 0.0],
         [0.5, 0.5, 0.0],
         [0.0, 0.0, 0.25],
         [0.25, 0.0, 0.25],
         [0.5, 0.0, 0.25],
         [0.25, 0.25, 0.25],
         [0.5, 0.25, 0.25],
         [0.5, 0.5, 0.25],
         [0.0, 0.0, 0.5],
         [0.25, 0.0, 0.5],
         [0.5, 0.0, 0.5],
         [0.25, 0.25, 0.5],
         [0.5, 0.25, 0.5],
         [0.5, 0.5, 0.5]], atol=1e-8)
Beispiel #11
0
    def __init__(self,
                 dynamical_matrix,
                 unitcell_ideal,
                 primitive_matrix_ideal,
                 mesh,
                 shift=None,
                 is_time_reversal=True,
                 is_mesh_symmetry=True,
                 is_eigenvectors=False,
                 is_gamma_center=False,
                 star="none",
                 group_velocity=None,
                 rotations=None, # Point group operations in real space
                 factor=VaspToTHz,
                 use_lapack_solver=False,
                 mode="eigenvector"):

        self._mesh = np.array(mesh, dtype='intc')
        self._is_eigenvectors = is_eigenvectors
        self._factor = factor

        primitive_ideal_wrt_unitcell = (
            get_primitive(unitcell_ideal, primitive_matrix_ideal))
        self._cell = primitive_ideal_wrt_unitcell

        # ._dynamical_matrix must be assigned for calculating DOS
        # using the tetrahedron method.
        # In the "DOS", this is used to get "primitive".
        # In the "TetrahedronMesh", this is used just as the "Atoms".
        # Currently, we must not use the tetrahedron method,
        # because now we do not give the primitive but the unitcell for the
        # self._dynamical_matrix.
        self._dynamical_matrix = dynamical_matrix
        self._use_lapack_solver = use_lapack_solver

        self._gp = GridPoints(self._mesh,
                              np.linalg.inv(self._cell.get_cell()),
                              q_mesh_shift=shift,
                              is_gamma_center=is_gamma_center,
                              is_time_reversal=is_time_reversal,
                              rotations=rotations,
                              is_mesh_symmetry=is_mesh_symmetry)

        self._qpoints = self._gp.get_ir_qpoints()
        self._weights = self._gp.get_ir_grid_weights()

        self._star = star

        self._eigenstates_unfolding = Eigenstates(
            dynamical_matrix,
            unitcell_ideal,
            primitive_matrix_ideal,
            mode=mode,
            star=star,
            verbose=False)

        self._frequencies = None
        self._eigenvalues = None
        self._eigenvectors = None
        self._set_phonon()

        self._group_velocities = None
        if group_velocity is not None:
            self._set_group_velocities(group_velocity)
Beispiel #12
0
def test_GridPoints_SnO2_with_rotations_MP(ph_sno2: Phonopy):
    """Test of GridPoints with non-gamma-centre mesh and rotations from SnO2."""
    rec_lat = np.linalg.inv(ph_sno2.primitive.cell)
    rotations = ph_sno2.primitive_symmetry.pointgroup_operations
    gp = GridPoints([4, 4, 4],
                    rec_lat,
                    rotations=rotations,
                    is_gamma_center=False)
    np.testing.assert_array_equal(gp.ir_grid_points, [0, 1, 5, 16, 17, 21])
    np.testing.assert_array_equal(gp.weights, [8, 16, 8, 8, 16, 8])
    np.testing.assert_array_equal(
        gp.grid_mapping_table,
        [
            0,
            1,
            1,
            0,
            1,
            5,
            5,
            1,
            1,
            5,
            5,
            1,
            0,
            1,
            1,
            0,
            16,
            17,
            17,
            16,
            17,
            21,
            21,
            17,
            17,
            21,
            21,
            17,
            16,
            17,
            17,
            16,
            16,
            17,
            17,
            16,
            17,
            21,
            21,
            17,
            17,
            21,
            21,
            17,
            16,
            17,
            17,
            16,
            0,
            1,
            1,
            0,
            1,
            5,
            5,
            1,
            1,
            5,
            5,
            1,
            0,
            1,
            1,
            0,
        ],
    )
    np.testing.assert_allclose(
        gp.qpoints,
        [
            [0.125, 0.125, 0.125],
            [0.375, 0.125, 0.125],
            [0.375, 0.375, 0.125],
            [0.125, 0.125, 0.375],
            [0.375, 0.125, 0.375],
            [0.375, 0.375, 0.375],
        ],
        atol=1e-8,
    )
Beispiel #13
0
def test_GridPoints():
    gp = GridPoints([2, 3, 4], [[-1, 1, 1], [1, -1, 1], [1, 1, -1]])
    np.testing.assert_array_equal(gp.grid_address, ga234)