Jump to content

Requests for technical support from the VASP team should be posted in the VASP Forum.

Vasprun.xml: Difference between revisions

From VASP Wiki
Csheldon (talk | contribs)
No edit summary
Csheldon (talk | contribs)
 
(29 intermediate revisions by 2 users not shown)
Line 1: Line 1:
In addition to {{FILE|OUTCAR}}, output from VASP is stored using XML format in the {{FILE|vasprun.xml}} file for ease of use. Below, the structure of such a file is given with links to the corresponding pages:
{{DISPLAYTITLE:vasprun.xml}}The {{FILE|vasprun.xml}} is written in xml format and contains both, general output that is written for any calculation and specific output depending on the method or quantity that is being computed. Below you see details regarding the general output, while the specific output, e.g. the dielectric function ({{TAG|LOPTICS}}), partial density of states ({{TAG|LORBIT}}), the electronic self-energy ({{TAG|LSELFENERGY}}) etc., are detailed on the corresponding tag documentation. Mind that newer features tend to write to {{FILE|vaspout.h5}}. The {{FILE|vaspout.h5}} should generally be preferred for reading large datasets.


== Contents of file ==
== File format ==
The structure of {{FILE|vasprun.xml}} has the following main hierarchy:


# generator
The root element is <code><modeling></code>. The file uses four repeating XML primitives throughout:
# incar
# primitive cell
# kpoints
# parameters
# atom info
# structure
# calculation


Each section will be shown, with links to the relevant pages in the Wiki.
* <code><i name="..." type="...">value</i></code> — a named scalar (real, integer, logical, or string).
* <code><v name="...">x y z</v></code> — a named row vector.
* <code><varray name="..."></code> — a named array of vectors, each on a <code><v></code> line.
* <code><array></code> — a labelled multi-field table with named dimensions; rows are stored as <code><r></code> elements inside <code><set></code> blocks.


== Generator ==
The overall layout of {{FILE|vasprun.xml}} is:
Contains all the information about the calculation run.


* '''program'''
<syntaxhighlight lang="xml">
** VASP
<modeling>
* '''version'''
  <generator>  ...  </generator>
** VASP version
  <incar>      ...  </incar>
* '''subversion'''
  <primitive_cell> ... </primitive_cell>
** Subversion and build details, including compilation details.
  <kpoints>    ...  </kpoints>
* '''platform'''
  <parameters>  ... </parameters>
** Operating system and compiler used.
  <atominfo>    ...  </atominfo>
* '''date'''
  <structure name="initialpos"> ... </structure>
** Date the calculation was performed (YYYY MM DD)
* '''time'''
  <!-- one block per ionic step (MD, relaxation): -->
** Time the calculation was performed (HH:MM:SS)
  <structure> ... </structure>
  <varray name="forces"> ... </varray>
  <varray name="stress"> ... </varray>
  <energy> ... </energy>
  <time name="totalsc"> ... </time>
  ...
  <!-- OR a single calculation block (single-point, GW, BSE): -->
  <calculation> ... </calculation>
  <structure name="finalpos"> ... </structure>
</modeling>
</syntaxhighlight>


== Incar ==
== Sections ==
Input parameters read from the {{FILE|INCAR}} file.


* '''SYSTEM'''
=== Generator ===
** System description: e.g., face-centered cubic Silicon.
* '''{{TAG|ISTART}}'''
** Controls how the wave functions are initialized.
* '''{{TAG|ICHARG}}'''
** Controls how the charge density is initialized.
* '''{{TAG|ENCUT}}'''
** Energy cutoff for plane-wave basis set in eV.
* '''{{TAG|ISMEAR}}'''
** Smearing method for occupations.
* '''{{TAG|SIGMA}}'''
** Smearing width in eV.


== Primitive cell ==
Contains the VASP version, build details, and the date and time of the run.
* '''Structure'''
** Structure details of the primitive cell.
*'''Crystal'''
** Crystal lattice information.
*'''Basis'''
** Basis vectors of the primitive unit cell in Angstroms: <math>a_1, a_2, a_3</math>
*'''Volume'''
** Volume of the primitive unit cell in ų.
*'''Rec_Basis'''
** Reciprocal lattice basis vectors: <math>b_1, b_2, b_3</math>
*'''Positions'''
** Atomic positions within the primitive cell (in direct coordinates). ''?????''
*'''Primitive_Index''' ''?????''
** Index representing the primitive cell.


== Kpoints ==
<syntaxhighlight lang="xml">
Specifies the Bloch vectors (k points) used in the {{FILE|KPOINTS}} file to sample the Brillouin zone.
<generator>
  <i name="program"    type="string">vasp </i>
  <i name="version"    type="string">6.5.0  </i>
  <i name="subversion" type="string">29Jan2024 (build Feb 14 2024) complex parallel</i>
  <i name="platform"  type="string">LinuxGNU </i>
  <i name="date"      type="string">2024 01 01 </i>
  <i name="time"      type="string">12:00:00 </i>
</generator>
</syntaxhighlight>


*'''Generation'''
=== INCAR ===
** Method used for k-point generation: e.g., Monkhorst-Pack.
*'''Divisions'''
** Divisions along each reciprocal lattice vector for the Monkhorst-Pack mesh.
*'''Usershift'''
** User-defined shift for the k-point mesh.
*'''Genvec1'''
** First generator vector for the k-points.
*'''Genvec2'''
** Second generator vector for the k-points.
*'''Genvec3'''
** Third generator vector for the k-points.
*'''Shift'''
** Shift applied to the k-point mesh.
*'''Kpointlist'''
** Explicit list of k-points in reciprocal space.
*'''Weights'''
** Weights corresponding to each k-point.


== Parameters ==
Contains only the tags explicitly set in the {{FILE|INCAR}} file, without defaults. This is a compact record of the user-specified settings for the run.
Parameters used for running the calculation.


=== General ===
<syntaxhighlight lang="xml">
General calculation parameters.
<incar>
*'''SYSTEM'''
  <i type="string" name="SYSTEM">diamond Si</i>
**System name.
  <i type="string" name="ALGO">Normal</i>
*'''{{TAG|LCOMPAT}}'''
  <i name="ENCUT">    500.00000000</i>
** Compatibility flag for older versions. ?????
  <i type="int" name="ISMEAR">    0</i>
=== Electronic ===
  <i name="SIGMA">      0.05000000</i>
Electronic structure calculation parameters.
</incar>
*'''{{TAG|PREC}}'''
</syntaxhighlight>
** Precision setting for calculations (normal).
 
*'''{{TAG|ENMAX}}'''
=== Primitive cell ===
** Maximum energy cutoff for plane waves in eV.
 
*'''{{TAG|ENAUG}}'''
Contains the structure and lattice of the primitive unit cell, along with the mapping of primitive-cell ion indices to the full simulation-cell ion indices.
** Augmentation charge cutoff in eV.
 
