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)
Csheldon (talk | contribs)
Comprehensive rewrite: add ionic steps, calculation block (GW/BSE), reading section (py4vasp, pymatgen, ASE, XML); condense parameters section
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:
The {{FILE|vasprun.xml}} file is VASP's machine-readable XML output file. It records the complete set of input parameters, the crystal structure, and all computed quantities for every ionic step of the calculation.


== Contents of file ==
In addition to {{FILE|OUTCAR}}, {{FILE|vasprun.xml}} is written automatically for every VASP run. All physical output that appears in {{FILE|OUTCAR}} is also present here, but in a structured, hierarchical XML form that is straightforward to process programmatically. For large calculations, the HDF5 alternative {{FILE|vaspout.h5}} is preferred.
The structure of {{FILE|vasprun.xml}} has the following main hierarchy:


# generator
== File format ==
# incar
# primitive cell
# kpoints
# parameters
# atom info
# structure
# calculation


Each section will be shown, with links to the relevant pages in the Wiki.
The root element is <code><modeling></code>. The file uses four repeating XML primitives throughout:


== Generator ==
* <code><i name="..." type="...">value</i></code> — a named scalar (real, integer, logical, or string).
Contains all the information about the calculation run.
* <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.


* '''program'''
The overall layout of {{FILE|vasprun.xml}} is:
** VASP
* '''version'''
** VASP version
* '''subversion'''
** Subversion and build details, including compilation details.
* '''platform'''
** Operating system and compiler used.
* '''date'''
** Date the calculation was performed (YYYY MM DD)
* '''time'''
** Time the calculation was performed (HH:MM:SS)


== Incar ==
<modeling>
Input parameters read from the {{FILE|INCAR}} file.
  <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>


* '''SYSTEM'''
== Sections ==
** 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 ==
=== Generator ===
* '''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 ==
Contains the VASP version, build details, and the date and time of the run.
Specifies the Bloch vectors (k points) used in the {{FILE|KPOINTS}} file to sample the Brillouin zone.


*'''Generation'''
<generator>
** Method used for k-point generation: e.g., Monkhorst-Pack.
  <i name="program"    type="string">vasp </i>
*'''Divisions'''
  <i name="version"    type="string">6.5.0  </i>
** Divisions along each reciprocal lattice vector for the Monkhorst-Pack mesh.
  <i name="subversion" type="string">29Jan2024 (build Feb 14 2024) complex parallel</i>
*'''Usershift'''
  <i name="platform"  type="string">LinuxGNU </i>
** User-defined shift for the k-point mesh.
  <i name="date"      type="string">2024 01 01 </i>
*'''Genvec1'''
  <i name="time"      type="string">12:00:00 </i>
** First generator vector for the k-points.
</generator>
*'''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 ==
=== INCAR ===
Parameters used for running the calculation.


