httk.io.vasp.poscar_reader ========================== .. py:module:: httk.io.vasp.poscar_reader .. autoapi-nested-parse:: A string-preserving reader for VASP POSCAR/CONTCAR files. :func:`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 --------- .. autoapisummary:: httk.io.vasp.poscar_reader.read_poscar Module Contents --------------- .. py:function:: read_poscar(source: Any) -> dict[str, Any] Parse a VASP POSCAR/CONTCAR into a neutral, string-preserving mapping. ``source`` may be a filename (``str`` or :class:`os.PathLike`, opened through :class:`httk.core.TextstreamFileView` so compressed files such as ``CONTCAR.bz2`` are decompressed transparently) or an already-open text stream / iterable of lines. The returned mapping has the keys ``format`` (always ``"vasp-poscar"``), ``comment``, ``scale`` and ``volume`` (exactly one is a string, the other ``None``), ``cell`` (a 3x3 list of coordinate strings), ``symbols`` (``list[str]`` for VASP-5, ``None`` for VASP-4), ``counts`` (``list[int]``), ``cartesian`` (``bool``), ``coords`` (an ``N``x3 list of strings), and ``selective_dynamics`` (an ``N``x3 list of booleans when the file declares selective dynamics, else ``None``). Malformed input raises a clear :class:`ValueError` naming the offending line.