I/O and Folders#

directupsampling.folders.read.fermi_dirac_distribution(energy: float | ndarray, fermi_level: float, beta: float) ndarray[source]#

Compute the Fermi–Dirac occupation probability for each energy level.

Parameters#

energyndarray of shape (…,), dtype=float64

Energy values.

fermi_levelfloat

The Fermi level.

betafloat

Inverse temperature 1 / (k_B * T).

Returns#

ndarray of shape (…,), dtype=float64

The occupation probability for each energy level.

directupsampling.folders.read.get_fixdos_fel(calc: SinglePointDFTCalculator, temperature: float) float[source]#

Calculate the electronic free energy within the fixed DOS approximation.

Parameters#

calc: ASE SinglePointDFTCalculator

Calculator instance containing eigenvalues.

temperature: float

The ‘electronic’ temperature going into the Fermi Dicac distribution.

Returns#

free_energy

The free energy at temperature.

directupsampling.folders.read.read_folders_to_sampler(sampler: GridSampler, path: os.PathLike, **kwargs)[source]#
directupsampling.folders.read.read_grid_from_folders(path: PathLike) list[tuple[float, float]][source]#
directupsampling.folders.write.write_folders_from_sampler(sampler: GridSampler, calc: FileIOCalculator, root_path: str | os.PathLike | None = None, **kwargs: dict) tuple[list, list][source]#

Write folder structure from a SnapshotSampler instance.

Returns#

joblist : list joblist_angk : list

directupsampling.folders.write.write_joblist(joblist: list[str], filename: str | Path = 'jobList') None[source]#
directupsampling.folders.write.write_snapshots(path: Path, snapshots: SnapshotContainer, calc: FileIOCalculator = None, sampler: GridSampler | None = None, fmt: str | None = None) list[Path][source]#

Write snapshots to folders.

Parameters#

pathPath

Root directory for this set of snapshots.

snapshotsSnapshotContainer

Snapshots to write.

calcFileIOCalculator | None

ASE FileIOCalculator to write calculator-specific input files. If None, a structure file is written using fmt.

samplerGridSampler | None

Used to look up reference energies when atoms carry no calculator.

fmtstr | None

ASE format string for the structure file when calc is None. Defaults to "vasp" (writes a POSCAR file).

Returns#

joblist : list[Path]

class directupsampling.io.jsonio.MyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]#

Bases: JSONEncoder

default(obj)[source]#

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return super().default(o)
directupsampling.io.jsonio.create_ndarray(shape, dtype, data)[source]#

Create ndarray from shape, dtype and flattened data.

directupsampling.io.jsonio.default(obj)[source]#
directupsampling.io.jsonio.fix_int_keys_in_dicts(obj)[source]#

Convert “int” keys: “1” -> 1.

The json.dump() function will convert int keys in dicts to str keys. This function goes the other way.

directupsampling.io.jsonio.intkey(key)[source]#

Convert str to int if possible.

directupsampling.io.jsonio.object_hook(dct)[source]#
directupsampling.io.jsonio.read_json(fd)[source]#
directupsampling.io.jsonio.write_json(fd, obj)[source]#