*'''{{TAG|EDIFF}}'''
<syntaxhighlight lang="xml">
** Convergence criterion for electronic self-consistency loop in eV.
<primitive_cell>
*'''{{TAG|IALGO}}'''
  <structure name="primitive_cell">
** Algorithm for electronic minimization.
    <crystal>
*'''{{TAG|IWAVPR}}'''
      <varray name="basis">            <!-- lattice vectors in A -->
** Controls when wavefunctions are written to WAVECAR.
        <v>  1.92  1.92  0.00 </v>
*'''{{TAG|NBANDS}}'''
        <v>  0.00  1.92  1.92 </v>
** Number of bands to be calculated.
        <v>  1.92  0.00  1.92 </v>
*'''{{TAG|NBANDSLOW}}'''
      </varray>
** Lower bound for bands considered in certain calculations. ?????
      <i name="volume">    28.35 </i>  <!-- volume in A^3 -->
*'''{{TAG|NBANDSHIGH}}'''
      <varray name="rec_basis">        <!-- reciprocal lattice vectors in A^-1 -->
** Upper bound for bands considered in certain calculations. ?????
        <v>  0.26  0.26 -0.26 </v>
*'''{{TAG|NELECT}}'''
        <v> -0.26  0.26  0.26 </v>
** Total number of electrons in the system.
        <v>  0.26 -0.26  0.26 </v>
*'''{{TAG|TURBO}}'''
      </varray>
** Controls turbo molecular dynamics.
    </crystal>
*'''{{TAG|IRESTART}}'''
    <varray name="positions">          <!-- fractional (direct) coordinates -->
** Controls restarts.
      <v> 0.00  0.00  0.00 </v>
*'''{{TAG|NREBOOT}}'''
      <v> 0.25  0.25  0.25 </v>
** Controls how many times the calculation restarts. ?????
    </varray>
*'''{{TAG|NMIN}}'''
  </structure>
** Minimum number of electronic steps.
  <varray name="primitive_index">      <!-- index of each primitive ion in the full cell -->
*'''{{TAG|EREF}}'''
    <v type="int"> 1 </v>
** Reference energy for some calculations. ?????
    <v type="int"> 2 </v>
=== Electronic Smearing ===
  </varray>
Parameters related to electronic smearing.
</primitive_cell>
*'''{{TAG|ISMEAR}}'''  
</syntaxhighlight>
** Smearing method.
 
*'''{{TAG|SIGMA}}'''
=== k points ===
** Smearing width in eV.
 
*'''{{TAG|KSPACING}}'''
Specifies the '''k'''-point sampling of the Brillouin zone, mirroring the {{FILE|KPOINTS}} file.
** K-point spacing for automatically generated KPOINTS.
 
*'''{{TAG|KGAMMA}}'''
<syntaxhighlight lang="xml">
** Enforces Gamma-centered k-point mesh. ?????
<kpoints>
*'''{{TAG|KBLOWUP}}'''
  <generation param="Gamma">            <!-- generation scheme: Gamma, Monkhorst-Pack, or Explicit -->
** Controls blow-up of k-point mesh. ?????
    <v type="int" name="divisions"> 4 4 4 </v>
=== Electronic Projectos' ===
    <v name="usershift"> 0.0  0.0  0.0 </v>
Parameters for projectors in PAW method.
    <v name="genvec1">  0.25 0.00 0.00 </v>
*'''{{TAG|LREAL}}'''
    <v name="genvec2">  0.00 0.25 0.00 </v>
** Controls projection operators in real space.
    <v name="genvec3">  0.00 0.00 0.25 </v>
*'''{{TAG|ROPT}}'''
    <v name="shift">    0.00 0.00 0.00 </v>
** Controls real-space grid for projections. ?????
  </generation>
*'''{{TAG|LMAXPAW}}'''
  <varray name="kpointlist">            <!-- '''k'''-point coordinates in reciprocal space -->
** Maximum angular momentum for PAW projectors. ?????
    <v>  0.000  0.000  0.000 </v>
*'''{{TAG|LMAXMIX}}'''
    <v>  0.250  0.000  0.000 </v>
** Maximum angular momentum for charge density mixing. ?????
    ...
*'''{{TAG|NLSPLINE}}'''
  </varray>
** Controls non-local spline interpolation. ?????
  <varray name="weights">              <!-- integration weights, normalized to sum to 1 -->
=== Electronic Startup ===
    <v> 0.00463 </v>
Parameters for initializing the electronic calculation.
    <v> 0.03704 </v>
*'''{{TAG|ISTART}}'''
    ...
** Controls how the wave functions are initialized.
  </varray>
*'''{{TAG|ICHARG}}'''
</kpoints>
** Controls how the charge density is initialized.
</syntaxhighlight>
*'''{{TAG|INIWAV}}'''
 
** Controls how initial wavefunctions are generated. ?????
=== Parameters ===
=== Electronic Spin ===
 
Parameters for spin polarization.
Contains a complete record of all effective {{FILE|INCAR}} parameters, including those not set explicitly (with their default values). The block is organized into named <code><separator></code> subsections corresponding to groups of related tags, for example:
*'''{{TAG|ISPIN}}'''
 
** Spin polarization.
* <code>general</code>
*'''{{TAG|LNONCOLLINEAR}}'''
* <code>electronic</code> (with sub-separators: <code>smearing</code>, <code>projectors</code>, <code>startup</code>, <code>spin</code>, <code>exchange-correlation</code>, <code>convergence</code>, <code>mixer</code>, <code>dipolcorrection</code>)
** Non-collinear magnetism.
* <code>grids</code>
*'''{{TAG|MAGMOM}}'''
* <code>ionic</code> and <code>ionic md</code>
** Initial magnetic moments for each atom.
* <code>symmetry</code>
*'''{{TAG|NUPDOWN}}'''
* <code>dos</code>
** Net magnetic moment. ??????
* <code>writing</code>
*'''{{TAG|LSORBIT}}'''
* <code>performance</code>
** Spin-orbit coupling.
* <code>miscellaneous</code>
*'''{{TAG|SAXIS}}'''
* <code>orbital magnetization</code>
** Axis for spin quantization.
* <code>response functions</code> (GW/BSE calculations)
*'''{{TAG|LSPIRAL}}'''
* <code>vdW DFT</code>
** Spiral magnetism. ?????
 
*'''{{TAG|QSPIRAL}}'''
There are several other groups that we have not included here. The full documentation for each tag is found on its individual tag page.
** Q-vector for spiral magnetism. ?????
 
*'''{{TAG|LZEROZ}}'''
=== Atom info ===
** For zeroing magnetization in z-direction. ?????
 
*'''Electronic Exchange-Correlation'''
Contains the atomic species and per-ion type information.
** Parameters for exchange-correlation functional.
 
*'''{{TAG|LASPH}}'''
<syntaxhighlight lang="xml">
** Controls non-spherical contributions to the PAW potentials.
 
*'''Electronic Convergence'''
<atominfo>
** Parameters for convergence criteria.
  <atoms> 2 </atoms>              <!-- total number of ions -->
