Exemplo n.º 1
0
    def get_frequency_shift(self,
                            grid_points,
                            epsilon=0.1,
                            temperatures=np.arange(0, 1001, 10, dtype='double'),
                            output_filename=None):
        fst = FrequencyShift(self._interaction)
        for gp in grid_points:
            fst.set_grid_point(gp)
            if self._log_level:
                weights = self._interaction.get_triplets_at_q()[1]
                print "------ Frequency shift -o- ------"
                print "Number of ir-triplets:",
                print "%d / %d" % (len(weights), weights.sum())
            fst.run_interaction()
            fst.set_epsilon(epsilon)
            delta = np.zeros((len(temperatures),
                              len(self._band_indices_flatten)),
                             dtype='double')
            for i, t in enumerate(temperatures):
                fst.set_temperature(t)
                fst.run()
                delta[i] = fst.get_frequency_shift()

            for i, bi in enumerate(self._band_indices):
                pos = 0
                for j in range(i):
                    pos += len(self._band_indices[j])

                write_frequency_shift(gp,
                                      bi,
                                      temperatures,
                                      delta[:, pos:(pos+len(bi))],
                                      self._mesh,
                                      epsilon=epsilon,
                                      filename=output_filename)
Exemplo n.º 2
0
def get_frequency_shift(interaction,
                        grid_points,
                        band_indices,
                        epsilons,
                        temperatures=None,
                        output_filename=None,
                        log_level=0):
    if temperatures is None:
        temperatures = [0.0, 300.0]
    fst = FrequencyShift(interaction)
    band_indices_flatten = interaction.get_band_indices()
    mesh = interaction.get_mesh_numbers()
    for gp in grid_points:
        fst.set_grid_point(gp)
        if log_level:
            weights = interaction.get_triplets_at_q()[1]
            print("------ Frequency shift -o- ------")
            print("Number of ir-triplets: "
                  "%d / %d" % (len(weights), weights.sum()))
        fst.run_interaction()

        for epsilon in epsilons:
            fst.set_epsilon(epsilon)
            delta = np.zeros((len(temperatures),
                              len(band_indices_flatten)),
                             dtype='double')
            for i, t in enumerate(temperatures):
                fst.set_temperature(t)
                fst.run()
                delta[i] = fst.get_frequency_shift()
    
            for i, bi in enumerate(band_indices):
                pos = 0
                for j in range(i):
                    pos += len(band_indices[j])
    
                write_frequency_shift(gp,
                                      bi,
                                      temperatures,
                                      delta[:, pos:(pos+len(bi))],
                                      mesh,
                                      epsilon=epsilon,
                                      filename=output_filename)
Exemplo n.º 3
0
def get_frequency_shift(interaction,
                        grid_points,
                        band_indices,
                        epsilons,
                        temperatures=None,
                        output_filename=None,
                        log_level=0):
    if temperatures is None:
        temperatures = [0.0, 300.0]
    fst = FrequencyShift(interaction)
    band_indices_flatten = interaction.get_band_indices()
    mesh = interaction.get_mesh_numbers()
    for gp in grid_points:
        fst.set_grid_point(gp)
        if log_level:
            weights = interaction.get_triplets_at_q()[1]
            print("------ Frequency shift -o- ------")
            print("Number of ir-triplets: "
                  "%d / %d" % (len(weights), weights.sum()))
        fst.run_interaction()

        for epsilon in epsilons:
            fst.set_epsilon(epsilon)
            delta = np.zeros((len(temperatures), len(band_indices_flatten)),
                             dtype='double')
            for i, t in enumerate(temperatures):
                fst.set_temperature(t)
                fst.run()
                delta[i] = fst.get_frequency_shift()

            for i, bi in enumerate(band_indices):
                pos = 0
                for j in range(i):
                    pos += len(band_indices[j])

                write_frequency_shift(gp,
                                      bi,
                                      temperatures,
                                      delta[:, pos:(pos + len(bi))],
                                      mesh,
                                      epsilon=epsilon,
                                      filename=output_filename)
