当前位置: 首页>>代码示例>>Python>>正文


Python outputs.Vasprun类代码示例

本文整理汇总了Python中pymatgen.io.vasp.outputs.Vasprun的典型用法代码示例。如果您正苦于以下问题:Python Vasprun类的具体用法?Python Vasprun怎么用?Python Vasprun使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Vasprun类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: find_dirac_nodes

def find_dirac_nodes():
    """
    Look for band crossings near (within `tol` eV) the Fermi level.

    Returns:
        boolean. Whether or not a band crossing occurs at or near
            the fermi level.
    """

    vasprun = Vasprun('vasprun.xml')
    dirac = False
    if vasprun.get_band_structure().get_band_gap()['energy'] < 0.1:
        efermi = vasprun.efermi
        bsp = BSPlotter(vasprun.get_band_structure('KPOINTS', line_mode=True,
                                                   efermi=efermi))
        bands = []
        data = bsp.bs_plot_data(zero_to_efermi=True)
        for d in range(len(data['distances'])):
            for i in range(bsp._nb_bands):
                x = data['distances'][d],
                y = [data['energy'][d][str(Spin.up)][i][j]
                     for j in range(len(data['distances'][d]))]
                band = [x, y]
                bands.append(band)

        considered = []
        for i in range(len(bands)):
            for j in range(len(bands)):
                if i != j and (j, i) not in considered:
                    considered.append((j, i))
                    for k in range(len(bands[i][0])):
                        if ((-0.1 < bands[i][1][k] < 0.1) and
                                (-0.1 < bands[i][1][k] - bands[j][1][k] < 0.1)):
                            dirac = True
    return dirac
开发者ID:henniggroup,项目名称:MPInterfaces,代码行数:35,代码来源:analysis.py

示例2: get_band_edges

def get_band_edges():
    """
    Calculate the band edge locations relative to the vacuum level
    for a semiconductor. If spin-polarized, returns all 4 band edges.
    """

    # Vacuum level energy from LOCPOT.
    locpot = Locpot.from_file("LOCPOT")
    evac = max(locpot.get_average_along_axis(2))

    vasprun = Vasprun("vasprun.xml")
    efermi = vasprun.efermi - evac

    if vasprun.get_band_structure().is_spin_polarized:
        eigenvals = {Spin.up: [], Spin.down: []}
        for band in vasprun.eigenvalues:
            for eigenvalue in vasprun.eigenvalues[band]:
                eigenvals[band[0]].append(eigenvalue)

        up_cbm = min([e[0] for e in eigenvals[Spin.up] if not e[1]]) - evac
        up_vbm = max([e[0] for e in eigenvals[Spin.up] if e[1]]) - evac
        dn_cbm = min([e[0] for e in eigenvals[Spin.down] if not e[1]]) - evac
        dn_vbm = max([e[0] for e in eigenvals[Spin.down] if e[1]]) - evac
        edges = {"up_cbm": up_cbm, "up_vbm": up_vbm, "dn_cbm": dn_cbm, "dn_vbm": dn_vbm, "efermi": efermi}

    else:
        bs = vasprun.get_band_structure()
        cbm = bs.get_cbm()["energy"] - evac
        vbm = bs.get_vbm()["energy"] - evac
        edges = {"cbm": cbm, "vbm": vbm, "efermi": efermi}

    return edges
开发者ID:ashtonmv,项目名称:twod_materials,代码行数:32,代码来源:analysis.py

示例3: test_get_band_structure

    def test_get_band_structure(self):
        filepath = os.path.join(test_dir, 'vasprun_Si_bands.xml')
        vasprun = Vasprun(filepath,
                          parse_projected_eigen=True, parse_potcar_file=False)
        bs = vasprun.get_band_structure(kpoints_filename=
                                        os.path.join(test_dir,
                                                     'KPOINTS_Si_bands'))
        cbm = bs.get_cbm()
        vbm = bs.get_vbm()
        self.assertEqual(cbm['kpoint_index'], [13], "wrong cbm kpoint index")
        self.assertAlmostEqual(cbm['energy'], 6.2301, "wrong cbm energy")
        self.assertEqual(cbm['band_index'], {Spin.up: [4], Spin.down: [4]},
                         "wrong cbm bands")
        self.assertEqual(vbm['kpoint_index'], [0, 63, 64])
        self.assertAlmostEqual(vbm['energy'], 5.6158, "wrong vbm energy")
        self.assertEqual(vbm['band_index'], {Spin.up: [1, 2, 3],
                                             Spin.down: [1, 2, 3]},
                         "wrong vbm bands")
        self.assertEqual(vbm['kpoint'].label, "\Gamma", "wrong vbm label")
        self.assertEqual(cbm['kpoint'].label, None, "wrong cbm label")

        projected = bs.get_projection_on_elements()
        self.assertAlmostEqual(projected[Spin.up][0][0]["Si"], 0.4238)
        projected = bs.get_projections_on_elements_and_orbitals({"Si": ["s"]})
        self.assertAlmostEqual(projected[Spin.up][0][0]["Si"]["s"], 0.4238)
