Ejemplo n.º 1
0
    def _frequency_shifts_at_bands(self, i, bi, freqs, interaction, weight):
        sum_d = 0
        for (j, k) in list(np.ndindex(interaction.shape[1:])):
            if (freqs[1, j] > self._cutoff_frequency and
                freqs[2, k] > self._cutoff_frequency):
                d = 0.0
                n2 = occupation(freqs[1, j], self._temperature)
                n3 = occupation(freqs[2, k], self._temperature)
                f1 = freqs[0, bi] + freqs[1, j] + freqs[2, k]
                f2 = freqs[0, bi] - freqs[1, j] - freqs[2, k]
                f3 = freqs[0, bi] - freqs[1, j] + freqs[2, k]
                f4 = freqs[0, bi] + freqs[1, j] - freqs[2, k]

                # if abs(f1) > self._epsilon:
                #     d -= (n2 + n3 + 1) / f1
                # if abs(f2) > self._epsilon:
                #     d += (n2 + n3 + 1) / f2
                # if abs(f3) > self._epsilon:
                #     d -= (n2 - n3) / f3
                # if abs(f4) > self._epsilon:
                #     d += (n2 - n3) / f4
                d -= (n2 + n3 + 1) * f1 / (f1 ** 2 + self._epsilon ** 2)
                d += (n2 + n3 + 1) * f2 / (f2 ** 2 + self._epsilon ** 2)
                d -= (n2 - n3) * f3 / (f3 ** 2 + self._epsilon ** 2)
                d += (n2 - n3) * f4 / (f4 ** 2 + self._epsilon ** 2)

                sum_d += d * interaction[i, j, k] * weight
        return sum_d
Ejemplo n.º 2
0
 def _ise_at_bands(self, i, bi, freqs, interaction, weight):
     sum_g = 0
     for (j, k) in list(np.ndindex(interaction.shape[1:])):
         if (freqs[1][j] > self._cutoff_frequency and
             freqs[2][k] > self._cutoff_frequency):
             n2 = occupation(freqs[1][j], self._temperature)
             n3 = occupation(freqs[2][k], self._temperature)
             g1 = gaussian(freqs[0, bi] - freqs[1, j] - freqs[2, k],
                           self._sigma)
             g2 = gaussian(freqs[0, bi] + freqs[1, j] - freqs[2, k],
                           self._sigma)
             g3 = gaussian(freqs[0, bi] - freqs[1, j] + freqs[2, k],
                           self._sigma)
             sum_g += ((n2 + n3 + 1) * g1 +
                       (n2 - n3) * (g2 - g3)) * interaction[i, j, k] * weight
     return sum_g
Ejemplo n.º 3
0
    def _run_c_with_g(self, is_band_freq=False):
        self.set_phonons(self._triplets_at_q.ravel())
        if is_band_freq == True:
            self._frequency_points = self._frequencies[self._grid_point]
        else:
            if self._sigma is None:
                f_max = np.max(self._frequencies) * 2
            else:
                f_max = np.max(self._frequencies) * 2 + self._sigma * 4
            f_max *= 1.005
            f_min = 0
            self._set_frequency_points(f_min, f_max)

        num_freq_points = len(self._frequency_points)
        num_mesh = np.prod(self._mesh)

        if self._temperatures is None:
            jdos = np.zeros((num_freq_points, 2), dtype='double')
        else:
            num_temps = len(self._temperatures)
            jdos = np.zeros((num_temps, num_freq_points, 2), dtype='double')
            occ_phonons = []
            for t in self._temperatures:
                freqs = self._frequencies[self._triplets_at_q[:, 1:]]
                occ_phonons.append(np.where(freqs > self._cutoff_frequency,
                                            occupation(freqs, t), 0))

        for i, freq_point in enumerate(self._frequency_points):
            g = get_triplets_integration_weights(
                self,
                np.array([freq_point], dtype='double'),
                self._sigma,
                neighboring_phonons=(i == 0),
                is_triplet_symmetry=False)


            if self._temperatures is None:
                jdos[i, 1] = np.sum(
                    np.tensordot(g[0, :, 0], self._weights_at_q, axes=(0, 0)))
                # gx = g[2] - g[0]
                gx = g[1] + g[2]
                jdos[i, 0] = - np.sum(
                    np.tensordot(gx[:, 0], self._weights_at_q, axes=(0, 0)))# the negative sign is for a clearer plot

            else:
                # g1 = g[1]
                g1 = g[2] - g[1]
                for j, n in enumerate(occ_phonons): # loop over temperature
                    for k, l in list(np.ndindex(g.shape[3:])): # double loop over other two phonon branches
                        jdos[j, i, 1] += np.dot(
                            (n[:, 0, k] + n[:, 1, l] + 1) *
                            g[0, :, 0, k, l], self._weights_at_q)
                        jdos[j, i, 0] += - np.dot((n[:, 0, k] - n[:, 1, l]) *
                                                g1[:, 0, k, l],
                                                self._weights_at_q) # the negative sign is for a clearer plot

        self._joint_dos = jdos / num_mesh
