示例#1
0
 def test_bz_plot(self):
     fig, ax = plot_ellipsoid(self.hessian,
                              self.center,
                              lattice=self.rec_latt)
     plot_brillouin_zone(self.rec_latt,
                         lines=self.kpath,
                         labels=self.labels,
                         kpoints=self.points,
                         ax=ax,
                         show=False)
示例#2
0
    def plot(self, ax=None, **kwargs):
        from pymatgen.electronic_structure.plotter import plot_brillouin_zone
        fold = False

        if self.is_path:
            labels = {k.name: k.frac_coords for k in self if k.name}
            frac_coords_lines = [self.frac_coords[line] for line in self.lines]
            return plot_brillouin_zone(self.reciprocal_lattice, lines=frac_coords_lines, labels=labels,
                                       ax=ax, fold=fold, **kwargs)
        else:
            # Not sure this works, I got points outside of the BZ in a simple with Si and Gamm-centered 8x8x8.
            # Don't know if it's a bug in matplotlib or plot_brillouin_zone.
            #print(self.frac_coords)
            return plot_brillouin_zone(self.reciprocal_lattice, kpoints=self.frac_coords,
                                       ax=ax, fold=fold, **kwargs)
示例#3
0
文件: kpoints.py 项目: Npikeulg/abipy
    def plot(self, ax=None, **kwargs):
        from pymatgen.electronic_structure.plotter import plot_brillouin_zone
        fold = False

        if self.is_path:
            labels = {k.name: k.frac_coords for k in self if k.name}
            frac_coords_lines = [self.frac_coords[line] for line in self.lines]
            return plot_brillouin_zone(self.reciprocal_lattice, lines=frac_coords_lines, labels=labels,
                                       ax=ax, fold=fold, **kwargs)
        else:
            # Not sure this works, I got points outside of the BZ in a simple with Si and Gamm-centered 8x8x8.
            # Don't know if it's a bug in matplotlib or plot_brillouin_zone.
            #print(self.frac_coords)
            return plot_brillouin_zone(self.reciprocal_lattice, kpoints=self.frac_coords,
                                       ax=ax, fold=fold, **kwargs)
示例#4
0
    def get_kpath_plot(self, **kwargs):
        """
        Gives the plot (as a matplotlib object) of the symmetry line path in
        the Brillouin Zone.

        Returns:
            `matplotlib` figure.


        ================  ====================================================
        kwargs            Meaning
        ================  ====================================================
        title             Title of the plot (Default: None).
        show              True to show the figure (default: True).
        savefig           'abc.png' or 'abc.eps' to save the figure to a file.
        size_kwargs       Dictionary with options passed to fig.set_size_inches
                          example: size_kwargs=dict(w=3, h=4)
        tight_layout      True if to call fig.tight_layout (default: False)
        ================  ====================================================
        """

        lines = [[self.kpath['kpoints'][k] for k in p]
                 for p in self.kpath['path']]
        return plot_brillouin_zone(bz_lattice=self._prim_rec,
                                   lines=lines,
                                   labels=self.kpath['kpoints'],
                                   **kwargs)
示例#5
0
    def plot_brillouin(self):
        """
        plot the Brillouin zone
        """

        # get labels and lines
        labels = {}
        for q in self._bs.qpoints:
            if q.label:
                labels[q.label] = q.frac_coords

        lines = []
        for b in self._bs.branches:
            lines.append([self._bs.qpoints[b['start_index']].frac_coords,
                          self._bs.qpoints[b['end_index']].frac_coords])

        plot_brillouin_zone(self._bs.lattice_rec, lines=lines, labels=labels)
示例#6
0
    def plot_brillouin(self):
        """
        plot the Brillouin zone
        """

        # get labels and lines
        labels = {}
        for q in self._bs.qpoints:
            if q.label:
                labels[q.label] = q.frac_coords

        lines = []
        for b in self._bs.branches:
            lines.append([self._bs.qpoints[b['start_index']].frac_coords,
                          self._bs.qpoints[b['end_index']].frac_coords])

        plot_brillouin_zone(self._bs.lattice_rec, lines=lines, labels=labels)
示例#7
0
def brillplot(filenames=None,
              prefix=None,
              directory=None,
              width=6,
              height=6,
              fonts=None,
              image_format="pdf",
              dpi=400):
    """Generate plot of first brillouin zone from a band-structure calculation.
    Args:
        filenames (:obj:`str` or :obj:`list`, optional): Path to input files.
            Vasp:
                Use vasprun.xml or vasprun.xml.gz file.
        image_format (:obj:`str`, optional): The image file format. Can be any
            format supported by matplotlib, including: png, jpg, pdf, and svg.
            Defaults to pdf.
        dpi (:obj:`int`, optional): The dots-per-inch (pixel density) for the
            image.
    """
    if not filenames:
        filenames = find_vasprun_files()
    elif isinstance(filenames, str):
        filenames = [filenames]
    bandstructures = []
    for vr_file in filenames:
        vr = BSVasprun(vr_file)
        bs = vr.get_band_structure(line_mode=True)
        bandstructures.append(bs)
    bs = get_reconstructed_band_structure(bandstructures)

    labels = {}
    for k in bs.kpoints:
        if k.label:
            labels[k.label] = k.frac_coords

    lines = []
    for b in bs.branches:
        lines.append([
            bs.kpoints[b['start_index']].frac_coords,
            bs.kpoints[b['end_index']].frac_coords
        ])

    plt = pretty_plot_3d(width, height, dpi=dpi, fonts=fonts)
    fig = plot_brillouin_zone(bs.lattice_rec,
                              lines=lines,
                              labels=labels,
                              ax=plt.gca())

    basename = "brillouin.{}".format(image_format)
    filename = "{}_{}".format(prefix, basename) if prefix else basename
    if directory:
        filename = os.path.join(directory, filename)
    fig.savefig(filename, format=image_format, dpi=dpi, bbox_inches="tight")
    return plt
示例#8
0
    def get_kpath_plot(self, **kwargs):
        """
        Gives the plot (as a matplotlib object) of the symmetry line path in
        the Brillouin Zone.

        Returns:
            `matplotlib` figure.


        ================  ====================================================
        kwargs            Meaning
        ================  ====================================================
        title             Title of the plot (Default: None).
        show              True to show the figure (default: True).
        savefig           'abc.png' or 'abc.eps' to save the figure to a file.
        size_kwargs       Dictionary with options passed to fig.set_size_inches
                          example: size_kwargs=dict(w=3, h=4)
        tight_layout      True if to call fig.tight_layout (default: False)
        ================  ====================================================
        """

        lines = [[self.kpath['kpoints'][k] for k in p] for p in self.kpath['path']]
        return plot_brillouin_zone(bz_lattice=self._prim_rec, lines=lines, labels=self.kpath['kpoints'], **kwargs)
示例#9
0
 def test_bz_plot(self):
     fig, ax = plot_ellipsoid(self.hessian, self.center, lattice=self.rec_latt)
     plot_brillouin_zone(self.rec_latt, lines=self.kpath, labels=self.labels, kpoints=self.points, ax=ax, show=False)