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


Python Vasprun.get_band_structure方法代码示例

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


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

示例1: find_dirac_nodes

# 需要导入模块: from pymatgen.io.vasp.outputs import Vasprun [as 别名]
# 或者: from pymatgen.io.vasp.outputs.Vasprun import get_band_structure [as 别名]
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,代码行数:37,代码来源:analysis.py

示例2: get_band_edges

# 需要导入模块: from pymatgen.io.vasp.outputs import Vasprun [as 别名]
# 或者: from pymatgen.io.vasp.outputs.Vasprun import get_band_structure [as 别名]
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,代码行数:34,代码来源:analysis.py

示例3: test_get_band_structure

# 需要导入模块: from pymatgen.io.vasp.outputs import Vasprun [as 别名]
# 或者: from pymatgen.io.vasp.outputs.Vasprun import get_band_structure [as 别名]
    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,代码行数:27,代码来源:test_outputs.py

示例4: plot_orb_projected_bands

# 需要导入模块: from pymatgen.io.vasp.outputs import Vasprun [as 别名]
# 或者: from pymatgen.io.vasp.outputs.Vasprun import get_band_structure [as 别名]
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,代码行数:28,代码来源:analysis.py

示例5: plot_local_potential

# 需要导入模块: from pymatgen.io.vasp.outputs import Vasprun [as 别名]
# 或者: from pymatgen.io.vasp.outputs.Vasprun import get_band_structure [as 别名]
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,代码行数:61,代码来源:analysis.py

示例6: test_get_band_structure

# 需要导入模块: from pymatgen.io.vasp.outputs import Vasprun [as 别名]
# 或者: from pymatgen.io.vasp.outputs.Vasprun import get_band_structure [as 别名]
 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,代码行数:16,代码来源:test_outputs.py

示例7: plot_elt_projected_bands

# 需要导入模块: from pymatgen.io.vasp.outputs import Vasprun [as 别名]
# 或者: from pymatgen.io.vasp.outputs.Vasprun import get_band_structure [as 别名]
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,代码行数:19,代码来源:analysis.py

示例8: get_band_edges

# 需要导入模块: from pymatgen.io.vasp.outputs import Vasprun [as 别名]
# 或者: from pymatgen.io.vasp.outputs.Vasprun import get_band_structure [as 别名]
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,代码行数:46,代码来源:analysis.py

示例9: read_convergence_data

# 需要导入模块: from pymatgen.io.vasp.outputs import Vasprun [as 别名]
# 或者: from pymatgen.io.vasp.outputs.Vasprun import get_band_structure [as 别名]
 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,代码行数:22,代码来源:codeinterfaces.py

示例10: plot_orb_projected_bands

# 需要导入模块: from pymatgen.io.vasp.outputs import Vasprun [as 别名]
# 或者: from pymatgen.io.vasp.outputs.Vasprun import get_band_structure [as 别名]
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,代码行数:22,代码来源:analysis.py

示例11: plot_color_projected_bands