*'''{{TAG|NELM}}'''
  <types> 1 </types>              <!-- number of distinct species -->
** Maximum number of electronic self-consistency steps.
  <array name="atoms">            <!-- per-ion element label and type index -->
*'''{{TAG|NELMDL}}'''
    <dimension dim="1">ion</dimension>
** Number of non-self-consistent steps at the beginning.
    <field type="string">element</field>
*'''{{TAG|NELMIN}}'''
    <field type="int">atomtype</field>
** Minimum number of electronic steps.
    <set>
*'''{{TAG|ENINI}}'''
      <rc><c>Si </c><c>  1</c></rc>
** Initial energy cutoff for basis set in eV.
      <rc><c>Si </c><c>  1</c></rc>
*'''Electronic Convergence Detail'''
    </set>
** Detailed convergence parameters.
  </array>
*'''{{TAG|LDIAG}}'''
  <array name="atomtypes">        <!-- per-species data -->
** Controls diagonalization.
    <dimension dim="1">type</dimension>
*'''{{TAG|LSUBROT}}'''
    <field type="int">atomspertype</field>
** Controls subspace rotation.
    <field type="string">element</field>
*'''{{TAG|WEIMIN}}'''
    <field>mass</field>            <!-- atomic mass in u -->
** Minimum weight for bands.
    <field>valence</field>        <!-- number of valence electrons -->
*'''{{TAG|EBREAK}}'''
    <field type="string">pseudopotential</field>  <!-- PAW potential label -->
** Energy difference convergence criterion in conjugate gradient.
    <set>
*'''{{TAG|DEPER}}'''
      <rc><c>  2</c><c>Si </c><c>    28.08500000</c><c>      4.00000000</c><c>PAW_PBE Si 05Jan2001</c></rc>
** Damping parameter.
    </set>
*'''{{TAG|NRMM}}'''
  </array>
** Number of vectors kept in RMM-DIIS.
</atominfo>
*'''{{TAG|TIME}}'''
</syntaxhighlight>
** Maximum time for one SCF step.
 
*'''Electronic Mixer'''
=== Initial structure ===
** Parameters for charge density mixer.
 
*'''{{TAG|AMIX}}'''
The ionic positions at the start of the run, read from {{FILE|POSCAR}}. For [[:Category:Molecular Dynamics|molecular-dynamics]] runs, this block also contains the initial ionic velocities.
** Linear mixing parameter.
 
*'''{{TAG|BMIX}}'''
<syntaxhighlight lang="xml">
** Kerker mixing parameter.
<structure name="initialpos">
*'''{{TAG|AMIN}}'''
  <crystal>
** Minimum linear mixing parameter.
    <varray name="basis">            <!-- lattice vectors in A -->
*'''{{TAG|AMIX_MAG}}'''
      <v>  5.43  0.00  0.00 </v>
** Linear mixing parameter for magnetization density.
      <v>  0.00  5.43  0.00 </v>
*'''{{TAG|BMIX_MAG}}'''
      <v>  0.00  0.00  5.43 </v>
** Kerker mixing parameter for magnetization density.
    </varray>
*'''Electronic Mixer Details'''
    <i name="volume">  160.10 </i>  <!-- cell volume in A^3 -->
** Detailed mixer parameters.
    <varray name="rec_basis">
*'''{{TAG|IMIX}}'''
      <v>  0.184  0.000  0.000 </v>
** Mixing type.
      <v>  0.000  0.184  0.000 </v>
*'''{{TAG|MIXFIRST}}'''
      <v>  0.000  0.000  0.184 </v>
** Mixes charge density from first step.
    </varray>
*'''{{TAG|MAXMIX}}'''
  </crystal>
** Maximum number of steps for mixing.
  <varray name="positions">          <!-- fractional (direct) coordinates -->
*'''{{TAG|WC}}'''
    <v>  0.000  0.000  0.000 </v>
** Kerker screening parameter.
    <v>  0.250  0.250  0.250 </v>
*'''{{TAG|INIMIX}}'''
  </varray>
** Initial mixing type.
  <!-- MD only: -->
*'''{{TAG|MIXPRE}}'''
  <varray name="velocities">        <!-- ionic velocities in A/fs -->
** Type of preconditioning for mixing.
    <v>  0.0005 -0.0004  0.0002 </v>
*'''{{TAG|MREMOVE}}'''
    <v> -0.0009  0.0004  0.0005 </v>
** Number of old vectors removed from mixing history.
  </varray>
*'''Electronic Dipolcorrection'''
</structure>
** Parameters for dipole correction.
</syntaxhighlight>
*'''{{TAG|LDIPOL}}'''
 
** Dipole correction.
=== Ionic steps ===
*'''{{TAG|LMONO}}'''
 
** Monopole correction.
For runs with ionic motion ([[:Category:Ionic minimization|relaxations]], [[:Category:Molecular Dynamics|MD]], [[:Category:Transition states|NEB]]), each ionic step is written as a sequence of flat blocks directly under <code><modeling></code>. There is no enclosing <code><calculation></code> element; each step contains:
*'''{{TAG|IDIPOL}}'''
 
** Direction for dipole correction.
<syntaxhighlight lang="xml">
*'''{{TAG|EPSILON}}'''
<!-- ionic step i (repeated for each step) -->
** Dielectric constant for dipole correction.
<structure>
*'''{{TAG|DIPOL}}'''
  <crystal>
** Position of the dipole.
    <varray name="basis"> ... </varray>
*'''{{TAG|EFIELD}}'''
    <i name="volume"> ... </i>
** External electric field.
    <varray name="rec_basis"> ... </varray>
*'''{{TAG|LVACPOTAV}}'''
  </crystal>
** Writes averaged vacuum potential.
  <varray name="positions"> ... </varray>  <!-- fractional coordinates -->
*'''Grids'''
</structure>
** Parameters for real-space grids.
<varray name="forces">              <!-- Hellmann-Feynman forces in eV/A -->
*'''{{TAG|NGX}}'''
  <v>  0.12 -0.03  0.00 </v>
** Number of grid points in x-direction for charge density.
  ...
*'''{{TAG|NGY}}'''
</varray>
** Number of grid points in y-direction for charge density.
<varray name="stress">              <!-- stress tensor in kB -->
*'''{{TAG|NGZ}}'''
  <v> -0.16  0.00  0.11 </v>
** Number of grid points in z-direction for charge density.
  <v>  0.00  0.00  0.00 </v>
*'''{{TAG|NGXF}}'''
  <v>  0.11  0.00 -0.08 </v>
** Number of grid points in x-direction for wavefunctions.
</varray>
*'''{{TAG|NGYF}}'''
<energy>
** Number of grid points in y-direction for wavefunctions.
  <i name="e_fr_energy"> -53.93 </i>  <!-- free energy F = E - TS (eV) -->
*'''{{TAG|NGZF}}'''
  <i name="e_wo_entrp">  -53.93 </i>  <!-- energy without entropy (eV) -->
