Exemple #1
0
def wave(**kwargs):
    """Extract wavefunction coefficients from a WAVECAR"""
    from pymatgen.io.vasp import BSVasprun

    from amset.constants import defaults
    from amset.electronic_structure.common import (
        get_band_structure,
        get_ibands,
        get_zero_weighted_kpoint_indices,
    )
    from amset.tools.common import echo_ibands
    from amset.wavefunction.io import write_coefficients

    output = kwargs.pop("output")
    planewave_cutoff = kwargs.pop("planewave_cutoff")
    pawpyseed = kwargs.pop("pawpyseed")

    energy_cutoff = kwargs.pop("energy_cutoff")
    if not energy_cutoff:
        energy_cutoff = defaults["energy_cutoff"]

    if kwargs["directory"]:
        vasprun_file = Path(kwargs["directory"]) / "vasprun.xml"
    else:
        vasprun_file = kwargs["vasprun"]

    try:
        vr = BSVasprun(vasprun_file)
    except FileNotFoundError:
        vr = BSVasprun(str(vasprun_file) + ".gz")

    zwk_mode = kwargs.pop("zero_weighted_kpoints")
    if not zwk_mode:
        zwk_mode = defaults["zero_weighted_kpoints"]

    bs = get_band_structure(vr, zero_weighted=zwk_mode)

    if "bands" in kwargs and kwargs["bands"] is not None:
        ibands = parse_ibands(kwargs["bands"])
    else:
        ibands = get_ibands(energy_cutoff, bs)
    ikpoints = get_zero_weighted_kpoint_indices(vr, zwk_mode)

    click.echo("******* Getting wavefunction coefficients *******\n")
    echo_ibands(ibands, bs.is_spin_polarized)
    click.echo("")

    if pawpyseed:
        coeffs, gpoints, kpoints = _wavefunction_pawpy(bs, ibands,
                                                       planewave_cutoff,
                                                       ikpoints, **kwargs)
    else:
        coeffs, gpoints = _wavefunction_vasp(ibands, planewave_cutoff,
                                             ikpoints, **kwargs)
        kpoints = np.array([k.frac_coords for k in bs.kpoints])

    structure = vr.final_structure

    click.echo("Writing coefficients to {}".format(output))
    write_coefficients(coeffs, gpoints, kpoints, structure, filename=output)
Exemple #2
0
def parse_calculation(folder,
                      zero_weighted_kpoints=defaults["zero_weighted_kpoints"]):
    vr = Vasprun(get_gzipped_file("vasprun.xml", folder))
    out = Outcar(get_gzipped_file("OUTCAR", folder))
    bs = get_band_structure(vr, zero_weighted=zero_weighted_kpoints)
    reference_level = get_reference_energy(bs, out)
    return {"reference": reference_level, "bandstructure": bs}
    def from_vasprun(cls,
                     vasprun,
                     zero_weighted_kpoints=defaults["zero_weighted_kpoints"],
                     **kwargs):
        from pymatgen.io.vasp import Vasprun

        if isinstance(vasprun, Path):
            vasprun = vasprun.as_posix()

        if isinstance(vasprun, str):
            vasprun_gz = vasprun + ".gz"

            if Path(vasprun).exists():
                vasprun = Vasprun(vasprun)

            elif Path(vasprun_gz).exists():
                vasprun = Vasprun(vasprun_gz)

        bandstructure = get_band_structure(vasprun,
                                           zero_weighted=zero_weighted_kpoints)
        nelect = vasprun.parameters["NELECT"]
        soc = vasprun.parameters["LSORBIT"]
        return cls(bandstructure, nelect, soc=soc, **kwargs)
Exemple #4
0
    def from_vasprun(vasprun: Union[str, Path, Vasprun],
                     settings: Dict[str, Any]) -> "Runner":
        """Initialise an AmsetRunner from a Vasprun.

        The nelect and soc options will be determined from the Vasprun
        automatically.

        Args:
            vasprun: Path to a vasprun or a Vasprun pymatgen object.
            settings: AMSET settings.

        Returns:
            A Runner object that can be used to calculate transport properties.
        """
        if not isinstance(vasprun, Vasprun):
            vasprun = Vasprun(vasprun, parse_projected_eigen=True)

        zwk_option = settings.get("zero_weighted_kpoints", "keep")
        band_structure = get_band_structure(vasprun, zero_weighted=zwk_option)
        nelect = vasprun.parameters["NELECT"]
        settings["soc"] = vasprun.parameters["LSORBIT"]

        return Runner(band_structure, nelect, settings)