Vasp class

Sub-package containing the functional.

class pylada.vasp.functional.Vasp(copy=None, species=None, kpoints=None, **kwargs)[source]

Bases: pylada.tools.input.block.AttrBlock

Interface to VASP code.

This interface makes it a bit easier to call VASP both for high-throughput calculations and for complex calculations involving more that one actual call to the program.

The main way to use the code is as follows.

First, one creates the actual functional:

>>> from pylada.vasp import Vasp
>>> functional = Vasp()

The one sets it up, taking care that all the required pseudo-potentials are defined:

>>> vasp.add_specie = 'H', '$HOME/pseudos/PAWGGA/H'
>>> vasp.add_specie = 'C', '$HOME/pseudos/PAWGGA/C'
>>> vasp.sigma = 0.2
>>> vasp.prec = 'accurate'
>>> vasp.lcharg = True

The parameters of the functional have the same name as the tags in the INCAR. The syntax is also the same, except that integers, floats, and booleans can be used wherever it makes sense.

Although a fair number of parameters already exist, some are missing. It is possible to add them with:

>>> vasp.add_keyword('tagname', value)

The tagname needs not be given in capital letters. The value can be a string, in which case it will be printed in the INCAR as is, basic types, such as integers, floats, and booleans, or list of such types. It is then possible to access the new parameter as with any other:

>>> vasp.tagname = 5
>>> vasp.tagname
5

There are few special parameters with enhanced behaviors, such as magmom, encut, or ediff_per_atom. Any parameter can be completely disabled with:

>>> vasp.sigma = None

In this case, SIGMA will simply not appear in the INCAR.

The functional is then called with two or more arguments:

>>> result = vasp(structure, 'this/directory', sigma=-1)

The first argument is a pylada.crystal.Structure instance on which to perform the calculation. The species in the structure should all have a pseudo-potential declared vias add_specie. The second argument is the directory where the calculations should take place. Other arguments, such as sigma above will change the appropriate parameter for the duration of the call (the call is stateless).

The result is an extraction object capable of grepping different properties from the OUTCAR. The major property is success. For more, please see Extract.

The best way to use this functional is in conjunction with the high-throughput interface pylada.jobfolder.

iter(structure, outdir=None, **kwargs)[source]

Allows asynchronous vasp calculations

This is a generator which yields two types of objects:

  • ProgramProcess: once started, this process will run an actual VASP calculation.
  • Extract: once the program has been runned, and extraction object is yielded, in order that the results of the run can be analyzed.

In a new calculation, an instance of each type will be yielded, in the order of their description above. It is expected that program is runned first, using the first object, before looping to the second object. Thie generator function makes it possible to run different instances of VASP simultaneously. It also makes it possible to create more complex calculations which necessitate more than one actual call to VASP (see iter_relax), while retaining the ability to run multiple VASP programs simultaneously.

If successful results (see Extract.success) already exist in outdir, Pylada defaults to not repeating the calculations. In that case, the first object described above is skipped and only an extraction object is yielded.

The __call__() method loops over this generator and makes actual VASP calls. Looking at its code is a good place to start, if you want to understand this looping business. The benefit of this approach can be seen in iter_relax (more complex calculations) and pylada.process.jobfolder.JobFolderProcess.

Parameters:
  • structureStructure structure to compute.
  • outdir – Output directory where the results should be stored. This directory will be checked for restart status, eg whether calculations already exist. If None, then results are stored in current working directory.
  • comm – Holds arguments for executing VASP externally.
  • overwrite – If True, will overwrite pre-existing results. If False, will check whether a successful calculation exists. If one does, then does not execute.
  • kwargs

    Any attribute of the VASP instance can be overridden for the duration of this call by passing it as keyword argument:

    >>> for program in vasp.iter(structure, outdir, sigma=0.5):
    ...
    

    The above would call VASP with smearing of 0.5 eV (unless a successfull calculation already exists, in which case the calculations are not overwritten).