=== General ===
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.
General calculation parameters.
*'''SYSTEM'''
**System name.
*'''{{TAG|LCOMPAT}}'''
** Compatibility flag for older versions. ?????
=== Electronic ===
Electronic structure calculation parameters.
*'''{{TAG|PREC}}'''
** Precision setting for calculations (normal).
*'''{{TAG|ENMAX}}'''
** Maximum energy cutoff for plane waves in eV.
*'''{{TAG|ENAUG}}'''
** Augmentation charge cutoff in eV.
*'''{{TAG|EDIFF}}'''
** Convergence criterion for electronic self-consistency loop in eV.
*'''{{TAG|IALGO}}'''
** Algorithm for electronic minimization.
*'''{{TAG|IWAVPR}}'''
** Controls when wavefunctions are written to WAVECAR.
*'''{{TAG|NBANDS}}'''
** Number of bands to be calculated.
*'''{{TAG|NBANDSLOW}}'''
** Lower bound for bands considered in certain calculations. ?????
*'''{{TAG|NBANDSHIGH}}'''
** Upper bound for bands considered in certain calculations. ?????
*'''{{TAG|NELECT}}'''
** Total number of electrons in the system.
*'''{{TAG|TURBO}}'''
** Controls turbo molecular dynamics.
*'''{{TAG|IRESTART}}'''
** Controls restarts.
*'''{{TAG|NREBOOT}}'''
** Controls how many times the calculation restarts. ?????
*'''{{TAG|NMIN}}'''
** Minimum number of electronic steps.
*'''{{TAG|EREF}}'''
** Reference energy for some calculations. ?????
=== Electronic Smearing ===
Parameters related to electronic smearing.
*'''{{TAG|ISMEAR}}'''
** Smearing method.
*'''{{TAG|SIGMA}}'''
** Smearing width in eV.
*'''{{TAG|KSPACING}}'''
** K-point spacing for automatically generated KPOINTS.
*'''{{TAG|KGAMMA}}'''
** Enforces Gamma-centered k-point mesh. ?????
*'''{{TAG|KBLOWUP}}'''
** Controls blow-up of k-point mesh. ?????
=== Electronic Projectos' ===
Parameters for projectors in PAW method.
*'''{{TAG|LREAL}}'''
** Controls projection operators in real space.
*'''{{TAG|ROPT}}'''
** Controls real-space grid for projections. ?????
*'''{{TAG|LMAXPAW}}'''
** Maximum angular momentum for PAW projectors. ?????
*'''{{TAG|LMAXMIX}}'''
** Maximum angular momentum for charge density mixing. ?????
*'''{{TAG|NLSPLINE}}'''
** Controls non-local spline interpolation. ?????
=== Electronic Startup ===
Parameters for initializing the electronic calculation.
*'''{{TAG|ISTART}}'''
** Controls how the wave functions are initialized.
*'''{{TAG|ICHARG}}'''
** Controls how the charge density is initialized.
*'''{{TAG|INIWAV}}'''
** Controls how initial wavefunctions are generated. ?????
=== Electronic Spin ===
Parameters for spin polarization.
*'''{{TAG|ISPIN}}'''
** Spin polarization.
*'''{{TAG|LNONCOLLINEAR}}'''
** Non-collinear magnetism.
*'''{{TAG|MAGMOM}}'''
** Initial magnetic moments for each atom.
*'''{{TAG|NUPDOWN}}'''
** Net magnetic moment. ??????
*'''{{TAG|LSORBIT}}'''
** Spin-orbit coupling.
*'''{{TAG|SAXIS}}'''
** Axis for spin quantization.
*'''{{TAG|LSPIRAL}}'''
** Spiral magnetism. ?????
*'''{{TAG|QSPIRAL}}'''
** Q-vector for spiral magnetism. ?????
*'''{{TAG|LZEROZ}}'''
** For zeroing magnetization in z-direction. ?????
=== Electronic Exchange-Correlation ===
Parameters for exchange-correlation functional.
*'''{{TAG|LASPH}}'''
** Controls non-spherical contributions to the PAW potentials.
=== Electronic Convergence ===
Parameters for convergence criteria.
*'''{{TAG|NELM}}'''
** Maximum number of electronic self-consistency steps.
*'''{{TAG|NELMDL}}'''
** Number of non-self-consistent steps at the beginning.
*'''{{TAG|NELMIN}}'''
** Minimum number of electronic steps.
*'''{{TAG|ENINI}}'''
** Initial energy cutoff for basis set in eV.
=== Electronic Convergence Detail ===
Detailed convergence parameters.
*'''{{TAG|LDIAG}}'''
** Controls diagonalization.
*'''{{TAG|LSUBROT}}'''
** Controls subspace rotation.
*'''{{TAG|WEIMIN}}'''
** Minimum weight for bands.
*'''{{TAG|EBREAK}}'''
** Energy difference convergence criterion in conjugate gradient.
*'''{{TAG|DEPER}}'''
** Damping parameter.
*'''{{TAG|NRMM}}'''
** Number of vectors kept in RMM-DIIS.
*'''{{TAG|TIME}}'''
** Maximum time for one SCF step.
=== Electronic Mixer ===
Parameters for charge density mixer.
*'''{{TAG|AMIX}}'''
** Linear mixing parameter.
*'''{{TAG|BMIX}}'''
** Kerker mixing parameter.
*'''{{TAG|AMIN}}'''
** Minimum linear mixing parameter.
*'''{{TAG|AMIX_MAG}}'''
** Linear mixing parameter for magnetization density.
*'''{{TAG|BMIX_MAG}}'''
** Kerker mixing parameter for magnetization density.
*'''Electronic Mixer Details'''
** Detailed mixer parameters.
*'''{{TAG|IMIX}}'''
** Mixing type.
*'''{{TAG|MIXFIRST}}'''
** Mixes charge density from first step.
*'''{{TAG|MAXMIX}}'''
** Maximum number of steps for mixing.
*'''{{TAG|WC}}'''
** Kerker screening parameter.
*'''{{TAG|INIMIX}}'''
** Initial mixing type.
*'''{{TAG|MIXPRE}}'''
** Type of preconditioning for mixing.
*'''{{TAG|MREMOVE}}'''
** Number of old vectors removed from mixing history.
=== Electronic Dipolcorrection ===
Parameters for dipole correction.
*'''{{TAG|LDIPOL}}'''
** Dipole correction.
*'''{{TAG|LMONO}}'''
** Monopole correction.
*'''{{TAG|IDIPOL}}'''
** Direction for dipole correction.
*'''{{TAG|EPSILON}}'''
** Dielectric constant for dipole correction.
*'''{{TAG|DIPOL}}'''
** Position of the dipole.
*'''{{TAG|EFIELD}}'''
** External electric field.
*'''{{TAG|LVACPOTAV}}'''
** Writes averaged vacuum potential.
=== Grids ===
Parameters for real-space grids.
*'''{{TAG|NGX}}'''
** Number of grid points in x-direction for charge density.
*'''{{TAG|NGY}}'''
** Number of grid points in y-direction for charge density.
*'''{{TAG|NGZ}}'''
** Number of grid points in z-direction for charge density.
*'''{{TAG|NGXF}}'''
** Number of grid points in x-direction for wavefunctions.
*'''{{TAG|NGYF}}'''
** Number of grid points in y-direction for wavefunctions.
*'''{{TAG|NGZF}}'''
** Number of grid points in z-direction for wavefunctions.
*'''{{TAG|ADDGRID}}'''
** Adds a finer grid for PAW.
=== Ionic ===
Parameters for ionic relaxation/molecular dynamics.
*'''{{TAG|NSW}}'''
** Maximum number of ionic steps.
*'''{{TAG|IBRION}}'''
** Ionic relaxation algorithm.
*'''{{TAG|MDALGO}}'''
** Molecular dynamics algorithm. LINK TO MD CALCULATIONS????
*'''{{TAG|ISIF}}'''
** Controls what is relaxed.
*'''{{TAG|PSTRESS}}'''
** External pressure in kB.
*'''{{TAG|EDIFFG}}'''
** Convergence criterion for forces in eV/Å.
*'''{{TAG|NFREE}}'''
** Number of degrees of freedom to relax.
*'''{{TAG|POTIM}}'''
** Time step for ionic relaxation or MD in fs.
*'''{{TAG|SMASS}}'''
** Specifies the "mass" of the ions for damped MD.
*'''{{TAG|SCALEE}}'''
** Scales all calculated energies.
=== Ionic MD ===
Parameters for molecular dynamics specifics.
*'''{{TAG|TEBEG}}'''
** Initial temperature for MD in K.
*'''{{TAG|TEEND}}'''
** Final temperature for MD in K.
*'''{{TAG|NBLOCK}}'''
** Writes output every NBLOCK steps.
*'''{{TAG|KBLOCK}}'''
** Controls specific output for MD.
*'''{{TAG|NPACO}}'''
** Number of plane waves for the augmentation charge.
*'''{{TAG|APACO}}'''
** Controls the cutoff for augmentation charge.
*'''Symmetry'''
** Parameters for symmetry detection.
*'''{{TAG|ISYM}}'''
** Controls symmetry handling.
*'''{{TAG|SYMPREC}}'''
** Precision for symmetry detection.
=== DOS ===
Parameters for Density of States (DOS) calculations.
*'''{{TAG|LORBIT}}'''
** Controls local orbital projected DOS (0: no projected DOS).
*'''{{TAG|RWIGS}}'''
** Wigner-Seitz radii for DOS projection.
*'''{{TAG|NEDOS}}'''
** Number of energy points for DOS.
*'''{{TAG|EMIN}}'''
** Minimum energy for DOS.
*'''{{TAG|EMAX}}'''
** Maximum energy for DOS.
*'''{{TAG|EFERMI}}'''
** Fermi energy.
=== Writing ===
Parameters for writing output files.
*'''{{TAG|NWRITE}}'''
** Controls verbosity of output.
*'''{{TAG|LWAVE}}'''
** Writes WAVECAR file.
*'''{{TAG|LDOWNSAMPLE}}'''
** Downsamples wave functions.
*'''{{TAG|LCHARG}}'''
** Writes {{FILE|CHGCAR}} and {{FILE|CHG}} files.
*'''{{TAG|LPARD}}'''
** Writes partial charge densities.
*'''{{TAG|LVTOT}}'''
** Writes total local potential.
*'''{{TAG|LVHAR}}'''
** Writes Hartree potential.
*'''{{TAG|LELF}}'''
** Writes Electron Localization Function (ELF).
*'''{{TAG|LOPTICS}}'''
** Calculates optical properties.
*'''{{TAG|STM}}'''
** Parameters for scanning tunneling microscopy.


