Utility module implementing several methods for parsing and interacting with VASP potential files.
PotcarParser(path_to_potcar_file, name=None, functional=None)¶
Minimalistic 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.
Update invalid and erroneous parameters running the stored quirks
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: str
Load POTCAR file contents.
Returns: the contents of the potcar file Return type: str
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: str
Extract the element stored with the potential
Returns: string containing the element name Return type: str Raises: PotcarParserError – if regex returns with no match
Extract header section from potential contents
Returns: string containing the potential header Return type: str Raises: PotcarParserError – if regex returns with no match
Extract the potential title (i.e. the first line of the file)
Extract creation date from the potential header
Returns: integer representation of the potential creation date Return type: int
Check if the parsed contents do make sense.
Utility 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 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: str Raises: PotcarPathError – if no valid functional identifier can be found in the given 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: str
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