Example #1
0
 def test_integration_wigner_seitz(self):
     interpolater = Interpolater(self.band_structure)
     new_bs, kpoint_dim = interpolater.interpolate_bands(1)
     fs = FermiSurface.from_band_structure(new_bs, kpoint_dim)
     plotter = FermiSurfacePlotter(fs)
     plotter.plot(plot_type="mpl",
                  interactive=False,
                  filename=self.output_file)
Example #2
0
def fsplot(
    filename: Optional[Union[Path, str]] = None,
    interpolate_factor: int = 8,
    mu: float = 0.0,
    wigner_seitz: bool = True,
    spin: Optional[Spin] = None,
    plot_type: str = "plotly",
    interactive: bool = False,
    slice_info: Optional[Tuple[float, float, float, float]] = None,
    prefix: Optional[str] = None,
    directory: Optional[Union[Path, str]] = None,
    image_format: str = "png",
    dpi: float = 400,
):
    """Plot Fermi surfaces from a vasprun.xml file.

    Args:
        filename: Path to input vasprun file.
        interpolate_factor: The factor by which to interpolate the bands.
        mu: The level above the Fermi energy at which the isosurfaces are to be plotted.
        wigner_seitz: Controls whether the cell is the Wigner-Seitz cell or the
            reciprocal unit cell parallelepiped.
        spin: The spin channel to plot. By default plots both spin channels.
        plot_type: Method used for plotting. Valid options are: "matplotlib", "plotly",
            "mayavi".
        interactive: Whether to enable interactive plots.
        prefix: Prefix for file names.
        slice_info: Slice through the Brillouin zone. Given as the plane normal and
            distance form the plane in fractional coordinates: E.g., ``[1, 0, 0, 0.2]``
            where ``(1, 0, 0)`` are the miller indices and ``0.2`` is the distance from
            the Gamma point.
        directory: The directory in which to save files.
        image_format: The image file format.
        dpi: The dots-per-inch (pixel density) for the image.

    Returns:
        The filename written to disk.
    """
    from ifermi.fermi_surface import FermiSurface
    from ifermi.interpolator import Interpolater
    from ifermi.plotter import FermiSurfacePlotter

    if not filename:
        filename = find_vasprun_file()

    vr = Vasprun(filename)
    bs = vr.get_band_structure()

    interpolater = Interpolater(bs)

    interp_bs, kpoint_dim = interpolater.interpolate_bands(interpolate_factor)
    fs = FermiSurface.from_band_structure(
        interp_bs, kpoint_dim, mu=mu, wigner_seitz=wigner_seitz
    )

    directory = directory if directory else "."
    prefix = "{}_".format(prefix) if prefix else ""

    if slice_info:
        plane_normal = slice_info[:3]
        distance = slice_info[3]

        fermi_slice = fs.get_fermi_slice(plane_normal, distance)
        plotter = FermiSlicePlotter(fermi_slice)

        output_filename = "{}fermi_slice.{}".format(prefix, image_format)
        output_filename = Path(directory) / output_filename
        plotter.plot(filename=output_filename, spin=spin)
    else:
        plotter = FermiSurfacePlotter(fs)

        output_filename = "{}fermi_surface.{}".format(prefix, image_format)
        output_filename = Path(directory) / output_filename
        plotter.plot(
            plot_type=plot_type,
            interactive=interactive,
            filename=output_filename,
            spin=spin,
        )