Example #1
0
    def _show_log(self, q, i):
        gp = self._grid_points[i]
        frequencies = self._frequencies[gp][self._pp.get_band_indices()]
        gv = self._gv[i]
        ave_pp = self._averaged_pp_interaction[i]

        print "Frequency     group velocity (x, y, z)     |gv|       Pqj",
        if self._gv_delta_q is None:
            print
        else:
            print " (dq=%3.1e)" % self._gv_delta_q

        if self._log_level > 1:
            rotation_map = get_grid_points_by_rotations(
                self._grid_address[gp], self._point_operations, self._mesh)
            for i, j in enumerate(np.unique(rotation_map)):
                for k, (rot, rot_c) in enumerate(
                        zip(self._point_operations,
                            self._rotations_cartesian)):
                    if rotation_map[k] != j:
                        continue

                    print " k*%-2d (%5.2f %5.2f %5.2f)" % (
                        (i + 1, ) + tuple(np.dot(rot, q)))
                    for f, v, pp in zip(frequencies,
                                        np.dot(rot_c, gv.T).T, ave_pp):
                        print "%8.3f   (%8.3f %8.3f %8.3f) %8.3f %11.3e" % (
                            f, v[0], v[1], v[2], np.linalg.norm(v), pp)
            print
        else:
            for f, v, pp in zip(frequencies, gv, ave_pp):
                print "%8.3f   (%8.3f %8.3f %8.3f) %8.3f %11.3e" % (
                    f, v[0], v[1], v[2], np.linalg.norm(v), pp)
Example #2
0
    def _show_log(self, q, i):
        gp = self._grid_points[i]
        frequencies = self._frequencies[gp]
        gv = self._gv[i]
        ave_pp = self._averaged_pp_interaction[i]
        
        print "Frequency     group velocity (x, y, z)     |gv|       Pqj",
        if self._gv_delta_q is None:
            print
        else:
            print " (dq=%3.1e)" % self._gv_delta_q

        if self._log_level > 1:
            rotation_map = get_grid_points_by_rotations(
                self._grid_address[gp],
                self._point_operations,
                self._mesh)
            for i, j in enumerate(np.unique(rotation_map)):
                for k, (rot, rot_c) in enumerate(zip(
                        self._point_operations, self._rotations_cartesian)):
                    if rotation_map[k] != j:
                        continue
    
                    print " k*%-2d (%5.2f %5.2f %5.2f)" % (
                        (i + 1,) + tuple(np.dot(rot, q)))
                    for f, v, pp in zip(frequencies,
                                    np.dot(rot_c, gv.T).T,
                                    ave_pp):
                        print "%8.3f   (%8.3f %8.3f %8.3f) %8.3f %11.3e" % (
                            f, v[0], v[1], v[2], np.linalg.norm(v), pp)
            print
        else:
            for f, v, pp in zip(frequencies, gv, ave_pp):
                print "%8.3f   (%8.3f %8.3f %8.3f) %8.3f %11.3e" % (
                    f, v[0], v[1], v[2], np.linalg.norm(v), pp)
    def _allocate_values(self):
        num_band = self._primitive.get_number_of_atoms() * 3
        num_grid_points = len(self._grid_points)
        num_ir_grid_points = len(self._ir_grid_points)

        self._kappa = np.zeros((len(self._sigmas),
                                len(self._temperatures),
                                6), dtype='double')
        self._gv = np.zeros((num_grid_points,
                             num_band,
                             3), dtype='double')
        self._mean_square_pp_strength = np.zeros((num_grid_points, num_band),
                                                 dtype='double')
        self._gamma = np.zeros((len(self._sigmas),
                                len(self._temperatures),
                                num_grid_points,
                                num_band), dtype='double')
        if self._isotope is not None:
            self._gamma_iso = np.zeros((len(self._sigmas),
                                        num_grid_points,
                                        num_band), dtype='double')

        if self._is_reducible_collision_matrix:
            num_mesh_points = np.prod(self._mesh)
            self._collision = CollisionMatrix(
                self._pp,
                is_reducible_collision_matrix=True)
            self._collision_matrix = np.zeros(
                (len(self._sigmas),
                 len(self._temperatures),
                 num_grid_points, num_band, num_mesh_points, num_band),
                dtype='double')
        else:
            self._rot_grid_points = np.zeros(
                (len(self._ir_grid_points), len(self._point_operations)),
                dtype='intc')
            self._rot_BZ_grid_points = np.zeros(
                (len(self._ir_grid_points), len(self._point_operations)),
                dtype='intc')
            for i, ir_gp in enumerate(self._ir_grid_points):
                self._rot_grid_points[i] = get_grid_points_by_rotations(
                    self._grid_address[ir_gp],
                    self._point_operations,
                    self._mesh)
                self._rot_BZ_grid_points[i] = get_BZ_grid_points_by_rotations(
                    self._grid_address[ir_gp],
                    self._point_operations,
                    self._mesh,
                    self._pp.get_bz_map())
            self._collision = CollisionMatrix(
                self._pp,
                point_operations=self._point_operations,
                ir_grid_points=self._ir_grid_points,
                rotated_grid_points=self._rot_BZ_grid_points)
            self._collision_matrix = np.zeros(
                (len(self._sigmas),
                 len(self._temperatures),
                 num_grid_points, num_band, 3,
                 num_ir_grid_points, num_band, 3),
                dtype='double')
