aiida_pseudo.groups.family.pseudo#

Subclass of Group that serves as a base class for representing pseudo potential families.

Module Contents#

Classes#

PseudoPotentialFamily

Group to represent a pseudo potential family.

class aiida_pseudo.groups.family.pseudo.PseudoPotentialFamily(*args, **kwargs)#

Bases: aiida.orm.Group

Group 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_types is not defined, any pseudo potential type is accepted in this family, as long as it is a subclass of PseudoPotentialData. Subclasses can limit which pseudo types can be hosted by setting _pseudo_types to a tuple of PseudoPotentialData subclasses.

property pseudo_type#

Return the type of the pseudopotentials that are hosted by this family.

Returns:

the pseudopotential type or None if none has been set yet.

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

_key_pseudo_type = '_pseudo_type'#
_pseudo_types = ()#
_pseudos#
__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 PseudoPotentialData that this family can host nodes of. If it returns None, that means all subclasses are supported.

classmethod _validate_pseudo_type(pseudo_type)#

Validate the pseudo_type passed to parse_pseudos_from_directory.

Returns:

the pseudo type to be used.

classmethod _validate_dirpath(dirpath)#

Validate the dirpath passed to parse_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 PseudoPotentialData to be used for the parsed pseudos. If not specified and the family only defines a single supported pseudo type in _pseudo_types then that will be used otherwise a ValueError is 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 dirpath is not a directory or contains anything other than files.

  • ValueError – if dirpath contains multiple pseudo potentials for the same element.

  • ValueError – if pseudo_type is explicitly specified and is not supported by this family class.

  • ValueError – if pseudo_type is 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 PseudoPotentialFamily from 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 PseudoPotentialData to be used for the parsed pseudos. If not specified and the family only defines a single supported pseudo type in _pseudo_types then that will be used otherwise a ValueError is 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 PseudoPotentialFamily already exists with the given name.

  • ValueError – if dirpath is not a directory or contains anything other than files.

  • ValueError – if dirpath contains multiple pseudo potentials for the same element.

  • ValueError – if pseudo_type is explicitly specified and is not supported by this family class.

  • ValueError – if pseudo_type is 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.

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 Node instances of type that is in PseudoPotentialFamily._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 PseudoPotentialData instances or subclasses thereof.

clear()#

Remove all the pseudopotentials from this family.

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: StructureData = None) Mapping[str, StructureData]#

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 StructureData node.

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.