Esempio n. 1
0
    def __init__(self, Data, band, kpoint_indices):
        """Initialise an instance of the Segment class.

        Args:
            Data (Data): Data instance initialised from the bandstructure which contains the segment
            band (int): the band number of the segment
            kpoint_indices (list(int)): the kpoint indices of the segment

        Returns:
            None.
        """

        self.band = band
        self.kpoint_indices = kpoint_indices
        self.kpoints = np.array([Data.kpoints[k] for k in kpoint_indices
                                 ])  # in units 2*pi/angstrom
        self.cartesian_kpoints = np.array([
            np.dot(k, Data.reciprocal_lattice) for k in self.kpoints
        ])  # in units 1/Angstrom. Reciprocal lattice includes factor 2*pi.
        self.dk_angs = np.linalg.norm(
            self.cartesian_kpoints - self.cartesian_kpoints[0], axis=1)
        self.dk_bohr = np.divide(
            self.dk_angs, angstrom_to_bohr
        )  # divide as we are in reciprocal space --> units in inverse length
        self.energies = np.array(
            [Data.energies[band, k] for k in kpoint_indices])  # in units eV
        self.dE_eV = self.energies - self.energies[0]
        self.dE_hartree = np.multiply(self.energies - self.energies[0],
                                      ev_to_hartree)
        if Data.occupancy is not None:
            self.occupancy = np.array(
                [Data.occupancy[band, k] for k in kpoint_indices])
        else:
            self.occupancy = None
        self.direction = extrema.calculate_direction(self.kpoints[1],
                                                     self.kpoints[2])
        self.fermi_energy = Data.fermi_energy
        self._VBM = Data.VBM
        self._CBM = Data.CBM
        self.band_type = self._band_type()
Esempio n. 2
0
def test_calculate_direction_opposite(toy_data_object):
    a = toy_data_object.kpoints[1]
    b = toy_data_object.kpoints[0]

    assert np.allclose(extrema.calculate_direction(a, b), np.array([1, 0, 0]))