Yields :

A process and/or an extraction object, as described above.

Raises:
  • RuntimeError – when computations do not complete.
  • IOError – when outdir exists but is not a directory.

Note

This function is stateless. It expects that self and structure can be deepcopied correctly.

Warning

This will never overwrite successfull VASP calculation, even if the parameters to the call are different.

__call__(structure, outdir=None, comm=None, overwrite=False, **kwargs)[source]

Calls vasp program and waits until completion.

This function makes a blocking call to the VASP external program. It will return only once the calculation is complete. To make asynchronous calls to VASP, please consider using iter().

For a description of the parameters, please see iter().

Returns:An extraction object of type Extract.
add_keyword(name, value=None)

Adds/Sets input keyword.

Extract = <class 'pylada.vasp.extract.Extract'>

Extraction class.

This extraction class is used to grep output from an OUTCAR file. This attribute merely describes the type of the extraction object as Extract.

addgrid = None

Adds additional support grid for augmentation charge evaluation.

Can be only True or False (or None for VASP default).

See also

ADDGRID

algo = None

Electronic minimization.

Defines the kind of algorithm vasp will run.
  • very fast
  • fast, f (default)
  • normal, n
  • all, a
  • damped, d
  • Diag
  • conjugate, c (vasp 5)
  • subrot (vasp 5)
  • eigenval (vasp 5)
  • Nothing (vasp 5)
  • Exact (vasp 5)
  • chi
  • gw
  • gw0
  • scgw
  • scgw0

If is_vasp_4 is an existing configuration variable of pylada the parameters marked as vasp 5 will fail.

Warning

The string None is not allowed, as it would lead to confusion with the python object None. Please use “Nothing” instead. The python object None will simply not print the ALGO keyword to the INCAR file.

Note

By special request, “fast” is the default algorithm.

See also

ALGO

ediff = None

Sets the absolute energy convergence criteria for electronic minimization.

EDIFF is set to this value in the INCAR.

Disables ediff_per_atom if set to anything but None. These two properties are mutually exclusive. If negative or null, defaults to zero.

See also

EDIFF, ediff_per_atom

ediff_per_atom = None

Sets the relative energy convergence criteria for electronic minimization.

EDIFF is set to this value times the number of atoms in the structure. This approach is more sensible than straight-off ediff when doing high-throughput over many structures.

Disables ediff if set to anything but None. These two properties are mutually exclusive. If negative or null, defaults to zero.

See also

EDIFF, ediff

ediffg = None

Sets the absolute energy convergence criteria for ionic relaxation.

EDIFFG is set to this value in the INCAR.

Disables ediffg_per_atom if set to anything but None. These two properties are mutually exclusive.

ediffg_per_atom = None

Sets the relative energy convergence criteria for ionic relaxation.

  • if positive: EDIFFG is set to this value times the number of atoms in the structure. This means that the criteria is for the total energy per atom.
  • if negative: same as a negative EDIFFG, since that convergence criteria is already per atom.

This approach is more sensible than straight-off ediffg when doing high-throughput over many structures. Disables ediffg if set to anything but None. These two properties are mutually exclusive.

See also

EDIFFG, ediffg

encut = None

Defines cutoff factor for calculation.

There are three ways to set this parameter:

  • if value is floating point and 0 < value <= 3: then the cutoff is value * ENMAX, where ENMAX is the maximum recommended cutoff for the species in the system.
  • if value > 3 eV, then ENCUT is exactly value (in eV). Any energy unit is acceptable.
  • if value < 0 eV or None, does not print anything to INCAR.

See also

ENCUT

encutgw = None

Defines cutoff factor for GW calculation.

There are three ways to set this parameter:

  • if value is floating point and 0 < value <= 3: then the cutoff is value * ENMAX, where ENMAX is the maximum recommended cutoff for the species in the system.
  • if value > 3 eV, then ENCUTGW is exactly value (in eV). Any energy unit is acceptable.
  • if value < 0 eV or None, does not print anything to INCAR.

