dfttopif.parsers.base module

class dfttopif.parsers.base.DFTParser(directory)[source]

Bases: object

Base class for all tools to parse a directory of output files from a DFT Calculation

To use this class, provide the path to a directory to containing the output files from a DFT calculation. Once
instantiated, call the methods provided by this class in order to retrieve the settings and results of the calculation.
To get a list of names of the settings available for this a particular instance, call get_setting_functions(). These
methods return a pypif Value object.
To get a list of the names of results available via a particular instance, call get_result_functions(). These
methods return a pypif Property object.
Settings and properties should...
return None if property or setting is not applicable, or if the test is a boolean and the value is false Raise exception if there is an error that would benefit from user intervention
To add a new setting or value to the output, add a new entry to the dictionary returned by get_setting_functions()
or get_result_functions(). The key for each entry is a ‘human-friendly’ name of the result and the value is the name of the function. This design was chosen because there is a single function for defining the human names of the results, which are what serve as the tags in the pif file. In this way, the same property will be ensured to have the same name in the pif.
__init__(directory)[source]

Initialize a parser.

Input:
directory - String, path to a directory of output files
get_KPPRA()[source]

Read output and calculate the number of k-points per reciprocal atom

Returns:
Value, number of k-points per reciprocal atom
get_U_settings()[source]

Get the DFT+U settings, if used

Returns: Value, which could contain several keys
‘Type’ -> String, type of DFT+U employed ‘Values’ -> dict of Element -> (L, U, J)

Note: Returns None if DFT+U was not used

get_band_gap()[source]

Get the band gap energy

Returns: Property

get_composition()[source]

Get composition of output structure

Returns:
String - Composition based on output structure
get_cutoff_energy()[source]

Read the cutoff energy from the output

Returns:
Value, cutoff energy (scalar) and units
get_dos()[source]

Get the total density of states

Returns: Property where DOS is a vector, and the energy at which the DOS was evaluated is a condition

get_name()[source]

Get the name of this program

get_output_structure()[source]

Get the output structure, if available

Returns:
ase.Atoms - Output structure from this calculation
or None if output file not found
get_positions()[source]
get_pp_name()[source]

Read output to get the pseudopotentials names used for each elements

Returns:
Value where the key “scalars” is the list of pseudopotentials names
get_pressure()[source]

Get the pressure acting on the system

Returns: Property, where pressure is a scalar

get_result_functions()[source]

Get a dictionary describing the names of methods that return results of the calculation

Returns:
dict, where the key is the name of a property,
and the value is the name of the function
get_setting_functions()[source]

Get a dictionary containing the names of methods that return settings of the calculation

Returns:
dict, where the key is the name of the setting,
and the value is function name of this parser
get_stresses()[source]

Get the stress tensor

Returns: Property where stresses is a 2d matrix

get_total_energy()[source]

Get the total energy of the last ionic step

Returns: Property

get_vdW_settings()[source]

Get the vdW settings, if applicable

Returns: Value where scalars is the name of the vdW method. None if vdW was not used

get_version_number()[source]

Get the version number of code that created these output files

Returns:
string, Version number
get_xc_functional()[source]

Parse the output file to tell which exchange-correlation functional was used

Returns:
Value - where “scalars” is the name of the functional
is_converged()[source]

Whether the calculation has converged

Returns: Property where “scalar” is a boolean indicating

is_relaxed()[source]

Parse the output file to tell if the structure was relaxed

Returns:
Blank Value if true, None otherwise
classmethod test_if_from(directory)[source]

Test whether a directory of output files seems like it is from this DFT code.

Input:
directory - String, path to a directory of output files
Returns:
boolean, whether directory was created by this code
uses_SOC()[source]

Parse the output file to tell if spin-orbit coupling was used

Returns:
Blank Value if true, None otherwise
dfttopif.parsers.base.Value_if_true(func)[source]

Returns: Value if x is True, else None