Esempio n. 1
0
def get_kpath(structure,
              mode="pymatgen",
              symprec=_symprec,
              kpt_list=None,
              labels=None):
    r"""Get a Kpath object

    If a manual list of kpoints is supplied using the `kpt_list`
    variable, the `mode` option will be ignored.

    Args:
        structure: The structure.
        mode: Method used for calculating the
            high-symmetry path. The options are:

            pymatgen
                Use the paths from pymatgen.

            seekpath
                Use the paths from SeeK-path.

        symprec: The tolerance for determining the crystal symmetry.
        kpt_list: List of k-points to use, formatted as a list of subpaths, each
            containing a list of fractional k-points. For example:

            ```
                [ [[0., 0., 0.], [0., 0., 0.5]], [[0.5, 0., 0.], [0.5, 0.5, 0.]] ]
            ```

            will return points along `0 0 0 -> 0 0 1/2 | 1/2 0 0 -> 1/2 1/2 0`
        labels: The k-point labels. These should be provided as a list of strings for
            each subpath of the overall path. For example::

            ```
                [ ['Gamma', 'Z'], ['X', 'M'] ]
            ```

            combined with the above example for `kpt_list` would indicate the path:
            `Gamma -> Z | X -> M`. If no labels are provided, letters from A -> Z will
            be used instead.

    Returns:
        A Kpath object.
    """
    from sumo.symmetry import SeekpathKpath, PymatgenKpath, CustomKpath

    if kpt_list:
        kpath = CustomKpath(structure, kpt_list, labels, symprec=symprec)
    elif mode == "seekpath":
        kpath = SeekpathKpath(structure, symprec=symprec)
    else:
        kpath = PymatgenKpath(structure, symprec=symprec)

    return kpath
Esempio n. 2
0
    def get_line_mode_band_structure(
        self,
        line_density: int = 50,
        kpath: Optional[Kpath] = None,
        symprec: Optional[float] = defaults["symprec"],
        return_other_properties: bool = False,
    ) -> Union[
        BandStructureSymmLine,
        Tuple[BandStructureSymmLine, Dict[Spin, Dict[str, np.ndarray]]],
    ]:
        """Gets the interpolated band structure along high symmetry directions.

        Args:
            line_density: The maximum number of k-points between each two
                consecutive high-symmetry k-points
            symprec: The symmetry tolerance used to determine the space group
                and high-symmetry path.
            return_other_properties: Whether to include the interpolated
                other_properties data for each k-point along the band structure path.

        Returns:
            The line mode band structure.
        """
        if not kpath:
            kpath = PymatgenKpath(self.structure, symprec=symprec)

        kpoints, labels = kpath.get_kpoints(line_density=line_density, cart_coords=True)
        labels_dict = {
            label: kpoint for kpoint, label in zip(kpoints, labels) if label != ""
        }

        rlat = self.structure.lattice.reciprocal_lattice
        frac_kpoints = rlat.get_fractional_coords(kpoints)

        energies = {}
        other_properties = defaultdict(dict)
        for spin in self.spins:
            energies[spin] = self._interpolate_spin(
                spin, frac_kpoints, self.bs_interpolator
            )

            if return_other_properties:
                for prop, property_interpolator in self.property_interpolators.items():
                    other_properties[spin][prop] = self._interpolate_spin(
                        spin, frac_kpoints, property_interpolator
                    )

        bs = BandStructureSymmLine(
            kpoints,
            energies,
            rlat,
            self.efermi,
            labels_dict,
            coords_are_cartesian=True,
            structure=self.structure,
        )

        if return_other_properties:
            return bs, other_properties
        else:
            return bs
Esempio n. 3
0
    def get_line_mode_band_structure(
        self,
        line_density: int = 50,
        kpath: Optional[Kpath] = None,
        energy_cutoff: Optional[float] = None,
        scissor: Optional[float] = None,
        bandgap: Optional[float] = None,
        symprec: float = defaults["symprec"],
        return_other_properties: bool = False,
    ) -> Union[BandStructureSymmLine, Tuple[BandStructureSymmLine, Dict[
            Spin, Dict[str, np.ndarray]]], ]:
        """Gets the interpolated band structure along high symmetry directions.

        Args:
            line_density: The maximum number of k-points between each two
                consecutive high-symmetry k-points
            energy_cutoff: The energy cut-off to determine which bands are
                included in the interpolation. If the energy of a band falls
                within the cut-off at any k-point it will be included. For
                metals the range is defined as the Fermi level ± energy_cutoff.
                For gapped materials, the energy range is from the VBM -
                energy_cutoff to the CBM + energy_cutoff.
            scissor: The amount by which the band gap is scissored. Cannot
                be used in conjunction with the ``bandgap`` option. Has no
                effect for metallic systems.
            bandgap: Automatically adjust the band gap to this value. Cannot
                be used in conjunction with the ``scissor`` option. Has no
                effect for metallic systems.
            symprec: The symmetry tolerance used to determine the space group
                and high-symmetry path.
            return_other_properties: Whether to include the interpolated
                other_properties data for each k-point along the band structure path.

        Returns:
            The line mode band structure.
        """
        if not kpath:
            kpath = PymatgenKpath(self._band_structure.structure,
                                  symprec=symprec)

        kpoints, labels = kpath.get_kpoints(line_density=line_density,
                                            cart_coords=True)
        labels_dict = {
            label: kpoint
            for kpoint, label in zip(kpoints, labels) if label != ""
        }

        energies = self.get_energies(
            kpoints,
            scissor=scissor,
            bandgap=bandgap,
            atomic_units=False,
            energy_cutoff=energy_cutoff,
            coords_are_cartesian=True,
            return_other_properties=return_other_properties,
            symprec=symprec,
        )

        if return_other_properties:
            energies, other_properties = energies

        bs = BandStructureSymmLine(
            kpoints,
            energies,
            self._band_structure.structure.lattice,
            self._band_structure.efermi,
            labels_dict,
            coords_are_cartesian=True,
        )

        if return_other_properties:
            return bs, other_properties
        else:
            return bs