=== Performance ===
<incar>
Parameters for performance optimization.
  <i type="string" name="SYSTEM">diamond Si</i>
*'''{{TAG|NPAR}}'''
  <i type="string" name="ALGO">Normal</i>
** Number of bands or k-points grouped on a node.
  <i name="ENCUT">    500.00000000</i>
*'''{{TAG|NSIM}}'''
  <i type="int" name="ISMEAR">    0</i>
** Number of bands treated simultaneously.
  <i name="SIGMA">      0.05000000</i>
*'''{{TAG|NBLK}}'''
</incar>
** Block size for band diagonalization.
 
*'''{{TAG|LPLANE}}'''
=== Primitive cell ===
** Parallelization over plane waves.
 
*'''{{TAG|LSCALAPACK}}'''
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.
** Uses ScaLAPACK for diagonalization.
 
*'''{{TAG|LSCAAWARE}}'''
<primitive_cell>
** Enables ScaLAPACK-aware mode.
  <structure name="primitive_cell">
*'''{{TAG|LSCALU}}'''
    <crystal>
** Uses LU decomposition for ScaLAPACK.
      <varray name="basis">            <!-- lattice vectors in A -->
*'''{{TAG|LASYNC}}'''
        <v>  1.92  1.92  0.00 </v>
** Asynchronous communication.
        <v>  0.00  1.92  1.92 </v>
*'''{{TAG|LORBITALREAL}}'''
        <v>  1.92  0.00  1.92 </v>
** Uses real orbitals.
      </varray>
=== Miscellaneous ===
      <i name="volume">    28.35 </i>  <!-- volume in A^3 -->
Miscellaneous parameters.
      <varray name="rec_basis">        <!-- reciprocal lattice vectors in A^-1 -->
*'''{{TAG|IDIOT}}'''
        <v>  0.26  0.26 -0.26 </v>
** Controls some internal settings.
        <v> -0.26  0.26  0.26 </v>
*'''{{TAG|PHON_NSTRUCT}}'''
        <v>  0.26 -0.26  0.26 </v>
** Number of structures for phonon calculations.
      </varray>
*'''{{TAG|LMUSIC}}'''
    </crystal>
** Enables MUSIC code coupling.
    <varray name="positions">          <!-- fractional (direct) coordinates -->
*'''{{TAG|POMASS}}'''  
      <v> 0.00  0.00  0.00 </v>
** Mass of the pseudo-ion for MD.
      <v> 0.25  0.25  0.25 </v>
*'''{{TAG|DARWINR}}'''
    </varray>
** Related to Darwin-Foldy term.
  </structure>
*'''{{TAG|DARWINV}}'''
  <varray name="primitive_index">      <!-- index of each primitive ion in the full cell -->
** Related to Darwin-Foldy term.
    <v type="int"> 1 </v>
*'''{{TAG|LCORR}}'''
    <v type="int"> 2 </v>
** Applies core correction.
  </varray>
*'''{{TAG|GGA_COMPAT}}'''
</primitive_cell>
** Ensures compatibility for GGA functionals.
 
