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) >= 4and then readlines[4], so a four-line file raisedIndexError;a shorter file left
start/end/element/nkptunbound, so the next statement raisedNameErrorinstead 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, whichmainprogram 19iterates 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 ranplot-scansix times withp,h,b,a,n,d– none of which it recognises. Only on the run that createdinput.in; afterwards the file was read back as a list and the loop behaved.plot_typesis alist[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
|
The parsed contents of |
Exceptions
Raised for an |
- 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 anddftfalls back todownload.inp.calcfromconfig.json. Unlikeparse(),dftis 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 (
endis exclusive).