aiida_pseudo.groups.family#
Module with group plugins to represent pseudo potential families.
Submodules#
Attributes#
Classes#
Subclass of |
|
Group to represent a pseudo potential family. |
|
Named tuple that represents a PseudoDojo configuration. |
|
Subclass of |
|
Named tuple that represents an SSSP configuration. |
|
Subclass of |
Package Contents#
- class aiida_pseudo.groups.family.CutoffsPseudoPotentialFamily(*args, **kwargs)#
Bases:
aiida_pseudo.groups.mixins.RecommendedCutoffMixin,aiida_pseudo.groups.family.pseudo.PseudoPotentialFamilySubclass of
PseudoPotentialFamilydesigned to represent a family with recommended cutoffs.This is mostly used for testing the functionality around the
RecommendedCutoffMixin.
- class aiida_pseudo.groups.family.PseudoPotentialFamily(*args, **kwargs)#
Bases:
aiida.orm.GroupGroup to represent a pseudo potential family.
This is a base class that provides most of the functionality but does not actually define what type of pseudo potentials can be contained. If
_pseudo_typesis not defined, any pseudo potential type is accepted in this family, as long as it is a subclass ofPseudoPotentialData. Subclasses can limit which pseudo types can be hosted by setting_pseudo_typesto a tuple ofPseudoPotentialDatasubclasses.- _key_pseudo_type = '_pseudo_type'#
- _pseudo_types#
- _pseudos = None#
- __repr__()#
Represent the instance for debugging purposes.
- __str__()#
Represent the instance for human-readable purposes.
- pseudo_types()#
Return the pseudo potential types that this family accepts.
- Returns:
the tuple of subclasses of
PseudoPotentialDatathat this family can host nodes of. If it returnsNone, that means all subclasses are supported.
- classmethod _validate_pseudo_type(pseudo_type)#
Validate the
pseudo_typepassed toparse_pseudos_from_directory.- Returns:
the pseudo type to be used.
- classmethod _validate_dirpath(dirpath)#
Validate the
dirpathpassed toparse_pseudos_from_directory.- Returns:
the directory path to be used.
- classmethod parse_pseudos_from_directory(dirpath, pseudo_type=None, deduplicate=True)#
Parse the pseudo potential files in the given directory into a list of data nodes.
Note
The directory pointed to by dirpath should only contain pseudo potential files. Optionally, it can contain just a single directory, that contains all the pseudo potential files. If any other files are stored in the basepath or the subdirectory, that cannot be successfully parsed as pseudo potential files the method will raise a
ValueError.- Parameters:
dirpath – absolute path to a directory containing pseudo potentials.
pseudo_type – subclass of
PseudoPotentialDatato be used for the parsed pseudos. If not specified and the family only defines a single supported pseudo type in_pseudo_typesthen that will be used otherwise aValueErroris raised.deduplicate – if True, will scan database for existing pseudo potentials of same type and with the same md5 checksum, and use that instead of the parsed one.
- Returns:
list of data nodes
- Raises:
ValueError – if
dirpathis not a directory or contains anything other than files.ValueError – if
dirpathcontains multiple pseudo potentials for the same element.ValueError – if
pseudo_typeis explicitly specified and is not supported by this family class.ValueError – if
pseudo_typeis not specified and the class supports more than one pseudo type.ParsingError – if the constructor of the pseudo type fails for one of the files in the
dirpath.
- classmethod create_from_folder(dirpath, label, *, description='', pseudo_type=None, deduplicate=True)#
Create a new
PseudoPotentialFamilyfrom the pseudo potentials contained in a directory.- Parameters:
dirpath – absolute path to the folder containing the UPF files.
label – label to give to the
PseudoPotentialFamily, should not already exist.description – description to give to the family.
pseudo_type – subclass of
PseudoPotentialDatato be used for the parsed pseudos. If not specified and the family only defines a single supported pseudo type in_pseudo_typesthen that will be used otherwise aValueErroris raised.deduplicate – if True, will scan database for existing pseudo potentials of same type and with the same md5 checksum, and use that instead of the parsed one.
- Raises:
ValueError – if a
PseudoPotentialFamilyalready exists with the given name.ValueError – if
dirpathis not a directory or contains anything other than files.ValueError – if
dirpathcontains multiple pseudo potentials for the same element.ValueError – if
pseudo_typeis explicitly specified and is not supported by this family class.ValueError – if
pseudo_typeis not specified and the class supports more than one pseudo type.ParsingError – if the constructor of the pseudo type fails for one of the files in the
dirpath.
- property pseudo_type#
Return the type of the pseudopotentials that are hosted by this family.
- Returns:
the pseudopotential type or
Noneif none has been set yet.
- update_pseudo_type()#
Update the pseudo type, stored as an extra, based on the current nodes in the family.
- add_nodes(nodes)#
Add a node or a set of nodes to the family.
- Parameters:
nodes – a single or list of
Nodeinstances of type that is inPseudoPotentialFamily._pseudo_types.- Raises:
ModificationNotAllowed – if the family is not stored.
TypeError – if nodes are not an instance or list of instance of any of the classes listed by
PseudoPotentialFamily._pseudo_types.ValueError – if any of the nodes are not stored or their elements already exist in this family.
- remove_nodes(nodes)#
Remove a pseudopotential or a set of pseudopotentials from the family.
- Parameters:
nodes – a single or list of
PseudoPotentialDatainstances or subclasses thereof.
- clear()#
Remove all the pseudopotentials from this family.
- property pseudos#
Return the dictionary of pseudo potentials of this family indexed on the element symbol.
- Returns:
dictionary of element symbol mapping pseudo potentials
- property elements#
Return the list of elements for which this family defines a pseudo potential.
- Returns:
list of element symbols
- get_pseudo(element)#
Return the pseudo potential for the given element.
- Parameters:
element – the element for which to return the corresponding pseudo potential.
- Returns:
pseudo potential instance if it exists
- Raises:
ValueError – if the family does not contain a pseudo potential for the given element
- get_pseudos(*, elements: List[str] | Tuple[str] | None = None, structure: structures_classes = None) Mapping[str, structures_classes]#
Return the mapping of kind names on pseudo potential data nodes for the given list of elements or structure.
- Parameters:
elements – list of element symbols.
structure – the
StructureDataorLegacyStructureDatanode.
- Returns:
dictionary mapping the kind names of a structure on the corresponding pseudo potential data nodes.
- Raises:
ValueError – if the family does not contain a pseudo for any of the elements of the given structure.
- class aiida_pseudo.groups.family.PseudoDojoConfiguration#
Bases:
NamedTupleNamed tuple that represents a PseudoDojo configuration.
- version: str#
- functional: str#
- relativistic: str#
- protocol: str#
- pseudo_format: str#
- __str__()#
Represent the configuration as a string.
- class aiida_pseudo.groups.family.PseudoDojoFamily(label=None, **kwargs)#
Bases:
aiida_pseudo.groups.mixins.RecommendedCutoffMixin,aiida_pseudo.groups.family.pseudo.PseudoPotentialFamilySubclass of
PseudoPotentialFamilydesigned to represent a PseudoDojo configuration.The
PseudoDojoFamilyis essentially aPseudoPotentialFamilywith some additional constraints. It can only be used to contain the pseudo potentials and corresponding metadata of an official PseudoDojo configuration.- _pseudo_types#
- _pseudo_repo_file_extensions = ('djrepo',)#
- label_template = 'PseudoDojo/{version}/{functional}/{relativistic}/{protocol}/{pseudo_format}'#
- default_configuration#
- valid_configurations#
- url_base = 'http://www.pseudo-dojo.org/pseudos/'#
- urls: ClassVar[dict[str, str]]#
- classmethod get_valid_labels() Sequence[str]#
Return the tuple of labels of all valid PseudoDojo configurations.
- classmethod format_configuration_label(configuration: PseudoDojoConfiguration) str#
Format a label for an PseudoDojoFamily with the required syntax.
- Parameters:
configuration – the PseudoDojo configuration.
- Returns:
label.
- classmethod get_url_archive(label)#
Return the URL for the pseudopotential archive file for a given family label.
- Parameters:
label – the family label as formatted by
format_configuration_label.- Returns:
the URL from which the pseudopotential archive can be downloaded.
- Raises:
ValueError if the label is not a valid configuration label.
- classmethod get_url_metadata(label)#
Return the URL for the pseudopotential metadata file for a given family label.
- Parameters:
label – the family label as formatted by
format_configuration_label.- Returns:
the URL from which the pseudopotential metadata can be downloaded.
- Raises:
ValueError if the label is not a valid configuration label.
- classmethod get_md5_from_djrepo(djrepo, pseudo_type)#
Get the appropriate md5 hash from a DJREPO file.
- Parameters:
djrepo – dictionary loaded from DJREPO JSON file.
- Reutnrs:
md5 string.
- classmethod get_cutoffs_from_djrepo(djrepo, pseudo_type)#
Collect and organize the suggested cutoffs (hints) from a DJREPO file.
DJREPO files only provide a kinetic energy cutoff, so for pseudo types which contain norm-conserving pseudos from PseudoDojo, we use a dual of 8.0 to generate the charge density (rho) cutoff.
For PAW potentials from PseudoDojo (which are assumed to be JthXmlData), a dual of 2.0 is used.
The cutoffs in DJREPO files are given in Hartree, which is converted to eV.
- Parameters:
djrepo – dictionary loaded from DJREPO JSON file
- Returns:
cutoffs dictionary (in eV) where keys are stringency levels and values are {‘cutoff_wfc’: …, ‘cutoff_rho’: …}
- classmethod parse_djrepos_from_folder(dirpath: pathlib.Path, pseudo_type)#
Parse the djrepo files in the given directory into a list of data nodes.
Note
The directory pointed to by dirpath should only contain djrepo files. Optionally, it can contain just a single directory, that contains all the djrepo files. If any other files are stored in the basepath or the subdirectory that cannot be successfully parsed as djrepo files the method will raise a ValueError.
- Parameters:
dirpath – absolute path to a directory containing djrepos.
- Returns:
list of data nodes.
- Raises:
ValueError – if dirpath is not a directory or contains anything other than files.
ValueError – if dirpath contains multiple djrepos for the same element.
ParsingError – if the constructor of the pseudo type fails for one of the files in the dirpath.
- classmethod parse_djrepos_from_archive(filepath_metadata: pathlib.Path, fmt=None, pseudo_type=None)#
Parse metadata from a djrepo .tgz archive.
Warning
the archive should not contain any subdirectories, but just the djrepo files.
- Parameters:
filepath_metadata – the path to the metadata .tgz archive.
fmt – the format of the archive, if not specified will attempt to guess based on extension of filepath.
pseudo_type – subclass of
PseudoPotentialDatato be used for the parsed pseudos. If not specified and the family only defines a single supported pseudo type in_pseudo_typesthen that will be used otherwise aValueErroris raised.
- Returns:
element: value dictionaries containing md5s and cutoffs.
- Raises:
OSError – if the archive could not be unpacked or the djrepos in it could not be parsed into md5s and cutoffs.
- class aiida_pseudo.groups.family.SsspConfiguration#
Bases:
NamedTupleNamed tuple that represents an SSSP configuration.
- version: str#
- functional: str#
- protocol: str#
- __str__()#
Represent the configuration as a string.
- class aiida_pseudo.groups.family.SsspFamily(label=None, **kwargs)#
Bases:
aiida_pseudo.groups.mixins.RecommendedCutoffMixin,aiida_pseudo.groups.family.pseudo.PseudoPotentialFamilySubclass of
PseudoPotentialFamilydesigned to represent an SSSP configuration.The
SsspFamilyis essentially aPseudoPotentialFamilywith some additional constraints. It can only be used to contain the pseudo potentials and corresponding metadata of an official SSSP configuration.- _pseudo_types#
- label_template = 'SSSP/{version}/{functional}/{protocol}'#
- filename_template = 'SSSP_{version}_{functional}_{protocol}'#
- default_configuration#
- valid_configurations#
- classmethod get_valid_labels() Sequence[str]#
Return the tuple of labels of all valid SSSP configurations.
- classmethod format_configuration_label(configuration: SsspConfiguration) str#
Format a label for an SsspFamily with the required syntax.
- Parameters:
configuration – the SSSP configuration
- Returns:
label
- classmethod format_configuration_filename(configuration: SsspConfiguration, extension: str, patch_version: str | None = None) str#
Format the filename for a file of a particular SSSP configuration as it is available from MC Archive.
- Parameters:
configuration – the SSSP configuration.
extension – the filename extension without the leading dot.
patch_version – patch version of the files which overrides the
versionspecified in theconfiguration. This is necessary because we only let users specify the minor version, not install configurations with a specific patch version. The filename on the archive however will contain the patch version, so this needs to be substituted.
- Returns:
filename
- aiida_pseudo.groups.family.__all__#