# 需要导入模块: from pymatgen.io.vasp.outputs import Vasprun [as 别名]
# 或者: from pymatgen.io.vasp.outputs.Vasprun import get_band_structure [as 别名]
def plot_color_projected_bands(ylim=(-5, 5), fmt="pdf"):
    """
    Plot a single band structure where the color of the band 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)
    plot = bspp.get_elt_projected_plots_color()
    fig = plot.gcf()
    ax = fig.gca()
    ax.set_xticklabels([r"$\mathrm{%s}$" % t for t in ax.get_xticklabels()])
    ax.set_ylim(ylim)
    fig.savefig("color_projected_bands.{}".format(fmt))
    plt.close()
开发者ID:ashtonmv,项目名称:twod_materials,代码行数:24,代码来源:analysis.py

示例12: plot_elt_projected_bands

# 需要导入模块: from pymatgen.io.vasp.outputs import Vasprun [as 别名]
# 或者: from pymatgen.io.vasp.outputs.Vasprun import get_band_structure [as 别名]
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)
    ax = bspp.get_elt_projected_plots(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('elt_projected_bands.{}'.format(fmt))
    plt.close()
开发者ID:henniggroup,项目名称:MPInterfaces,代码行数:25,代码来源:analysis.py

示例13: get_fermi_velocities

# 需要导入模块: from pymatgen.io.vasp.outputs import Vasprun [as 别名]
# 或者: from pymatgen.io.vasp.outputs.Vasprun import get_band_structure [as 别名]
def get_fermi_velocities():
    """
    Calculates the fermi velocity of each band that crosses the fermi
    level, according to v_F = dE/(h_bar*dk).

    Returns:
        fermi_velocities (list). The absolute values of the
            adjusted slopes of each band, in Angstroms/s.
    """

    vr = Vasprun('vasprun.xml')
    # eigenvalues = vr.eigenvalues
    bs = vr.get_band_structure()
    bands = bs.bands
    kpoints = bs.kpoints
    efermi = bs.efermi
    h_bar = 6.582e-16  # eV*s

    fermi_bands = []
    for spin in bands:
        for i in range(len(bands[spin])):
            if max(bands[spin][i]) > efermi > min(bands[spin][i]):
                fermi_bands.append(bands[spin][i])

    fermi_velocities = []
    for band in fermi_bands:
        for i in range(len(band)-1):
            if (band[i] < efermi < band[i+1]) or (band[i] > efermi > band[i+1]):
                dk = np.sqrt((kpoints[i+1].cart_coords[0]
                              - kpoints[i].cart_coords[0])**2
                             + (kpoints[i+1].cart_coords[1]
                                - kpoints[i].cart_coords[1])**2)
                v_f = abs((band[i+1] - band[i]) / (h_bar * dk))
                fermi_velocities.append(v_f)

    return fermi_velocities  # Values are in Angst./s
开发者ID:henniggroup,项目名称:MPInterfaces,代码行数:38,代码来源:analysis.py

示例14: plot_band_structure

# 需要导入模块: from pymatgen.io.vasp.outputs import Vasprun [as 别名]
# 或者: from pymatgen.io.vasp.outputs.Vasprun import get_band_structure [as 别名]
def plot_band_structure(ylim=(-5, 5), draw_fermi=False, fmt="pdf"):
    """
    Plot a standard band structure with no projections.

    Args:
        ylim (tuple): minimum and maximum potentials for the plot's
            y-axis.
        draw_fermi (bool): whether or not to draw a dashed line at
            E_F.
        fmt (str): matplotlib format style. Check the matplotlib
            docs for options.
    """

    vasprun = Vasprun("vasprun.xml")
    efermi = vasprun.efermi
    bsp = BSPlotter(vasprun.get_band_structure("KPOINTS", line_mode=True, efermi=efermi))
    plot = bsp.get_plot(ylim=ylim)
    fig = plot.gcf()
    ax = fig.gca()
    ax.set_xticklabels([r"$\mathrm{%s}$" % t for t in ax.get_xticklabels()])
    if draw_fermi:
        ax.plot([ax.get_xlim()[0], ax.get_xlim()[1]], [0, 0], "k--")
    fig.savefig("band_structure.{}".format(fmt), transparent=True)
    plt.close()
开发者ID:ashtonmv,项目名称:twod_materials,代码行数:26,代码来源:analysis.py

示例15: assimilate

# 需要导入模块: from pymatgen.io.vasp.outputs import Vasprun [as 别名]
# 或者: from pymatgen.io.vasp.outputs.Vasprun import get_band_structure [as 别名]

#.........这里部分代码省略.........
                        for i in [1,2]:
                            o_path = os.path.join(path,"relax"+str(i),"OUTCAR")
                            o_path = o_path if os.path.exists(o_path) else o_path+".gz"
                            outcar = Outcar(o_path)
                            d["calculations"][i-1]["output"]["outcar"] = outcar.as_dict()
                            run_stats["relax"+str(i)] = outcar.run_stats
                    except:
                        logger.error("Bad OUTCAR for {}.".format(path))

                    try:
                        overall_run_stats = {}
                        for key in ["Total CPU time used (sec)", "User time (sec)",
                                    "System time (sec)", "Elapsed time (sec)"]:
                            overall_run_stats[key] = sum([v[key]
                                              for v in run_stats.values()])
                        run_stats["overall"] = overall_run_stats
                    except:
                        logger.error("Bad run stats for {}.".format(path))

                    d["run_stats"] = run_stats

                # add is_compatible
                mpc = MaterialsProjectCompatibility("Advanced")

                try:
                    func = d["pseudo_potential"]["functional"]
                    labels = d["pseudo_potential"]["labels"]
                    symbols = ["{} {}".format(func, label) for label in labels]
                    parameters = {"run_type": d["run_type"],
                              "is_hubbard": d["is_hubbard"],
                              "hubbards": d["hubbards"],
                              "potcar_symbols": symbols}
                    entry = ComputedEntry(Composition(d["unit_cell_formula"]),
                                          0.0, 0.0, parameters=parameters,
                                          entry_id=d["task_id"])

                    d['is_compatible'] = bool(mpc.process_entry(entry))
                except:
                    traceback.print_exc()
                    print 'ERROR in getting compatibility'
                    d['is_compatible'] = None


                #task_type dependent processing
                if 'static' in d['task_type']:
                    launch_doc = launches_coll.find_one({"fw_id": d['fw_id'], "launch_dir": {"$regex": d["dir_name"]}}, {"action.stored_data": 1})
                    for i in ["conventional_standard_structure", "symmetry_operations",
                              "symmetry_dataset", "refined_structure"]:
                        try:
                            d['stored_data'][i] = launch_doc['action']['stored_data'][i]
                        except:
                            pass

                #parse band structure if necessary
                if ('band structure' in d['task_type'] or "Uniform" in d['task_type'])\
                    and d['state'] == 'successful':
                    launch_doc = launches_coll.find_one({"fw_id": d['fw_id'], "launch_dir": {"$regex": d["dir_name"]}},
                                                        {"action.stored_data": 1})
                    vasp_run = Vasprun(zpath(os.path.join(path, "vasprun.xml")), parse_projected_eigen=False)

                    if 'band structure' in d['task_type']:
                        def string_to_numlist(stringlist):
                            g=re.search('([0-9\-\.eE]+)\s+([0-9\-\.eE]+)\s+([0-9\-\.eE]+)', stringlist)
                            return [float(g.group(i)) for i in range(1,4)]

                        for i in ["kpath_name", "kpath"]:
                            d['stored_data'][i] = launch_doc['action']['stored_data'][i]
                        kpoints_doc = d['stored_data']['kpath']['kpoints']
                        for i in kpoints_doc:
                            kpoints_doc[i]=string_to_numlist(kpoints_doc[i])
                        bs=vasp_run.get_band_structure(efermi=d['calculations'][0]['output']['outcar']['efermi'],
                                                       line_mode=True)
                    else:
                        bs=vasp_run.get_band_structure(efermi=d['calculations'][0]['output']['outcar']['efermi'],
                                                       line_mode=False)
                    bs_json = json.dumps(bs.as_dict(), cls=MontyEncoder)
                    fs = gridfs.GridFS(db, "band_structure_fs")
                    bs_id = fs.put(bs_json)
                    d['calculations'][0]["band_structure_fs_id"] = bs_id

                    # also override band gap in task doc
                    gap = bs.get_band_gap()
                    vbm = bs.get_vbm()
                    cbm = bs.get_cbm()
                    update_doc = {'bandgap': gap['energy'], 'vbm': vbm['energy'], 'cbm': cbm['energy'], 'is_gap_direct': gap['direct']}
                    d['analysis'].update(update_doc)
                    d['calculations'][0]['output'].update(update_doc)

		coll.update_one({"dir_name": d["dir_name"]}, {'$set': d}, upsert=True)

                return d["task_id"], d
            else:
                logger.info("Skipping duplicate {}".format(d["dir_name"]))
                return result["task_id"], result

        else:
            d["task_id"] = 0
            logger.info("Simulated insert into database for {} with task_id {}"
            .format(d["dir_name"], d["task_id"]))
            return 0, d
开发者ID:xhqu1981,项目名称:MPWorks,代码行数:104,代码来源:mp_vaspdrone.py


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