Calculations¶
In qmpy
a VASP calculation is represented by a Calculation
object. This object contains tools for writing calcualtion inputs and reading
calculation outputs. Additionally, it provides tools for automatically
correcting errors in calculations.
Calculation¶
- class qmpy.Calculation(*args, **kwargs)[source]¶
Base class for storing a VASP calculation.
- Relationships:
Composition
via compositionDOS
via dosStructure
via input. Input structure.Structure
via output. Resulting structure.Element
via element_set.Potential
via potential_set.Hubbard
via hubbard_set.Entry
via entry.Fit
via fit. Reference energy sets that have been fit usingthis calculation.FormationEnergy
via formationenergy_set. Formationenergies computed from this calculation, for different choices offit sets.MetaData
via meta_data- Attributes:
- idlabel: key for entry.calculations dict.attempt: # of this attempt at a calculation.band_gap: Energy gap occupied by the fermi energy.configuration: Type of calculation (module).converged: Did the calculation converge electronically and ionically.energy: Total energy (eV/UC)energy_pa: Energy per atom (eV/atom)irreducible_kpoints: # of irreducible k-points.magmom: Total magnetic moment (mu_b)magmom_pa: Magnetic moment per atom. (mu_b/atom)natoms: # of atoms in the input.nsteps: # of ionic steps.path: Calculation path.runtime: Runtime in seconds.settings: dictionary of VASP settings.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- backup(path=None)[source]¶
Create a copy of the calculation folder in a subdirectory of the current Calculation.
- Keyword arguments:
path: If None, the backup folder is generated based on the Calculation.attempt and Calculation.errors.
Return: None
- property co_spin_objects¶
Return list of co_spins (MetaData objects of type co_spin)
- compress(files=['OUTCAR', 'CHGCAR', 'CHG', 'PROCAR', 'DOSCAR', 'EIGENVAL', 'LOCPOT', 'ELFCAR', 'vasprun.xml'])[source]¶
gzip every file in files
- Keyword arguments:
files: List of files to zip up.
Return: None
- property error_objects¶
Return list of errors (MetaData objects of type error)
- get_outcar()[source]¶
Sets the calculations outcar attribute to a list of lines from the outcar.
Examples:
>>> calc = Calculation.read('calculation_path') >>> print calc.outcar None >>> calc.get_outcar() >>> len(calc.outcar) 12345L
- static read(path)[source]¶
Reads the outcar specified by the objects path. Populates input field values, as well as outputs, in addition to finding errors and confirming convergence.
Examples:
>>> path = '/analysis/vasp/files/normal/standard/' >>> calc = Calculation.read(INSTALL_PATH+path)
- read_charges()[source]¶
Reads and returns VASP-calculated projected charge for each atom. Returns the RAW charge, not NET charge.
Examples:
>>> calc = Calculation.read('path_to_calculation') >>> calc.read_charges()
- read_chgcar(filename='CHGCAR.gz', filetype='CHGCAR')[source]¶
Reads a VASP CHGCAR or ELFCAR and returns a GridData instance.
- read_elements()[source]¶
Reads the elements of the atoms in the structure. Returned as a list of atoms of shape (natoms,).
Examples:
>>> calc = Calculation.read('path_to_calculation') >>> calc.read_elements() ['Fe', 'Fe', 'O', 'O', 'O']
- read_energies()[source]¶
Returns a numpy.ndarray of energies over all ionic steps.
Examples:
>>> calc = Calculation.read('calculation_path') >>> calc.read_energies() array([-12.415236, -12.416596, -12.416927])
- read_lattice_vectors()[source]¶
Reads and returns a numpy ndarray of lattice vectors for every ionic step of the calculation.
Examples:
>>> path = 'analysis/vasp/files/magnetic/standard' >>> calc = Calculation.read(INSTALL_PATH+'/'+path) >>> calc.read_lattice_vectors() array([[[ 5.707918, 0. , 0. ], [ 0. , 5.707918, 0. ], [ 0. , 0. , 7.408951]], [[ 5.707918, 0. , 0. ], [ 0. , 5.707918, 0. ], [ 0. , 0. , 7.408951]]])
- read_stresses()[source]¶
Using vasprun.xml.gz to collect stresses. In future, this function will be moved to read_output_from_vasprun()
- save(*args, **kwargs)[source]¶
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- set_chgcar(source)[source]¶
Copy the CHGCAR specified by source to this calculation.
- Arguments:
source: can be another
Calculation
instance or a string containing a path to a CHGCAR. If it is a path, it should be a absolute, i.e. begin with “/”, and can either end with the CHGCAR or simply point to the path that contains it. For example, if you want to take the CHGCAR from a previous calculation you can do any of:>>> c1 # old calculation >>> c2 # new calculation >>> c2.set_chgcar(c1) >>> c2.set_chgcar(c1.path) >>> c2.set_chgcar(c1.path+'/CHGCAR')
- set_wavecar(source)[source]¶
Copy the WAVECAR specified by source to this calculation.
- Arguments:
source: can be another
Calculation
instance or a string containing a path to a WAVECAR. If it is a path, it should be a absolute, i.e. begin with “/”, and can either end with the WAVECAR or simply point to the path that contains it. For example, if you want to take the WAVECAR from a previous calculation you can do any of:>>> c1 # old calculation >>> c2 # new calculation >>> c2.set_wavecar(c1) >>> c2.set_wavecar(c1.path) >>> c2.set_wavecar(c1.path+'/WAVECAR')
- static setup(structure, configuration='static', path=None, entry=None, hubbard='wang', potentials='vasp_rec', settings={}, chgcar=None, wavecar=None, **kwargs)[source]¶
Method for creating a new VASP calculation.
- Arguments:
structure:
Structure
instance, or string indicating an input structure file.- Keyword Arguments:
- configuration:
String indicating the type of calculation to perform. Options can be found with qmpy.VASP_SETTINGS.keys(). Create your own configuration options by adding a new file to configuration/vasp_settings/inputs/ using the files already in that directory as a guide. Default=”static”
- settings:
Dictionary of VASP settings to be applied to the calculation. Is applied after the settings which are provided by the configuration choice.
- path:
Location at which to perform the calculation. If the calculation takes repeated iterations to finish successfully, all steps will be nested in the path directory.
- entry:
If the full qmpy data structure is being used, you can specify an entry to associate with the calculation.
- hubbard:
String indicating the hubbard correctionconvention. Options found with qmpy.HUBBARDS.keys(), and can be added to or altered by editing configuration/vasp_settings/hubbards.yml. Default=”wang”.
- potentials:
String indicating the vasp potentials to use. Options can be found with qmpy.POTENTIALS.keys(), and can be added to or altered by editing configuration/vasp_settings/potentials/yml. Default=”vasp_rec”.
- chgcar/wavecar:
Calculation, or path, indicating where to obtain an initial CHGCAR/WAVECAR file for the calculation.
- property warning_objects¶
Return list of warnings (MetaData objects of type warning)
Density of States¶
- class qmpy.DOS(*args, **kwargs)[source]¶
Electronic density of states..
- Relationships:
- Attributes:
- iddata: Numpy array of DOS occupations.file: Source file.gap: Band gap in eV.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- property energy¶
Return the array with the energies.
- get_projected_dos(strc, element, orbital=None, debug=False)[source]¶
Get the density of states for a certain element
- Returns an NDOSx1 array with DOS for the chosen element
and orbital type
- strc: qmpy.materials.Structure
Structure associated with this DOS
- element: str
Symbol of the element
- orbital: str or list or None
Which orbitals to retrieve. See site_dos for options. Use None to integrate all orbitals If you specify an orbital without phase factors or spins,
this operation will automatically sum all bands that match that criteria (ex: if you specify ‘d+’, this may sum the dxy+, dyz+, dz2+, … orbitals. Another example, if you put “+” it will get only the positive band
- site_dos(atom, orbital)[source]¶
Return an NDOSx1 array with dos for the chosen atom and orbital.
- atom: int
Atom index
- orbital: int or str
Which orbital to plot
If the orbital is given as an integer: If spin-unpolarized calculation, no phase factors: s = 0, p = 1, d = 2 Spin-polarized, no phase factors: s-up = 0, s-down = 1, p-up = 2, p-down = 3, d-up = 4, d-down = 5 If phase factors have been calculated, orbitals are s, py, pz, px, dxy, dyz, dz2, dxz, dx2 double in the above fashion if spin polarized.