Example #4
0
    def _get_gv_by_gv(self, i):
        rotation_map = get_grid_points_by_rotations(
            self._grid_points[i], self._point_operations, self._mesh)
        gv_by_gv = np.zeros((len(self._gv[i]), 3, 3), dtype='double')
        
        if self._no_kappa_stars:
            count = 0
            for r, r_gp in zip(self._rotations_cartesian, rotation_map):
                if r_gp == rotation_map[0]:
                    gvs_rot = np.dot(r, self._gv[i].T).T
                    gv_by_gv += [np.outer(r_gv, r_gv) for r_gv in gvs_rot]
                    count += 1
            gv_by_gv /= count
            order_kstar = 1
        else:
            for r in self._rotations_cartesian:
                gvs_rot = np.dot(r, self._gv[i].T).T
                gv_by_gv += [np.outer(r_gv, r_gv) for r_gv in gvs_rot]
            gv_by_gv /= len(rotation_map) / len(np.unique(rotation_map))
            order_kstar = len(np.unique(rotation_map))
            # check if the number of rotations is correct.
            if self._grid_weights is not None:
                if len(set(rotation_map)) != self._grid_weights[i]:
                    if self._log_level:
                        print "*" * 33  + "Warning" + "*" * 33
                        print (" Number of elements in k* is unequal "
                               "to number of equivalent grid-points.")
                        print "*" * 73
                # assert len(rotations) == self._grid_weights[i], \
                #     "Num rotations %d, weight %d" % (
                #     len(rotations), self._grid_weights[i])

        return gv_by_gv, order_kstar
Example #5
0
    def set_rot_grid_points(self):
        num_rot = len(self._kpoint_operations)
        num_mesh_points = np.prod(self._mesh)
        self._rot_grid_points = np.zeros((num_rot, num_mesh_points),
                                         dtype='intc')

        for i in range(num_mesh_points):
            self._rot_grid_points[:, i] = get_grid_points_by_rotations(
                self._grid_address[i], self._kpoint_operations, self._mesh)