*'''{{TAG|LBERRY}}'''
=== k points ===
** Enables Berry phase calculation.
 
*'''{{TAG|ICORELEVEL}}'''
Specifies the '''k'''-point sampling of the Brillouin zone, mirroring the {{FILE|KPOINTS}} file.
** Controls core level spectroscopy.
 
*'''{{TAG|LDAU}}'''
<kpoints>
** Enables LDA+U correction.
  <generation param="Gamma">            <!-- generation scheme: Gamma, Monkhorst-Pack, or Explicit -->
*'''{{TAG|I_CONSTRAINED_M}}'''
    <v type="int" name="divisions"> 4 4 4 </v>
** Constrained magnetization calculation.
    <v name="usershift"> 0.0  0.0  0.0 </v>
*'''Electronic Exchange-Correlation'''
    <v name="genvec1">  0.25 0.00 0.00 </v>
** Parameters for exchange-correlation functional.
    <v name="genvec2">  0.00 0.25 0.00 </v>
*'''{{TAG|GGA}}'''
    <v name="genvec3">  0.00 0.00 0.25 </v>
** Functional used.
    <v name="shift">    0.00 0.00 0.00 </v>
*'''{{TAG|XC_C}}'''
  </generation>
** Specific correlation functional choice.
  <varray name="kpointlist">            <!-- '''k'''-point coordinates in reciprocal space -->
*'''{{TAG|VOSKOWN}}'''
    <v>  0.000  0.000  0.000 </v>
** Voskown correlation.
    <v>  0.250  0.000  0.000 </v>
*'''{{TAG|LHFCALC}}'''
    ...
** Enables Hartree-Fock calculations.
  </varray>
*'''{{TAG|PRECFOCK}}'''
  <varray name="weights">              <!-- integration weights, normalized to sum to 1 -->
** Precision for Fock exchange.
    <v> 0.00463 </v>
*'''{{TAG|LSYMGRAD}}'''
    <v> 0.03704 </v>
** Uses symmetric gradients in Fock exchange.
    ...
*'''{{TAG|LHFONE}}'''
  </varray>
** One-shot Hartree-Fock calculation.
</kpoints>
*'''{{TAG|LRHFCALC}}'''
 
** Performs real-space Hartree-Fock calculation.
=== Parameters ===
*'''{{TAG|LTHOMAS}}'''
 