** Number of grid points in z-direction for wavefunctions.
  <i name="e_0_energy">  -53.93 </i>  <!-- energy extrapolated to sigma->0 (eV) -->
*'''{{TAG|ADDGRID}}'''
  <!-- MD only: -->
** Adds a finer grid for PAW.
  <i name="kinetic">      0.10 </i>  <!-- ionic kinetic energy (eV) -->
*'''Ionic'''
  <i name="lattice kinetic"> 0.00 </i> <!-- lattice kinetic energy, e.g. for NPT (eV) -->
** Parameters for ionic relaxation/molecular dynamics.
  <i name="total">      -53.83 </i>  <!-- total energy E + E_kin, conserved in NVE (eV) -->
*'''{{TAG|NSW}}'''
</energy>
** Maximum number of ionic steps.
<time name="totalsc"> 0.04 0.01 </time>  <!-- CPU and wall time for this step (s) -->
*'''{{TAG|IBRION}}'''
</syntaxhighlight>
** Ionic relaxation algorithm.
{{NB|mind|For {{TAG|IBRION}}{{=}}0 ([[:Category:Molecular Dynamics|MD]]) with a large number of steps ({{TAG|NSW}} >> 1), {{FILE|vasprun.xml}} can become very large. Consider using {{FILE|vaspout.h5}} instead, or reading with a streaming XML parser (see [[#Direct XML parsing|below]]).}}
*'''{{TAG|MDALGO}}'''
 
** Molecular dynamics algorithm. LINK TO MD CALCULATIONS????
=== Electronic-structure calculation block ===
*'''{{TAG|ISIF}}'''
 
** Controls what is relaxed.
For a [[Setting up an electronic minimization|single-point electronic minimization calculations]] ({{TAG|NSW|0}}) and [[:Category:Many-body perturbation theory|post-DFT methods]] (GW, BSE), a single <code><calculation></code> block instead of per-step ionic-step blocks is written. It contains eigenvalues, the density of states (DOS), the partial DOS ({{TAG|LORBIT}}) and, for optical calculations, the dielectric function ({{TAG|LOPTICS}}).
*'''{{TAG|PSTRESS}}'''
 
** External pressure in kB.
For [[GW calculations]] (e.g., {{TAG|ALGO}}{{=}}EVGW0 or GW0), <code><eigenvalues></code> contains the quasiparticle energies updated by the GW self-energy. Multiple <code><dielectricfunction></code> blocks appear in the same <code><calculation></code>, each labelled by its <code>comment</code> attribute.
*'''{{TAG|EDIFFG}}'''
 
** Convergence criterion for forces in eV/Å.
=== Final structure ===
*'''{{TAG|NFREE}}'''
 
** Number of degrees of freedom to relax.
The ionic positions at the end of the run. For [[MD runs]], this block also contains the final ionic velocities (also see {{TAG|VELOCITY}} for {{FILE|vaspout.h5}} output), suitable for restarting the trajectory.
*'''{{TAG|POTIM}}'''
 
** Time step for ionic relaxation or MD in fs.
<syntaxhighlight lang="xml">
*'''{{TAG|SMASS}}'''
<structure name="finalpos">
** Specifies the "mass" of the ions for damped MD.
  <crystal>
*'''{{TAG|SCALEE}}'''
    <varray name="basis"> ... </varray>
** Scales all calculated energies.
    <i name="volume"> ... </i>
*'''Ionic MD'''
    <varray name="rec_basis"> ... </varray>
** Parameters for molecular dynamics specifics.
  </crystal>
*'''{{TAG|TEBEG}}'''
  <varray name="positions"> ... </varray>
** Initial temperature for MD in K.
  <!-- MD only: -->
*'''{{TAG|TEEND}}'''
  <varray name="velocities"> ... </varray>
** Final temperature for MD in K.
</structure>
*'''{{TAG|NBLOCK}}'''
</syntaxhighlight>
** Writes output every NBLOCK steps.
 
*'''{{TAG|KBLOCK}}'''
== Reading vasprun.xml ==
** Controls specific output for MD.
=== pymatgen ===
*'''{{TAG|NPACO}}'''
 
** Number of plane waves for the augmentation charge.
The [https://pymatgen.org pymatgen] library provides the <code>Vasprun</code> class:
*'''{{TAG|APACO}}'''
 
** Controls the cutoff for augmentation charge.
<syntaxhighlight lang="python">
*'''Symmetry'''
from pymatgen.io.vasp import Vasprun
** Parameters for symmetry detection.
 
*'''{{TAG|ISYM}}'''
vr = Vasprun("vasprun.xml")
** Controls symmetry handling.
 
*'''{{TAG|SYMPREC}}'''
print(vr.final_energy)        # total energy of the final ionic step (eV)
** Precision for symmetry detection.
 
*'''DOS'''
# Iterate over ionic steps
** Parameters for Density of States (DOS) calculations.
for step in vr.ionic_steps:
*'''{{TAG|LORBIT}}'''
    e = step["electronic_steps"][-1]["e_fr_energy"]
** Controls local orbital projected DOS (0: no projected DOS).
    print(e)
*'''{{TAG|RWIGS}}'''
 
** Wigner-Seitz radii for DOS projection.
print(vr.final_structure)    # pymatgen Structure object
*'''{{TAG|NEDOS}}'''
dos = vr.complete_dos        # total and projected DOS
** Number of energy points for DOS.
</syntaxhighlight>
*'''{{TAG|EMIN}}'''
 
** Minimum energy for DOS.
=== ASE ===
*'''{{TAG|EMAX}}'''
 
** Maximum energy for DOS.
The [https://wiki.fysik.dtu.dk/ase/ Atomic Simulation Environment] (ASE) reads {{FILE|vasprun.xml}} as a sequence of <code>Atoms</code> objects:
*'''{{TAG|EFERMI}}'''
 
** Fermi energy.
<syntaxhighlight lang="python">
*'''Writing'''
from ase.io import read
** Parameters for writing output files.
 
*'''{{TAG|NWRITE}}'''
images = read("vasprun.xml", index=":")   # all ionic steps
** Controls verbosity of output.
atoms  = images[-1]                      # final structure
*'''{{TAG|LWAVE}}'''
 
** Writes WAVECAR file.
print(atoms.get_potential_energy())      # total energy (eV)
*'''{{TAG|LDOWNSAMPLE}}'''
print(atoms.get_forces())                # forces (eV/Å)
** Downsamples wave functions.
</syntaxhighlight>
*'''{{TAG|LCHARG}}'''
 
** Writes {{FILE|CHGCAR}} and {{FILE|CHG}} files.
=== Direct XML parsing ===
*'''{{TAG|LPARD}}'''
==== ElementTree ====
** Writes partial charge densities.
 
*'''{{TAG|LVTOT}}'''  
For custom workflows, parse {{FILE|vasprun.xml}} with Python's standard library:
** Writes total local potential.
 
*'''{{TAG|LVHAR}}'''
<syntaxhighlight lang="python">
** Writes Hartree potential.
import xml.etree.ElementTree as ET
*'''{{TAG|LELF}}'''  
 
** Writes Electron Localization Function (ELF).
tree = ET.parse("vasprun.xml")
*'''{{TAG|LOPTICS}}'''
root = tree.getroot()
** Calculates optical properties.
 
*'''{{TAG|STM}}'''
# Read INCAR tags
** Parameters for scanning tunneling microscopy.
for tag in root.find("incar"):
=== Performance ===
    print(tag.attrib.get("name"), "=", tag.text.strip())
Parameters for performance optimization.
 
*'''{{TAG|NPAR}}'''
# Read forces from each ionic step
** Number of bands or k-points grouped on a node.
for forces in root.iter("varray"):
*'''{{TAG|NSIM}}'''
    if forces.attrib.get("name") == "forces":
** Number of bands treated simultaneously.
        data = [[float(x) for x in v.text.split()] for v in forces]
*'''{{TAG|NBLK}}'''
        print(data)
** Block size for band diagonalization.
</syntaxhighlight>
*'''{{TAG|LPLANE}}'''
{{NB|mind|For large MD trajectories, use <code>xml.etree.ElementTree.iterparse</code> to stream the file element by element and avoid loading it entirely into memory.}}
** Parallelization over plane waves.
 
*'''{{TAG|LSCALAPACK}}'''
==== lxml ====
** Uses ScaLAPACK for diagonalization.
 
*'''{{TAG|LSCAAWARE}}'''
There are also plenty of other Python packages that can be used to read {{FILE|vasprun.xml}}, e.g., <code>lxml</code>:
** Enables ScaLAPACK-aware mode.
 
*'''{{TAG|LSCALU}}'''
<syntaxhighlight lang="python">
** Uses LU decomposition for ScaLAPACK.
from lxml import etree
*'''{{TAG|LASYNC}}'''
 
** Asynchronous communication.
# Parse XML
*'''{{TAG|LORBITALREAL}}'''
tree = etree.parse("vasprun.xml")
** Uses real orbitals.
root = tree.getroot()
=== Miscellaneous ===
 
Miscellaneous parameters.
# Read INCAR tags
*'''{{TAG|IDIOT}}'''
incar = root.find("incar")
** Controls some internal settings.
 
*'''{{TAG|PHON_NSTRUCT}}'''
for tag in incar:
** Number of structures for phonon calculations.
    name = tag.attrib.get("name")
*'''{{TAG|LMUSIC}}'''
    value = tag.text.strip() if tag.text else None
** Enables MUSIC code coupling.
    print(name, "=", value)
*'''{{TAG|POMASS}}'''
 
** Mass of the pseudo-ion for MD.
# Read the final energy
*'''{{TAG|DARWINR}}'''
energies = root.xpath(".//i[@name='e_0_energy']/text()")
** Related to Darwin-Foldy term.
final_energy = float(energies[-1])
*'''{{TAG|DARWINV}}'''
 
** Related to Darwin-Foldy term.
print(final_energy)
*'''{{TAG|LCORR}}'''
 
** Applies core correction.
# Read forces from each ionic step
*'''{{TAG|GGA_COMPAT}}'''
forces_blocks = root.xpath(".//varray[@name='forces']")
** Ensures compatibility for GGA functionals.
 
*'''{{TAG|LBERRY}}'''
for forces in forces_blocks:
** Enables Berry phase calculation.
    data = [
*'''{{TAG|ICORELEVEL}}'''
        [float(x) for x in v.text.split()]
** Controls core level spectroscopy.
        for v in forces
*'''{{TAG|LDAU}}'''
    ]
** Enables LDA+U correction.
    print(data)
*'''{{TAG|I_CONSTRAINED_M}}'''
</syntaxhighlight>
** Constrained magnetization calculation.
 
*'''Electronic Exchange-Correlation'''
There are plenty of other Python packages that can be used, or other languages if you prefer, which we will not describe here.
** Parameters for exchange-correlation functional.
 
*'''{{TAG|GGA}}'''
=== Terminal commands ===
** Functional used.
==== xmllint ====
*'''{{TAG|XC_C}}'''
The [https://xmllint.com/ xmllint] tool can be used to view the contents of the {{FILE|vasprun.xml}} file based from command line. E.g.,
** Specific correlation functional choice.
<syntaxhighlight lang="shell">
*'''{{TAG|VOSKOWN}}'''
xmllint --xpath '//dos/partial' vasprun.xml
** Voskown correlation.
</syntaxhighlight>
*'''{{TAG|LHFCALC}}'''
will print the partial density of states to terminal.  
** Enables Hartree-Fock calculations.
 
*'''{{TAG|PRECFOCK}}'''
==== xmlstarlet ====
** Precision for Fock exchange.
Alternatively, the [https://xmlstar.sourceforge.net/ xmlstarlet] tool can be used {{FILE|vasprun.xml}}, e.g.,
*'''{{TAG|LSYMGRAD}}'''
<syntaxhighlight lang="shell">
** Uses symmetric gradients in Fock exchange.
xmlstarlet sel -t -c '//dos/partial' vasprun.xml
*'''{{TAG|LHFONE}}'''
</syntaxhighlight>
** One-shot Hartree-Fock calculation.
will print the partial density of states to terminal.  
*'''{{TAG|LRHFCALC}}'''
 
** Performs real-space Hartree-Fock calculation.
There are several other command line tools that can be used for analysis, e.g., [https://pymatgen.org/#pmg-command-line-interface mpg] that we will not go into detail in here.
*'''{{TAG|LTHOMAS}}'''
 
** Includes Thomas-Fermi screening.
== Related tags and articles ==
*'''{{TAG|LMODELHF}}'''
 
** Uses a model Hartree-Fock.
* {{FILE|OUTCAR}} — the human-readable logfile.
*'''{{TAG|LFOCKACE}}'''
* {{FILE|vaspout.h5}} — the HDF5 alternative to {{FILE|vasprun.xml}}, preferred for large runs and newer features.
** Uses accelerated Fock exchange.
 
*'''{{TAG|ENCUT4O}}'''
[[Category:Files]]
** Energy cutoff for 4-center integrals in hybrid functionals.
[[Category:Output files]]
*'''{{TAG|EXXOEP}}'''
** Exact exchange for optimized effective potential.
*'''{{TAG|FOURORBIT}}'''
** Controls 4-orbital calculations.
*'''{{TAG|AEXX}}'''
** Mixing parameter for exact exchange.
*'''{{TAG|HFALPHA}}'''
** Mixing parameter for Hartree-Fock.
*'''{{TAG|MCALPHA}}'''
** Mixing parameter for Monte Carlo.
*'''{{TAG|ALDAX}}'''
** Mixing parameter for LDA exchange.
*'''{{TAG|AGGAX}}'''
** Mixing parameter for GGA exchange.
*'''{{TAG|AMGGAX}}'''
** Mixing parameter for meta-GGA exchange.
*'''{{TAG|ALDAC}}'''
** Mixing parameter for LDA correlation.
*'''{{TAG|AGGAC}}'''
** Mixing parameter for GGA correlation.
*'''{{TAG|AMGGAC}}'''
** Mixing parameter for meta-GGA correlation.
*'''{{TAG|NKREDX}}'''
** Reduction of k-points in x-direction for Fock exchange.
*'''{{TAG|NKREDY}}'''
** Reduction of k-points in y-direction for Fock exchange.
*'''{{TAG|NKREDZ}}'''
** Reduction of k-points in z-direction for Fock exchange.
*'''{{TAG|SHIFTRED}}'''
** Shifts the reduced k-mesh.
*'''{{TAG|ODDONLY}}'''
** Uses odd k-points only.
*'''{{TAG|EVENONLY}}'''
** Uses even k-points only.
*'''{{TAG|LMAXFOCK}}'''
** Maximum angular momentum for Fock exchange.
*'''{{TAG|NMAXFOCKAE}}'''
** Controls basis set for all-electron Fock exchange.
*'''{{TAG|LFOCKAEDFT}}'''
** Performs all-electron Fock exchange.
*'''{{TAG|HFSCREEN}}'''
** Screening parameter for hybrid functionals.
*'''{{TAG|HFSCREENC}}'''
** Screening parameter for correlation in hybrid functionals.
*'''{{TAG|NBANDSGWLOW}}'''
** Lower band index for GW calculations.
*'''VdW DFT'''
** Parameters for van der Waals (vdW) density functional theory.
*'''{{TAG|LUSE_VDW}}'''
** Enables vdW density functional.
*'''{{TAG|IVDW_NL}}'''
** Chooses specific non-local vdW functional.
*'''{{TAG|LSPIN_VDW}}'''
** Includes spin in vdW calculations.
*'''{{TAG|ZAB_VDW}}'''
** Parameter for vdW-DF.
*'''{{TAG|GAMMA_VDW}}'''
** Parameter for vdW-DF.
*'''{{TAG|ALPHA_VDW}}'''
** Parameter for vdW-DF.
*'''{{TAG|PARAM1}}'''
** General parameter for vdW calculations.
*'''{{TAG|PARAM2}}'''
** General parameter for vdW calculations.
*'''{{TAG|BPARAM}}'''
** Parameter for DFT-D3.
*'''{{TAG|CPARAM}}'''
** Parameter for DFT-D3.
=== '''Model GW''' ===
Parameters for model GW calculations.
*'''{{TAG|MODEL_GW}}'''
** Type of model GW calculation.
*'''{{TAG|MODEL_EPS0}}'''
** Static dielectric constant for model GW.
*'''{{TAG|MODEL_ALPHA}}'''
** Mixing parameter for model GW.
*'''Linear Response Parameters'''
** Parameters for linear response calculations.
*'''{{TAG|LEPSILON}}'''
** Calculates dielectric function.
*'''{{TAG|LRPA}}'''
** Uses RPA for response functions.
*'''{{TAG|LNABLA}}'''
** Calculates derivatives with respect to nabla.
*'''{{TAG|LVEL}}'''
** Calculates current-current response.
*'''{{TAG|CSHIFT}}'''
** Complex shift for dielectric function.
*'''{{TAG|OMEGAMAX}}'''
** Maximum frequency for response functions.
*'''{{TAG|DEG_THRESHOLD}}'''
** Threshold for degeneracy.
*'''{{TAG|RTIME}}'''
** Imaginary part of the frequency in real-time propagation.
*'''{{TAG|WPLASMAI}}'''
** Imaginary part of plasma frequency.
*'''{{TAG|DFIELD}}'''
** Applied displacement field.
*'''{{TAG|WPLASMA}}'''
** Plasma frequency parameters.
*'''Orbital Magnetization'''
** Parameters for orbital magnetization calculations.
*'''{{TAG|NUCIND}}'''
** Nuclear induced magnetic field.
*'''{{TAG|MAGPOS}}'''
** Position for local orbital magnetization.
*'''{{TAG|LNICSALL}}'''
** Calculates non-local orbital magnetization for all atoms.
*'''{{TAG|ORBITALMAG}}'''
** Calculates orbital magnetization.
*'''{{TAG|LMAGBLOCH}}'''
** Bloch-orbital magnetization.
*'''{{TAG|LCHIMAG}}'''
** Magnetic susceptibility.
*'''{{TAG|LGAUGE}}'''
** Applies a gauge transformation.
*'''{{TAG|MAGATOM}}'''
** Specifies atom for local orbital magnetization.
*'''{{TAG|MAGDIPOL}}'''
** Magnetic dipole moments.
*'''{{TAG|AVECCONST}}'''
** Constant vector potential.
*'''Response Functions'''
** Parameters for various response function calculations.
*'''{{TAG|LALL_IN_ONE}}'''
** Calculates all response functions in one run.
*'''{{TAG|IALL_IN_ONE}}'''
** Selects specific response functions.
*'''{{TAG|NBANDS_WAVE}}'''
** Number of bands for response function calculations.
*'''{{TAG|LFINITE_TEMPERATURE}}'''
** Finite temperature effects.
*'''{{TAG|LADDER}}'''
** Includes ladder diagrams.
*'''{{TAG|LRPAFORCE}}'''
** Calculates RPA forces.
*'''{{TAG|LFXC}}'''
** Includes beyond RPA exchange-correlation kernel.
*'''{{TAG|LHARTREE}}'''
** Includes Hartree term in response.
*'''{{TAG|IBSE}}'''
** Specifies the type of Bethe-Salpeter Equation (BSE) calculation.
*'''{{TAG|KPOINT}}'''
** Specific k-point for some response calculations.
*'''{{TAG|LTCTC}}'''
** Calculates current-current correlation function.
*'''{{TAG|LTCTE}}'''
** Calculates current-energy correlation function.
*'''{{TAG|LTETE}}'''
** Calculates energy-energy correlation function.
*'''{{TAG|LTRIPLET}}'''
** Includes triplet states in BSE.
*'''{{TAG|LFXCEPS}}'''
** Includes exchange-correlation effects in the dielectric function.
*'''{{TAG|LFXHEG}}'''
** Uses uniform electron gas approximation for exchange-correlation effects.
*'''{{TAG|NATURALO}}'''
** Controls natural orbital calculations.
*'''{{TAG|LHOLEGF}}'''
** Calculates hole Green's function.
*'''{{TAG|L2ORDER}}'''
** Performs second order calculations.
*'''{{TAG|LDMP1}}'''
** First damping parameter.
*'''{{TAG|LMP2LT}}'''
** Performs MP2 calculation for lattice dynamics.
*'''{{TAG|LSMP2LT}}'''
** Performs spin-polarized MP2 calculation for lattice dynamics.
*'''{{TAG|LGWLF}}'''
** Calculates GW quasiparticle lifetimes.
*'''{{TAG|ENCUTGW}}'''
** Energy cutoff for GW calculations.
*'''{{TAG|ENCUTGWSOFT}}'''
** Soft energy cutoff for GW calculations.
*'''{{TAG|ENCUTLF}}'''
** Energy cutoff for local field effects.
*'''{{TAG|ESF_SPLINES}}'''
** Uses splines for energy shift function.
*'''{{TAG|ESF_CONV}}'''
** Convergence for energy shift function.
*'''{{TAG|ESF_NINTER}}'''
** Number of interpolation points for energy shift function.
*'''{{TAG|LMAXM}}'''
** ADD DESCRIPTION

Latest revision as of 08:25, 17 June 2026

The vasprun.xml is written in xml format and contains both, general output that is written for any calculation and specific output depending on the method or quantity that is being computed. Below you see details regarding the general output, while the specific output, e.g. the dielectric function (LOPTICS), partial density of states (LORBIT), the electronic self-energy (LSELFENERGY) etc., are detailed on the corresponding tag documentation. Mind that newer features tend to write to vaspout.h5. The vaspout.h5 should generally be preferred for reading large datasets.

File format

The root element is <modeling>. The file uses four repeating XML primitives throughout:

  • value — a named scalar (real, integer, logical, or string).
  • <v name="...">x y z</v> — a named row vector.
  • <varray name="..."> — a named array of vectors, each on a <v> line.
  • <array> — a labelled multi-field table with named dimensions; rows are stored as <r> elements inside <set> blocks.

The overall layout of vasprun.xml is:

 <modeling>
   <generator>   ...  </generator>
   <incar>       ...  </incar>
   <primitive_cell> ... </primitive_cell>
   <kpoints>     ...  </kpoints>
   <parameters>  ...  </parameters>
   <atominfo>    ...  </atominfo>
   <structure name="initialpos"> ... </structure>
 
   <!-- one block per ionic step (MD, relaxation): -->
   <structure> ... </structure>
   <varray name="forces"> ... </varray>
   <varray name="stress"> ... </varray>
   <energy> ... </energy>
   <time name="totalsc"> ... </time>
   ...
 
   <!-- OR a single calculation block (single-point, GW, BSE): -->
   <calculation> ... </calculation>
 
   <structure name="finalpos"> ... </structure>
 </modeling>

Sections

Generator

Contains the VASP version, build details, and the date and time of the run.

 <generator>
   <i name="program"    type="string">vasp </i>
   <i name="version"    type="string">6.5.0  </i>
   <i name="subversion" type="string">29Jan2024 (build Feb 14 2024) complex parallel</i>
   <i name="platform"   type="string">LinuxGNU </i>
   <i name="date"       type="string">2024 01 01 </i>
   <i name="time"       type="string">12:00:00 </i>
 </generator>

INCAR

Contains only the tags explicitly set in the INCAR file, without defaults. This is a compact record of the user-specified settings for the run.

 <incar>
   <i type="string" name="SYSTEM">diamond Si</i>
   <i type="string" name="ALGO">Normal</i>
   <i name="ENCUT">    500.00000000</i>
   <i type="int" name="ISMEAR">     0</i>
   <i name="SIGMA">      0.05000000</i>
 </incar>

Primitive cell

Contains the structure and lattice of the primitive unit cell, along with the mapping of primitive-cell ion indices to the full simulation-cell ion indices.

 <primitive_cell>
   <structure name="primitive_cell">
     <crystal>
       <varray name="basis">            <!-- lattice vectors in A -->
         <v>  1.92  1.92  0.00 </v>
         <v>  0.00  1.92  1.92 </v>
         <v>  1.92  0.00  1.92 </v>
       </varray>
       <i name="volume">     28.35 </i>  <!-- volume in A^3 -->
       <varray name="rec_basis">        <!-- reciprocal lattice vectors in A^-1 -->
         <v>  0.26  0.26 -0.26 </v>
         <v> -0.26  0.26  0.26 </v>
         <v>  0.26 -0.26  0.26 </v>
       </varray>
     </crystal>
     <varray name="positions">          <!-- fractional (direct) coordinates -->
       <v> 0.00  0.00  0.00 </v>
       <v> 0.25  0.25  0.25 </v>
     </varray>
   </structure>
   <varray name="primitive_index">      <!-- index of each primitive ion in the full cell -->
     <v type="int"> 1 </v>
     <v type="int"> 2 </v>
   </varray>
 </primitive_cell>

k points

Specifies the k-point sampling of the Brillouin zone, mirroring the KPOINTS file.

 <kpoints>
   <generation param="Gamma">             <!-- generation scheme: Gamma, Monkhorst-Pack, or Explicit -->
     <v type="int" name="divisions"> 4 4 4 </v>
     <v name="usershift"> 0.0  0.0  0.0 </v>
     <v name="genvec1">   0.25 0.00 0.00 </v>
     <v name="genvec2">   0.00 0.25 0.00 </v>
     <v name="genvec3">   0.00 0.00 0.25 </v>
     <v name="shift">     0.00 0.00 0.00 </v>
   </generation>
   <varray name="kpointlist">             <!-- '''k'''-point coordinates in reciprocal space -->
     <v>  0.000  0.000  0.000 </v>
     <v>  0.250  0.000  0.000 </v>
     ...
   </varray>
   <varray name="weights">               <!-- integration weights, normalized to sum to 1 -->
     <v> 0.00463 </v>
     <v> 0.03704 </v>
     ...
   </varray>
 </kpoints>

Parameters

Contains a complete record of all effective INCAR parameters, including those not set explicitly (with their default values). The block is organized into named <separator> subsections corresponding to groups of related tags, for example:

  • general
  • electronic (with sub-separators: smearing, projectors, startup, spin, exchange-correlation, convergence, mixer, dipolcorrection)
  • grids
  • ionic and ionic md
  • symmetry
  • dos
  • writing
  • performance
  • miscellaneous
  • orbital magnetization
  • response functions (GW/BSE calculations)
  • vdW DFT

There are several other groups that we have not included here. The full documentation for each tag is found on its individual tag page.

Atom info

Contains the atomic species and per-ion type information.

 <atominfo>
   <atoms> 2 </atoms>               <!-- total number of ions -->
   <types> 1 </types>               <!-- number of distinct species -->
   <array name="atoms">             <!-- per-ion element label and type index -->
     <dimension dim="1">ion</dimension>
     <field type="string">element</field>
     <field type="int">atomtype</field>
     <set>
       <rc><c>Si </c><c>   1</c></rc>
       <rc><c>Si </c><c>   1</c></rc>
     </set>
   </array>
   <array name="atomtypes">         <!-- per-species data -->
     <dimension dim="1">type</dimension>
     <field type="int">atomspertype</field>
     <field type="string">element</field>
     <field>mass</field>            <!-- atomic mass in u -->
     <field>valence</field>         <!-- number of valence electrons -->
     <field type="string">pseudopotential</field>   <!-- PAW potential label -->
     <set>
       <rc><c>   2</c><c>Si </c><c>     28.08500000</c><c>      4.00000000</c><c>PAW_PBE Si 05Jan2001</c></rc>
     </set>
   </array>
 </atominfo>

Initial structure

The ionic positions at the start of the run, read from POSCAR. For molecular-dynamics runs, this block also contains the initial ionic velocities.

 <structure name="initialpos">
   <crystal>
     <varray name="basis">            <!-- lattice vectors in A -->
       <v>  5.43  0.00  0.00 </v>
       <v>  0.00  5.43  0.00 </v>
       <v>  0.00  0.00  5.43 </v>
     </varray>
     <i name="volume">   160.10 </i>  <!-- cell volume in A^3 -->
     <varray name="rec_basis">
       <v>  0.184  0.000  0.000 </v>
       <v>  0.000  0.184  0.000 </v>
       <v>  0.000  0.000  0.184 </v>
     </varray>
   </crystal>
   <varray name="positions">          <!-- fractional (direct) coordinates -->
     <v>  0.000  0.000  0.000 </v>
     <v>  0.250  0.250  0.250 </v>
   </varray>
   <!-- MD only: -->
   <varray name="velocities">         <!-- ionic velocities in A/fs -->
     <v>  0.0005 -0.0004  0.0002 </v>
     <v> -0.0009  0.0004  0.0005 </v>
   </varray>
 </structure>

Ionic steps

For runs with ionic motion (relaxations, MD, NEB), each ionic step is written as a sequence of flat blocks directly under <modeling>. There is no enclosing <calculation> element; each step contains:

 <!-- ionic step i (repeated for each step) -->
 <structure>
   <crystal>
     <varray name="basis"> ... </varray>
     <i name="volume"> ... </i>
     <varray name="rec_basis"> ... </varray>
   </crystal>
   <varray name="positions"> ... </varray>   <!-- fractional coordinates -->
 </structure>
 <varray name="forces">               <!-- Hellmann-Feynman forces in eV/A -->
   <v>  0.12 -0.03  0.00 </v>
   ...
 </varray>
 <varray name="stress">               <!-- stress tensor in kB -->
   <v> -0.16  0.00  0.11 </v>
   <v>  0.00  0.00  0.00 </v>
   <v>  0.11  0.00 -0.08 </v>
 </varray>
 <energy>
   <i name="e_fr_energy"> -53.93 </i>  <!-- free energy F = E - TS (eV) -->
   <i name="e_wo_entrp">  -53.93 </i>  <!-- energy without entropy (eV) -->
   <i name="e_0_energy">  -53.93 </i>  <!-- energy extrapolated to sigma->0 (eV) -->
   <!-- MD only: -->
   <i name="kinetic">       0.10 </i>  <!-- ionic kinetic energy (eV) -->
   <i name="lattice kinetic"> 0.00 </i> <!-- lattice kinetic energy, e.g. for NPT (eV) -->
   <i name="total">       -53.83 </i>  <!-- total energy E + E_kin, conserved in NVE (eV) -->
 </energy>
 <time name="totalsc"> 0.04 0.01 </time>   <!-- CPU and wall time for this step (s) -->

Electronic-structure calculation block

For a single-point electronic minimization calculations (NSW = 0) and post-DFT methods (GW, BSE), a single <calculation> block instead of per-step ionic-step blocks is written. It contains eigenvalues, the density of states (DOS), the partial DOS (LORBIT) and, for optical calculations, the dielectric function (LOPTICS).

For GW calculations (e.g., ALGO=EVGW0 or GW0), <eigenvalues> contains the quasiparticle energies updated by the GW self-energy. Multiple <dielectricfunction> blocks appear in the same <calculation>, each labelled by its comment attribute.

Final structure

The ionic positions at the end of the run. For MD runs, this block also contains the final ionic velocities (also see VELOCITY for vaspout.h5 output), suitable for restarting the trajectory.

 <structure name="finalpos">
   <crystal>
     <varray name="basis"> ... </varray>
     <i name="volume"> ... </i>
     <varray name="rec_basis"> ... </varray>
   </crystal>
   <varray name="positions"> ... </varray>
   <!-- MD only: -->
   <varray name="velocities"> ... </varray>
 </structure>

Reading vasprun.xml

pymatgen

The pymatgen library provides the Vasprun class:

from pymatgen.io.vasp import Vasprun

vr = Vasprun("vasprun.xml")

print(vr.final_energy)        # total energy of the final ionic step (eV)

# Iterate over ionic steps
for step in vr.ionic_steps:
    e = step["electronic_steps"][-1]["e_fr_energy"]
    print(e)

print(vr.final_structure)     # pymatgen Structure object
dos = vr.complete_dos         # total and projected DOS

ASE

The Atomic Simulation Environment (ASE) reads vasprun.xml as a sequence of Atoms objects:

from ase.io import read

images = read("vasprun.xml", index=":")   # all ionic steps
atoms  = images[-1]                       # final structure

print(atoms.get_potential_energy())       # total energy (eV)
print(atoms.get_forces())                 # forces (eV/Å)

Direct XML parsing

ElementTree

For custom workflows, parse vasprun.xml with Python's standard library:

import xml.etree.ElementTree as ET

tree = ET.parse("vasprun.xml")
root = tree.getroot()

# Read INCAR tags
for tag in root.find("incar"):
    print(tag.attrib.get("name"), "=", tag.text.strip())

# Read forces from each ionic step
for forces in root.iter("varray"):
    if forces.attrib.get("name") == "forces":
        data = [[float(x) for x in v.text.split()] for v in forces]
        print(data)

lxml

There are also plenty of other Python packages that can be used to read vasprun.xml, e.g., lxml:

from lxml import etree

# Parse XML
tree = etree.parse("vasprun.xml")
root = tree.getroot()

# Read INCAR tags
incar = root.find("incar")

for tag in incar:
    name = tag.attrib.get("name")
    value = tag.text.strip() if tag.text else None
    print(name, "=", value)

# Read the final energy
energies = root.xpath(".//i[@name='e_0_energy']/text()")
final_energy = float(energies[-1])

print(final_energy)

# Read forces from each ionic step
forces_blocks = root.xpath(".//varray[@name='forces']")

for forces in forces_blocks:
    data = [
        [float(x) for x in v.text.split()]
        for v in forces
    ]
    print(data)

There are plenty of other Python packages that can be used, or other languages if you prefer, which we will not describe here.

Terminal commands

xmllint

The xmllint tool can be used to view the contents of the vasprun.xml file based from command line. E.g.,

 xmllint --xpath '//dos/partial' vasprun.xml

will print the partial density of states to terminal.

xmlstarlet

Alternatively, the xmlstarlet tool can be used vasprun.xml, e.g.,

 xmlstarlet sel -t -c '//dos/partial' vasprun.xml

will print the partial density of states to terminal.

There are several other command line tools that can be used for analysis, e.g., mpg that we will not go into detail in here.

Related tags and articles

  • OUTCAR — the human-readable logfile.
  • vaspout.h5 — the HDF5 alternative to vasprun.xml, preferred for large runs and newer features.