py4vasp is a Python interface for analyzing and setting up VASP calculations, primarily by extracting data from the new HDF5 file format (`VASP_H5_data.h5`). It's designed for quick data inspection, plotting, and export to other tools, serving as a powerful assistant for materials science researchers working with VASP output. The library is actively developed, with regular releases providing new features and improvements.
pip install py4vaspVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize a `Calculation` object from a VASP output directory, access common data types like the Density of States (DOS), plot them, and export them to a Python dictionary. It includes error handling for cases where VASP output files are missing or incomplete.
Update your code to use `py4vasp.data.Kpoints` and call the `.plot()` method directly on data objects, e.g., `calc.bands.plot()` instead of `calc.bands.plot_bands()`.
Consult the `py4vasp` documentation for the specific data type you are working with. Data is now typically accessed directly as attributes (e.g., `calc.dos.energies`) or by passing arguments to methods like `.to_dict()` or `.plot()`.
Always provide the correct absolute or relative path to your VASP calculation directory: `calc = pv.Calculation('/absolute/path/to/my_vasp_output')` or ensure your script's working directory is the calculation directory.Ensure your VASP version (VASP 6+) is configured to produce `VASP_H5_data.h5`. Check that the file exists in the directory passed to `pv.Calculation()` or the current working directory. If you are using an older VASP version, py4vasp will not work without manual data conversion.
Update your code to use the generic `.plot()` method. For example, change `calc.bands.plot_bands()` to `calc.bands.plot()` and `calc.dos.plot_dos()` to `calc.dos.plot()`.
Re-run the VASP calculation to ensure it completes successfully and generates a valid HDF5 file. Check the file size; a very small `VASP_H5_data.h5` often indicates a truncated or empty file. You can also use `h5dump` or `h5ls` command-line tools to inspect the file integrity.
Verify that your VASP input files (e.g., INCAR, KPOINTS) were correctly configured to perform the calculation that generates the desired data. Refer to the VASP manual for required tags. You can inspect the contents of `VASP_H5_data.h5` using `h5ls VASP_H5_data.h5` to see what data is actually available.