See also

ENCUTGW

extraelectron = None

Number of electrons relative to neutral system.

Gets the number of electrons in the (neutral) system. Then adds value to it and computes with the resulting number of electrons.

>>> vasp.extraelectron =  0  # charge neutral system
>>> vasp.extraelectron =  1  # charge -1 (1 extra electron)
>>> vasp.extraelectron = -1  # charge +1 (1 extra hole)

Disables nelect if set to anything but None: these two properties are mutually exclusive.

See also

NELECT, nelect

ferdo = None

Occupancy of the down-spin states for ISMEAR=-2.

List of floating points.

See also

FERDO, ismear, ferwe

ferwe = None

Occupancy of the states for ISMEAR=-2.

List of floating points.

See also

FERWE, ismear, ferdo

ibrion = None

Ions/cell-shape/volume optimization method.

Can only take a restricted set of values: -1 | 0 | 1 | 2 | 3 | 5 | 6 | 7 | 8 | 44.

See also

IBRION, relaxation, isif, nsw

icharg = None

Charge from which to start.

This tag decides whether to restart from a previously calculated charge density, or not. It is best to keep this attribute set to -1, in which case, Pylada takes care of copying the relevant files.

  • -1: (Default) Automatically determined by Pylada. Depends on the

    value of restart and the existence of the relevant files. Also takes care of non-scf bit.

  • 0: Tries to restart from wavefunctions. Uses the latest WAVECAR

    file between the one currently in the output directory and the one in the restart directory (if specified). Sets nonscf to False.

    Note

    CHGCAR is also copied, just in case.

  • 1: Tries to restart from wavefunctions. Uses the latest WAVECAR

    file between the one currently in the output directory and the one in the restart directory (if specified). Sets nonscf to False.

  • 2: Superimposition of atomic charge densities. Sets

    nonscf to False.

  • 4: Reads potential from POT file (VASP-5.1 only). The POT file is

    deduced the same way as for CHGAR and WAVECAR above. Sets nonscf to False.

  • 10, 11, 12: Same as 0, 1, 2 above, but also sets nonscf

    to True. This is a shortcut. The value is actually kept to 0, 1, or 2:

    >>> vasp.icharg = 10
    >>> vasp.nonscf, vasp.icharg
    (True, 0)
    

Note

Files are copied right before the calculation takes place, not before.

isif = None

Degree of librerty to optimize during geometry optimization

See also

ISIF, relaxation, ibrion, nsw

ismear = None

Smearing function

Vasp allows a number of options:

  • metal (-5): Tetrahedron method with Blöchl correction (requires a Γ-centered k-mesh)
  • tetra (-4): Tetrahedron method (requires a Γ-centered k-mesh)
  • dynamic (-3): Performs a loop over smearing parameters supplied in smearings
  • fixed: (-2): Fixed occupation, set via ferwe and ferdo
  • fermi (-1): Fermi function
  • gaussian (0): Gaussian function
  • mp n (n>0): Methfessel-Paxton smearing function of order n
ispin = None

Whether to perform spin-polarized or spin-unpolarized calculations.

Can be only 1 or 2 (or None for VASP default).

See also

ISPIN

istart = None

Starting wavefunctions.

This tag is about which wavefunction (WAVECAR) file to read from, if any. It is best to keep this attribute set to -1, in which case, Pylada takes care of copying the relevant files.

  • -1, ‘auto’: (Default) Automatically determined by Pylada. Depends on the value of restart and the existence of the relevant files. If a WAVECAR file exists, then ISTART will be set to 1 (constant cutoff).
  • 0, ‘scratch’: Start from scratch.
  • 1, ‘cutoff’: Restart with constant cutoff.
  • 2, ‘basis’: Restart with constant basis.
  • 3, ‘full’: Full restart, including TMPCAR.