开发者ID:adozier,项目名称:pymatgen,代码行数:25,代码来源:test_outputs.py

示例4: assimilate

    def assimilate(self, path):
        files = os.listdir(path)
        if "relax1" in files and "relax2" in files:
            filepath = glob.glob(os.path.join(path, "relax2",
                                              "vasprun.xml*"))[0]
        else:
            vasprun_files = glob.glob(os.path.join(path, "vasprun.xml*"))
            filepath = None
            if len(vasprun_files) == 1:
                filepath = vasprun_files[0]
            elif len(vasprun_files) > 1:
                # Since multiple files are ambiguous, we will always read
                # the one that it the last one alphabetically.
                filepath = sorted(vasprun_files)[-1]
                warnings.warn("%d vasprun.xml.* found. %s is being parsed." %
                              (len(vasprun_files), filepath))

        try:
            vasprun = Vasprun(filepath)
        except Exception as ex:
            logger.debug("error in {}: {}".format(filepath, ex))
            return None

        entry = vasprun.get_computed_entry(self._inc_structure,
                                           parameters=self._parameters,
                                           data=self._data)

        # entry.parameters["history"] = _get_transformation_history(path)
        return entry
开发者ID:ExpHP,项目名称:pymatgen,代码行数:29,代码来源:hive.py

示例5: plot_orb_projected_bands

def plot_orb_projected_bands(orbitals, fmt='pdf', ylim=(-5, 5)):
    """
    Plot a separate band structure for each orbital of each element in
    orbitals.

    Args:
        orbitals (dict): dictionary of the form
            {element: [orbitals]},
            e.g. {'Mo': ['s', 'p', 'd'], 'S': ['p']}
        ylim (tuple): minimum and maximum energies for the plot's
            y-axis.
        fmt (str): matplotlib format style. Check the matplotlib
            docs for options.
    """

    vasprun = Vasprun('vasprun.xml', parse_projected_eigen=True)
    bs = vasprun.get_band_structure('KPOINTS', line_mode=True)
    bspp = BSPlotterProjected(bs)
    ax = bspp.get_projected_plots_dots(orbitals, ylim=ylim).gcf().gca()
    ax.set_xticklabels([r'$\mathrm{%s}$' % t for t in ax.get_xticklabels()])
    ax.set_yticklabels([r'$\mathrm{%s}$' % t for t in ax.get_yticklabels()])
    if fmt == "None":
        return ax
    else:
        plt.savefig('orb_projected_bands.{}'.format(fmt))
    plt.close()
开发者ID:henniggroup,项目名称:MPInterfaces,代码行数:26,代码来源:analysis.py

示例6: plot_local_potential

def plot_local_potential(axis=2, ylim=(-20, 0), fmt='pdf'):
    """
    Plot data from the LOCPOT file along any of the 3 primary axes.
    Useful for determining surface dipole moments and electric
    potentials on the interior of the material.

    Args:
        axis (int): 0 = x, 1 = y, 2 = z
        ylim (tuple): minimum and maximum potentials for the plot's y-axis.
        fmt (str): matplotlib format style. Check the matplotlib docs
            for options.
    """

    ax = plt.figure(figsize=(16, 10)).gca()

    locpot = Locpot.from_file('LOCPOT')
    structure = Structure.from_file('CONTCAR')
    vd = VolumetricData(structure, locpot.data)
    abs_potentials = vd.get_average_along_axis(axis)
    vacuum_level = max(abs_potentials)

    vasprun = Vasprun('vasprun.xml')
    bs = vasprun.get_band_structure()
    if not bs.is_metal():
        cbm = bs.get_cbm()['energy'] - vacuum_level
        vbm = bs.get_vbm()['energy'] - vacuum_level

    potentials = [potential - vacuum_level for potential in abs_potentials]
    axis_length = structure.lattice._lengths[axis]
    positions = np.arange(0, axis_length, axis_length / len(potentials))

    ax.plot(positions, potentials, linewidth=2, color='k')

    ax.set_xlim(0, axis_length)
    ax.set_ylim(ylim[0], ylim[1])

    ax.set_xticklabels(
        [r'$\mathrm{%s}$' % tick for tick in ax.get_xticks()], size=20)
    ax.set_yticklabels(
        [r'$\mathrm{%s}$' % tick for tick in ax.get_yticks()], size=20)
    ax.set_xlabel(r'$\mathrm{\AA}$', size=24)
    ax.set_ylabel(r'$\mathrm{V\/(eV)}$', size=24)

    if not bs.is_metal():
        ax.text(ax.get_xlim()[1], cbm, r'$\mathrm{CBM}$',
                horizontalalignment='right', verticalalignment='bottom',
                size=20)
        ax.text(ax.get_xlim()[1], vbm, r'$\mathrm{VBM}$',
                horizontalalignment='right', verticalalignment='top', size=20)
        ax.fill_between(ax.get_xlim(), cbm, ax.get_ylim()[1],
                        facecolor=plt.cm.jet(0.3), zorder=0, linewidth=0)
        ax.fill_between(ax.get_xlim(), ax.get_ylim()[0], vbm,
                        facecolor=plt.cm.jet(0.7), zorder=0, linewidth=0)

    if fmt == "None":
        return ax
    else:
        plt.savefig('locpot.{}'.format(fmt))
    plt.close()
