aiida_castep.data package#

Submodules#

aiida_castep.data.otfg module#

Storing OTFG configuration as Data nodes

class aiida_castep.data.otfg.OTFGData(**kwargs)[source]#

Bases: Data

Class representing an OTFG configuration

__abstractmethods__ = frozenset({})#
__init__(**kwargs)[source]#

Store a string for on-the-fly generation of pseudopotentials

Parameters:

str (otfg_entry) – a string specifying the generation.

The element this potential is for can also be included. For example: ‘O 2|1.1|15|18|20|20:21(qc=7)’

__module__ = 'aiida_castep.data.otfg'#
__parameters__ = ()#
_abc_impl = <_abc_data object>#
_logger: Optional[Logger] = <Logger aiida_castep.data.otfg.OTFGData (WARNING)>#
_plugin_type_string: ClassVar[str] = 'data.castep.otfgdata.OTFGData.'#
_query_type_string: ClassVar[str] = 'data.castep.otfgdata.'#
_validate()[source]#

Validate the format of OTFG configuration

property element#

Element of the OTFG. May not be available

property entry#

Plain format of the OTFG

classmethod from_entry(entry)[source]#

Return a list of OTFG that matches with the string

classmethod get_or_create(otfg_entry, use_first=False, store_otfg=True)[source]#

Create or retrieve OTFG from database :param otfg_entry: CASTEP styled OTFG entry. Can either be the name of library (e.g C9) or the full specification with element like: “O 2|1.1|15|18|20|20:21(qc=7)”

The created OTFGData node will by default labelled by the fully entry.

classmethod get_otfg_group(group_label)[source]#

Return the OTFGData group with the given name.

classmethod get_otfg_groups(filter_elements=None, user=None)[source]#

Return all names of groups of type otfg, possibly with some filters.

Parameters:
  • filter_elements – A string or a list of strings. If present, returns only the groups that contains one Usp for every element present in the list. Default=None, meaning that all families are returned.

  • user – if None (default), return the groups for all users. If defined, it should be either a DbUser instance, or a string for the user name (that is, the user email).

otfg_family_type_string = 'castep.otfg'#
set_element(element)[source]#

Set the element of OTFGData instance

set_string(otfg_entry)[source]#

Set the full string of OTFGData instance

store(*args, **kwargs)[source]#

Store the node in the database while saving its attributes and repository directory.

After being called attributes cannot be changed anymore! Instead, extras can be changed only AFTER calling this store() function.

Note:

After successful storage, those links that are in the cache, and for which also the parent node is already stored, will be automatically stored. The others will remain unstored.

Parameters:

with_transaction – if False, do not use a transaction because the caller will already have opened one.

property string#
class aiida_castep.data.otfg.OTFGGroup(label: Optional[str] = None, user: Optional[User] = None, description: str = '', type_string: Optional[str] = None, backend: Optional[StorageBackend] = None)[source]#

Bases: Group

Class representing an OTFGGroup

__abstractmethods__ = frozenset({})#
__module__ = 'aiida_castep.data.otfg'#
__parameters__ = ()#
_abc_impl = <_abc_data object>#
_type_string: ClassVar[Optional[str]] = 'castep.otfg'#
aiida_castep.data.otfg.migrate_otfg_family()[source]#

Migrate the old OTFG families to new families

aiida_castep.data.otfg.upload_otfg_family(entries, group_label, group_description, stop_if_existing=True)[source]#

Set a family for the OTFG pseudo potential strings

aiida_castep.data.usp module#

Module for storing usp files into the database

class aiida_castep.data.usp.UspData(**kwargs)[source]#

Bases: SinglefileData

Class for a single usp file These usp files are stored as individual file nodes in the database

__abstractmethods__ = frozenset({})#
__init__(**kwargs)[source]#

Initialize a UspData node :param file str: A full path to the file of the potential :param filename str: The filename needs to be used if file is a file-like object. :param element: The element that this pseudo potential should be used for

__module__ = 'aiida_castep.data.usp'#
__parameters__ = ()#
_abc_impl = <_abc_data object>#
_logger: Optional[Logger] = <Logger aiida_castep.data.usp.UspData (WARNING)>#
_plugin_type_string: ClassVar[str] = 'data.castep.uspdata.UspData.'#
_query_type_string: ClassVar[str] = 'data.castep.uspdata.'#
_validate()[source]#

Ensure that there is one object stored in the repository, whose key matches value set for filename attr.

property element#
classmethod from_md5(md5)[source]#

Return a list of all usp pseudopotentials that match a given MD5 hash.

Note that the hash has to be stored in a md5 attribute, otherwise the pseudo will not be found. We use a special md5 attribute to avoid searching through irrelevant data types.

classmethod get_or_create(filename, element=None, use_first=False, store_usp=True)[source]#

Same ase init. Check md5 in the db, it is found return a UspData. Otherwise will store the data into the db

:return (usp, created)

classmethod get_usp_group(group_label)[source]#

Return the UspFamily group with the given name.

classmethod get_usp_groups(filter_elements=None, user=None)[source]#

Return all names of groups of type UpfFamily, possibly with some filters.

Parameters:
  • filter_elements – A string or a list of strings. If present, returns only the groups that contains one Upf for every element present in the list. Default=None, meaning that all families are returned.

  • user – if None (default), return the groups for all users. If defined, it should be either a DbUser instance, or a string for the username (that is, the user email).

property md5sum#

MD5 sum of the usp/recpot file

set_element(element)[source]#

Set the element

set_file(file, filename=None)[source]#

Extract element and compute the md5hash

store(*args, **kwargs)[source]#

Store the node. Automatically set md5 and element

property string#

Alias of the md5sum

uspfamily_type_string = 'castep.otfg'#
aiida_castep.data.usp.upload_usp_family(folder, group_label, group_description, stop_if_existing=True)[source]#

Upload a set of usp/recpot files in a give group

Parameters:
  • folder – a path containing all UPF files to be added. Only files ending in .usp/.recpot are considered.

  • group_label – the name of the group to create. If it exists and is non-empty, a UniquenessError is raised.

  • group_description – a string to be set as the group description. Overwrites previous descriptions, if the group was existing.

  • stop_if_existing – if True, check for the md5 of the files and, if the file already exists in the DB, raises a MultipleObjectsError. If False, simply adds the existing UPFData node to the group.

aiida_castep.data.utils module#

Utilities module This module does not have top level AiiDA orm imports

aiida_castep.data.utils.get_usp_element(filepath)[source]#

infer element from usp/recpot filename :return element: a string of element name or None if not found

aiida_castep.data.utils.split_otfg_entry(otfg)[source]#

Split an entry of otfg in the form of element_settings :returns (element, entry):

Module contents#

Module for additional Data classes

aiida_castep.data._get_pseudos_from_aiida_pseudo(structure, label)[source]#

Attempt to get pseudopotentials that are managed by the aiida-pseudo package

Parameters:
  • structure – A StructureData for which the pseudopotentials needs to be selected.

  • label – The name of the pseudopotential family

Returns:

A dictionary of each element and its pseudopotential.

aiida_castep.data.get_pseudos_from_structure(structure, family_name)[source]#

Given a family name (of UpfData or OTFGData) and a AiiDA structure, return a dictionary associating each kind name with its pseduopotential object.

Raises:
  • MultipleObjectsError – if more than one UPF for the same element is found in the group.

  • NotExistent – if no UPF for an element in the group is found in the group.

Returns:

A dictionary maps kind to the psueodpotential node