示例#1
0
def _log_band_structure_information(band_structure: BandStructure):
    log_banner("BAND STRUCTURE")

    info = [
        "# bands: {}".format(band_structure.nb_bands),
        "# k-points: {}".format(len(band_structure.kpoints)),
        "Fermi level: {:.3f} eV".format(band_structure.efermi),
        "spin polarized: {}".format(band_structure.is_spin_polarized),
        "metallic: {}".format(band_structure.is_metal()),
    ]
    logger.info("Input band structure information:")
    log_list(info)

    if band_structure.is_metal():
        return

    logger.info("Band gap:")
    band_gap_info = []

    bg_data = band_structure.get_band_gap()
    if not bg_data["direct"]:
        band_gap_info.append("indirect band gap: {:.3f} eV".format(
            bg_data["energy"]))

    direct_data = band_structure.get_direct_band_gap_dict()
    direct_bg = min((spin_data["value"] for spin_data in direct_data.values()))
    band_gap_info.append("direct band gap: {:.3f} eV".format(direct_bg))

    direct_kpoint = []
    for spin, spin_data in direct_data.items():
        direct_kindex = spin_data["kpoint_index"]
        kpt_str = _kpt_str.format(
            k=band_structure.kpoints[direct_kindex].frac_coords)
        direct_kpoint.append(kpt_str)

    band_gap_info.append("direct k-point: {}".format(", ".join(direct_kpoint)))
    log_list(band_gap_info)

    vbm_data = band_structure.get_vbm()
    cbm_data = band_structure.get_cbm()

    logger.info("Valence band maximum:")
    _log_band_edge_information(band_structure, vbm_data)

    logger.info("Conduction band minimum:")
    _log_band_edge_information(band_structure, cbm_data)
示例#2
0
def bs_graph(rawdatadir, savedir, e_fermi, soc=False):
    run = BSVasprun("{}/vasprun.xml".format(rawdatadir),
                    parse_projected_eigen=True)
    bs = run.get_band_structure(efermi=e_fermi,
                                line_mode=True,
                                force_hybrid_mode=True)
    bsplot = BSPlotter(bs)

    # Get the plot
    bsplot.get_plot(vbm_cbm_marker=True, ylim=(-1.5, 1.5), zero_to_efermi=True)
    bs_graph.e_fermi = float(bs.efermi)
    bs_graph.band_gap = float(bs.get_band_gap()["energy"])
    ax = plt.gca()
    xlim = ax.get_xlim()
    ylim = ax.get_ylim()
    ax.hlines(0, xlim[0], xlim[1], linestyle="--", color="black")
    ax.tick_params(labelsize=20)
    if not soc:
        ax.plot((), (), "r-", label="spin up")
        ax.plot((), (), "b-", label="spin down")
        ax.legend(fontsize=16, loc="upper left")
    plt.savefig("{}/BSGraph".format(savedir))
    plt.close()

    if not soc:
        # Print quick info about band gap (source: vasprun.xml)
        #print(bs_graph.e_fermi)
        #print(bs_graph.band_gap)

        # Get quick info about band gap (source: EIGENVAL)
        eigenval = Eigenval("{}/EIGENVAL".format(rawdatadir))
        bs_graph.band_properties = eigenval.eigenvalue_band_properties

        # Get detailed info about band gap and CB/VB in each spin channel
        # (source: EIGENVAL)
        bs_graph.eigenvalues = eigenval.eigenvalues
        bs_graph.kpoints = eigenval.kpoints
        poscar = Poscar.from_file("{}/POSCAR".format(rawdatadir))
        bs_graph.lattice = poscar.structure.lattice.reciprocal_lattice

        bs_graph.eigenvalues[Spin.up] = bs_graph.eigenvalues[
            Spin.up][:, :, :-1]
        bs_graph.eigenvalues[Spin.down] = bs_graph.eigenvalues[
            Spin.down][:, :, :-1]
        bs_graph.eigenvalues[Spin.up] = bs_graph.eigenvalues[Spin.up][:, :, 0]
        bs_graph.eigenvalues[Spin.down] = bs_graph.eigenvalues[Spin.down][:, :,
                                                                          0]

        bs_graph.eigenvalues[Spin.up] = \
            np.transpose(bs_graph.eigenvalues[Spin.up])
        bs_graph.eigenvalues[Spin.down] = \
            np.transpose(bs_graph.eigenvalues[Spin.down])

        bs = BandStructure(bs_graph.kpoints, bs_graph.eigenvalues,
                           bs_graph.lattice, bs_graph.e_fermi)
        bs_graph.vbm = bs.get_vbm()["energy"]
        bs_graph.cbm = bs.get_cbm()["energy"]
        bs_graph.electronic_gap = bs.get_band_gap()["energy"]
        bs_graph.direct = bs.get_band_gap()["direct"]
        if bs_graph.vbm and bs_graph.cbm and bs_graph.electronic_gap:
            bs_graph.gap_by_spin = bs.get_direct_band_gap_dict()
    return