aiida_cusp.utils.potcar module
Utility module implementing several methods for parsing and interacting with VASP potential files.
- class aiida_cusp.utils.potcar.PotcarParser(path_to_potcar_file, name=None, functional=None)
Bases:
objectMinimalistic parsing library for VASP POTCAR files.
Only tries to parse the basic potential identifiers from the file, i.e. the potential version and the associated element. Does not perform any checks on the validity of the parsed results but only raises if no match was retrieved at all.
- Parameters:
path_to_potcar_file (pathlib.Path) – path to a VASP POTCAR file
name (str) – name of the potential (i.e. Li, Li_sv, …)
functional (str) – functional of the potential, i.e. one of lda_us, lda, lda_52, lda_54, pbe, pbe_52, pbe_54, pw91 or pw91_us
- apply_quirks()
Update invalid and erroneous parameters running the stored quirks
- hash_contents()
Hash potential contents using secure hashing.
Calculates the hash based on the reduced instead of the full potential contents to avoid potentials being assumed as different if whitespaces differ.
- Returns:
return sha256 hash for potential contents
- Return type:
- load_potential_contents()
Load POTCAR file contents.
- Returns:
the contents of the potcar file
- Return type:
- load_reduced_contents()
Load POTCAR file contents and return a reduced version without consecutive whitespaces and occasionally occuring ‘^’ chars
- Returns:
returns the reduced contents of the potcar file
- Return type:
- potential_element()
Extract the element stored with the potential
- Returns:
string containing the element name
- Return type:
- Raises:
PotcarParserError – if regex returns with no match
- potential_header()
Extract header section from potential contents
- Returns:
string containing the potential header
- Return type:
- Raises:
PotcarParserError – if regex returns with no match
- potential_title()
Extract the potential title (i.e. the first line of the file)
- potential_version()
Extract creation date from the potential header
- Returns:
integer representation of the potential creation date
- Return type:
- verify_parsed()
Check if the parsed contents do make sense.
- class aiida_cusp.utils.potcar.PotcarPathParser(potcar_file_path)
Bases:
objectUtility class for parsing POTCAR file paths.
Assumes a POTCAR file path of the form /path/[FUNCTIONAL]/[NAME]/POTCAR with [FUNCTIONAL] containing the archive name of the potential libraries as shipped by VASP, i.e. one of potuspp_lda, potpaw_lda, potpaw_lda.52, potpaw_lda.54, potpaw_pbe, potpaw_pbe.52, potpaw_pbe.54, potuspp_gga or potpaw_gga. Tries to determine the potential’s functional and name from the given path and raises an exception if this fails.
- Parameters:
potcar_file_path (pathlib.Path) – file path pointing to a VASP pseudo-potential
- Raises:
PotcarPathError – if the path does not point to a POTCAR file or if the path does not contain a valid archive name to identify the corresponding functional
- parse_functional(path)
Parse the potential’s functional type from the given path.
Search the given path for functional identifiers corresponding to the archive names chosen by the pseudo-potential libraries shipped with VASP.
- Parameters:
path (pathlib.Path) – file path pointing to a VASP pseudo-potential
- Returns:
plugin internal functional identifier
- Return type:
- Raises:
PotcarPathError – if no valid functional identifier can be found in the given path.
- parse_name(path)
Parse the unique functional name from the path.
Simply returns the name of the parent folder containing the POTCAR file.
- Parameters:
path (pathlib.Path) – file path pointing to a VASP pseudo-potential
- Returns:
the pseudo-potential’s unique name
- Return type:
- validate_path_is_potcar_file(path)
Check if the given path points to a file of type POTCAR .
- Parameters:
path (pathlib.Path) – file path pointing to a VASP pseudo-potential
- Raises:
PotcarPathError – if the parser cannot extract the functional from the path or if the path does not point to a potential