httk.io.vasp.poscar_reader¶
A string-preserving reader for VASP POSCAR/CONTCAR files.
read_poscar() parses a POSCAR/CONTCAR file into a neutral, JSON-able
mapping whose numeric fields are kept as the verbatim strings found in the
file. It performs no numeric conversion and imports nothing from
httk-atomistic; turning the mapping into a Structure is the job of
httk.atomistic.structure_from_poscar.
Functions¶
|
Parse a VASP POSCAR/CONTCAR into a neutral, string-preserving mapping. |
Module Contents¶
- httk.io.vasp.poscar_reader.read_poscar(source: Any) dict[str, Any][source]¶
Parse a VASP POSCAR/CONTCAR into a neutral, string-preserving mapping.
sourcemay be a filename (stroros.PathLike, opened throughhttk.core.TextstreamFileViewso compressed files such asCONTCAR.bz2are decompressed transparently) or an already-open text stream / iterable of lines.The returned mapping has the keys
format(always"vasp-poscar"),comment,scaleandvolume(exactly one is a string, the otherNone),cell(a 3x3 list of coordinate strings),symbols(list[str]for VASP-5,Nonefor VASP-4),counts(list[int]),cartesian(bool),coords(anN``x3 list of strings), and ``selective_dynamics(anN``x3 list of booleans when the file declares selective dynamics, else ``None). Malformed input raises a clearValueErrornaming the offending line.Three further keys report how precisely the file wrote its numbers, each the coarsest claim among the tokens it covers, or
Nonewhen none of them claim anything:cell_precision,scale_precision, andcoordinate_precision. They are the precisions of the tokens as written, deliberately not converted: the cell vectors are still to be multiplied by the scaling factor, and the coordinates may be Cartesian or fractional depending oncartesian. Doing that conversion needs the assembled cell, so it belongs to whoever builds the structure —httk.atomistic.structure_from_poscar()— not to the reader.