Ejemplo n.º 4
0
    def _ise_thm_with_frequency_points(self):
        for i, (tp, w, interaction) in enumerate(zip(self._triplets_at_q,
                                                     self._weights_at_q,
                                                     self._fc3_normal_squared)):
            for j, k in list(np.ndindex(interaction.shape[1:])):
                f1 = self._frequencies[tp[1]][j]
                f2 = self._frequencies[tp[2]][k]
                if (f1 > self._cutoff_frequency and
                    f2 > self._cutoff_frequency):
                    n2 = occupation(f1, self._temperature)
                    n3 = occupation(f2, self._temperature)
                    g1 = self._g[0, i, :, j, k]
                    g2_g3 = self._g[1, i, :, j, k] # g2 - g3
                    for l in range(len(interaction)):
                        self._imag_self_energy[:, l] += (
                            (n2 + n3 + 1) * g1 +
                            (n2 - n3) * (g2_g3)) * interaction[l, j, k] * w

        self._imag_self_energy *= self._unit_conversion
Ejemplo n.º 5
0
 def _ise_with_frequency_points(self, freqs, interaction, weight):
     for j, k in list(np.ndindex(interaction.shape[1:])):
         if (freqs[0][j] > self._cutoff_frequency and
             freqs[1][k] > self._cutoff_frequency):
             n2 = occupation(freqs[0][j], self._temperature)
             n3 = occupation(freqs[1][k], self._temperature)
             g1 = gaussian(self._frequency_points
                           - freqs[0][j] - freqs[1][k], self._sigma)
             g2 = gaussian(self._frequency_points
                           + freqs[0][j] - freqs[1][k], self._sigma)
             g3 = gaussian(self._frequency_points
                           - freqs[0][j] + freqs[1][k], self._sigma)
         else:
             continue
         
         for i in range(len(interaction)):
             self._imag_self_energy[:, i] += (
                 (n2 + n3 + 1) * g1 +
                 (n2 - n3) * (g2 - g3)) * interaction[i, j, k] * weight
Ejemplo n.º 6
0
    def _ise_thm_with_frequency_points(self):
        for i, (tp, w, interaction) in enumerate(zip(self._triplets_at_q,
                                                     self._weights_at_q,
                                                     self._pp_strength)):
            for j, k in list(np.ndindex(interaction.shape[1:])):
                f1 = self._frequencies[tp[1]][j]
                f2 = self._frequencies[tp[2]][k]
                if (f1 > self._cutoff_frequency and
                    f2 > self._cutoff_frequency):
                    n2 = occupation(f1, self._temperature)
                    n3 = occupation(f2, self._temperature)
                    g1 = self._g[0, i, :, j, k]
                    g2_g3 = self._g[1, i, :, j, k] # g2 - g3
                    for l in range(len(interaction)):
                        self._imag_self_energy[:, l] += (
                            (n2 + n3 + 1) * g1 +
                            (n2 - n3) * (g2_g3)) * interaction[l, j, k] * w

        self._imag_self_energy *= self._unit_conversion