This attribute can be set equivalently using an integer or a string, as shown above. In practice, the integers will be converted to strings within the python interface:

>>> vasp.istart = 0
>>> vasp.istart
'scratch'

Note

Files are copied right before the calculation takes place, not when the attribute is set.

See also

ISTART, icharg, istruc, restart

istruc = None

Initial structure.

Determines which structure is written to the POSCAR. In practice, it makes it possible to restart a crashed job from the latest contcar. There are two possible options:

  • auto: Pylada determines automatically what to use. If a CONTCAR

    exists in either the current directory or in the restart directory (if any), then uses the latest. Otherwise, uses input structure.

  • scratch: Always uses input structure.

  • contcar: Always use CONTCAR structure unless overwrite == True.

  • input: Always use input structure, never restart or CONTCAR structure.

If the run was given the overwrite option, then always uses the input structure.

Note

There is no VASP equivalent to this option.

See also

restart, icharg, istart

isym = None

Symmetry scheme.

See also

ISYM

kpoints = None

kpoints for which to perform calculations.

lcharg = None

Whether or not to write the charge density to the CHGCAR.

Must be a boolean. Defaults to True.

See also

LWAVE

ldau = None

Sets U, nlep, and enlep parameters.

The U, nlep, and enlep parameters of the atomic species are set at the same time as the pseudo-potentials. This object merely sets up the INCAR with right input.

However, it does accept one parameter, which can be “off”, “on”, “occ” or “all”, and defines the level of verbosity of VASP (with respect to U and nlep).

lmaxmix = None

Cutoff l-quantum number of PAW charge densities passed to mixer

See also

LMAXMIX

loptics = None

Whether to compute the frequency dependent dielectic matrix.

Must be a boolean or None (leaves default to VASP).

See also

LOPTICS

lorbit = None

Decides whether PROOUT and PROOCAR are writtent to disk.

Can be one of 0|1|2|5|10|11|12|None.

See also

LORBIT

lpead = None

Compute the finite-difference k-derivative of the wavefunctions.

Must be a boolean or None (leaves default to VASP).

See also

LPEAD

lrpa = None

Whether to include local field effects at the Hartree level only.

Must be a boolean or None (leaves default to VASP).

See also

LRPA

lsorbit = None

Run calculation with spin-orbit coupling.

Accepts None, True, or False. If True, then sets nonscf to True and ispin to 2.

lvtot = None

Whether or not to write the local potential to the LOCPOT file.

Must be a boolean. Defaults to False.

See also

LVTOT

lwave = None

Whether or not to write the wavefunctions to the WAVECAR.

Must be a boolean. Defaults to False (unlike VASP).

See also

LWAVE

magmom = None

Sets the initial magnetic moments on each atom.

There are three types of usage:

  • if None or False, does nothing
  • if calculations are not spin-polarized, does nothing.
  • if a string, uses that as for the MAGMOM keyword
  • if True and at least one atom in the structure has a non-zero magmom attribute, then creates the relevant moment input for VASP

If the calculation is not spin-polarized, then the magnetic moment tag is not set.

Note

Please set by hand for non-collinear calculations

See also

MAGMOM

nbands = None

Number of bands in the calculation.

Can be any integer.

See also

NBANDS

nelect = None

Sets the absolute number of electrons.

Disables extraelectron if set to something other than None.

See also

NELECT, extraelectron

nelm = None

Maximum number of self-consistent electronic minimization steps.

Must be an integer or None (leaves default to VASP).

See also

NELM

nelmdl = None

Number of non-selfconsistent steps at the beginning.

Must be an integer or None (leaves default to VASP).

See also

NELMDL

nelmin = None

Minimum number of self-consistent electronic minimization steps.

Must be an integer or None (leaves default to VASP).

See also

NELMIN

ngx = None

number of grid points in the FFT-grid along the first lattice vector.

Must be an integer or None (leaves default to VASP).

See also

NGX, ngy, ngz

ngy = None

number of grid points in the FFT-grid along the second lattice vector.

Must be an integer or None (leaves default to VASP).

See also

NGY, ngx, ngz

ngz = None

number of grid points in the FFT-grid along the third lattice vector.

Must be an integer or None (leaves default to VASP).

See also

NGZ, ngx, ngy

nomega = None

Number of frequency grid points.

Can be any integer.

See also

NOMEGA

nonscf = None

If True, performs a non-self consistent calculation.

The value of this keyword is checked by icharg and used appropriately. The attribute lsorbit also acts and checks on it. It is False by default.

npar = None

Parallelization over bands.

Npar defines how many nodes work on one band. It can be set to a particular number:

>>> vasp.npar = 2

Or it can be deduced automatically. Different schemes are available:

  • power of two: npar is set to the largest power of 2 which divides the number of processors.

    >>> vasp.npar = "power of two"
    

    If the number of processors is not a power of two, prints nothing.

  • square root: npar is set to the square root of the number of processors.

    >>> vasp.npar = "sqrt"
    
nsw = None

Maxium number of ionic iterations.

See also

NSW

prec = None

Sets accuracy of calculation.

  • accurate (default)
  • low
  • medium
  • high
  • single

See also

PREC

precfock = None

Sets up FFT grid in hartree-fock related routines.

Allowable options are:

  • low
  • medium
  • fast
  • normal
  • accurate

See also

PRECFOCK

program = None

Path to vasp program.

Can be one of the following:

  • None: defaults to vasp_program. vasp_program can take the same values as described here, except for None.
  • string: Should be the path to the vasp executable. It can be either a full path, or an executable within the environment’s $PATH variable.
  • callable: The callable is called with a Vasp as sole argument. It should return a string, as described above. In other words, different vasp executables can be used depending on the parameters.
relaxation = None

Short-cut for setting up relaxation.

It accepts two parameters:

  • static: for calculation without geometric relaxation.
  • combination of ionic, volume, cellshape: for the type of relaxation requested.

It makes sure that isif, ibrion, and nsw take the right value for the kind of relaxation.

See also

isif, ibrion, nsw

restart = None

Calculation from which to restart.

Depending on the values of istart, icharg, and istruc, this calculation will copy the charge density, wavefunctions, and structure from this object. It should be either None, or an extraction object returned by a previous calculation (e.g. Extract):

calc1 = vasp(structure)
calc2 = vasp(structure, restart=calc2, nonscf=True)

The snippet above performs a non-self-consistent calculation using the first calculation. In this example, it is expected that istart, icharg, and istruc are all set to ‘auto’, in which case Pylada knows to do the right thing, e.g. copy whatever is available, and nothing is vasp.restart is None.

Note

The calculation from which to restart needs be successful, otherwise it is not considered.

See also

istart, istruc, icharg

sigma = None

Width of the smearing function.

Accepts floating points which may be signed with an energy unit using the quantities package:

from quantities import eV, hartree

vasp.smearing = 0.2           # Defaults to eV.
vasp.smearing = 0.2 * eV      # Same as above, but more explicit.
vasp.smearing = 0.5 * hartree # if you are so inclined.

See also

SIGMA, quantities, ismear

smearings = None

Smearing steps for ISMEAR=-3.

List of floating points. Does not accept quantities.

See also

ISMEAR, ismear

species = None

Species in the system.

Defines both POTCAR, U, and/or NLEP parameters. This is generally done using the method add_specie().

system = None

System title to use for calculation.

  • If None and ...
    • if the structure has a name attribute, uses that as the calculations title
    • else does not use SYSTEM tag
  • If something else which is convertible to a string, and ...
    • if the structure has a name attribute, uses ‘string: name’ as the title
    • otherwise, uses the string

See also

SYSTEM

Previous topic

Vasp Module

Next topic

Relaxation methods

This Page