Beispiel #1
0
def calc_effective_mass(args: Namespace):
    vasprun, outcar = Vasprun(args.vasprun), Outcar(args.outcar)
    band_edge_prop = VaspBandEdgeProperties(vasprun, outcar)
    effective_mass = make_effective_mass(vasprun, args.temperature,
                                         args.concentrations,
                                         band_edge_prop.band_gap)
    print(effective_mass)
Beispiel #2
0
def make_diele_func(vasprun: Vasprun,
                    outcar: Outcar,
                    use_vasp_real: bool = True,
                    ita: float = 0.01) -> DieleFuncData:

    energies, real, imag = vasprun.dielectric_data["density"]
    imag = np.array(imag)
    if use_vasp_real:
        real = np.array(real)
    else:
        # When CSHIFT = 0.0, the first component becomes 99999.0
        # the following lines are copied from the vasprun.xml
        # <dielectricfunction>
        # <imag>
        # <array>
        # <dimension dim=“1”>gridpoints</dimension>
        # <field>energy</field>
        # <field>xx</field>
        # <field>yy</field>
        # <field>zz</field>
        # <field>xy</field>
        # <field>yz</field>
        # <field>zx</field>
        # <set>
        # <r>     0.0000     0.0000     0.0000    -0.0000 99999.0000 99999.0000 99999.0000 </r>
        imag[0] = 0.0
        real = kramers_kronig_trans(imag, energies, ita)
    band_gap = VaspBandEdgeProperties(vasprun, outcar).band_gap
    return DieleFuncData(energies, real.tolist(), imag.tolist(), band_gap)
Beispiel #3
0
def test_band_edge_properties_from_vasp(test_data_files):
    vasprun_file = str(test_data_files / "MnO_uniform_vasprun.xml")
    vasprun = Vasprun(vasprun_file)
    outcar_file = str(test_data_files / "MnO_uniform_OUTCAR")
    outcar = Outcar(outcar_file)
    band_edge = VaspBandEdgeProperties(vasprun, outcar)
    assert pytest.approx(band_edge.band_gap) == 0.4702
Beispiel #4
0
def make_calc_results_from_vasp(vasprun: Vasprun,
                                outcar: Outcar) -> CalcResults:
    structure = vasprun.final_structure
    magnetization = outcar.total_mag or 0.0

    symmetrizer = StructureSymmetrizer(
        structure,
        symprec=defaults.symmetry_length_tolerance,
        angle_tolerance=defaults.symmetry_angle_tolerance,
        time_reversal=abs(magnetization) > defaults.integer_criterion)
    band_edge_prop = VaspBandEdgeProperties(vasprun, outcar,
                                            defaults.integer_criterion)

    return CalcResults(structure=structure,
                       site_symmetry=symmetrizer.point_group,
                       energy=outcar.final_energy,
                       magnetization=magnetization,
                       kpoint_coords=vasprun.actual_kpoints,
                       kpoint_weights=vasprun.actual_kpoints_weights,
                       potentials=[-p for p in outcar.electrostatic_potential],
                       vbm_info=band_edge_prop.vbm_info,
                       cbm_info=band_edge_prop.cbm_info,
                       fermi_level=vasprun.efermi,
                       electronic_conv=vasprun.converged_electronic,
                       ionic_conv=vasprun.converged_ionic)
Beispiel #5
0
def test_band_edge_properties_from_vasp_non_mag(test_data_files):
    vasprun_file = str(test_data_files / "MgO_band_vasprun.xml")
    vasprun = Vasprun(vasprun_file)
    outcar_file = str(test_data_files / "MgO_band_OUTCAR")
    outcar = Outcar(outcar_file)
    band_edge = VaspBandEdgeProperties(vasprun, outcar)

    assert pytest.approx(band_edge.band_gap) == 4.6597
def make_perfect_band_edge_state_from_vasp(
        procar: Procar, vasprun: Vasprun, outcar: Outcar
) -> PerfectBandEdgeState:

    band_edge_prop = VaspBandEdgeProperties(vasprun, outcar,
                                            v_defaults.integer_criterion)
    orbs, s = procar.data, vasprun.final_structure
    vbm_info = get_edge_info(band_edge_prop.vbm_info, orbs, s, vasprun)
    cbm_info = get_edge_info(band_edge_prop.cbm_info, orbs, s, vasprun)
    return PerfectBandEdgeState(vbm_info, cbm_info)
Beispiel #7
0
def calc_effective_mass(args: Namespace):
    vasprun, outcar = Vasprun(args.vasprun), Outcar(args.outcar)
    band_edge_prop = VaspBandEdgeProperties(vasprun, outcar)
    try:
        vbm, cbm = band_edge_prop.vbm_cbm
    except TypeError:
        logger.warning("Band gap does not exist, so not suited for effective"
                       "mass calculation.")
        return
    effective_mass = make_effective_mass(vasprun, args.temperature,
                                         args.concentrations, vbm, cbm)
    print(effective_mass)
