htesp.inputin

Reading and writing input.in.

input.in is the six-line file every HTESP command starts from:

1            <- start index (1-based, inclusive)
30           <- end index   (EXCLUSIVE -- the loops run ii < end)
200 0        <- nkpt [kcut]
mpid-list.in <- tracking file
phband dos   <- plot types, whitespace separated
DFT = QE     <- QE or VASP

The original parser in mainprogram.py had three defects, all reproduced by the tests in tests/test_inputin.py:

  • it guarded with len(lines) >= 4 and then read lines[4], so a four-line file raised IndexError;

  • a shorter file left start/end/element/nkpt unbound, so the next statement raised NameError instead of reporting the real problem;

  • the two branches disagreed about the type of line 5. Reading an existing file gave lines[4].split(" ") – a list, which mainprogram 19 iterates to plot one type per entry, as intended. Creating a missing file assigned the bare string 'phband'. A string iterates too, so the same correct loop walked its characters and ran plot-scan six times with p, h, b, a, n, d – none of which it recognises. Only on the run that created input.in; afterwards the file was read back as a list and the loop behaved. plot_types is a list[str] everywhere now, so both paths agree.

The sixth line is written unconditionally here. The bash layer tested [ $dft == 'vasp' ] at 31 sites, which aborts with “unary operator expected” when the line is missing.

Classes

InputIn(start, end, nkpt, kcut, track, ...)

The parsed contents of input.in.

Exceptions

InputInError

Raised for an input.in that cannot be understood.

exception htesp.inputin.InputInError[source]

Raised for an input.in that cannot be understood.

class htesp.inputin.InputIn(start: int = 1, end: int = 2, nkpt: int = 200, kcut: int = 0, track: str = 'mpid-list.in', plot_types: list[str] = <factory>, dft: str = 'QE', path: Path | None = None)[source]

The parsed contents of input.in.

classmethod load(path: PathLike | str = 'input.in', config: dict | None = None) → InputIn[source]

Best-effort parse that never raises.

The workflow layer must keep going when a single field is malformed – the bash layer simply used an empty variable, which is how [ $dft == 'vasp' ] came to abort with “unary operator expected” at 31 call sites. Missing fields fall back to the documented defaults and dft falls back to download.inp.calc from config.json. Unlike parse(), dft is returned lower-cased.

classmethod load_or_create(path: PathLike | str = 'input.in', dft: str | None = None) → InputIn[source]

Read input.in, creating a sensible default when it is absent.

property count: int

Number of materials the range covers (end is exclusive).

check_track_file(root: PathLike | str = '.') → list[str][source]

Warn when the range does not line up with the tracking file.