Ejemplo n.º 7
0
    def _ise_with_frequency_points(self, freqs, interaction, weight):
        for j, k in list(np.ndindex(interaction.shape[1:])):
            if (freqs[0][j] > self._cutoff_frequency and
                freqs[1][k] > self._cutoff_frequency):
                n2 = occupation(freqs[0][j], self._temperature)
                n3 = occupation(freqs[1][k], self._temperature)
                g1 = gaussian(self._frequency_points
                              - freqs[0][j] - freqs[1][k], self._sigma)
                g2 = gaussian(self._frequency_points
                              + freqs[0][j] - freqs[1][k], self._sigma)
                g3 = gaussian(self._frequency_points
                              - freqs[0][j] + freqs[1][k], self._sigma)
            else:
                continue

            for i in range(len(interaction)):
                self._imag_self_energy[:, i] += (
                    (n2 + n3 + 1) * g1 +
                    (n2 - n3) * (g2 - g3)) * interaction[i, j, k] * weight
Ejemplo n.º 8
0
    def _run_c_with_g(self):
        self.set_phonon(self._triplets_at_q.ravel())
        if self._sigma is None:
            f_max = np.max(self._frequencies) * 2
        else:
            f_max = np.max(self._frequencies) * 2 + self._sigma * 4
        f_max *= 1.005
        f_min = 0
        self._set_uniform_frequency_points(f_min, f_max)

        num_freq_points = len(self._frequency_points)
        num_mesh = np.prod(self._mesh)

        if self._temperatures is None:
            jdos = np.zeros((num_freq_points, 2), dtype='double')
        else:
            num_temps = len(self._temperatures)
            jdos = np.zeros((num_temps, num_freq_points, 2), dtype='double')
            occ_phonons = []
            for t in self._temperatures:
                freqs = self._frequencies[self._triplets_at_q[:, 1:]]
                occ_phonons.append(
                    np.where(freqs > self._cutoff_frequency,
                             occupation(freqs, t), 0))

        for i, freq_point in enumerate(self._frequency_points):
            g = get_triplets_integration_weights(self,
                                                 np.array([freq_point],
                                                          dtype='double'),
                                                 self._sigma,
                                                 is_collision_matrix=True,
                                                 neighboring_phonons=(i == 0))

            if self._temperatures is None:
                jdos[i, 1] = np.sum(
                    np.tensordot(g[0, :, 0], self._weights_at_q, axes=(0, 0)))
                gx = g[2] - g[0]
                jdos[i, 0] = np.sum(
                    np.tensordot(gx[:, 0], self._weights_at_q, axes=(0, 0)))
            else:
                for j, n in enumerate(occ_phonons):
                    for k, l in list(np.ndindex(g.shape[3:])):
                        jdos[j, i, 1] += np.dot(
                            (n[:, 0, k] + n[:, 1, l] + 1) * g[0, :, 0, k, l],
                            self._weights_at_q)
                        jdos[j, i, 0] += np.dot(
                            (n[:, 0, k] - n[:, 1, l]) * g[1, :, 0, k, l],
                            self._weights_at_q)

        self._joint_dos = jdos / num_mesh