开发者ID:henniggroup,项目名称:MPInterfaces,代码行数:59,代码来源:analysis.py

示例7: test_as_dict

 def test_as_dict(self):
     filepath = os.path.join(test_dir, "vasprun.xml")
     vasprun = Vasprun(filepath, parse_potcar_file=False)
     # Test that as_dict() is json-serializable
     self.assertIsNotNone(json.dumps(vasprun.as_dict()))
     self.assertEqual(
         vasprun.as_dict()["input"]["potcar_type"], ["PAW_PBE", "PAW_PBE", "PAW_PBE", "PAW_PBE", "PAW_PBE"]
     )
开发者ID:shyamd,项目名称:pymatgen,代码行数:8,代码来源:test_outputs.py

示例8: __init__

    def __init__(self, filename, ionic_step_skip=None,
                 ionic_step_offset=0, parse_dos=True,
                 parse_eigen=True, parse_projected_eigen=False,
                 parse_potcar_file=True):

        Vasprun.__init__(self, filename,
                         ionic_step_skip=ionic_step_skip,
                         ionic_step_offset=ionic_step_offset,
                         parse_dos=parse_dos, parse_eigen=parse_eigen,
                         parse_projected_eigen=parse_projected_eigen,
                         parse_potcar_file=parse_potcar_file)
开发者ID:JARVIS-Unifies,项目名称:MPInterfaces,代码行数:11,代码来源:data_processor.py

示例9: test_get_band_structure

 def test_get_band_structure(self):
     filepath = os.path.join(test_dir, "vasprun_Si_bands.xml")
     vasprun = Vasprun(filepath, parse_potcar_file=False)
     bs = vasprun.get_band_structure(kpoints_filename=os.path.join(test_dir, "KPOINTS_Si_bands"))
     cbm = bs.get_cbm()
     vbm = bs.get_vbm()
     self.assertEqual(cbm["kpoint_index"], [13], "wrong cbm kpoint index")
     self.assertAlmostEqual(cbm["energy"], 6.2301, "wrong cbm energy")
     self.assertEqual(cbm["band_index"], {Spin.up: [4], Spin.down: [4]}, "wrong cbm bands")
     self.assertEqual(vbm["kpoint_index"], [0, 63, 64])
     self.assertAlmostEqual(vbm["energy"], 5.6158, "wrong vbm energy")
     self.assertEqual(vbm["band_index"], {Spin.up: [1, 2, 3], Spin.down: [1, 2, 3]}, "wrong vbm bands")
     self.assertEqual(vbm["kpoint"].label, "\Gamma", "wrong vbm label")
     self.assertEqual(cbm["kpoint"].label, None, "wrong cbm label")
开发者ID:shyamd,项目名称:pymatgen,代码行数:14,代码来源:test_outputs.py

示例10: plot_elt_projected_bands

def plot_elt_projected_bands(ylim=(-5, 5), fmt="pdf"):
    """
    Plot separate band structures for each element where the size of the
    markers indicates the elemental character of the eigenvalue.

    Args:
        ylim (tuple): minimum and maximum energies for the plot's
            y-axis.
        fmt (str): matplotlib format style. Check the matplotlib
            docs for options.
    """

    vasprun = Vasprun("vasprun.xml", parse_projected_eigen=True)
    bs = vasprun.get_band_structure("KPOINTS", line_mode=True)
    bspp = BSPlotterProjected(bs)
    bspp.get_elt_projected_plots(ylim=ylim).savefig("elt_projected_bands.{}".format(fmt))
    plt.close()