Example #6
0
    def _allocate_values(self):
        num_band = self._primitive.get_number_of_atoms() * 3
        num_grid_points = len(self._grid_points)
        num_ir_grid_points = len(self._ir_grid_points)

        self._kappa = np.zeros((len(self._sigmas), len(self._temperatures), 6),
                               dtype='double')
        self._gv = np.zeros((num_grid_points, num_band, 3), dtype='double')
        self._averaged_pp_interaction = np.zeros((num_grid_points, num_band),
                                                 dtype='double')
        self._gamma = np.zeros((len(self._sigmas), len(
            self._temperatures), num_grid_points, num_band),
                               dtype='double')
        if self._isotope is not None:
            self._gamma_iso = np.zeros(
                (len(self._sigmas), num_grid_points, num_band), dtype='double')

        if self._is_reducible_collision_matrix:
            num_mesh_points = np.prod(self._mesh)
            self._mode_kappa = np.zeros(
                (len(self._sigmas), len(
                    self._temperatures), num_mesh_points, num_band, 6),
                dtype='double')
            self._collision = CollisionMatrix(
                self._pp, is_reducible_collision_matrix=True)
            self._collision_matrix = np.zeros(
                (len(self._sigmas), len(self._temperatures), num_grid_points,
                 num_band, num_mesh_points, num_band),
                dtype='double')
        else:
            self._mode_kappa = np.zeros(
                (len(self._sigmas), len(
                    self._temperatures), num_grid_points, num_band, 6),
                dtype='double')
            self._rot_grid_points = np.zeros(
                (len(self._ir_grid_points), len(self._point_operations)),
                dtype='intc')
            self._rot_BZ_grid_points = np.zeros(
                (len(self._ir_grid_points), len(self._point_operations)),
                dtype='intc')
            for i, ir_gp in enumerate(self._ir_grid_points):
                self._rot_grid_points[i] = get_grid_points_by_rotations(
                    self._grid_address[ir_gp], self._point_operations,
                    self._mesh)
                self._rot_BZ_grid_points[i] = get_BZ_grid_points_by_rotations(
                    self._grid_address[ir_gp], self._point_operations,
                    self._mesh, self._pp.get_bz_map())
            self._collision = CollisionMatrix(
                self._pp,
                point_operations=self._point_operations,
                ir_grid_points=self._ir_grid_points,
                rotated_grid_points=self._rot_BZ_grid_points)
            self._collision_matrix = np.zeros(
                (len(self._sigmas), len(self._temperatures), num_grid_points,
                 num_band, 3, num_ir_grid_points, num_band, 3),
                dtype='double')
    def _expand_collisions(self):
        num_mesh_points = np.prod(self._mesh)
        num_rot = len(self._point_operations)
        num_band = self._primitive.get_number_of_atoms() * 3
        rot_grid_points = np.zeros(
            (num_rot, num_mesh_points), dtype='intc')
        collision_matrix = np.zeros(
            (len(self._sigmas),
             len(self._temperatures),
             num_mesh_points, num_band, num_mesh_points, num_band),
            dtype='double')
        gamma = np.zeros((len(self._sigmas),
                          len(self._temperatures),
                          num_mesh_points,
                          num_band), dtype='double')
        gv = np.zeros((num_mesh_points,
                       num_band,
                       3), dtype='double')
        
        if self._gamma_iso is not None:
            gamma_iso = np.zeros((len(self._sigmas),
                                  num_mesh_points,
                                  num_band), dtype='double')
        
        for i in range(num_mesh_points):
            rot_grid_points[:, i] = get_grid_points_by_rotations(
                self._grid_address[i],
                self._point_operations,
                self._mesh)
            
        for i, ir_gp in enumerate(self._ir_grid_points):
            multi = (rot_grid_points[:, ir_gp] == ir_gp).sum()
            g_elem = self._gamma[:, :, i, :] / multi
            if self._gamma_iso is not None:
                giso_elem = self._gamma_iso[:, i, :] / multi
            for j, r in enumerate(self._rotations_cartesian):
                gp_r = rot_grid_points[j, ir_gp]
                gamma[:, :, gp_r, :] += g_elem
                if self._gamma_iso is not None:
                    gamma_iso[:, gp_r, :] += giso_elem
                for k in range(num_mesh_points):
                    colmat_elem = self._collision_matrix[:, :, i, :, k, :]
                    colmat_elem = colmat_elem.copy() / multi
                    gp_c = rot_grid_points[j, k]
                    collision_matrix[:, :, gp_r, :, gp_c, :] += colmat_elem
                    
                gv[gp_r] += np.dot(self._gv[i], r.T) / multi

        self._gamma = gamma
        self._collision_matrix = collision_matrix
        if self._gamma_iso is not None:
            self._gamma_iso = gamma_iso
        self._gv = gv
Example #8
0
    def _expand_collisions(self):
        num_mesh_points = np.prod(self._mesh)
        num_rot = len(self._point_operations)
        num_band = self._primitive.get_number_of_atoms() * 3
        rot_grid_points = np.zeros(
            (num_rot, num_mesh_points), dtype='intc')
        collision_matrix = np.zeros(
            (len(self._sigmas),
             len(self._temperatures),
             num_mesh_points, num_band, num_mesh_points, num_band),
            dtype='double')
        gamma = np.zeros((len(self._sigmas),
                          len(self._temperatures),
                          num_mesh_points,
                          num_band), dtype='double')
        gv = np.zeros((num_mesh_points,
                       num_band,
                       3), dtype='double')
        
        if self._gamma_iso is not None:
            gamma_iso = np.zeros((len(self._sigmas),
                                  num_mesh_points,
                                  num_band), dtype='double')
        
        for i in range(num_mesh_points):
            rot_grid_points[:, i] = get_grid_points_by_rotations(
                self._grid_address[i],
                self._point_operations,
                self._mesh)
            
        for i, ir_gp in enumerate(self._ir_grid_points):
            multi = (rot_grid_points[:, ir_gp] == ir_gp).sum()
            g_elem = self._gamma[:, :, i, :] / multi
            if self._gamma_iso is not None:
                giso_elem = self._gamma_iso[:, i, :] / multi
            for j, r in enumerate(self._rotations_cartesian):
                gp_r = rot_grid_points[j, ir_gp]
                gamma[:, :, gp_r, :] += g_elem
                if self._gamma_iso is not None:
                    gamma_iso[:, gp_r, :] += giso_elem
                for k in range(num_mesh_points):
                    colmat_elem = self._collision_matrix[:, :, i, :, k, :]
                    colmat_elem = colmat_elem.copy() / multi
                    gp_c = rot_grid_points[j, k]
                    collision_matrix[:, :, gp_r, :, gp_c, :] += colmat_elem
                    
                gv[gp_r] += np.dot(self._gv[i], r.T) / multi

        self._gamma = gamma
        self._collision_matrix = collision_matrix
        if self._gamma_iso is not None:
            self._gamma_iso = gamma_iso
        self._gv = gv