Ejemplo n.º 9
0
    def _run_c_with_g(self):
        self.set_phonon(self._triplets_at_q.ravel())
        if self._sigma is None:
            f_max = np.max(self._frequencies) * 2
        else:
            f_max = np.max(self._frequencies) * 2 + self._sigma * 4
        f_max *= 1.005
        f_min = 0
        self._set_frequency_points(f_min, f_max)

        num_freq_points = len(self._frequency_points)
        num_mesh = np.prod(self._mesh)

        if self._temperatures is None:
            jdos = np.zeros((num_freq_points, 2), dtype='double')
        else:
            num_temps = len(self._temperatures)
            jdos = np.zeros((num_temps, num_freq_points, 2), dtype='double')
            occ_phonons = []
            for t in self._temperatures:
                freqs = self._frequencies[self._triplets_at_q[:, 1:]]
                occ_phonons.append(np.where(freqs > self._cutoff_frequency,
                                            occupation(freqs, t), 0))
        
        for i, freq_point in enumerate(self._frequency_points):
            g = get_triplets_integration_weights(
                self,
                np.array([freq_point], dtype='double'),
                self._sigma,
                is_collision_matrix=True,
                neighboring_phonons=(i == 0))

            if self._temperatures is None:
                jdos[i, 0] = np.sum(
                    np.tensordot(g[0, :, 0], self._weights_at_q, axes=(0, 0)))
                gx = g[2] - g[0]
                jdos[i, 1] = np.sum(
                    np.tensordot(gx[:, 0], self._weights_at_q, axes=(0, 0)))
            else:
                for j, n in enumerate(occ_phonons):
                    for k, l in list(np.ndindex(g.shape[3:])):
                        jdos[j, i, 0] += np.dot(
                            (n[:, 0, k] + n[:, 1, l] + 1) *
                            g[0, :, 0, k, l], self._weights_at_q)
                        jdos[j, i, 1] += np.dot((n[:, 0, k] - n[:, 1, l]) *
                                                g[1, :, 0, k, l],
                                                self._weights_at_q)

        self._joint_dos = jdos / num_mesh
Ejemplo n.º 10
0
    def _ise_thm_with_band_indices(self):
        freqs = self._frequencies[self._triplets_at_q[:, [1, 2]]]
        freqs = np.where(freqs > self._cutoff_frequency, freqs, 1)
        n = occupation(freqs, self._temperature)
        for i, (tp, w, interaction) in enumerate(zip(self._triplets_at_q,
                                                     self._weights_at_q,
                                                     self._fc3_normal_squared)):
            for j, k in list(np.ndindex(interaction.shape[1:])):
                f1 = self._frequencies[tp[1]][j]
                f2 = self._frequencies[tp[2]][k]
                if (f1 > self._cutoff_frequency and
                    f2 > self._cutoff_frequency):
                    n2 = n[i, 0, j]
                    n3 = n[i, 1, k]
                    g1 = self._g[0, i, :, j, k]
                    g2_g3 = self._g[1, i, :, j, k] # g2 - g3
                    self._imag_self_energy[:] += (
                        (n2 + n3 + 1) * g1 +
                        (n2 - n3) * (g2_g3)) * interaction[:, j, k] * w

        self._imag_self_energy *= self._unit_conversion
Ejemplo n.º 11
0
    def _ise_thm_with_band_indices(self):
        freqs = self._frequencies[self._triplets_at_q[:, [1, 2]]]
        freqs = np.where(freqs > self._cutoff_frequency, freqs, 1)
        n = occupation(freqs, self._temperature)
        for i, (tp, w, interaction) in enumerate(
                zip(self._triplets_at_q, self._weights_at_q,
                    self._pp_strength)):
            for j, k in list(np.ndindex(interaction.shape[1:])):
                f1 = self._frequencies[tp[1]][j]
                f2 = self._frequencies[tp[2]][k]
                if (f1 > self._cutoff_frequency
                        and f2 > self._cutoff_frequency):
                    n2 = n[i, 0, j]
                    n3 = n[i, 1, k]
                    g1 = self._g[0, i, :, j, k]
                    g2_g3 = self._g[1, i, :, j, k]  # g2 - g3
                    self._imag_self_energy[:] += (
                        (n2 + n3 + 1) * g1 + (n2 - n3) *
                        (g2_g3)) * interaction[:, j, k] * w

        self._imag_self_energy *= self._unit_conversion