开发者ID:ashtonmv,项目名称:twod_materials,代码行数:17,代码来源:analysis.py

示例11: test_update_potcar

    def test_update_potcar(self):
        filepath = os.path.join(test_dir, "vasprun.xml")
        potcar_path = os.path.join(test_dir, "POTCAR.LiFePO4.gz")
        potcar_path2 = os.path.join(test_dir, "POTCAR2.LiFePO4.gz")
        vasprun = Vasprun(filepath, parse_potcar_file=False)
        self.assertEqual(
            vasprun.potcar_spec,
            [
                {"titel": "PAW_PBE Li 17Jan2003", "hash": None},
                {"titel": "PAW_PBE Fe 06Sep2000", "hash": None},
                {"titel": "PAW_PBE Fe 06Sep2000", "hash": None},
                {"titel": "PAW_PBE P 17Jan2003", "hash": None},
                {"titel": "PAW_PBE O 08Apr2002", "hash": None},
            ],
        )

        vasprun.update_potcar_spec(potcar_path)
        self.assertEqual(
            vasprun.potcar_spec,
            [
                {"titel": "PAW_PBE Li 17Jan2003", "hash": "65e83282d1707ec078c1012afbd05be8"},
                {"titel": "PAW_PBE Fe 06Sep2000", "hash": "9530da8244e4dac17580869b4adab115"},
                {"titel": "PAW_PBE Fe 06Sep2000", "hash": "9530da8244e4dac17580869b4adab115"},
                {"titel": "PAW_PBE P 17Jan2003", "hash": "7dc3393307131ae67785a0cdacb61d5f"},
                {"titel": "PAW_PBE O 08Apr2002", "hash": "7a25bc5b9a5393f46600a4939d357982"},
            ],
        )

        vasprun2 = Vasprun(filepath, parse_potcar_file=False)
        self.assertRaises(ValueError, vasprun2.update_potcar_spec, potcar_path2)
        vasprun = Vasprun(filepath, parse_potcar_file=potcar_path)

        self.assertEqual(
            vasprun.potcar_spec,
            [
                {"titel": "PAW_PBE Li 17Jan2003", "hash": "65e83282d1707ec078c1012afbd05be8"},
                {"titel": "PAW_PBE Fe 06Sep2000", "hash": "9530da8244e4dac17580869b4adab115"},
                {"titel": "PAW_PBE Fe 06Sep2000", "hash": "9530da8244e4dac17580869b4adab115"},
                {"titel": "PAW_PBE P 17Jan2003", "hash": "7dc3393307131ae67785a0cdacb61d5f"},
                {"titel": "PAW_PBE O 08Apr2002", "hash": "7a25bc5b9a5393f46600a4939d357982"},
            ],
        )

        self.assertRaises(ValueError, Vasprun, filepath, parse_potcar_file=potcar_path2)
开发者ID:shyamd,项目名称:pymatgen,代码行数:44,代码来源:test_outputs.py

示例12: get_band_edges

def get_band_edges():
    """
    Calculate the band edge locations relative to the vacuum level
    for a semiconductor. For a metal, returns the fermi level.

    Returns:
        edges (dict): {'up_cbm': , 'up_vbm': , 'dn_cbm': , 'dn_vbm': , 'efermi'}
    """
    # Vacuum level energy from LOCPOT.
    locpot = Locpot.from_file('LOCPOT')
    evac = max(locpot.get_average_along_axis(2))

    vasprun = Vasprun('vasprun.xml')
    bs = vasprun.get_band_structure()
    eigenvals = vasprun.eigenvalues
    efermi = vasprun.efermi - evac

    if bs.is_metal():
        edges = {'up_cbm': None, 'up_vbm': None, 'dn_cbm': None, 'dn_vbm': None,
                 'efermi': efermi}

    elif bs.is_spin_polarized:
        up_cbm = min(
            [min([e[0] for e in eigenvals[Spin.up][i] if not e[1]])
             for i in range(len(eigenvals[Spin.up]))]) - evac
        up_vbm = max(
            [max([e[0] for e in eigenvals[Spin.up][i] if e[1]])
             for i in range(len(eigenvals[Spin.up]))]) - evac
        dn_cbm = min(
            [min([e[0] for e in eigenvals[Spin.down][i] if not e[1]])
             for i in range(len(eigenvals[Spin.down]))]) - evac
        dn_vbm = max(
            [max([e[0] for e in eigenvals[Spin.down][i] if e[1]])
             for i in range(len(eigenvals[Spin.down]))]) - evac
        edges = {'up_cbm': up_cbm, 'up_vbm': up_vbm, 'dn_cbm': dn_cbm,
                 'dn_vbm': dn_vbm, 'efermi': efermi}

    else:
        cbm = bs.get_cbm()['energy'] - evac
        vbm = bs.get_vbm()['energy'] - evac
        edges = {'up_cbm': cbm, 'up_vbm': vbm, 'dn_cbm': cbm, 'dn_vbm': vbm,
                 'efermi': efermi}

    return edges