Beispiel #8
0
def make_unitcell_from_vasp(vasprun_band: Vasprun, outcar_band: Outcar,
                            outcar_dielectric_clamped,
                            outcar_dielectric_ionic) -> Unitcell:
    outcar_dielectric_clamped.read_lepsilon()
    outcar_dielectric_ionic.read_lepsilon_ionic()
    band_edge_properties = VaspBandEdgeProperties(vasprun_band, outcar_band)
    vbm, cbm = band_edge_properties.vbm_cbm

    return Unitcell(
        vbm=vbm,
        cbm=cbm,
        ele_dielectric_const=outcar_dielectric_clamped.dielectric_tensor,
        ion_dielectric_const=outcar_dielectric_ionic.dielectric_ionic_tensor)
Beispiel #9
0
def make_unitcell_from_vasp(vasprun_band: Vasprun,
                            outcar_band: Outcar,
                            outcar_dielectric_clamped: Outcar,
                            outcar_dielectric_ionic: Outcar,
                            system_name: str = None) -> Unitcell:
    name = (system_name
            or vasprun_band.final_structure.composition.reduced_formula)
    outcar_dielectric_clamped.read_lepsilon()
    outcar_dielectric_ionic.read_lepsilon_ionic()
    band_edge_properties = VaspBandEdgeProperties(vasprun_band, outcar_band)
    vbm, cbm = band_edge_properties.vbm_cbm

    return Unitcell(
        system=name,
        # vbm and cbm are <class 'numpy.float64'>.
        vbm=float(vbm),
        cbm=float(cbm),
        ele_dielectric_const=outcar_dielectric_clamped.dielectric_tensor,
        ion_dielectric_const=outcar_dielectric_ionic.dielectric_ionic_tensor)
Beispiel #10
0
def prior_info_from_calc_dir(prev_dir_path: Path,
                             vasprun: str = "vasprun.xml",
                             outcar: str = "OUTCAR",
                             potcar: str = "POTCAR"):

    vasprun = Vasprun(str(prev_dir_path / vasprun))
    outcar = Outcar(str(prev_dir_path / outcar))
    potcar = Potcar.from_file(str(prev_dir_path / potcar))

    charge = get_net_charge_from_vasp(vasprun.final_structure,
                                      vasprun.parameters["NELECT"], potcar)
    structure = vasprun.final_structure.copy()
    energy_per_atom = outcar.final_energy / len(structure)
    band_edge_property = VaspBandEdgeProperties(vasprun, outcar)
    total_magnetization = outcar.total_mag

    return PriorInfo(structure=structure,
                     charge=charge,
                     energy_per_atom=energy_per_atom,
                     band_gap=band_edge_property.band_gap,
                     vbm_cbm=band_edge_property.vbm_cbm,
                     total_magnetization=total_magnetization)
Beispiel #11
0
def plot_dos(args: Namespace):
    vasprun = Vasprun(args.vasprun)
    outcar = Outcar(args.outcar)
    band_edge = VaspBandEdgeProperties(vasprun, outcar)

    if band_edge.band_gap:
        vertical_lines = [band_edge.vbm_info.energy, band_edge.cbm_info.energy]
    else:
        vertical_lines = [vasprun.efermi]

    if args.base_energy is None:
        base = vertical_lines[0]
    else:
        base = args.base_energy

    dos_data_from_vasp = \
        DosDataFromVasp(vasprun, vertical_lines, base, args.crop_first_value)
    dos_data = dos_data_from_vasp.make_dos_data()

    ylim_set = None
    if args.y_max_ranges:
        if dos_data.spin:
            ylim_set = [[-y_max, y_max] for y_max in args.y_max_ranges]
        else:
            ylim_set = [[0, y_max] for y_max in args.y_max_ranges]

    structure = vasprun.final_structure
    grouped_atom_indices = args.type.grouped_atom_indices(
        structure, args.target)
    logger.info(f"Grouped atom indices: {grouped_atom_indices}")
    plot_data = dos_data.dos_plot_data(grouped_atom_indices,
                                       xlim=args.x_range,
                                       ylim_set=ylim_set)
    plot_data.to_json_file()
    plotter = DosPlotter(plot_data, args.legend)
    plotter.construct_plot()
    plotter.plt.savefig(args.filename, format="pdf")
Beispiel #12
0
def band_edge_properties(args: Namespace):
    vasprun = Vasprun(args.vasprun)
    outcar = Outcar(args.outcar)
    print(VaspBandEdgeProperties(vasprun, outcar))