コード例 #1
0
ファイル: conductivity.py プロジェクト: chrinide/phono3py
 def _get_gv(self, q):
     return get_group_velocity(
         q,
         self._dm,
         q_length=self._gv_delta_q,
         symmetry=self._symmetry,
         frequency_factor_to_THz=self._frequency_factor_to_THz)
コード例 #2
0
ファイル: conductivity.py プロジェクト: chueter/phonopy
 def _get_gv(self, q):
     return get_group_velocity(
         q,
         self._dm,
         q_length=self._gv_delta_q,
         symmetry=self._symmetry,
         frequency_factor_to_THz=self._frequency_factor_to_THz)
コード例 #3
0
ファイル: conductivity.py プロジェクト: arbegla/phonopy
 def _set_gv(self, i):
     # Group velocity [num_freqs, 3]
     self._gv[i] = get_group_velocity(
         self._qpoints[i],
         self._dm,
         q_length=self._gv_delta_q,
         symmetry=self._symmetry,
         frequency_factor_to_THz=self._frequency_factor_to_THz)
コード例 #4
0
ファイル: collision.py プロジェクト: Johnson-Wang/phonopy
    def get_boundary_scattering_strength(self):
        self._set_group_velocity(grid_points=[self._grid_point])
        bnd_collision_unit = 100. / 1e-6 / THz / (2 * np.pi) # unit in THz, unit of length is micron
        gv = self._gv_all[self._grid_point]
        dm = self._pp.get_dynamical_matrix()
        gv1 = get_group_velocity(self._qpoint,
                                dm,
                                symmetry=self._pp._symmetry,
                                q_length=self._gv_delta_q,
                                frequency_factor_to_THz=self._pp.get_frequency_factor_to_THz())

        gv_average = np.sqrt(np.sum(gv ** 2, axis=-1))
        n = self._occupations_all[self._grid_point, self._itemp]
        cout_bnd = gv_average / self._length * n * (n + 1)
        return cout_bnd * bnd_collision_unit
コード例 #5
0
    def get_boundary_scattering_strength(self):
        self._set_group_velocity(grid_points=[self._grid_point])
        bnd_collision_unit = 100. / 1e-6 / THz / (
            2 * np.pi)  # unit in THz, unit of length is micron
        gv = self._gv_all[self._grid_point]
        dm = self._pp.get_dynamical_matrix()
        gv1 = get_group_velocity(
            self._qpoint,
            dm,
            symmetry=self._pp._symmetry,
            q_length=self._gv_delta_q,
            frequency_factor_to_THz=self._pp.get_frequency_factor_to_THz())

        gv_average = np.sqrt(np.sum(gv**2, axis=-1))
        n = self._occupations_all[self._grid_point, self._itemp]
        cout_bnd = gv_average / self._length * n * (n + 1)
        return cout_bnd * bnd_collision_unit
コード例 #6
0
    def _set_kappa_at_sigmas(self, i):
        freqs = self._frequencies[i]
        
        # Group velocity [num_freqs, 3]
        if not self._read_gv:
            gv = get_group_velocity(
                self._qpoint,
                self._dm,
                self._symmetry,
                q_length=self._gv_delta_q,
                frequency_factor_to_THz=self._frequency_factor_to_THz)
            self._gv[i] = gv
        # self._gv[i] = self._get_degenerate_gv(i)

        
        # Heat capacity [num_temps, num_freqs]
        cv = self._get_cv(freqs)
        self._cv[i] = cv
        num_kstar_counted = False
        try:
            import anharmonic._phono3py as phono3c
            rec_lat = np.linalg.inv(self._primitive.get_cell())
            kpt_rotations_at_q = self._get_rotations_for_star(i)
            if self._sigma_iteration_step == 0:
                self._sum_num_kstar += len(kpt_rotations_at_q)
                num_kstar_counted = True
            deg = degenerate_sets(self._frequencies[i])
            degeneracy = np.zeros(len(self._frequencies[i]), dtype="intc")
            for ele in deg:
                for sub_ele in ele:
                    degeneracy[sub_ele]=ele[0]
            for j, sigma in enumerate(self._sigmas):
                kappa_at_qs = np.zeros_like(self._kappa[j,i])
                mfp = np.zeros((len(self._temperatures), self._frequencies.shape[1], 3), dtype="double")
                for t, temp in enumerate(self._temperatures):
                    for k in range(3):
                        mfp[t,:,k] = np.where(self._gamma[j,i,t] > 0.5 / self._cutoff_lifetime / THz,
                                          self._gv[i,:,k] /  self._gamma[j,i,t],
                                          0)
                phono3c.thermal_conductivity_at_grid(kappa_at_qs,
                                                     kpt_rotations_at_q.astype("intc").copy(),
                                                     rec_lat.copy(),
                                                     cv.copy(),
                                                     mfp.copy(),
                                                     self._gv[i].copy(),
                                                     degeneracy.copy())
                self._kappa[j,i] = kappa_at_qs / 2 * self._conversion_factor

        except ImportError:
            print "Warning: kappa calculation (the final step) went wrong in the C implementation. Changing to python instead..."
            # Outer product of group velocities (v x v) [num_k*, num_freqs, 3, 3]
            gv_by_gv_tensor = self._get_gv_by_gv(i)
            if self._sigma_iteration_step == 0 and num_kstar_counted == False:
                self._sum_num_kstar += len(gv_by_gv_tensor)

            # Sum all vxv at k*
            gv_sum2 = np.zeros((6, len(freqs)), dtype='double')
            for j, vxv in enumerate(
                ([0, 0], [1, 1], [2, 2], [1, 2], [0, 2], [0, 1])):
                gv_sum2[j] = gv_by_gv_tensor[:, :, vxv[0], vxv[1]].sum(axis=0)

            # Kappa
            for j, sigma in enumerate(self._sigmas):
                for k, l in list(np.ndindex(len(self._temperatures), len(freqs))):
                    if self._gamma[j, i, k, l] < 0.5 / self._cutoff_lifetime / THz:
                        continue
                    self._kappa[j, i, k, l, :] = (
                        gv_sum2[:, l] * cv[k, l] / (self._gamma[j, i, k, l] * 2) *
                        self._conversion_factor)