开发者ID:henniggroup,项目名称:MPInterfaces,代码行数:44,代码来源:analysis.py

示例13: plot_orb_projected_bands

def plot_orb_projected_bands(orbitals, fmt="pdf", ylim=(-5, 5)):
    """
    Plot a separate band structure for each orbital of each element in
    orbitals.

    Args:
        orbitals (dict): dictionary of the form
            {element: [orbitals]},
            e.g. {'Mo': ['s', 'p', 'd'], 'S': ['p']}
        ylim (tuple): minimum and maximum energies for the plot's
            y-axis.
        fmt (str): matplotlib format style. Check the matplotlib
            docs for options.
    """

    vasprun = Vasprun("vasprun.xml", parse_projected_eigen=True)
    bs = vasprun.get_band_structure("KPOINTS", line_mode=True)
    bspp = BSPlotterProjected(bs)
    bspp.get_projected_plots_dots(orbitals, ylim=ylim).savefig("orb_projected_bands.{}".format(fmt))
    plt.close()
开发者ID:ashtonmv,项目名称:twod_materials,代码行数:20,代码来源:analysis.py

示例14: read_convergence_data

 def read_convergence_data(self, data_dir):
     results = {}
     if 'G0W0' in data_dir or 'GW0' in data_dir or 'scGW0' in data_dir:
         run = os.path.join(data_dir, 'vasprun.xml')
         kpoints = os.path.join(data_dir, 'IBZKPT')
         if os.path.isfile(run):
             try:
                 logger.debug(run)
                 print(run)
                 data = Vasprun(run, ionic_step_skip=1)
                 parameters = data.incar.as_dict()
                 bandstructure = data.get_band_structure(kpoints)
                 results = {'ecuteps': parameters['ENCUTGW'],
                            'nbands': parameters['NBANDS'],
                            'nomega': parameters['NOMEGA'],
                            'gwgap': bandstructure.get_band_gap()['energy']}
                 print(results)
             except (IOError, OSError, IndexError, KeyError):
                 pass
     return results
开发者ID:davidwaroquiers,项目名称:abipy,代码行数:20,代码来源:codeinterfaces.py

示例15: assimilate

    def assimilate(self, path):
        files = os.listdir(path)
        if "relax1" in files and "relax2" in files:
            filepath = glob.glob(os.path.join(path, "relax2",
                                              "vasprun.xml*"))[0]
        else:
            vasprun_files = glob.glob(os.path.join(path, "vasprun.xml*"))
            filepath = None
            if len(vasprun_files) == 1:
                filepath = vasprun_files[0]
            elif len(vasprun_files) > 1:
                """
                This is a bit confusing, since there maybe be multi-steps. By
                default, assimilate will try to find a file simply named
                vasprun.xml, vasprun.xml.bz2, or vasprun.xml.gz.  Failing which
                it will try to get a relax2 from an aflow style run if
                possible. Or else, a randomly chosen file containing
                vasprun.xml is chosen.
                """
                for fname in vasprun_files:
                    if os.path.basename(fname) in ["vasprun.xml",
                                                   "vasprun.xml.gz",
                                                   "vasprun.xml.bz2"]:
                        filepath = fname
                        break
                    if re.search("relax2", fname):
                        filepath = fname
                        break
                    filepath = fname

        try:
            vasprun = Vasprun(filepath)
        except Exception as ex:
            logger.debug("error in {}: {}".format(filepath, ex))
            return None

        entry = vasprun.get_computed_entry(self._inc_structure,
                                           parameters=self._parameters,
                                           data=self._data)
        entry.parameters["history"] = _get_transformation_history(path)
        return entry
开发者ID:zulissi,项目名称:pymatgen,代码行数:41,代码来源:hive.py


注:本文中的pymatgen.io.vasp.outputs.Vasprun类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。