Example #9
0
    def _show_log(self, q, i):
        gp = self._grid_points[i]
        frequencies = self._frequencies[gp][self._pp.get_band_indices()]
        gv = self._gv[i]

        if self._is_full_pp or self._use_ave_pp:
            ave_pp = self._averaged_pp_interaction[i]

        if self._is_full_pp or self._use_ave_pp:
            text = "Frequency     group velocity (x, y, z)     |gv|       Pqj"
        else:
            text = "Frequency     group velocity (x, y, z)     |gv|"
        if self._gv_delta_q is None:
            pass
        else:
            text += "  (dq=%3.1e)" % self._gv_delta_q
        print(text)

        if self._log_level > 1:
            rotation_map = get_grid_points_by_rotations(
                self._grid_address[gp],
                self._point_operations,
                self._mesh)
            for i, j in enumerate(np.unique(rotation_map)):
                for k, (rot, rot_c) in enumerate(zip(
                        self._point_operations, self._rotations_cartesian)):
                    if rotation_map[k] != j:
                        continue

                    print(" k*%-2d (%5.2f %5.2f %5.2f)" %
                          ((i + 1,) + tuple(np.dot(rot, q))))
                    if self._is_full_pp or self._use_ave_pp:
                        for f, v, pp in zip(frequencies,
                                            np.dot(rot_c, gv.T).T,
                                            ave_pp):
                            print("%8.3f   (%8.3f %8.3f %8.3f) %8.3f %11.3e" %
                                  (f, v[0], v[1], v[2], np.linalg.norm(v), pp))
                    else:
                        for f, v in zip(frequencies, np.dot(rot_c, gv.T).T):
                            print("%8.3f   (%8.3f %8.3f %8.3f) %8.3f" %
                                  (f, v[0], v[1], v[2], np.linalg.norm(v)))
            print('')
        else:
            if self._is_full_pp or self._use_ave_pp:
                for f, v, pp in zip(frequencies, gv, ave_pp):
                    print("%8.3f   (%8.3f %8.3f %8.3f) %8.3f %11.3e" %
                          (f, v[0], v[1], v[2], np.linalg.norm(v), pp))
            else:
                for f, v in zip(frequencies, gv):
                    print("%8.3f   (%8.3f %8.3f %8.3f) %8.3f" %
                          (f, v[0], v[1], v[2], np.linalg.norm(v)))
Example #10
0
    def _get_gv_by_gv(self, i):
        rotation_map = get_grid_points_by_rotations(
            self._grid_address[self._grid_points[i]], self._point_operations,
            self._mesh)
        gv_by_gv = np.zeros((len(self._gv[i]), 3, 3), dtype='double')

        for r in self._rotations_cartesian:
            gvs_rot = np.dot(self._gv[i], r.T)
            gv_by_gv += [np.outer(r_gv, r_gv) for r_gv in gvs_rot]
        gv_by_gv /= len(rotation_map) // len(np.unique(rotation_map))
        order_kstar = len(np.unique(rotation_map))

        if order_kstar != self._grid_weights[i]:
            if self._log_level:
                print("*" * 33 + "Warning" + "*" * 33)
                print(" Number of elements in k* is unequal "
                      "to number of equivalent grid-points.")
                print("*" * 73)

        return gv_by_gv, order_kstar
Example #11
0
    def _get_gv_by_gv(self, i):
        rotation_map = get_grid_points_by_rotations(
            self._grid_address[self._grid_points[i]],
            self._point_operations,
            self._mesh)
        gv_by_gv = np.zeros((len(self._gv[i]), 3, 3), dtype='double')
        
        for r in self._rotations_cartesian:
            gvs_rot = np.dot(self._gv[i], r.T)
            gv_by_gv += [np.outer(r_gv, r_gv) for r_gv in gvs_rot]
        gv_by_gv /= len(rotation_map) / len(np.unique(rotation_map))
        order_kstar = len(np.unique(rotation_map))

        if order_kstar != self._grid_weights[i]:
            if self._log_level:
                print "*" * 33  + "Warning" + "*" * 33
                print (" Number of elements in k* is unequal "
                       "to number of equivalent grid-points.")
                print "*" * 73

        return gv_by_gv, order_kstar