$ show PytLab/VASPy
VASPy is a pure Python library for manipulating and analyzing VASP (Vienna Ab initio Simulation Package) input and output files. It provides object-oriented parsers for common VASP formats including POSCAR, CONTCAR, XDATCAR, OUTCAR, OSZICAR, INCAR, DOS, ELFCAR, CHGCAR, and also supports Materials Studio formats (XSD, ARC, XTD). The library exposes high-level classes like PosCar, OutCar, DosX, and InCar that encapsulate file parsing, coordinate transformations, and data extraction, enabling users to programmatically read, modify, and visualize simulation results. It also includes a set of command-line scripts for common tasks such as creating VASP inputs, extracting forces, computing zero-point energies, and converting between file formats. The architecture is modular, with separate modules for atomic coordinates, electronic structure, iterative outputs, and Material Studio interoperability, all built on a shared base class and utility functions. Visualization is a key feature, with matplotlib and PyVista backends for plotting DOS, charge densities, and trajectories. The library is designed for computational materials science researchers and DFT practitioners who need to automate post-processing and workflow tasks around VASP calculations.
The LLM identified 4 files worth highlighting for reuse:
Implements a LazyProperty descriptor that caches computed properties on first access. This is a clean, self-contained pattern for memoization in Python classes, reusable in any project needing deferred computation without external dependencies.
Provides static methods dir2cart and cart2dir for converting between direct (fractional) and Cartesian coordinates given lattice vectors. These are pure, stateless functions that can be extracted and reused in any crystallographic or molecular modeling codebase.
Contains a contour_decorator that slices 3D volumetric data (e.g., ELFCAR) along a plane and generates contour plots, plus an expand_data static method for replicating periodic grids. The decorator pattern is reusable for any 3D scalar field visualization task, and the expansion logic is generic for supercell replication.
Defines iforces and ifreq generators that lazily yield force and frequency blocks from large OUTCAR files. This streaming approach avoids loading entire files into memory and is a reusable pattern for parsing any large, block-structured text output.