This package implements modules for input and output to and from VASP. It imports the key classes form both vasp_input and vasp_output to allow most classes to be simply called as pymatgen.io.vaspio.Incar for example, to retain backwards compatibility.
Classes for reading/manipulating/writing VASP input files. All major VASP input files.
Bases: dict
INCAR object for reading and writing INCAR files. Essentially consists of a dictionary with some helper functions
Creates an Incar object.
Diff function for Incar. Compares two Incars and indicates which parameters are the same and which are not. Useful for checking whether two runs were done using the same parameters.
Reads an Incar object from a file.
Returns a string representation of the INCAR. The reason why this method is different from the __str__ method is to provide options for pretty printing.
Bases: pymatgen.serializers.json_coders.MSONable
KPOINT reader/writer.
Highly flexible constructor for Kpoints object. The flexibility comes at the cost of usability and in general, it is recommended that you use the default constructor only if you know exactly what you are doing and requires the flexibility. For most usage cases, the three automatic schemes can be constructed far more easily using the convenience static constructors (automatic, gamma_automatic, monkhorst_automatic) and it is recommended that you use those.
The default behavior of the constructor is for a Gamma centered, 1x1x1 KPOINTS with no shift.
Convenient static constructor for a fully automatic Kpoint grid, with gamma centered Monkhorst-Pack grids and the number of subdivisions along each reciprocal lattice vector determined by the scheme in the VASP manual.
Returns an automatic Kpoint object based on a structure and a kpoint density. Uses Gamma centered meshes for hexagonal cells and Monkhorst-Pack grids otherwise.
Reads a Kpoints object from a KPOINTS file.
Convenient static constructor for an automatic Gamma centered Kpoint grid.
Convenient static constructor for an automatic Monkhorst pack Kpoint grid.
Bases: pymatgen.serializers.json_coders.MSONable
Object for representing the data in a POSCAR or CONTCAR file. Please note that this current implementation. Most attributes can be set directly.
Associated Structure.
Optional comment string.
Boolean indication whether Poscar contains actual real names parsed from either a POTCAR or the POSCAR itself.
Selective dynamics attribute for each site if available. A Nx3 array of booleans.
Velocities for each site (typically read in from a CONTCAR). A Nx3 array of floats.
Predictor corrector coordinates for each site (typically read in from a MD CONTCAR).
Temperature of velocity Maxwell-Boltzmann initialization. Initialized to -1 (MB hasn”t been performed).
Reads a Poscar from a file.
The code will try its best to determine the elements in the POSCAR in the following order: 1. If check_for_POTCAR is True, the code will try to check if a POTCAR is in the same directory as the POSCAR and use elements from that by default. (This is the VASP default sequence of priority). 2. If the input file is Vasp5-like and contains element symbols in the 6th line, the code will use that if check_for_POTCAR is False or there is no POTCAR found. 3. Failing (2), the code will check if a symbol is provided at the end of each coordinate.
If all else fails, the code will just assign the first n elements in increasing atomic number, where n is the number of species, to the Poscar. For example, H, He, Li, .... This will ensure at least a unique element is assigned to each site and any analysis that does not require specific elemental properties should work fine.
Reads a Poscar from a string.
The code will try its best to determine the elements in the POSCAR in the following order: 1. If default_names are supplied and valid, it will use those. Usually, default names comes from an external source, such as a POTCAR in the same directory. 2. If there are no valid default names but the input file is Vasp5-like and contains element symbols in the 6th line, the code will use that. 3. Failing (2), the code will check if a symbol is provided at the end of each coordinate.
If all else fails, the code will just assign the first n elements in increasing atomic number, where n is the number of species, to the Poscar. For example, H, He, Li, .... This will ensure at least a unique element is assigned to each site and any analysis that does not require specific elemental properties should work fine.
Returns a string to be written as a POSCAR file. By default, site symbols are written, which means compatibility is for vasp >= 5.
Sequence of number of sites of each type associated with the Poscar. Similar to 7th line in vasp 5+ POSCAR or the 6th line in vasp 4 POSCAR.
Initializes the velocities based on Maxwell-Boltzmann distribution. Removes linear, but not angular drift (same as VASP)
Scales the energies to the exact temperature (microcanonical ensemble) Velocities are given in A/fs. This is the vasp default when direct/cartesian is not specified (even when positions are given in direct coordinates)
Overwrites imported velocities, if any.
Bases: list
Object for reading and writing POTCAR files for calculations. Consists of a list of PotcarSingle.
Initialize the POTCAR from a set of symbols. Currently, the POTCARs can be fetched from a location specified in the environment variable VASP_PSP_DIR or in a pymatgen.cfg or specified explicitly in a map.
Bases: pymatgen.io.vaspio.vasp_input.PotcarSingle
Object for a single POTCAR. The builder assumes the complete string is the POTCAR contains the complete untouched data in “data” as a string and a dict of keywords.
POTCAR data as a string.
Keywords parsed from the POTCAR as a dict. All keywords are also accessible as attributes in themselves. E.g., potcar.enmax, potcar.encut, etc.
Bases: dict, pymatgen.serializers.json_coders.MSONable
Class to contain a set of vasp input objects corresponding to a run.
Read in a set of VASP input from a directory. Note that only the standard INCAR, POSCAR, POTCAR and KPOINTS files are read unless optional_filenames is specified.
Classes for reading/manipulating/writing VASP ouput files.
Bases: pymatgen.io.vaspio.vasp_output.VolumetricData
Simple object for reading a CHGCAR file.
Bases: pymatgen.io.vaspio.vasp_output.VolumetricData
Simple object for reading a LOCPOT file.
Bases: object
A basic parser for an OSZICAR output from VASP. In general, while the OSZICAR is useful for a quick look at the output from a VASP run, we recommend that you use the Vasprun parser instead, which gives far richer information about a run.
All electronic steps as a list of list of dict. e.g., [[{“rms”: 160.0, “E”: 4507.24605593, “dE”: 4507.2, “N”: 1, “deps”: -17777.0, “ncg”: 16576}, ...], [....] where electronic_steps[index] refers the list of electronic steps in one ionic_step, electronic_steps[index][subindex] refers to a particular electronic step at subindex in ionic step at index. The dict of properties depends on the type of VASP run, but in general, “E”, “dE” and “rms” should be present in almost all runs.
All ionic_steps as a list of dict, e.g., [{“dE”: -526.36, “E0”: -526.36024, “mag”: 0.0, “F”: -526.36024}, ...] This is the typical output from VASP at the end of each ionic step.
Bases: object
Parser for data in OUTCAR that is not available in Vasprun.xml
Note, this class works a bit differently than most of the other VaspObjects, since the OUTCAR can be very different depending on which “type of run” performed.
Creating the OUTCAR class with a filename reads “regular parameters” that are always present.
Magnetization on each ion as a tuple of dict, e.g., ({“d”: 0.0, “p”: 0.003, “s”: 0.002, “tot”: 0.005}, ... ) Note that this data is not always present. LORBIT must be set to some other value than the default.
Charge on each ion as a tuple of dict, e.g., ({“p”: 0.154, “s”: 0.078, “d”: 0.0, “tot”: 0.232}, ...) Note that this data is not always present. LORBIT must be set to some other value than the default.
True if OUTCAR is from a stopped run (using STOPCAR, see Vasp Manual).
Various useful run stats as a dict including “System time (sec)”, “Total CPU time used (sec)”, “Elapsed time (sec)”, “Maximum memory used (kb)”, “Average memory used (kb)”, “User time (sec)”.
One can then call a specific reader depending on the type of run being performed. These are currently: read_igpar(), read_lepsilon() and read_lcalcpol().
See the documentation of those methods for more documentation.
Authors: Rickard Armiento, Shyue Ping Ong
(See VASP section “LBERRY, IGPAR, NPPSTR, DIPOL tags” for info on what these are).
Bases: object
Object for reading a PROCAR file.
A nested dict containing the PROCAR data of the form below. It should be noted that VASP uses 1-based indexing for atoms, but this is converted to zero-based indexing in this parser to be consistent with representation of structures in pymatgen:
{
atom_index: {
kpoint_index: {
"bands": {
band_index: {
"p": 0.002,
"s": 0.025,
"d": 0.0
},
...
},
"weight": 0.03125
},
...
}
Deprecated since version v2.6.4: Use get_occpuation instead.
Returns the d occupation of a particular atom.
Returns the occupation for a particular orbital of a particular atom.
Bases: object
Vastly improved sax-based parser for vasprun.xml files. Speedup over Dom is at least 2x for smallish files (~1Mb) to orders of magnitude for larger files (~10Mb). All data is stored as attributes, which are delegated to the VasprunHandler object. Note that the results would differ depending on whether the read_electronic_structure option is set to True.
Vasp results
All ionic steps in the run as a list of {“structure”: structure at end of run, “electronic_steps”: {All electronic step data in vasprun file}, “stresses”: stress matrix}
List of Structure objects for the structure at each ionic step.
Total dos calculated at the end of run.
Integrated dos calculated at the end of run.
List of list of PDos objects. Access as pdos[atomindex][orbitalindex]
Fermi energy
Available only if parse_eigen=True. Final eigenvalues as a dict of {(spin, kpoint index):[[eigenvalue, occu]]}. This representation is based on actual ordering in VASP and is meant as an intermediate representation to be converted into proper objects. The kpoint index is 0-based (unlike the 1-based indexing in VASP).
Final projected eigenvalues as a dict of {(atom index, band index, kpoint index, Orbital, Spin):float} This representation is based on actual ordering in VASP and is meant as an intermediate representation to be converted into proper objects. The kpoint, band and atom indices are 0-based (unlike the 1-based indexing in VASP).
Vasp inputs
Incar object for parameters specified in INCAR file.
Incar object with parameters that vasp actually used, including all defaults.
Kpoints object for KPOINTS specified in run.
List of actual kpoints, e.g., [[0.25, 0.125, 0.08333333], [-0.25, 0.125, 0.08333333], [0.25, 0.375, 0.08333333], ....]
List of kpoint weights, E.g., [0.04166667, 0.04166667, 0.04166667, 0.04166667, 0.04166667, ....]
List of atomic symbols, e.g., [“Li”, “Fe”, “Fe”, “P”, “P”, “P”]
List of POTCAR symbols. e.g., [“PAW_PBE Li 17Jan2003”, “PAW_PBE Fe 06Sep2000”, ..]
Author: Shyue Ping Ong
True if a relaxation run is converged. Checking is performed on both the final electronic convergence as well as whether the number of ionic steps is equal to the NSW setting.
Band properties from the eigenvalues as a tuple, (band gap, cbm, vbm, is_band_gap_direct).
Returns the band structure as a BandStructure object
a BandStructure object (or more specifically a BandStructureSymmLine object if the run is detected to be a run along symmetry lines)
Two types of runs along symmetry lines are accepted: non-sc with Line-Mode in the KPOINT file or hybrid, self-consistent with a uniform grid+a few kpoints along symmetry lines (explicit KPOINTS file) (it’s not possible to run a non-sc band structure with hybrid functionals). The explicit KPOINTS file needs to have data on the kpoint label as commentary.
Returns the run type. Currently supports only GGA and HF calcs.
TODO: Fix for other functional types like LDA, PW91, etc.
Bases: xml.sax.handler.ContentHandler
Sax handler for vasprun.xml. Attributes are mirrored into Vasprun object. Generally should not be initiatized on its own.
Bases: object
Simple volumetric object for reading LOCPOT and CHGCAR type files.
Structure associated with the Volumetric Data object
..attribute:: is_spin_polarized
True if run is spin polarized
..attribute:: dim
Tuple of dimensions of volumetric grid in each direction (nx, ny, nz).
..attribute:: data
Actual data as a dict of {string: np.array}. The string are “total” and “diff”, in accordance to the output format of vasp LOCPOT and CHGCAR files where the total spin density is written first, followed by the difference spin density.
Total number of grid points in volumetric data.
Typically, this constructor is not used directly and the static from_file constructor is used. This constructor is designed to allow summation and other operations between VolumetricData objects.
Get the averaged total of the volumetric data a certain axis direction. For example, useful for visualizing Hartree Potentials from a LOCPOT file.
Get integrated difference of atom index ind up to radius. This can be an extremely computationally intensive process, depending on how many grid points are in the VolumetricData.
Method to do a linear sum of volumetric objects. Used by + and - operators as well. Returns a VolumetricData object containing the linear sum.
Convenience method to parse a generic volumetric data file in the vasp like format. Used by subclasses for parsing file.
When running a band structure computations the fermi level needs to be take from the static run that gave the charge density used for the non-self consistent band structure run. Sometimes this fermi level is however a little too low because of the mismatch between the uniform grid used in the static run and the band structure k-points (e.g., the VBM is on Gamma and the Gamma point is not in the uniform mesh). Here we use a procedure consisting in looking for energy levels higher than the static fermi level (but lower than the LUMO) if any of these levels make the band structure appears insulating and not metallic anymore, we keep this adjusted fermi level. This procedure has shown to detect correctly most insulators.
this method is used to get band structure info from a VASP directory. It takes into account that the run can be divided in several branches named “branch_x”. If the run has not been divided in branches the method will turn to parsing vasprun.xml directly.
The method returns None is there”s a parsing error
Helper function to convert a Vasprun parameter into the proper type. Boolean, int and float types are converted.
Helper function to convert a Vasprun array-type parameter into the proper type. Boolean, int and float types are converted.