示例#1
0
 def _set_integration_weights_c(self, thm, infinitesmal=1e-10):
     # infinitesmal is to prevent divergence of the results
     import anharmonic._phono3py as phono3c
     unique_vertices = thm.get_unique_tetrahedra_vertices()
     neighboring_grid_points = np.zeros(len(unique_vertices) *
                                        len(self._grid_points2),
                                        dtype='intc')
     phono3c.neighboring_grid_points(
         neighboring_grid_points,
         self._grid_points2.astype("intc").copy(),
         unique_vertices.astype("intc").copy(),
         self._mesh.astype("intc").copy(),
         self._grid_address.astype("intc").copy(),
         self._bz_map.astype("intc").copy())
     self._set_phonon_c(np.unique(neighboring_grid_points))
     freq_points = np.array(
         self._frequencies[self._grid_point, self._band_indices] +
         infinitesmal,
         dtype='double',
         order='C')
     phono3c.integration_weights(self._integration_weights,
                                 freq_points.astype("double").copy(),
                                 thm.get_tetrahedra(),
                                 self._mesh.astype("intc").copy(),
                                 self._grid_points2.astype("intc").copy(),
                                 self._frequencies, self._grid_address,
                                 self._bz_map)
示例#2
0
def _set_triplets_integration_weights_c(g,
                                        interaction,
                                        frequency_points,
                                        neighboring_phonons=True):
    import anharmonic._phono3py as phono3c

    reciprocal_lattice = np.linalg.inv(interaction.get_primitive().get_cell())
    mesh = interaction.get_mesh_numbers()
    thm = TetrahedronMethod(reciprocal_lattice, mesh=mesh)
    grid_address = interaction.get_grid_address()
    bz_map = interaction.get_bz_map()
    triplets_at_q = interaction.get_triplets_at_q()[0]

    if neighboring_phonons:
        unique_vertices = thm.get_unique_tetrahedra_vertices()
        for i, j in zip((1, 2), (1, -1)):
            neighboring_grid_points = np.zeros(len(unique_vertices) *
                                               len(triplets_at_q),
                                               dtype='intc')
            phono3c.neighboring_grid_points(neighboring_grid_points,
                                            triplets_at_q[:, i].flatten(),
                                            j * unique_vertices, mesh,
                                            grid_address, bz_map)
            interaction.set_phonon(np.unique(neighboring_grid_points))

    phono3c.triplets_integration_weights(g, frequency_points,
                                         thm.get_tetrahedra(), mesh,
                                         triplets_at_q,
                                         interaction.get_phonons()[0],
                                         grid_address, bz_map)
示例#3
0
文件: isotope.py 项目: matk86/phonopy
 def _set_integration_weights_c(self, thm):
     import anharmonic._phono3py as phono3c
     unique_vertices = thm.get_unique_tetrahedra_vertices()
     neighboring_grid_points = np.zeros(
         len(unique_vertices) * len(self._grid_points), dtype='intc')
     phono3c.neighboring_grid_points(
         neighboring_grid_points,
         self._grid_points,
         unique_vertices,
         self._mesh,
         self._grid_address,
         self._bz_map)
     self._set_phonon_c(np.unique(neighboring_grid_points))
     freq_points = np.array(
         self._frequencies[self._grid_point, self._band_indices],
         dtype='double', order='C')
     phono3c.integration_weights(
         self._integration_weights,
         freq_points,
         thm.get_tetrahedra(),
         self._mesh,
         self._grid_points,
         self._frequencies,
         self._grid_address,
         self._bz_map)
示例#4
0
文件: isotope.py 项目: nfh/phonopy
 def _set_integration_weights_c(self, thm):
     import anharmonic._phono3py as phono3c
     unique_vertices = thm.get_unique_tetrahedra_vertices()
     neighboring_grid_points = np.zeros(
         len(unique_vertices) * len(self._grid_points), dtype='intc')
     phono3c.neighboring_grid_points(
         neighboring_grid_points,
         self._grid_points,
         unique_vertices,
         self._mesh,
         self._grid_address,
         self._bz_map)
     self._set_phonon_c(np.unique(neighboring_grid_points))
     freq_points = np.array(
         self._frequencies[self._grid_point, self._band_indices],
         dtype='double', order='C')
     phono3c.integration_weights(
         self._integration_weights,
         freq_points,
         thm.get_tetrahedra(),
         self._mesh,
         self._grid_points,
         self._frequencies,
         self._grid_address,
         self._bz_map)
