{"library":"py4vasp","title":"py4vasp","description":"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.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install py4vasp"],"cli":null},"imports":["import py4vasp as pv","from py4vasp import Calculation"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import py4vasp as pv\nimport matplotlib.pyplot as plt\nimport os\n\n# This example assumes a VASP calculation's output files\n# (especially VASP_H5_data.h5) are present in the 'example_calc_path' directory.\n# Replace 'example_calc_path' with the actual directory containing your VASP output.\n# For demonstration, we use a placeholder and handle potential errors.\n\n# If you have VASP output in a specific directory, set it here:\nexample_calc_path = os.environ.get(\"VASP_CALC_PATH\", \".\") # Defaults to current directory\n\ntry:\n    # Initialize a Calculation object from the path\n    calc = pv.Calculation(example_calc_path)\n\n    # Access and plot the Density of States (DOS)\n    if hasattr(calc, 'dos') and calc.dos.is_readable():\n        print(f\"Loading DOS from: {example_calc_path}\")\n        dos_plot = calc.dos.plot()\n        # dos_plot.show() # Uncomment to display the plot (requires matplotlib backend)\n\n        # Export DOS data to a dictionary\n        dos_data = calc.dos.to_dict()\n        print(\"DOS data keys:\", dos_data.keys())\n    else:\n        print(f\"DOS data not found or not readable in '{example_calc_path}'.\")\n        print(\"Ensure VASP_H5_data.h5 exists and contains DOS information.\")\n\nexcept Exception as e:\n    print(f\"Error accessing VASP calculation at '{example_calc_path}': {e}\")\n    print(\"Please ensure the path is correct and contains valid VASP HDF5 output files.\")\n\n# Example of accessing the band structure data object directly\nbands_object = pv.data.band()\nprint(f\"\\nExample of accessing band structure data object: {bands_object}\")\n# bands_object.plot().show() # Would require a VASP_H5_data.h5 with band data","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}