Example #1
0
def run(**kwargs):
    """
    Run AMSET on an ab initio band structure
    """

    from amset.constants import defaults
    from amset.core.run import Runner
    from amset.log import initialize_amset_logger

    if kwargs["print_log"] is not False:
        initialize_amset_logger()

    settings_override: Dict[str, Dict[str, Any]] = defaultdict(dict)
    for setting in defaults:
        if setting in kwargs and kwargs[setting] is not None:
            settings_override[setting] = kwargs[setting]

    runner = Runner.from_directory(
        directory=kwargs["directory"],
        vasprun=kwargs["vasprun"],
        settings_file=kwargs["settings"],
        settings_override=settings_override,
    )

    runner.run()
Example #2
0
def test_run_amset_from_vasprun(
    example_dir, system, settings, transport, max_aniso, files, scats
):
    vasprun, settings = _prep_inputs(example_dir, system, settings)
    runner = Runner.from_vasprun(vasprun, settings)
    amset_data = runner.run()
    _validate_data(amset_data, transport, max_aniso, files, scats)
Example #3
0
def test_run_amset_from_directory(
    example_dir, system, settings, transport, max_aniso, files, scats
):
    vasprun, settings = _prep_inputs(example_dir, system, settings)
    dumpfn(settings, "settings.yaml")
    runner = Runner.from_directory(".", input_file=vasprun, settings_override=settings)
    amset_data = runner.run()
    _validate_data(amset_data, transport, max_aniso, files, scats)
Example #4
0
def test_run_tricky_spin_polarized(band_structure_data):
    settings = {
        "interpolation_factor": 2,
        "temperatures": [300],
        "doping": [1e15],
        "deformation_potential": (6.5, 6.5),
        "elastic_constant": 190,
        "use_projections": True,
        "scattering_type": ["ADP"],
        "nworkers": 1,
    }
    files = ["transport", "!mesh"]
    scats = ["ADP"]
    transport = {
        ("mobility", ("overall", (0, 0))): 1.261213643946453,
        ("seebeck", (0, 0)): 1356.1341462605026,
    }

    bs = band_structure_data["tricky_sp"]["band_structure"]
    nelect = band_structure_data["tricky_sp"]["nelect"]
    runner = Runner(bs, nelect, settings)
    amset_data = runner.run()
    _validate_data(amset_data, transport, 1, files, scats)
Example #5
0
    # general settings
    "doping": [-3e13],
    "temperatures": [201, 290, 401, 506, 605, 789, 994],
    "bandgap": 1.33,

    # electronic_structure settings
    "interpolation_factor": 50,

    # scattering rate settings
    "deformation_potential": (1.2, 8.6),
    "elastic_constant": 139.7,
    "donor_charge": 1,
    "acceptor_charge": 1,
    "static_dielectric": 12.18,
    "high_frequency_dielectric": 10.32,
    "pop_frequency": 8.16,

    # performance settings
    "mobility_rates_only": True,
    "write_mesh": True,
}


if __name__ == "__main__":
    runner = Runner.from_vasprun("vasprun.xml.gz", settings)
    amset_data = runner.run()

    plotter = RatesPlotter(amset_data)
    plt = plotter.get_plot()
    plt.savefig("GaAs_rates.png", bbox_inches="tight", dpi=400)
Example #6
0
def eff_mass(filename, **kwargs):
    """
    Calculate conductivity effective mass.
    """
    import numpy as np
    from monty.serialization import loadfn
    from scipy import constants
    from tabulate import tabulate

    from amset.constants import bohr_to_cm, defaults
    from amset.core.run import Runner

    settings = {
        "scattering_type": ["CRT"],
        "constant_relaxation_time": 1e-14,
        "use_projections": True,
        "calculate_mobility": False,
        "separate_mobility": False,
        "write_log": False,
        "file_format": None,
    }
    for setting in defaults:
        if setting in kwargs and kwargs[setting] is not None:
            settings[setting] = kwargs[setting]
        elif setting == "doping" or setting == "temperatures":
            settings[setting] = temp_doping_defaults[setting]

    if "json" in filename:
        data = loadfn(filename)
        runner = Runner(data["band_structure"], data["nelect"], settings)
    else:
        runner = Runner.from_vasprun(filename, settings)

    amset_data = runner.run()
    inv_cond = np.linalg.inv(amset_data.conductivity)
    doping_scale = 1 / bohr_to_cm**3
    doping = (np.abs(amset_data.doping) * doping_scale)[:, None, None, None]
    crt = settings["constant_relaxation_time"]

    masses = inv_cond * crt * doping * 10**6 * constants.e**2 / constants.m_e
    mass_info = []
    for n, t in np.ndindex(amset_data.fermi_levels.shape):
        info = [
            amset_data.doping[n] * doping_scale, amset_data.temperatures[t]
        ]
        if kwargs["average"]:
            eigs = np.linalg.eigvals(masses).real
            info.append(3 / (1 / eigs[n, t]).sum())
        else:
            xyz = np.diagonal(masses, axis1=-2, axis2=-1)
            info.extend(xyz[n, t].tolist())
        mass_info.append(info)

    headers = ["conc [cm⁻³]", "temp [K]"]
    floatfmt = [".2e", ".1f"]

    if kwargs["average"]:
        headers.append("m*")
        floatfmt.append(".3f")
    else:
        headers.extend(["mₓₓ*", "mᵧᵧ*", "m₂₂*"])
        floatfmt.extend([".3f"] * 3)

    table = tabulate(
        mass_info,
        headers=headers,
        numalign="right",
        stralign="center",
        floatfmt=floatfmt,
    )

    click.echo("\nEffective masses:\n")
    click.echo(table)

    return mass_info