Exemplo n.º 4
0
    def run_frequency_shift(self, grid_points):
        if self._log_level:
            print "------------------------",
            print "Frequency shifts of fc4 ",
            print "------------------------"

        freq_shifts = []
        num_band = len(self._band_indices_flatten)
        for i, gp in enumerate(grid_points):
            qpoint = self._grid_address[gp].astype(float) / self._mesh
            if self._log_level:
                print "=========================",
                print "Grid point %d (%d/%d)" % (gp, i + 1, len(grid_points)),
                print "========================="
                print "q-point:", qpoint
            self._interaction.set_grid_point(gp)
            self._interaction.run()
            f_shifts_at_temps = self._interaction.get_frequency_shifts()
            if self._log_level:
                print "Harmonic phonon frequencies:"
                freqs = self._frequencies[gp][self._band_indices_flatten]
                print "%7s " % "",
                print("%8.4f " * num_band) % tuple(freqs)
                print "Frequency shifts:"
                for t, f_shift in zip(self._temperatures, f_shifts_at_temps):
                    print "%7.1f " % t,
                    print("%8.4f " * num_band) % tuple(f_shift)
            freq_shifts.append(f_shifts_at_temps)

        self._frequency_shifts = np.array(freq_shifts, dtype='double')

        for i, gp in enumerate(grid_points):
            for j, bi in enumerate(self._band_indices):
                pos = 0
                for k in range(j):
                    pos += len(self._band_indices[k])

                write_frequency_shift(gp, bi, self._temperatures,
                                      freq_shifts[i][:, pos:(pos + len(bi))],
                                      self._mesh)
Exemplo n.º 5
0
    def run_frequency_shift(self, grid_points):
        if self._log_level:
            print "------------------------",
            print "Frequency shifts of fc4 ",
            print "------------------------"

        freq_shifts = []
        num_band = len(self._band_indices_flatten)
        for i, gp in enumerate(grid_points):
            qpoint = self._grid_address[gp].astype(float) / self._mesh
            if self._log_level:
                print "=========================",
                print "Grid point %d (%d/%d)" % (gp, i + 1, len(grid_points)),
                print "========================="
                print "q-point:", qpoint
            self._interaction.set_grid_point(gp)
            self._interaction.run()
            f_shifts_at_temps = self._interaction.get_frequency_shifts()
            if self._log_level:
                print "Harmonic phonon frequencies:"
                freqs = self._frequencies[gp][self._band_indices_flatten]
                print "%7s " % "",
                print ("%8.4f " * num_band) % tuple(freqs)
                print "Frequency shifts:"
                for t, f_shift in zip(self._temperatures, f_shifts_at_temps):
                    print "%7.1f " % t,
                    print ("%8.4f " * num_band) % tuple(f_shift)
            freq_shifts.append(f_shifts_at_temps)

        self._frequency_shifts = np.array(freq_shifts, dtype="double")

        for i, gp in enumerate(grid_points):
            for j, bi in enumerate(self._band_indices):
                pos = 0
                for k in range(j):
                    pos += len(self._band_indices[k])

                write_frequency_shift(gp, bi, self._temperatures, freq_shifts[i][:, pos : (pos + len(bi))], self._mesh)
Exemplo n.º 6
0
    def get_frequency_shift(self,
                            grid_points,
                            epsilon=0.1,
                            temperatures=np.linspace(0,
                                                     1000,
                                                     endpoint=True,
                                                     num=101),
                            filename=None):
        fst = FrequencyShift(self._interaction)
        for gp in grid_points:
            fst.set_grid_point(gp)
            if self._log_level:
                weights = self._interaction.get_triplets_at_q()[1]
                print "------ Frequency shift -o- ------"
                print "Number of ir-triplets:",
                print "%d / %d" % (len(weights), weights.sum())
            fst.run_interaction()
            fst.set_epsilon(epsilon)
            delta = np.zeros((len(temperatures), len(self._band_indices)),
                             dtype='double')
            for i, t in enumerate(temperatures):
                fst.set_temperature(t)
                fst.run()
                delta[i] = fst.get_frequency_shift()

            for i, bi in enumerate(self._band_indices):
                pos = 0
                for j in range(i):
                    pos += len(self._band_indices[j])

                write_frequency_shift(gp,
                                      bi,
                                      temperatures,
                                      delta[:, pos:(pos + len(bi))],
                                      self._mesh,
                                      epsilon=epsilon,
                                      filename=filename)