示例#5
0
def _set_triplets_integration_weights_c(g, interaction, frequency_points):
    import anharmonic._phono3py as phono3c

    reciprocal_lattice = np.linalg.inv(interaction.get_primitive().get_cell())
    mesh = interaction.get_mesh_numbers()
    thm = TetrahedronMethod(reciprocal_lattice, mesh=mesh)
    grid_address = interaction.get_grid_address()
    bz_map = interaction.get_bz_map()
    triplets_at_q = interaction.get_triplets_at_q()[0]
    unique_vertices = thm.get_unique_tetrahedra_vertices()
    
    for i, j in zip((1, 2), (1, -1)):
        neighboring_grid_points = np.zeros(
            len(unique_vertices) * len(triplets_at_q), dtype='intc')
        phono3c.neighboring_grid_points(
            neighboring_grid_points,
            triplets_at_q[:, i].flatten(),
            j * unique_vertices,
            mesh,
            grid_address,
            bz_map)
        interaction.set_phonon(np.unique(neighboring_grid_points))

    phono3c.triplets_integration_weights(
        g,
        np.array(frequency_points, dtype='double'),
        thm.get_tetrahedra(),
        mesh,
        triplets_at_q,
        interaction.get_phonons()[0],
        grid_address,
        bz_map)
示例#6
0
def _set_triplets_integration_weights_c(g,
                                        interaction,
                                        frequency_points=None,
                                        neighboring_phonons=True,
                                        triplets_at_q=None,
                                        band_indices=None,
                                        is_triplet_symmetry=False):
    import anharmonic._phono3py as phono3c
    if triplets_at_q == None:
        triplets_at_q = interaction.get_triplets_at_q()[0]
    if len(triplets_at_q) == 0:
        return
    reciprocal_lattice = np.linalg.inv(interaction.get_primitive().get_cell())
    mesh = interaction.get_mesh_numbers()
    thm = TetrahedronMethod(reciprocal_lattice, mesh=mesh)

    grid_address = interaction.get_grid_address()
    bz_map = interaction.get_bz_map()
    if neighboring_phonons:
        unique_vertices = thm.get_unique_tetrahedra_vertices()
        for i in (1, 2, 0):  # index inside a triplet
            for j in (1, -1):
                neighboring_grid_points = np.zeros(
                    len(unique_vertices) * len(np.unique(triplets_at_q[:, i])),
                    dtype='intc')
                phono3c.neighboring_grid_points(
                    neighboring_grid_points,
                    np.unique(triplets_at_q[:, i]).astype("intc"),
                    j * unique_vertices, mesh, grid_address, bz_map)
            interaction.set_phonons(np.unique(neighboring_grid_points))

    frequencies = interaction.get_phonons()[0]

    if len(np.where(mesh == 1)[0]) < 2:
        if band_indices is None:
            phono3c.triplets_integration_weights_fpoints(
                g, frequency_points,
                thm.get_tetrahedra().astype("intc").copy(), mesh,
                triplets_at_q, frequencies, grid_address, bz_map)
        else:
            phono3c.triplets_integration_weights(
                g,
                thm.get_tetrahedra().astype("intc").copy(),
                mesh, triplets_at_q, frequencies,
                np.array(band_indices, dtype='intc'), grid_address, bz_map,
                is_triplet_symmetry)
    else:  # 1D case
        possible_shift = np.array((np.array(mesh) != 1), dtype='intc')
        relative_address = np.array(
            [[[0, 0, 0], possible_shift], [[0, 0, 0], -possible_shift]],
            dtype="intc")
        if band_indices is None:
            phono3c.triplets_integration_weights_1D_fpoints(
                g, frequency_points, relative_address, mesh, triplets_at_q,
                frequencies, grid_address, bz_map)
        else:
            phono3c.triplets_integration_weights_1D(
                g, relative_address, mesh, triplets_at_q, frequencies,
                np.array(band_indices, dtype='intc'), grid_address, bz_map,
                is_triplet_symmetry)
示例#7
0
 def _set_integration_weights_c(self, thm, infinitesmal = 1e-10):
     # infinitesmal is to prevent divergence of the results
     import anharmonic._phono3py as phono3c
     unique_vertices = thm.get_unique_tetrahedra_vertices()
     neighboring_grid_points = np.zeros(
         len(unique_vertices) * len(self._grid_points2), dtype='intc')
     phono3c.neighboring_grid_points(
         neighboring_grid_points,
         self._grid_points2.astype("intc").copy(),
         unique_vertices.astype("intc").copy(),
         self._mesh.astype("intc").copy(),
         self._grid_address.astype("intc").copy(),
         self._bz_map.astype("intc").copy())
     self._set_phonon_c(np.unique(neighboring_grid_points))
     freq_points = np.array(
         self._frequencies[self._grid_point, self._band_indices] + infinitesmal,
         dtype='double', order='C')
     phono3c.integration_weights(
         self._integration_weights,
         freq_points.astype("double").copy(),
         thm.get_tetrahedra(),
         self._mesh.astype("intc").copy(),
         self._grid_points2.astype("intc").copy(),
         self._frequencies,
         self._grid_address,
         self._bz_map)