Esempio n. 4
0
def get_path_data(structure,
                  mode='bradcrack',
                  symprec=0.01,
                  spg=None,
                  line_density=60,
                  cart_coords=False,
                  kpt_list=None,
                  labels=None,
                  phonopy=False):
    r"""Get the k-point path, coordinates and symmetry labels for a structure.

    If a manual :obj:`list` of kpoints is supplied using the ``kpt_list``
    variable, the ``mode`` option will be ignored.

    The format of the returned data will be different if phonopy is ``True`` or
    ``False``. This is because phonopy requires the labels and kpoints to be
    provided in a different format than kgen.

    Args:
        structure (:obj:`~pymatgen.core.structure.Structure`): The structure.
        mode (:obj:`str`, optional): Method used for calculating the
            high-symmetry path. The options are:

            bradcrack
                Use the paths from Bradley and Cracknell. See [brad]_.

            pymatgen
                Use the paths from pymatgen. See [curt]_.

            seekpath
                Use the paths from SeeK-path. See [seek]_.

        symprec (:obj:`float`, optional): The tolerance for determining the
            crystal symmetry.
        spg (:obj:`~pymatgen.symmetry.groups.SpaceGroup`, optional): Space
            group used to override the symmetry determined by spglib. This is
            not recommended and only provided for testing purposes.
            This option will only take effect when ``mode = 'bradcrack'``.
        line_density (:obj:`int`, optional): Density of k-points along the
            path.
        cart_coords (:obj:`bool`, optional): Whether the k-points are returned
            in cartesian or reciprocal coordinates. Defaults to ``False``
            (fractional coordinates).
        kpt_list (:obj:`list`, optional): List of k-points to use, formatted as
            a list of subpaths, each containing a list of fractional k-points.
            For example::

                [ [[0., 0., 0.], [0., 0., 0.5]],
                  [[0.5, 0., 0.], [0.5, 0.5, 0.]] ]

            Will return points along ``0 0 0 -> 0 0 1/2 | 1/2 0 0
            -> 1/2 1/2 0``
        path_labels (:obj:`list`, optional): The k-point labels. These should
            be provided as a :obj:`list` of :obj:`str` for each subpath of the
            overall path. For example::

                [ ['Gamma', 'Z'], ['X', 'M'] ]

            combined with the above example for ``kpt_list`` would indicate the
            path: Gamma -> Z | X -> M. If no labels are provided, letters from
            A -> Z will be used instead.
        phonopy (:obj:`bool`, optional): Format the k-points and labels for
            use with phonopy. Defaults to ``False``.

    Returns:
        tuple: A tuple of a :obj:`~sumo.symmetry.kpath` object, the k-points
        along the high-symmetry path, and the k-point labels. Returned as
        ``(kpath, kpoints, labels)``.

        The type of ``kpath`` object will depend on the value of ``mode`` and
        whether ``kpt_list`` is set.

        If ``phonopy == False``, then:

            * ``kpoints`` is a :obj:`numpy.ndarray` of the k-point
                coordinates along the high-symmetry path. For example::

                    [[0, 0, 0], [0.25, 0, 0], [0.5, 0, 0], [0.5, 0, 0.25],
                    [0.5, 0, 0.5]]

            * ``labels`` is a :obj:`list` of the high symmetry labels for
                each k-point (will be an empty :obj:`str` if the k-point has
                no label). For example::

                    ['\Gamma', '', 'X', '', 'Y']

        If ``phonopy == True``, then:

            * ``kpoints`` is a :obj:`list` of :obj:`numpy.ndarray`
                containing the k-points for each branch of the band
                structure. This means that the first and last k-points of a
                particular branch may be repeated. For example::

                    [[[0, 0, 0], [0.25, 0, 0], [0.5, 0, 0]],
                    [[0.5, 0, 0], [0.5, 0, 0.25], [0.5, 0, 0.5]]]

            * ``labels`` is a :obj:`list` of the high symmetry labels.
                For example::

                    ['\Gamma', 'X', 'Y']
    """
    import logging
    from sumo.symmetry import (BradCrackKpath, SeekpathKpath, PymatgenKpath,
                               CustomKpath)
    spg = _get_space_group_object(spg, mode)

    if kpt_list:
        kpath = CustomKpath(structure, kpt_list, labels, symprec=symprec)
    elif mode == 'bradcrack':
        kpath = BradCrackKpath(structure, symprec=symprec, spg=spg)
    elif mode == 'seekpath':
        kpath = SeekpathKpath(structure, symprec=symprec)
    elif mode == 'pymatgen':
        kpath = PymatgenKpath(structure, symprec=symprec)

    kpoints, labels = kpath.get_kpoints(line_density=line_density,
                                        phonopy=phonopy)
    path_str = kpath.path_string
    kpt_dict = kpath.kpoints

    logging.info('Structure information:'.format(structure.num_sites))
    logging.info('\tSpace group number: {}'.format(kpath._spg_data['number']))

    logging.info('\tInternational symbol: {}'.format(kpath.spg_symbol))
    logging.info('\tLattice type: {}'.format(kpath.lattice_type))

    logging.info('\nk-point path:\n\t{}'.format(path_str))
    logging.info('\nk-points:')

    for label, kpoint in iter(kpt_dict.items()):
        coord_str = ' '.join(['{}'.format(c) for c in kpoint])
        logging.info('\t{}: {}'.format(label, coord_str))

    return kpath, kpoints, labels