** Includes Thomas-Fermi screening.
Contains a complete record of all effective 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|LMODELHF}}'''
 
** Uses a model Hartree-Fock.
* <code>general</code>
*'''{{TAG|LFOCKACE}}'''
* <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>)
** Uses accelerated Fock exchange.
* <code>grids</code>
*'''{{TAG|ENCUT4O}}'''
* <code>ionic</code> and <code>ionic md</code>
** Energy cutoff for 4-center integrals in hybrid functionals.
* <code>symmetry</code>
*'''{{TAG|EXXOEP}}'''
* <code>dos</code>
** Exact exchange for optimized effective potential.
* <code>writing</code>
*'''{{TAG|FOURORBIT}}'''
* <code>performance</code>
** Controls 4-orbital calculations.
* <code>response functions</code> (GW/BSE calculations)
*'''{{TAG|AEXX}}'''
* <code>vdW DFT</code>
** Mixing parameter for exact exchange.
 
*'''{{TAG|HFALPHA}}'''
The full documentation for each tag is found on its individual tag page.
** Mixing parameter for Hartree-Fock.
 
*'''{{TAG|MCALPHA}}'''
=== Atom info ===
** Mixing parameter for Monte Carlo.
 
*'''{{TAG|ALDAX}}'''
Contains the atomic species and per-ion type information.
** Mixing parameter for LDA exchange.
 
*'''{{TAG|AGGAX}}'''
<atominfo>
** Mixing parameter for GGA exchange.
  <atoms> 2 </atoms>              <!-- total number of ions -->
*'''{{TAG|AMGGAX}}'''
  <types> 1 </types>              <!-- number of distinct species -->
** Mixing parameter for meta-GGA exchange.
  <array name="atoms">            <!-- per-ion element label and type index -->
*'''{{TAG|ALDAC}}'''
    <dimension dim="1">ion</dimension>
** Mixing parameter for LDA correlation.
    <field type="string">element</field>
*'''{{TAG|AGGAC}}'''
    <field type="int">atomtype</field>
** Mixing parameter for GGA correlation.
    <set>
*'''{{TAG|AMGGAC}}'''
      <rc><c>Si </c><c>  1</c></rc>
** Mixing parameter for meta-GGA correlation.
      <rc><c>Si </c><c>  1</c></rc>
*'''{{TAG|NKREDX}}'''
    </set>
** Reduction of k-points in x-direction for Fock exchange.
  </array>
*'''{{TAG|NKREDY}}'''
  <array name="atomtypes">        <!-- per-species data -->
** Reduction of k-points in y-direction for Fock exchange.
    <dimension dim="1">type</dimension>
*'''{{TAG|NKREDZ}}'''
    <field type="int">atomspertype</field>
** Reduction of k-points in z-direction for Fock exchange.
    <field type="string">element</field>
*'''{{TAG|SHIFTRED}}'''
    <field>mass</field>            <!-- atomic mass in u -->
** Shifts the reduced k-mesh.
    <field>valence</field>        <!-- number of valence electrons -->
*'''{{TAG|ODDONLY}}'''
    <field type="string">pseudopotential</field>  <!-- PAW potential label -->
** Uses odd k-points only.
    <set>
*'''{{TAG|EVENONLY}}'''
      <rc><c>  2</c><c>Si </c><c>    28.08500000</c><c>      4.00000000</c><c>PAW_PBE Si 05Jan2001</c></rc>
** Uses even k-points only.
    </set>
*'''{{TAG|LMAXFOCK}}'''
  </array>
** Maximum angular momentum for Fock exchange.
</atominfo>
*'''{{TAG|NMAXFOCKAE}}'''
 
** Controls basis set for all-electron Fock exchange.
=== Initial structure ===
*'''{{TAG|LFOCKAEDFT}}'''
 
** Performs all-electron Fock exchange.
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.
*'''{{TAG|HFSCREEN}}'''
 
** Screening parameter for hybrid functionals.
<structure name="initialpos">
*'''{{TAG|HFSCREENC}}'''
  <crystal>
** Screening parameter for correlation in hybrid functionals.
    <varray name="basis">            <!-- lattice vectors in A -->
*'''{{TAG|NBANDSGWLOW}}'''
      <v>  5.43  0.00  0.00 </v>
** Lower band index for GW calculations.
      <v>  0.00  5.43  0.00 </v>
*'''VdW DFT'''
      <v>  0.00  0.00  5.43 </v>
** Parameters for van der Waals (vdW) density functional theory.
    </varray>
*'''{{TAG|LUSE_VDW}}'''
    <i name="volume">  160.10 </i>  <!-- cell volume in A^3 -->
** Enables vdW density functional.
    <varray name="rec_basis">
*'''{{TAG|IVDW_NL}}'''
      <v>  0.184  0.000  0.000 </v>
** Chooses specific non-local vdW functional.
      <v>  0.000  0.184  0.000 </v>
*'''{{TAG|LSPIN_VDW}}'''
      <v>  0.000  0.000  0.184 </v>
** Includes spin in vdW calculations.
    </varray>
*'''{{TAG|ZAB_VDW}}'''
  </crystal>
** Parameter for vdW-DF.
  <varray name="positions">          <!-- fractional (direct) coordinates -->
*'''{{TAG|GAMMA_VDW}}'''
    <v>  0.000  0.000  0.000 </v>
** Parameter for vdW-DF.
    <v>  0.250  0.250  0.250 </v>
*'''{{TAG|ALPHA_VDW}}'''
  </varray>
** Parameter for vdW-DF.
  <!-- MD only: -->
*'''{{TAG|PARAM1}}'''
  <varray name="velocities">        <!-- ionic velocities in A/fs -->
** General parameter for vdW calculations.
    <v>  0.0005 -0.0004  0.0002 </v>
*'''{{TAG|PARAM2}}'''
    <v> -0.0009  0.0004  0.0005 </v>
** General parameter for vdW calculations.
  </varray>
*'''{{TAG|BPARAM}}'''
</structure>
** Parameter for DFT-D3.
 
*'''{{TAG|CPARAM}}'''
=== Ionic steps ===
** Parameter for DFT-D3.
 
=== '''Model GW''' ===
For runs with ionic motion (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:
Parameters for model GW calculations.
 
*'''{{TAG|MODEL_GW}}'''
<!-- ionic step i (repeated for each step) -->
** Type of model GW calculation.
<structure>
*'''{{TAG|MODEL_EPS0}}'''
  <crystal>
** Static dielectric constant for model GW.
    <varray name="basis"> ... </varray>
*'''{{TAG|MODEL_ALPHA}}'''
    <i name="volume"> ... </i>
** Mixing parameter for model GW.
    <varray name="rec_basis"> ... </varray>
*'''Linear Response Parameters'''
  </crystal>
** Parameters for linear response calculations.
  <varray name="positions"> ... </varray>  <!-- fractional coordinates -->
*'''{{TAG|LEPSILON}}'''
</structure>
** Calculates dielectric function.
<varray name="forces">              <!-- Hellmann-Feynman forces in eV/A -->
*'''{{TAG|LRPA}}'''
  <v>  0.12 -0.03  0.00 </v>
** Uses RPA for response functions.
  ...
*'''{{TAG|LNABLA}}'''
</varray>
** Calculates derivatives with respect to nabla.
<varray name="stress">              <!-- stress tensor in kB -->
*'''{{TAG|LVEL}}'''
  <v> -0.16  0.00  0.11 </v>
** Calculates current-current response.
  <v>  0.00  0.00  0.00 </v>
*'''{{TAG|CSHIFT}}'''
  <v>  0.11  0.00 -0.08 </v>
** Complex shift for dielectric function.
</varray>
*'''{{TAG|OMEGAMAX}}'''
<energy>
** Maximum frequency for response functions.
  <i name="e_fr_energy"> -53.93 </i>  <!-- free energy F = E - TS (eV) -->
*'''{{TAG|DEG_THRESHOLD}}'''
  <i name="e_wo_entrp">  -53.93 </i>  <!-- energy without entropy (eV) -->
** Threshold for degeneracy.
  <i name="e_0_energy">  -53.93 </i>  <!-- energy extrapolated to sigma->0 (eV) -->
*'''{{TAG|RTIME}}'''
  <!-- MD only: -->
** Imaginary part of the frequency in real-time propagation.
  <i name="kinetic">      0.10 </i>  <!-- ionic kinetic energy (eV) -->
*'''{{TAG|WPLASMAI}}'''
  <i name="lattice kinetic"> 0.00 </i> <!-- lattice kinetic energy, e.g. for NPT (eV) -->
** Imaginary part of plasma frequency.
  <i name="total">      -53.83 </i>  <!-- total energy E + E_kin, conserved in NVE (eV) -->
*'''{{TAG|DFIELD}}'''
</energy>
** Applied displacement field.
<time name="totalsc"> 0.04 0.01 </time>  <!-- CPU and wall time for this step (s) -->
*'''{{TAG|WPLASMA}}'''
 
** Plasma frequency parameters.
{{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]]).}}
*'''Orbital Magnetization'''
 
** Parameters for orbital magnetization calculations.
=== Electronic-structure calculation block ===
*'''{{TAG|NUCIND}}'''
 
** Nuclear induced magnetic field.
For single-point calculations ({{TAG|NSW}}{{=}}0) and post-DFT methods (GW, BSE), VASP writes a single <code><calculation></code> block instead of per-step ionic-step blocks. It contains eigenvalues, the density of states, and — for optical calculations — the dielectric function.
*'''{{TAG|MAGPOS}}'''
 
** Position for local orbital magnetization.
<calculation>
*'''{{TAG|LNICSALL}}'''
  <kpoints> ... </kpoints>          <!-- same layout as the top-level <kpoints> block -->
** Calculates non-local orbital magnetization for all atoms.
*'''{{TAG|ORBITALMAG}}'''
  <!-- Present if LOPTICS = .TRUE., or for GW/BSE:
** Calculates orbital magnetization.
        one or more dielectricfunction blocks, each labelled by a comment attribute -->
*'''{{TAG|LMAGBLOCH}}'''
  <dielectricfunction comment="HEAD OF MICROSCOPIC DIELECTRIC TENSOR (INDEPENDENT PARTICLE)">
** Bloch-orbital magnetization.
    <imag>                          <!-- imaginary part epsilon_2(omega) -->
*'''{{TAG|LCHIMAG}}'''
      <array>
** Magnetic susceptibility.
        <dimension dim="1">gridpoints</dimension>
*'''{{TAG|LGAUGE}}'''
        <field>energy</field>        <!-- frequency grid in eV -->
** Applies a gauge transformation.
        <field>xx</field>
*'''{{TAG|MAGATOM}}'''
        <field>yy</field>
** Specifies atom for local orbital magnetization.
        <field>zz</field>
*'''{{TAG|MAGDIPOL}}'''
        <field>xy</field>
** Magnetic dipole moments.
        <field>yz</field>
*'''{{TAG|AVECCONST}}'''
        <field>zx</field>
** Constant vector potential.
        <set>
*'''Response Functions'''
          <r>  0.000  0.000  0.000  0.000  0.000  0.000  0.000 </r>
** Parameters for various response function calculations.
          <r>  1.066  0.075  0.075  0.075  0.000  0.000  0.000 </r>
*'''{{TAG|LALL_IN_ONE}}'''
          ...
** Calculates all response functions in one run.
        </set>
*'''{{TAG|IALL_IN_ONE}}'''
      </array>
** Selects specific response functions.
    </imag>
*'''{{TAG|NBANDS_WAVE}}'''
    <real> ... </real>              <!-- real part epsilon_1(omega), same layout -->
** Number of bands for response function calculations.
  </dielectricfunction>
*'''{{TAG|LFINITE_TEMPERATURE}}'''
** Finite temperature effects.
  <!-- For GW/BSE, additional dielectricfunction blocks appear:
*'''{{TAG|LADDER}}'''
        "1 + v P, with REDUCIBLE POLARIZABILITY P=P_0 (1 -(v+f) P_0)^-1"
** Includes ladder diagrams.
        "INVERSE MACROSCOPIC DIELECTRIC TENSOR (including local field effects in RPA (Hartree))"
*'''{{TAG|LRPAFORCE}}'''
        "screened Coulomb potential"  -->
** Calculates RPA forces.
*'''{{TAG|LFXC}}'''
  <eigenvalues>                      <!-- KS (DFT) or quasiparticle (GW) eigenvalues -->
** Includes beyond RPA exchange-correlation kernel.
    <array>
*'''{{TAG|LHARTREE}}'''
      <dimension dim="1">band</dimension>
** Includes Hartree term in response.
      <dimension dim="2">kpoint</dimension>
*'''{{TAG|IBSE}}'''
      <dimension dim="3">spin</dimension>
** Specifies the type of Bethe-Salpeter Equation (BSE) calculation.
      <field>eigene</field>          <!-- eigenvalue in eV -->
*'''{{TAG|KPOINT}}'''
      <field>occ</field>            <!-- occupation number -->
** Specific k-point for some response calculations.
      <set>
*'''{{TAG|LTCTC}}'''
        <set comment="spin 1">
** Calculates current-current correlation function.
          <set comment="kpoint 1">
*'''{{TAG|LTCTE}}'''
            <r>  -10.504  1.0000 </r>
** Calculates current-energy correlation function.
            <r>  11.891  1.0000 </r>
*'''{{TAG|LTETE}}'''
            ...
** Calculates energy-energy correlation function.
          </set>
*'''{{TAG|LTRIPLET}}'''
          ...
** Includes triplet states in BSE.
        </set>
*'''{{TAG|LFXCEPS}}'''
      </set>
** Includes exchange-correlation effects in the dielectric function.
    </array>
*'''{{TAG|LFXHEG}}'''
  </eigenvalues>
** Uses uniform electron gas approximation for exchange-correlation effects.
*'''{{TAG|NATURALO}}'''
  <dos>                              <!-- density of states (present if LORBIT or NEDOS is set) -->
** Controls natural orbital calculations.
    <i name="efermi"> 6.12 </i>    <!-- Fermi energy in eV -->
*'''{{TAG|LHOLEGF}}'''
    <total>
** Calculates hole Green's function.
      <array>
*'''{{TAG|L2ORDER}}'''
        <dimension dim="1">gridpoints</dimension>
** Performs second order calculations.
        <dimension dim="2">spin</dimension>
*'''{{TAG|LDMP1}}'''
        <field>energy</field>        <!-- energy grid in eV -->
** First damping parameter.
        <field>total</field>        <!-- total DOS in states/eV -->
*'''{{TAG|LMP2LT}}'''
        <field>integrated</field>    <!-- integrated DOS (number of states) -->
** Performs MP2 calculation for lattice dynamics.
        <set> ... </set>
*'''{{TAG|LSMP2LT}}'''
      </array>
** Performs spin-polarized MP2 calculation for lattice dynamics.
    </total>
*'''{{TAG|LGWLF}}'''
    <partial> ... </partial>        <!-- orbital-projected DOS (present if LORBIT >= 10) -->
** Calculates GW quasiparticle lifetimes.
  </dos>
*'''{{TAG|ENCUTGW}}'''
** Energy cutoff for GW calculations.
  <time name="total"> 12.3  14.1 </time>  <!-- total CPU and wall time (s) -->
*'''{{TAG|ENCUTGWSOFT}}'''
</calculation>
** Soft energy cutoff for GW calculations.
 
*'''{{TAG|ENCUTLF}}'''
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.
** Energy cutoff for local field effects.
 
*'''{{TAG|ESF_SPLINES}}'''
=== Final structure ===
** Uses splines for energy shift function.
 
*'''{{TAG|ESF_CONV}}'''
The ionic positions at the end of the run. For MD runs, this block also contains the final ionic velocities, suitable for restarting the trajectory.
** Convergence for energy shift function.
 
*'''{{TAG|ESF_NINTER}}'''
<structure name="finalpos">
** Number of interpolation points for energy shift function.
  <crystal>
*'''{{TAG|LMAXM}}'''
    <varray name="basis"> ... </varray>
** ADD DESCRIPTION
    <i name="volume"> ... </i>
    <varray name="rec_basis"> ... </varray>
  </crystal>
  <varray name="positions"> ... </varray>
  <!-- MD only: -->
  <varray name="velocities"> ... </varray>
</structure>
 
== Reading vasprun.xml ==
 
=== py4vasp ===
 
[https://py4vasp.readthedocs.io py4vasp] reads {{FILE|vasprun.xml}} (and {{FILE|vaspout.h5}}) transparently. Given a calculation directory:
 
<syntaxhighlight lang="python">
import py4vasp
 
calc = py4vasp.Calculation.from_path(".")
 
structure = calc.structure.read()  # crystal structure (all ionic steps)
energy    = calc.energy.read()      # total energy (all ionic steps)
forces    = calc.force.read()      # forces in eV/Å
dos      = calc.dos.read()        # density of states
bands    = calc.band.read()        # band structure
</syntaxhighlight>
 
See the [https://py4vasp.readthedocs.io py4vasp documentation] for the full list of accessible quantities.
 
=== pymatgen ===
 
The [https://pymatgen.org pymatgen] library provides the <code>Vasprun</code> class:
 
<syntaxhighlight lang="python">
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
</syntaxhighlight>
 
=== ASE ===
 
The [https://wiki.fysik.dtu.dk/ase/ Atomic Simulation Environment] (ASE) reads {{FILE|vasprun.xml}} as a sequence of <code>Atoms</code> objects:
 
<syntaxhighlight lang="python">
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/Å)
</syntaxhighlight>
 
=== Direct XML parsing ===
 
For custom workflows, parse {{FILE|vasprun.xml}} with Python's standard library:
 
<syntaxhighlight lang="python">
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)
</syntaxhighlight>
 
{{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.}}
 
== Related tags and articles ==
 
* {{TAG|NSW}} — controls the number of ionic steps written to {{FILE|vasprun.xml}}.
* {{TAG|IBRION}} — selects the ionic update algorithm (relaxation or [[Molecular dynamics calculations|MD]]).
* {{TAG|MDALGO}} — selects the [[Molecular dynamics calculations|molecular-dynamics]] algorithm.
* {{TAG|LORBIT}} — controls whether orbital-projected DOS is written.
* {{TAG|LOPTICS}} — enables optical-property output (adds the dielectric function to the <code><calculation></code> block).
* {{TAG|ALGO}} — setting {{TAG|ALGO}}{{=}}EVGW0, GW0, etc. adds GW quasiparticle eigenvalues and screened-Coulomb blocks.
* {{TAG|IBSE}} — BSE calculations; adds the excitonic dielectric function.
* {{TAG|NWRITE}} — controls the verbosity of {{FILE|OUTCAR}}, but does not affect {{FILE|vasprun.xml}}.
* {{FILE|OUTCAR}} — the human-readable counterpart to {{FILE|vasprun.xml}}.
* {{FILE|vaspout.h5}} — the HDF5 alternative to {{FILE|vasprun.xml}}, preferred for large runs.
 
== References ==
<references/>
 
[[Category:Files]]
[[Category:Output files]]

Revision as of 14:31, 22 May 2026

The vasprun.xml file is VASP's machine-readable XML output file. It records the complete set of input parameters, the crystal structure, and all computed quantities for every ionic step of the calculation.

In addition to OUTCAR, vasprun.xml is written automatically for every VASP run. All physical output that appears in OUTCAR is also present here, but in a structured, hierarchical XML form that is straightforward to process programmatically. For large calculations, the HDF5 alternative vaspout.h5 is preferred.

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>

  <structure> ... </structure>
  <varray name="forces"> ... </varray>
  <varray name="stress"> ... </varray>
  <energy> ... </energy>
  
  ...

  <calculation> ... </calculation>

  <structure name="finalpos"> ... </structure>
</modeling>

Sections

Generator

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

<generator>
  vasp 
  6.5.0  
  29Jan2024 (build Feb 14 2024) complex parallel
  LinuxGNU 
  2024 01 01 
  12:00:00 
</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>
  diamond Si
  Normal
      500.00000000
       0
        0.05000000
</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">            
        <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>
           28.35   
      <varray name="rec_basis">        
        <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">          
      <v> 0.00  0.00  0.00 </v>
      <v> 0.25  0.25  0.25 </v>
    </varray>
  </structure>
  <varray name="primitive_index">      
    <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">             
    <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">             
    <v>  0.000  0.000  0.000 </v>
    <v>  0.250  0.000  0.000 </v>
    ...
  </varray>
  <varray name="weights">               
    <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
  • response functions (GW/BSE calculations)
  • vdW DFT

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>               
  <types> 1 </types>               
  <array name="atoms">             
    <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">         
    <dimension dim="1">type</dimension>
    <field type="int">atomspertype</field>
    <field type="string">element</field>
    <field>mass</field>            
    <field>valence</field>         
    <field type="string">pseudopotential</field>   
    <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">            
      <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>
       160.10   
    <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">          
    <v>  0.000  0.000  0.000 </v>
    <v>  0.250  0.250  0.250 </v>
  </varray>
  <varray name="velocities">         
    <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:

<structure>
  <crystal>
    <varray name="basis"> ... </varray>
     ... 
    <varray name="rec_basis"> ... </varray>
  </crystal>
  <varray name="positions"> ... </varray>   
</structure>
<varray name="forces">               
  <v>  0.12 -0.03  0.00 </v>
  ...
</varray>
<varray name="stress">               
  <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>
   -53.93   
    -53.93   
    -53.93   
         0.10   
   0.00  
         -53.83   
</energy>
   


Electronic-structure calculation block

For single-point calculations (NSW=0) and post-DFT methods (GW, BSE), VASP writes a single <calculation> block instead of per-step ionic-step blocks. It contains eigenvalues, the density of states, and — for optical calculations — the dielectric function.

<calculation>
  <kpoints> ... </kpoints>           

  <dielectricfunction comment="HEAD OF MICROSCOPIC DIELECTRIC TENSOR (INDEPENDENT PARTICLE)">
    <imag>                           
      <array>
        <dimension dim="1">gridpoints</dimension>
        <field>energy</field>        
        <field>xx</field>
        <field>yy</field>
        <field>zz</field>
        <field>xy</field>
        <field>yz</field>
        <field>zx</field>
        <set>
          <r>  0.000   0.000  0.000  0.000  0.000  0.000  0.000 </r>
          <r>  1.066   0.075  0.075  0.075  0.000  0.000  0.000 </r>
          ...
        </set>
      </array>
    </imag>
    <real> ... </real>               
  </dielectricfunction>


  <eigenvalues>                      
    <array>
      <dimension dim="1">band</dimension>
      <dimension dim="2">kpoint</dimension>
      <dimension dim="3">spin</dimension>
      <field>eigene</field>          
      <field>occ</field>             
      <set>
        <set comment="spin 1">
          <set comment="kpoint 1">
            <r>  -10.504   1.0000 </r>
            <r>   11.891   1.0000 </r>
            ...
          </set>
          ...
        </set>
      </set>
    </array>
  </eigenvalues>

  <dos>                              
     6.12      
    <total>
      <array>
        <dimension dim="1">gridpoints</dimension>
        <dimension dim="2">spin</dimension>
        <field>energy</field>        
        <field>total</field>         
        <field>integrated</field>    
        <set> ... </set>
      </array>
    </total>
    <partial> ... </partial>         
  </dos>

     
</calculation>

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, suitable for restarting the trajectory.

<structure name="finalpos">
  <crystal>
    <varray name="basis"> ... </varray>
     ... 
    <varray name="rec_basis"> ... </varray>
  </crystal>
  <varray name="positions"> ... </varray>
  <varray name="velocities"> ... </varray>
</structure>

Reading vasprun.xml

py4vasp

py4vasp reads vasprun.xml (and vaspout.h5) transparently. Given a calculation directory:

import py4vasp

calc = py4vasp.Calculation.from_path(".")

structure = calc.structure.read()   # crystal structure (all ionic steps)
energy    = calc.energy.read()      # total energy (all ionic steps)
forces    = calc.force.read()       # forces in eV/Å
dos       = calc.dos.read()         # density of states
bands     = calc.band.read()        # band structure

See the py4vasp documentation for the full list of accessible quantities.

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

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)


Related tags and articles

  • NSW — controls the number of ionic steps written to vasprun.xml.
  • IBRION — selects the ionic update algorithm (relaxation or MD).
  • MDALGO — selects the molecular-dynamics algorithm.
  • LORBIT — controls whether orbital-projected DOS is written.
  • LOPTICS — enables optical-property output (adds the dielectric function to the <calculation> block).
  • ALGO — setting ALGO=EVGW0, GW0, etc. adds GW quasiparticle eigenvalues and screened-Coulomb blocks.
  • IBSE — BSE calculations; adds the excitonic dielectric function.
  • NWRITE — controls the verbosity of OUTCAR, but does not affect vasprun.xml.
  • OUTCAR — the human-readable counterpart to vasprun.xml.
  • vaspout.h5 — the HDF5 alternative to vasprun.xml, preferred for large runs.

References