示例#8
0
    def _run_c_tetrahedron_method(self):
        """
        This is not very faster than _run_c_tetrahedron_method and
        use much more memory space. So this function is not set as default.
        """
        import anharmonic._phono3py as phono3c
        thm = self._tetrahedron_method 
        unique_vertices = thm.get_unique_tetrahedra_vertices()
        for i, j in zip((1, 2), (1, -1)):
            neighboring_grid_points = np.zeros(
                len(unique_vertices) * len(self._triplets_at_q), dtype='intc')
            phono3c.neighboring_grid_points(
                neighboring_grid_points,
                self._triplets_at_q[:, i].flatten(),
                j * unique_vertices,
                self._mesh,
                self._grid_address,
                self._bz_map)
            self._set_phonon(np.unique(neighboring_grid_points))

        f_max = np.max(self._frequencies) * 2 + self._frequency_step / 10
        f_min = np.min(self._frequencies) * 2
        frequency_points = np.arange(f_min, f_max, self._frequency_step,
                                     dtype='double')

        num_band = self._num_band
        num_triplets = len(self._triplets_at_q)
        num_freq_points = len(frequency_points)
        g = np.zeros((num_triplets, num_freq_points, num_band, num_band, 2),
                     dtype='double')

        phono3c.triplets_integration_weights(
            g,
            frequency_points,
            thm.get_tetrahedra(),
            self._mesh,
            self._triplets_at_q,
            self._frequencies,
            self._grid_address,
            self._bz_map)

        jdos = np.tensordot(g, self._weights_at_q, axes=([0, 0]))
        jdos = jdos.sum(axis=1).sum(axis=1)[:, 0]
        self._joint_dos = jdos / np.prod(self._mesh)
        self._frequency_points = frequency_points
示例#9
0
def _set_triplets_integration_weights_c(g,
                                        interaction,
                                        frequency_points = None,
                                        neighboring_phonons=True,
                                        triplets_at_q=None,
                                        band_indices=None,
                                        is_triplet_symmetry=False):
    import anharmonic._phono3py as phono3c
    if triplets_at_q == None:
        triplets_at_q = interaction.get_triplets_at_q()[0]
    if len(triplets_at_q) == 0:
        return
    reciprocal_lattice = np.linalg.inv(interaction.get_primitive().get_cell())
    mesh = interaction.get_mesh_numbers()
    thm = TetrahedronMethod(reciprocal_lattice, mesh=mesh)

    grid_address = interaction.get_grid_address()
    bz_map = interaction.get_bz_map()
    if neighboring_phonons:
        unique_vertices = thm.get_unique_tetrahedra_vertices()
        for i in (1, 2, 0): # index inside a triplet
            for j in (1, -1):
                neighboring_grid_points = np.zeros(
                    len(unique_vertices) * len(np.unique(triplets_at_q[:, i])), dtype='intc')
                phono3c.neighboring_grid_points(
                neighboring_grid_points,
                np.unique(triplets_at_q[:, i]).astype("intc"),
                j * unique_vertices,
                mesh,
                grid_address,
                bz_map)
            interaction.set_phonons(np.unique(neighboring_grid_points))

    frequencies = interaction.get_phonons()[0]

    if len(np.where(mesh == 1)[0]) < 2:
        if band_indices is None:
            phono3c.triplets_integration_weights_fpoints(
                g,
                frequency_points,
                thm.get_tetrahedra().astype("intc").copy(),
                mesh,
                triplets_at_q,
                frequencies,
                grid_address,
                bz_map)
        else:
            phono3c.triplets_integration_weights(
                g,
                thm.get_tetrahedra().astype("intc").copy(),
                mesh,
                triplets_at_q,
                frequencies,
                np.array(band_indices, dtype='intc'),
                grid_address,
                bz_map,
                is_triplet_symmetry)
    else: # 1D case
        possible_shift = np.array((np.array(mesh) != 1), dtype='intc')
        relative_address = np.array([[[0, 0, 0],
                                      possible_shift],
                                     [[0, 0, 0],
                                      -possible_shift]], dtype="intc")
        if band_indices is None:
            phono3c.triplets_integration_weights_1D_fpoints(
                g,
                frequency_points,
                relative_address,
                mesh,
                triplets_at_q,
                frequencies,
                grid_address,
                bz_map)
        else:
            phono3c.triplets_integration_weights_1D(
                g,
                relative_address,
                mesh,
                triplets_at_q,
                frequencies,
                np.array(band_indices, dtype='intc'),
                grid_address,
                bz_map,
                is_triplet_symmetry)