Skip to main content

vaspparser

Pipeline codecov Binder

vaspparser reads the output files of a VASP calculation - OUTCAR, vasprun.xml, OSZICAR, CONTCAR/POSCAR, PROCAR, CHGCAR, LOCPOT, AECCAR0/AECCAR2 and REPORT - and turns them into plain Python data: an ASE Atoms object for the structure, numpy arrays for energies/forces/charge densities, and nested dictionaries for everything else. There is no VASP-specific object model to learn - if you already know what a vasprun.xml or a CHGCAR contains, vaspparser gets it into your Python session with minimal ceremony.

Installation

Via pip

pip install vaspparser

Via conda

conda install -c conda-forge vaspparser

Quick start

For a finished calculation, parse_vasp_output() collects everything that is available in the working directory into a single hierarchical dictionary:

from vaspparser.vasp.output import parse_vasp_output

output_dict = parse_vasp_output(working_directory="path/to/calculation")
list(output_dict.keys())
# ['description', 'generic', 'structure', 'electronic_structure', 'outcar', ...]

output_dict["generic"]["energy_tot"][-1]  # final total energy in eV

vasprun.xml is preferred when present (it is the most complete and most precise source), with OUTCAR used as a fallback or to fill in quantities vasprun.xml does not report (stresses, elastic constants, ...). LOCPOT/CHGCAR are parsed when found, and Bader charges are computed automatically when AECCAR0/AECCAR2 are present.

If you only need one piece of information, or want more control, the individual parsers below can be used directly instead.

Features

Structure I/O

Read a POSCAR/CONTCAR into an ASE Atoms object, and write one back out:

from vaspparser.vasp.structure import read_atoms, write_poscar, vasp_sorter

structure = read_atoms("POSCAR", species_list=["Fe"])
write_poscar(structure, filename="POSCAR_new")

# VASP groups atoms by species; vasp_sorter() gives the permutation that does that
vasp_sorter(structure)

Individual output files

Each file also has a parser that can be used on its own, e.g. for scripting against a single quantity without parsing the full directory:

from vaspparser.vasp.parser.oszicar import Oszicar
from vaspparser.vasp.parser.outcar import Outcar
from vaspparser.vasp.vasprun import Vasprun

oszicar = Oszicar()
oszicar.from_file(filename="OSZICAR")
oszicar.parse_dict["energy_pot"]  # energy at every electronic/ionic step

outcar = Outcar()
outcar.from_file(filename="OUTCAR")
outcar.parse_dict["fermi_level"]

vasprun = Vasprun()
vasprun.from_file(filename="vasprun.xml")
vasprun.vasprun_dict["total_fr_energies"]

Electronic structure: DOS and band gap

Vasprun.get_electronic_structure() (or the PROCAR parser below) returns an ElectronicStructure object holding eigenvalues and occupancies for every k-point and spin channel, from which the band gap and density of states (DOS) can be computed:

electronic_structure = vasprun.get_electronic_structure()
electronic_structure.get_band_gap()
# {0: {'band_gap': 0.62, 'vbm': {...}, 'cbm': {...}}}

dos = electronic_structure.get_dos(n_bins=200)
dos.plot_total_dos()  # requires matplotlib

Atom- and orbital-projected DOS (PROCAR)

The PROCAR file holds atom- and orbital-projected band/DOS information, useful for analysing the chemical character of bands:

from vaspparser.vasp.procar import Procar

procar_es = Procar().from_file(filename="PROCAR")
band = procar_es.kpoints[0].bands[0][0]
band.atom_resolved_dos  # contribution of each atom to this band
band.orbital_resolved_dos  # contribution of each orbital (s, p, d, ...)

Volumetric data: charge density and electrostatic potential

CHGCAR/LOCPOT-type files describe a quantity on a real-space grid. VaspVolumetricData parses them and offers helpers such as averaging along one lattice direction (handy for work-function or interface analysis):

from vaspparser.vasp.volumetric_data import VaspVolumetricData

charge_density = VaspVolumetricData()
charge_density.from_file(filename="CHGCAR", normalize=True)
charge_density.total_data.shape  # (Nx, Ny, Nz)
charge_density.get_average_along_axis(
    ind=2
)  # average over the ab-plane, as a function of c

Bader charge analysis

Bader analysis partitions the charge density into atomic basins. Running it requires the external bader executable; vaspparser builds its CHGCAR-style inputs from AECCAR0/AECCAR2 and parses the result:

from vaspparser.dft.bader import Bader

bader = Bader(structure=structure, working_directory="path/to/calculation")
charges, volumes = bader.compute_bader_charges()

Documentation

Metadata

Release files for vaspparser 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vaspparser 0.1.2
File Size Uploaded Provenance Actions
vaspparser-0.1.2.tar.gz 48.3 kB With provenance Details for vaspparser-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vaspparser 0.1.2
File Interpreter ABI Platform Actions
vaspparser-0.1.2-py3-none-any.whl Python 3 none any Details for vaspparser-0.1.2-py3-none-any.whl

Total release size: 104.5 kB

Release files / vaspparser-0.1.2.tar.gz

Download URL vaspparser-0.1.2.tar.gz
Size 48.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4d2acab7bbcddf4a5e583d5c6cb8d9fde17d81d8e2f2112325ae2e44553aaef5
BLAKE2b-256 checksum
How to use checksums
1ebc3b39b02f74290064a5ade4a7e5ad34e7b182ccad720d45a751e0684720f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / vaspparser-0.1.2-py3-none-any.whl

Download URL vaspparser-0.1.2-py3-none-any.whl
Size 56.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
66ce1e44d72ea4cdc6e84edd1f3d8430de2c60e97cafbe871e038e609b3408ad
BLAKE2b-256 checksum
How to use checksums
29f9885ca47f6a647dc670e0c57d6ee25abd34ab656b6923ee8f432df132cd9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for vaspparser 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for vaspparser-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page