# IO functions¶

class storq.vasp.readers.Readers[source]

Mixin class of reader-type methods for the Vasp calculator.

These methods are all dependent on some calculator property or reimplement ASE methods and hence cannot be factored out of the calculator.

read_atoms()[source]

Read the final atoms object. and return the user defined order (unsort) if able.

Returns: Atoms or None
read_basic()[source]

Read the self.parameters and atoms, not the results(!).

Overwrites the parent ase calculator method, and is called upon initialization of the calculator. Restart is ignored but part of the signature for ase.

Todo

complete docstring with description of parameters and return value

read_forces(latest=True)[source]

Method that reads forces from OUTCAR file.

If ‘latest’ is switched off, the forces for all ionic steps in the OUTCAR file be returned, in other case only the forces for the last ionic configuration is returned.

read_incar(fname=None)[source]

This only reads simple INCAR files, e.g. one tag per line, and with no comments in the line. There is no knowledge of any Vasp keywords in this, and the values are converted to Python types by some simple rules.

Parameters: fname (str) – name of input file parameters from INCAR file dict
read_kpoints(fname=None)[source]

Parameters: fname (str) – name of input file k-point tags ASE Parameters dictionary
read_potcar(fname: str = None)[source]

Read the POTCAR file to get the information regarding PAW/pseudopotential setups.

Parameters: fname (str) – name of input file PAW/pseudopotential setups ASE Parameters dictionary
read_results()[source]

Read energy, forces, stress, magmom and magmoms from output file.

Other quantities will be read by other functions. This depends on the calculator state.

Todo

complete docstring with description of parameters and return value

storq.vasp.readers.isfloat(s)[source]

Return True if s is a float.

We check if it is not an integer first, then try to cast it as a float.

Parameters: s (str) – input string boolean
storq.vasp.readers.read_convergence(outcar=None)[source]

Checks whether a calculation has converged.

Performs a strict convergence checks in the sense that electronic as well as ionic convergence is explicitly chechked for by comparing their magnitude to EDIFF and EDIFFG.

Returns: A list of two bools indicating if the electronic SCF cycle and the ionic relaxation converged, respectively. list
storq.vasp.readers.read_enmax(potcar)[source]

Return ENMAX from the potcar file.

storq.vasp.readers.read_enmin(potcar)[source]

Return ENMIN from the potcar file.

storq.vasp.readers.read_num_ionic_steps(outcar: str = None) → int[source]

Returns the number of ionic steps from the OUTCAR file.

Parameters: outcar – name of input file [default: OUTCAR]
storq.vasp.readers.read_outcar_validity(outcar: str = None) → bool[source]

Returns True if VASP finished properly.

If VASP itself is cancelled (batch_walltime or explicitly by user) or encounters certain errors it won’t ouput the typical Voluntary context switch count on the last line of the OUTCAR.

Parameters: outcar – name of input file [default: OUTCAR]
storq.vasp.readers.read_zval(potcar)[source]

Return the ZVAL for a potcar file.

parse this line:
POMASS = 106.420; ZVAL = 10.000 mass and valenz

## Writers¶

class storq.vasp.writers.Writers[source]
write_db(db_name, data=None, append=True, **kwargs)[source]

Write database used by storq calculation persistence.

The database consists of a single row with information about atoms, results, parameters and confiugration for easy restart.

Parameters: db_name (str) – Name of a db file (existing or new) to write to. append (bool) – Whether the database file should be overwritten or not. keys (dict) – Additional key-value-pairs to include in the database. data (dict) – Additional data to include in the database.
write_incar()[source]

Write INCAR file.

Boolean values are written as .TRUE./.FALSE.; integers, floats and strings are written out as is; lists and tuples are written out as space separated values.

Parameters: fname (str) – output file name
write_input()[source]

Writes all input files required for a calculation.

write_kpoints()[source]

Write KPOINTS file.

The KPOINTS file format is as follows::

line 1: a comment line 2: number of kpoints

n <= 0 Automatic kpoint generation n > 0 explicit number of kpoints
line 3: kpt format
if n > 0:
C,c,K,k = cartesian coordinates anything else = reciprocal coordinates
if n <= 0
M,m,G,g for Monkhorst-Pack or Gamma grid anything else is a special case
line 4: if n <= 0, the Monkhorst-Pack grid
if n > 0, then one line per kpoint

line 5: if n <= 0 it is the gamma shift

After the kpts may follow information regarding the tetrahedra, but we do not support that for now.

Parameters: fname (str) – output file name
write_persistence_db(atoms=None, parser=None, overwrite=True, keys={}, data={}, del_info=[], **kwargs)[source]

Database containing persistence information for storq calculations.

Contains atoms, results, parameters and confiugration for easy restart. Note that the datbase should only contain a single row.

Parameters: atoms (ASE Atoms objectc) – Structure to write to the database. If None, the atoms object will be the image attached to the calculator. parser (str) – A tool for generating key-value-pairs from the calculators directory path. Pairs will be separated by directory and key- values will be separated by parser. If None, no key-value-pair information will be collected. overwrite (bool) – Whether the database file should be overwritten or not. keys (dict) – Additional key-value-pairs to include in the database. data (dict) – Additional data to include in the database. del_info (list) – Keys to be removed from the data of key_value_pairs of the database file.
write_poscar()[source]

Write POSCAR file.

write_potcar()[source]

Write POTCAR file.

POTCARs are expected to reside in self.conf[‘vasp_potentials’].

Parameters: fname (str) – output file name