示例#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 get_energy_cutoffs(
    energy_cutoff: float, band_structure: BandStructure
) -> Tuple[float, float]:
    if energy_cutoff and band_structure.is_metal():
        min_e = band_structure.efermi - energy_cutoff
        max_e = band_structure.efermi + energy_cutoff
    elif energy_cutoff:
        min_e = band_structure.get_vbm()["energy"] - energy_cutoff
        max_e = band_structure.get_cbm()["energy"] + energy_cutoff
    else:
        min_e = min(
            [band_structure.bands[spin].min() for spin in band_structure.bands.keys()]
        )
        max_e = max(
            [band_structure.bands[spin].max() for spin in band_structure.bands.keys()]
        )

    return min_e, max_e
示例#3
0
efermi = vasp.efermi
eigenvals = vasp.eigenvalues
bs = vasp.get_band_structure(kpoints_filename='KPOINTS',
                             efermi=efermi,
                             line_mode=True)
#kpoints_modes = Kpoints_support_modes(3) #Line mode
kpoints = Kpoints.from_file('KPOINTS')
poscar = Poscar.from_file('POSCAR')
incar = Incar.from_file(('INCAR'))
struc = IStructure.from_file('POSCAR')
lattice = struc.lattice
labels = kpoints.labels
space_group = struc.get_space_group_info()
#coords = struc.frac_coords()
BS = BandStructure(kpoints.kpts, eigenvals, lattice, efermi,
                   structure=struc)  #kpoints.kpts
labels_dict = BS.labels_dict
BSSL = BandStructureSymmLine(kpoints.kpts,
                             eigenvals,
                             lattice,
                             efermi,
                             labels_dict,
                             structure=struc)
b = vasp.eigenvalue_band_properties
vbm = BS.get_vbm()
cbm = BS.get_cbm()
print(b, efermi, 'cbm:', bs.get_cbm(), 'vbm:',
      bs.get_vbm())  #,cbm,vbm#BSSL.get_branch(90)#,kpoints.kpts
#print a.eigenvalue_band_properties,fermi
#vbm = a.eigenvalue_band_properties
示例#4
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