vaspparser
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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vaspparser-0.0.9.tar.gz.
File metadata
- Download URL: vaspparser-0.0.9.tar.gz
- Upload date:
- Size: 48.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87d837f339117c9a60d38be1841ee9ba601f2e8186f05e8ecd6653e5670a4d53
|
|
| MD5 |
bded4022582954f24df68ecf5ed79f99
|
|
| BLAKE2b-256 |
e7983d7f0271a351a511fc13be878a2d08be8401fe65dc47f68531daeb57edde
|
Provenance
The following attestation bundles were made for vaspparser-0.0.9.tar.gz:
Publisher:
deploy.yml on pyiron/vaspparser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vaspparser-0.0.9.tar.gz -
Subject digest:
87d837f339117c9a60d38be1841ee9ba601f2e8186f05e8ecd6653e5670a4d53 - Sigstore transparency entry: 2281137956
- Sigstore integration time:
-
Permalink:
pyiron/vaspparser@fdabc0f46e8d5a5a8e29881108ea82a33282bd53 -
Branch / Tag:
refs/tags/vaspparser-0.0.9 - Owner: https://github.com/pyiron
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@fdabc0f46e8d5a5a8e29881108ea82a33282bd53 -
Trigger Event:
push
-
Statement type:
File details
Details for the file vaspparser-0.0.9-py3-none-any.whl.
File metadata
- Download URL: vaspparser-0.0.9-py3-none-any.whl
- Upload date:
- Size: 56.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f981e1e56ce3142116cbee2514a370ac72a3806484b9ecf53dffbcfc9aa5f17e
|
|
| MD5 |
23649e78dc58590944a7eed845c2f7b4
|
|
| BLAKE2b-256 |
91e4064806f7dfd69644842a06ddbc03219fe27aa191b60eb1cbf4b01fd3f416
|
Provenance
The following attestation bundles were made for vaspparser-0.0.9-py3-none-any.whl:
Publisher:
deploy.yml on pyiron/vaspparser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vaspparser-0.0.9-py3-none-any.whl -
Subject digest:
f981e1e56ce3142116cbee2514a370ac72a3806484b9ecf53dffbcfc9aa5f17e - Sigstore transparency entry: 2281137962
- Sigstore integration time:
-
Permalink:
pyiron/vaspparser@fdabc0f46e8d5a5a8e29881108ea82a33282bd53 -
Branch / Tag:
refs/tags/vaspparser-0.0.9 - Owner: https://github.com/pyiron
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@fdabc0f46e8d5a5a8e29881108ea82a33282bd53 -
Trigger Event:
push
-
Statement type: