# aiida.restapi.translator.nodes.data package#

Translator for data node

class aiida.restapi.translator.nodes.data.DataTranslator(**kwargs)[source]#

Translator relative to resource ‘data’ and aiida class ~aiida.orm.nodes.data.data.Data

class Data(*args, source=None, **kwargs)#

The base class for all Data nodes.

AiiDA Data classes are subclasses of Node and must support multiple inheritance.

Architecture note: Calculation plugins are responsible for converting raw output data from simulation codes to Data nodes. Nodes are responsible for validating their content (see _validate method).

__abstractmethods__ = frozenset({})#
__annotations__ = {'_CLS_COLLECTION': 'Type[CollectionType]', '_export_format_replacements': typing.Dict[str, str], '_hash_ignored_attributes': 'Tuple[str, ...]', '_logger': 'Optional[Logger]', '_plugin_type_string': 'ClassVar[str]', '_query_type_string': 'ClassVar[str]', '_updatable_attributes': 'Tuple[str, ...]'}#
__copy__()#

Copying a Data node is not supported, use copy.deepcopy or call Data.clone().

__deepcopy__(memo)#

Create a clone of the Data node by piping through to the clone method and return the result.

Returns

an unstored clone of this Data node

__init__(*args, source=None, **kwargs)#

Construct a new instance, setting the source attribute if provided as a keyword argument.

__module__ = 'aiida.orm.nodes.data.data'#
__parameters__ = ()#
_abc_impl = <_abc_data object>#
_export_format_replacements: Dict[str, str] = {}#
_exportcontent(fileformat, main_file_name='', **kwargs)#

Converts a Data node to one (or multiple) files.

Note: Export plugins should return utf8-encoded bytes, which can be directly dumped to file.

Parameters
• fileformat (str) – the extension, uniquely specifying the file format.

• main_file_name (str) – (empty by default) Can be used by plugin to infer sensible names for additional files, if necessary. E.g. if the main file is ‘../myplot.gnu’, the plugin may decide to store the dat file under ‘../myplot_data.dat’.

• kwargs – other parameters are passed down to the plugin

Returns

a tuple of length 2. The first element is the content of the otuput file. The second is a dictionary (possibly empty) in the format {filename: filecontent} for any additional file that should be produced.

Return type

(bytes, dict)

_get_converters()#

Get all implemented converter formats. The convention is to find all _get_object_… methods. Returns a list of strings.

_get_exporters()#

Get all implemented export formats. The convention is to find all _prepare_… methods. Returns a dictionary of method_name: method_function

_get_importers()#

Get all implemented import formats. The convention is to find all _parse_… methods. Returns a list of strings.

_logger: Optional[Logger] = <Logger aiida.orm.nodes.data.data.Data (REPORT)>#
_plugin_type_string: ClassVar[str] = 'data.Data.'#
_query_type_string: ClassVar[str] = 'data.'#
_source_attributes = ['db_name', 'db_uri', 'uri', 'id', 'version', 'extras', 'source_md5', 'description', 'license']#
_storable = True#
_unstorable_message = 'storing for this node has been disabled'#
clone()#

Create a clone of the Data node.

Returns

an unstored clone of this Data node

convert(object_format=None, *args)#

Convert the AiiDA StructureData into another python object

Parameters

object_format – Specify the output format

property creator#

Return the creator of this node or None if it does not exist.

Returns

the creating node or None

export(path, fileformat=None, overwrite=False, **kwargs)#

Save a Data object to a file.

Parameters
• fname – string with file name. Can be an absolute or relative path.

• fileformat – kind of format to use for the export. If not present, it will try to use the extension of the file name.

• overwrite – if set to True, overwrites file found at path. Default=False

• kwargs – additional parameters to be passed to the _exportcontent method

Returns

the list of files created

classmethod get_export_formats()#

Get the list of valid export format strings

Returns

a list of valid formats

importfile(fname, fileformat=None)#

Populate a Data object from a file.

Parameters
• fname – string with file name. Can be an absolute or relative path.

• fileformat – kind of format to use for the export. If not present, it will try to use the extension of the file name.

importstring(inputstring, fileformat, **kwargs)#

Converts a Data object to other text format.

Parameters

fileformat – a string (the extension) to describe the file format.

Returns

a string with the structure description.

set_source(source)#

Sets the dictionary describing the source of Data object.

property source#

Gets the dictionary describing the source of Data object. Possible fields:

• db_name: name of the source database.

• db_uri: URI of the source database.

• uri: URI of the object’s source. Should be a permanent link.

• id: object’s source identifier in the source database.

• version: version of the object’s source.

• extras: a dictionary with other fields for source description.

• source_md5: MD5 checksum of object’s source.

• description: human-readable free form description of the object’s source.

Note

some limitations for setting the data source exist, see _validate method.

Returns

dictionary describing the source of Data object.

__label__ = 'data'#
__module__ = 'aiida.restapi.translator.nodes.data'#
_aiida_class#
_aiida_type = 'data.Data'#
_result_type = 'data'#

Parameters

Returns

## Submodules#

Translator for CifData

class aiida.restapi.translator.nodes.data.cif.CifDataTranslator(**kwargs)[source]#

Translator relative to resource ‘structures’ and aiida class CifData

class CifData(ase=None, file=None, filename=None, values=None, scan_type=None, parse_policy=None, **kwargs)#

Wrapper for Crystallographic Interchange File (CIF)

Note

the file (physical) is held as the authoritative source of information, so all conversions are done through the physical file: when setting ase or values, a physical CIF file is generated first, the values are updated from the physical CIF file.

_PARSE_POLICIES = ('eager', 'lazy')#
_PARSE_POLICY_DEFAULT = 'eager'#
_SCAN_TYPES = ('standard', 'flex')#
_SCAN_TYPE_DEFAULT = 'standard'#
_SET_INCOMPATIBILITIES = [('ase', 'file'), ('ase', 'values'), ('file', 'values')]#
__abstractmethods__ = frozenset({})#
__annotations__ = {'_CLS_COLLECTION': 'Type[CollectionType]', '_export_format_replacements': typing.Dict[str, str], '_hash_ignored_attributes': 'Tuple[str, ...]', '_logger': 'Optional[Logger]', '_plugin_type_string': 'ClassVar[str]', '_query_type_string': 'ClassVar[str]', '_updatable_attributes': 'Tuple[str, ...]'}#
__init__(ase=None, file=None, filename=None, values=None, scan_type=None, parse_policy=None, **kwargs)#

Construct a new instance and set the contents to that of the file.

Parameters
• file – an absolute filepath or filelike object for CIF. Hint: Pass io.BytesIO(b”my string”) to construct the SinglefileData directly from a string.

• filename – specify filename to use (defaults to name of provided file).

• ase – ASE Atoms object to construct the CifData instance from.

• values – PyCifRW CifFile object to construct the CifData instance from.

• scan_type – scan type string for parsing with PyCIFRW (‘standard’ or ‘flex’). See CifFile.ReadCif

• parse_policy – ‘eager’ (parse CIF file on set_file) or ‘lazy’ (defer parsing until needed)

__module__ = 'aiida.orm.nodes.data.cif'#
__parameters__ = ()#
_abc_impl = <_abc_data object>#
_ase = None#
_get_object_ase()#

Converts CifData to ase.Atoms

Returns

an ase.Atoms object

_get_object_pycifrw()#

Converts CifData to PyCIFRW.CifFile

Returns

a PyCIFRW.CifFile object

_logger: Optional[Logger] = <Logger aiida.orm.nodes.data.cif.CifData (REPORT)>#
_plugin_type_string: ClassVar[str] = 'data.core.cif.CifData.'#
_prepare_cif(**kwargs)#

Return CIF string of CifData object.

If parsed values are present, a CIF string is created and written to file. If no parsed values are present, the CIF string is read from file.

_query_type_string: ClassVar[str] = 'data.core.cif.'#
_validate()#

Validates MD5 hash of CIF file.

_values = None#
property ase#

ASE object, representing the CIF.

Note

requires ASE module.

classmethod from_md5(md5, backend=None)#

Return a list of all CIF files that match a given MD5 hash.

Note

the hash has to be stored in a _md5 attribute, otherwise the CIF file will not be found.

generate_md5()#

Computes and returns MD5 hash of the CIF file.

get_ase(**kwargs)#

Returns ASE object, representing the CIF. This function differs from the property ase by the possibility to pass the keyworded arguments (kwargs) to ase.io.cif.read_cif().

Note

requires ASE module.

get_formulae(mode='sum', custom_tags=None)#

Return chemical formulae specified in CIF file.

Note: This does not compute the formula, it only reads it from the appropriate tag. Use refine_inline to compute formulae.

classmethod get_or_create(filename, use_first=False, store_cif=True)#

Pass the same parameter of the init; if a file with the same md5 is found, that CifData is returned.

Parameters
• filename – an absolute filename on disk

• use_first – if False (default), raise an exception if more than one CIF file is found. If it is True, instead, use the first available CIF file.

• store_cif (bool) – If false, the CifData objects are not stored in the database. default=True.

Return (cif, created)

where cif is the CifData object, and create is either True if the object was created, or False if the object was retrieved from the DB.

get_spacegroup_numbers()#

Get the spacegroup international number.

get_structure(converter='pymatgen', store=False, **kwargs)#

New in version 1.0: Renamed from _get_aiida_structure

Parameters
• converter – specify the converter. Default ‘pymatgen’.

• store – if True, intermediate calculation gets stored in the AiiDA database for record. Default False.

• primitive_cell – if True, primitive cell is returned, conventional cell if False. Default False.

• occupancy_tolerance – If total occupancy of a site is between 1 and occupancy_tolerance, the occupancies will be scaled down to 1. (pymatgen only)

• site_tolerance – This tolerance is used to determine if two sites are sitting in the same position, in which case they will be combined to a single disordered site. Defaults to 1e-4. (pymatgen only)

Returns
property has_atomic_sites#

Returns whether there are any atomic sites defined in the cif data. That is to say, it will check all the values for the _atom_site_fract_* tags and if they are all equal to ? that means there are no relevant atomic sites defined and the function will return False. In all other cases the function will return True

Returns

False when at least one atomic site fractional coordinate is not equal to ? and True otherwise

property has_attached_hydrogens#

Check if there are hydrogens without coordinates, specified as attached to the atoms of the structure.

Returns

True if there are attached hydrogens, False otherwise.

property has_partial_occupancies#

Return if the cif data contains partial occupancies

A partial occupancy is defined as site with an occupancy that differs from unity, within a precision of 1E-6

Returns

True if there are partial occupancies, False otherwise

property has_undefined_atomic_sites#

Return whether the cif data contains any undefined atomic sites.

An undefined atomic site is defined as a site where at least one of the fractional coordinates specified in the _atom_site_fract_* tags, cannot be successfully interpreted as a float. If the cif data contains any site that matches this description, or it does not contain any atomic site tags at all, the cif data is said to have undefined atomic sites.

Returns

boolean, True if no atomic sites are defined or if any of the defined sites contain undefined positions and False otherwise

property has_unknown_species#

Returns whether the cif contains atomic species that are not recognized by AiiDA.

The known species are taken from the elements dictionary in aiida.common.constants, with the exception of the “unknown” placeholder element with symbol ‘X’, as this could not be used to construct a real structure. If any of the formula of the cif data contain species that are not in that elements dictionary, the function will return True and False in all other cases. If there is no formulae to be found, it will return None

Returns

True when there are unknown species in any of the formulae, False if not, None if no formula found

parse(scan_type=None)#

Parses CIF file and sets attributes.

Parameters

scan_type – See set_scan_type

A wrapper method that simulates the behavior of the old function ase.io.cif.read_cif by using the new generic ase.io.read function.

Somewhere from 3.12 to 3.17 the tag concept was bundled with each Atom object. When reading a CIF file, this is incremented and signifies the atomic species, even though the CIF file do not have specific tags embedded. On reading CIF files we thus force the ASE tag to zero for all Atom elements.

set_ase(aseatoms)#

Set the contents of the CifData starting from an ASE atoms object

Parameters

aseatoms – the ASE atoms object

set_file(file, filename=None)#

Set the file.

If the source is set and the MD5 checksum of new file is different from the source, the source has to be deleted.

Parameters
• file – filepath or filelike object of the CIF file to store. Hint: Pass io.BytesIO(b”my string”) to construct the file directly from a string.

• filename – specify filename to use (defaults to name of provided file).

set_parse_policy(parse_policy)#

Set the parse policy.

Parameters

parse_policy – Either ‘eager’ (parse CIF file on set_file) or ‘lazy’ (defer parsing until needed)

set_scan_type(scan_type)#

Set the scan_type for PyCifRW.

The ‘flex’ scan_type of PyCifRW is faster for large CIF files but does not yet support the CIF2 format as of 02/2018. See the CifFile.ReadCif function

Parameters

scan_type – Either ‘standard’ or ‘flex’ (see _scan_types)

set_values(values)#

Set internal representation to values.

Warning: This also writes a new CIF file.

Parameters

values – PyCifRW CifFile object

Note

requires PyCifRW module.

store(*args, **kwargs)#

Store the node.

property values#

PyCifRW structure, representing the CIF datablocks.

Note

requires PyCifRW module.

__label__ = 'cifs'#
__module__ = 'aiida.restapi.translator.nodes.data.cif'#
_aiida_class#
_aiida_type = 'data.core.cif.CifData'#
_result_type = 'cifs'#
static get_derived_properties(node)[source]#

Generic function extended for cif. Currently it is not implemented.

Parameters

node – node object

Returns

empty dict

Translator for code

class aiida.restapi.translator.nodes.data.code.CodeTranslator(**kwargs)[source]#

Translator relative to resource ‘codes’ and aiida class Code

class Code(remote_computer_exec=None, local_executable=None, input_plugin_name=None, files=None, **kwargs)#

A code entity. It can either be ‘local’, or ‘remote’.

• Local code: it is a collection of files/dirs (added using the add_path() method), where one file is flagged as executable (using the set_local_executable() method).

• Remote code: it is a pair (remotecomputer, remotepath_of_executable) set using the set_remote_computer_exec() method.

For both codes, one can set some code to be executed right before or right after the execution of the code, using the set_preexec_code() and set_postexec_code() methods (e.g., the set_preexec_code() can be used to load specific modules required for the code to be run).

HIDDEN_KEY = 'hidden'#
__abstractmethods__ = frozenset({})#
__annotations__ = {'_CLS_COLLECTION': 'Type[CollectionType]', '_KEY_ATTRIBUTE_APPEND_TEXT': 'str', '_KEY_ATTRIBUTE_DEFAULT_CALC_JOB_PLUGIN': 'str', '_KEY_ATTRIBUTE_PREPEND_TEXT': 'str', '_KEY_ATTRIBUTE_USE_DOUBLE_QUOTES': 'str', '_KEY_EXTRA_IS_HIDDEN': 'str', '_export_format_replacements': 'Dict[str, str]', '_hash_ignored_attributes': 'Tuple[str, ...]', '_logger': 'Optional[Logger]', '_plugin_type_string': 'ClassVar[str]', '_query_type_string': 'ClassVar[str]', '_updatable_attributes': 'Tuple[str, ...]'}#
__init__(remote_computer_exec=None, local_executable=None, input_plugin_name=None, files=None, **kwargs)#

Construct a new instance.

Parameters
• default_calc_job_plugin – The entry point name of the default CalcJob plugin to use.

• append_text – The text that should be appended to the run line in the job script.

• prepend_text – The text that should be prepended to the run line in the job script.

• use_double_quotes – Whether the command line invocation of this code should be escaped with double quotes.

• is_hidden – Whether the code is hidden.

__module__ = 'aiida.orm.nodes.data.code.legacy'#
__parameters__ = ()#
__str__()#

Return str(self).

_abc_impl = <_abc_data object>#
_logger: Optional[Logger] = <Logger aiida.orm.nodes.data.code.legacy.Code (REPORT)>#
_plugin_type_string: ClassVar[str] = 'data.core.code.Code.'#
_query_type_string: ClassVar[str] = 'data.core.code.'#
_set_local()#

Set the code as a ‘local’ code, meaning that all the files belonging to the code will be copied to the cluster, and the file set with set_exec_filename will be run.

It also deletes the flags related to the local case (if any)

_set_remote()#

Set the code as a ‘remote’ code, meaning that the code itself has no files attached, but only a location on a remote computer (with an absolute path of the executable on the remote computer).

It also deletes the flags related to the local case (if any)

_validate()#

Validate information stored in Node object.

For the Node base class, this check is always valid. Subclasses can override this method to perform additional checks and should usually call super()._validate() first!

This method is called automatically before storing the node in the DB. Therefore, use get() and similar methods that automatically read either from the DB or from the internal attribute cache.

can_run_on(computer)#

Return True if this code can run on the given computer, False otherwise.

Local codes can run on any machine; remote codes can run only on the machine on which they reside.

TODO: add filters to mask the remote machines on which a local code can run.

can_run_on_computer(computer: aiida.orm.computers.Computer) bool#

Return whether the code can run on a given computer.

Parameters

computer – The computer.

Returns

True if the code can run on computer, False otherwise.

property full_label#

Get full label of this code.

Returns label of the form <code-label>@<computer-name>.

classmethod get(pk=None, label=None, machinename=None)#

Get a Computer object with given identifier string, that can either be the numeric ID (pk), or the label (and computername) (if unique).

Parameters
• pk – the numeric ID (pk) for code

• label – the code label identifying the code to load

• machinename – the machine name where code is setup

Raises
get_append_text()#

Return the postexec_code, or an empty string if no post-exec code was defined.

classmethod get_code_helper(label, machinename=None, backend=None)#
Parameters
• label – the code label identifying the code to load

• machinename – the machine name where code is setup

Raises
get_computer_label()#

Get label of this code’s computer.

get_description()#

Return a string description of this Code instance.

Returns

string description of this Code instance

get_execname()#

Return the executable string to be put in the script. For local codes, it is ./LOCAL_EXECUTABLE_NAME For remote codes, it is the absolute path to the executable.

get_executable() #

Return the executable that the submission script should execute to run the code.

Returns

The executable to be called in the submission script.

classmethod get_from_string(code_string)#

Get a Computer object with given identifier string in the format label@machinename. See the note below for details on the string detection algorithm.

Note

the (leftmost) ‘@’ symbol is always used to split code and computername. Therefore do not use ‘@’ in the code name if you want to use this function (‘@’ in the computer name are instead valid).

Parameters

code_string – the code string identifying the code to load

Raises
get_input_plugin_name()#

Return the name of the default input plugin (or None if no input plugin was set.

get_local_executable()#
get_prepend_text()#

Return the code that will be put in the scheduler script before the execution, or an empty string if no pre-exec code was defined.

get_remote_computer()#

Return the remote computer associated with this code.

get_remote_exec_path()#
get_use_double_quotes() bool#

Return whether the command line invocation of this code should be escaped with double quotes.

Returns

True if to escape with double quotes, False otherwise which is also the default.

property hidden#

Determines whether the Code is hidden or not

hide()#

Hide the code (prevents from showing it in the verdi code list)

is_local()#

Return True if the code is ‘local’, False if it is ‘remote’ (see also documentation of the set_local and set_remote functions).

classmethod list_for_plugin(plugin, labels=True, backend=None)#

Return a list of valid code strings for a given plugin.

Parameters
• plugin – The string of the plugin.

• labels – if True, return a list of code names, otherwise return the code PKs (integers).

Returns

a list of string, with the code names if labels is True, otherwise a list of integers with the code PKs.

relabel(new_label)#

Relabel this code.

Parameters

new_label – new code label

reveal()#

Reveal the code (allows to show it in the verdi code list) By default, it is revealed

set_append_text(code)#

Pass a string of code that will be put in the scheduler script after the execution of the code.

set_files(files)#

Given a list of filenames (or a single filename string), add it to the path (all at level zero, i.e. without folders). Therefore, be careful for files with the same name!

Todo

decide whether to check if the Code must be a local executable to be able to call this function.

set_input_plugin_name(input_plugin)#

Set the name of the default input plugin, to be used for the automatic generation of a new calculation.

set_local_executable(exec_name)#

Set the filename of the local executable. Implicitly set the code as local.

set_prepend_text(code)#

Pass a string of code that will be put in the scheduler script before the execution of the code.

set_remote_computer_exec(remote_computer_exec)#

Set the code as remote, and pass the computer on which it resides and the absolute path on that computer.

Parameters

remote_computer_exec – a tuple (computer, remote_exec_path), where computer is a aiida.orm.Computer and remote_exec_path is the absolute path of the main executable on remote computer.

set_use_double_quotes(use_double_quotes: bool)#

Set whether the command line invocation of this code should be escaped with double quotes.

Parameters

use_double_quotes – True if to escape with double quotes, False otherwise.

validate_remote_exec_path()#

Validate the remote_exec_path attribute.

Checks whether the executable exists on the remote computer if a transport can be opened to it. This method is intentionally not called in _validate as to allow the creation of Code instances whose computers can not yet be connected to and as to not require the overhead of opening transports in storing a new code.

Raises

ValidationError – if no transport could be opened or if the defined executable does not exist on the remote computer.

__label__ = 'codes'#
__module__ = 'aiida.restapi.translator.nodes.data.code'#
_aiida_class#
_aiida_type = 'data.core.code.Code'#
_result_type = 'codes'#
static get_derived_properties(node)[source]#

Generic function extended for codes data. Currently it is not implemented.

Parameters

node – node object

Returns

empty dict

Translator for kpoints data

class aiida.restapi.translator.nodes.data.kpoints.KpointsDataTranslator(**kwargs)[source]#

Translator relative to resource ‘kpoints’ and aiida class KpointsData

class KpointsData(*args, source=None, **kwargs)#

Class to handle array of kpoints in the Brillouin zone. Provide methods to generate either user-defined k-points or path of k-points along symmetry lines. Internally, all k-points are defined in terms of crystal (fractional) coordinates. Cell and lattice vector coordinates are in Angstroms, reciprocal lattice vectors in Angstrom^-1 . :note: The methods setting and using the Bravais lattice info assume the PRIMITIVE unit cell is provided in input to the set_cell or set_cell_from_structure methods.

__abstractmethods__ = frozenset({})#
__annotations__ = {'_CLS_COLLECTION': 'Type[CollectionType]', '_export_format_replacements': typing.Dict[str, str], '_hash_ignored_attributes': 'Tuple[str, ...]', '_logger': 'Optional[Logger]', '_plugin_type_string': 'ClassVar[str]', '_query_type_string': 'ClassVar[str]', '_updatable_attributes': 'Tuple[str, ...]'}#
__module__ = 'aiida.orm.nodes.data.array.kpoints'#
__parameters__ = ()#
_abc_impl = <_abc_data object>#
_change_reference(kpoints, to_cartesian=True)#

Change reference system, from cartesian to crystal coordinates (units of b1,b2,b3) or viceversa. :param kpoints: a list of (3) point coordinates :return kpoints: a list of (3) point coordinates in the new reference

property _dimension#

Dimensionality of the structure, found from its pbc (i.e. 1 if it’s a 1D structure, 2 if its 2D, 3 if it’s 3D …). :return dimensionality: 0, 1, 2 or 3 :note: will return 3 if pbc has not been set beforehand

_logger: Optional[Logger] = <Logger aiida.orm.nodes.data.array.kpoints.KpointsData (REPORT)>#
_plugin_type_string: ClassVar[str] = 'data.core.array.kpoints.KpointsData.'#
_query_type_string: ClassVar[str] = 'data.core.array.kpoints.'#
_set_cell(value)#

Validate if ‘value’ is a allowed crystal unit cell :param value: something compatible with a 3x3 tuple of floats

_set_labels(value)#

set label names. Must pass in input a list like: [[0,'X'],[34,'L'],... ]

_set_pbc(value)#

validate the pbc, then store them

_validate_kpoints_weights(kpoints, weights)#

Validate the list of kpoints and of weights before storage. Kpoints and weights must be convertible respectively to an array of N x dimension and N floats

property cell#

The crystal unit cell. Rows are the crystal vectors in Angstroms. :return: a 3x3 numpy.array

get_description()#

Returns a string with infos retrieved from kpoints node’s properties. :param node: :return: retstr

get_kpoints(also_weights=False, cartesian=False)#

Return the list of kpoints

Parameters
• also_weights – if True, returns also the list of weights. Default = False

• cartesian – if True, returns points in cartesian coordinates, otherwise, returns in crystal coordinates. Default = False.

get_kpoints_mesh(print_list=False)#

Get the mesh of kpoints.

Parameters

print_list – default=False. If True, prints the mesh of kpoints as a list

Raises

AttributeError – if no mesh has been set

Return mesh,offset

(if print_list=False) a list of 3 integers and a list of three floats 0<x<1, representing the mesh and the offset of kpoints

Return kpoints

(if print_list = True) an explicit list of kpoints coordinates, similar to what returned by get_kpoints()

property labels#

Labels associated with the list of kpoints. List of tuples with kpoint index and kpoint name: [(0,'G'),(13,'M'),...]

property pbc#

The periodic boundary conditions along the vectors a1,a2,a3.

Returns

a tuple of three booleans, each one tells if there are periodic boundary conditions for the i-th real-space direction (i=1,2,3)

property reciprocal_cell#

Compute reciprocal cell from the internally set cell.

Returns

reciprocal cell in units of 1/Angstrom with cell vectors stored as rows. Use e.g. reciprocal_cell[0] to access the first reciprocal cell vector.

set_cell(cell, pbc=None)#

Set a cell to be used for symmetry analysis. To set a cell from an AiiDA structure, use “set_cell_from_structure”.

Parameters
• cell – 3x3 matrix of cell vectors. Orientation: each row represent a lattice vector. Units are Angstroms.

• pbc – list of 3 booleans, True if in the nth crystal direction the structure is periodic. Default = [True,True,True]

set_cell_from_structure(structuredata)#

Set a cell to be used for symmetry analysis from an AiiDA structure. Inherits both the cell and the pbc’s. To set manually a cell, use “set_cell”

Parameters

structuredata – an instance of StructureData

set_kpoints(kpoints, cartesian=False, labels=None, weights=None, fill_values=0)#

Set the list of kpoints. If a mesh has already been stored, raise a ModificationNotAllowed

Parameters
• kpoints

a list of kpoints, each kpoint being a list of one, two or three coordinates, depending on self.pbc: if structure is 1D (only one True in self.pbc) one allows singletons or scalars for each k-point, if it’s 2D it can be a length-2 list, and in all cases it can be a length-3 list. Examples:

• [[0.,0.,0.],[0.1,0.1,0.1],…] for 1D, 2D or 3D

• [[0.,0.],[0.1,0.1,],…] for 1D or 2D

• [[0.],[0.1],…] for 1D

• [0., 0.1, …] for 1D (list of scalars)

For 0D (all pbc are False), the list can be any of the above or empty - then only Gamma point is set. The value of k for the non-periodic dimension(s) is set by fill_values

• cartesian – if True, the coordinates given in input are treated as in cartesian units. If False, the coordinates are crystal, i.e. in units of b1,b2,b3. Default = False

• labels – optional, the list of labels to be set for some of the kpoints. See labels for more info

• weights – optional, a list of floats with the weight associated to the kpoint list

• fill_values – scalar to be set to all non-periodic dimensions (indicated by False in self.pbc), or list of values for each of the non-periodic dimensions.

set_kpoints_mesh(mesh, offset=None)#

Set KpointsData to represent a uniformily spaced mesh of kpoints in the Brillouin zone. This excludes the possibility of set/get kpoints

Parameters
• mesh – a list of three integers, representing the size of the kpoint mesh along b1,b2,b3.

• offset – (optional) a list of three floats between 0 and 1. [0.,0.,0.] is Gamma centered mesh [0.5,0.5,0.5] is half shifted [1.,1.,1.] by periodicity should be equivalent to [0.,0.,0.] Default = [0.,0.,0.].

set_kpoints_mesh_from_density(distance, offset=None, force_parity=False)#

Set a kpoints mesh using a kpoints density, expressed as the maximum distance between adjacent points along a reciprocal axis

Parameters
• distance – distance (in 1/Angstrom) between adjacent kpoints, i.e. the number of kpoints along each reciprocal axis i is $$|b_i|/distance$$ where $$|b_i|$$ is the norm of the reciprocal cell vector.

• offset – (optional) a list of three floats between 0 and 1. [0.,0.,0.] is Gamma centered mesh [0.5,0.5,0.5] is half shifted Default = [0.,0.,0.].

• force_parity – (optional) if True, force each integer in the mesh to be even (except for the non-periodic directions).

Note

a cell should be defined first.

Note

the number of kpoints along non-periodic axes is always 1.

__label__ = 'kpoints'#
__module__ = 'aiida.restapi.translator.nodes.data.kpoints'#
_aiida_class#
_aiida_type = 'data.core.array.kpoints.KpointsData'#
_result_type = 'kpoints'#
static get_derived_properties(node)[source]#

Returns: data in a format required by dr.js to visualize a 2D plot with multiple data series.

Strategy: For the time being rely on the function implemented in seekpath to calculate brillouin zone faces, and triangulate them. The other fields of the response are retrieved by ordinary kpointsdata methods, except the logic to create a list of explicit keypoints from the mesh and the cell vectors.

Translator for structure data

class aiida.restapi.translator.nodes.data.structure.StructureDataTranslator(**kwargs)[source]#

Translator relative to resource ‘structures’ and aiida class StructureData

class StructureData(cell=None, pbc=None, ase=None, pymatgen=None, pymatgen_structure=None, pymatgen_molecule=None, **kwargs)#

This class contains the information about a given structure, i.e. a collection of sites together with a cell, the boundary conditions (whether they are periodic or not) and other related useful information.

__abstractmethods__ = frozenset({})#
__annotations__ = {'_CLS_COLLECTION': 'Type[CollectionType]', '_export_format_replacements': typing.Dict[str, str], '_hash_ignored_attributes': 'Tuple[str, ...]', '_logger': 'Optional[Logger]', '_plugin_type_string': 'ClassVar[str]', '_query_type_string': 'ClassVar[str]', '_updatable_attributes': 'Tuple[str, ...]'}#
__init__(cell=None, pbc=None, ase=None, pymatgen=None, pymatgen_structure=None, pymatgen_molecule=None, **kwargs)#

Construct a new instance, setting the source attribute if provided as a keyword argument.

__module__ = 'aiida.orm.nodes.data.structure'#
__parameters__ = ()#
_abc_impl = <_abc_data object>#

If the structure was imported from an xyz file, it lacks a cell. This method will adjust the cell

_dimensionality_label = {0: '', 1: 'length', 2: 'surface', 3: 'volume'}#
_get_object_ase()#

Converts StructureData to ase.Atoms

Returns

an ase.Atoms object

_get_object_phonopyatoms()#

Converts StructureData to PhonopyAtoms

Returns

a PhonopyAtoms object

_get_object_pymatgen(**kwargs)#

Converts StructureData to pymatgen object

Returns

a pymatgen Structure for structures with periodic boundary conditions (in three dimensions) and Molecule otherwise

Note

Requires the pymatgen module (version >= 3.0.13, usage of earlier versions may cause errors).

_get_object_pymatgen_molecule(**kwargs)#

Converts StructureData to pymatgen Molecule object

Returns

a pymatgen Molecule object corresponding to this StructureData object.

Note

Requires the pymatgen module (version >= 3.0.13, usage of earlier versions may cause errors)

_get_object_pymatgen_structure(**kwargs)#

Converts StructureData to pymatgen Structure object :param add_spin: True to add the spins to the pymatgen structure. Default is False (no spin added).

Note

The spins are set according to the following rule:

• if the kind name ends with 1 -> spin=+1

• if the kind name ends with 2 -> spin=-1

Returns

a pymatgen Structure object corresponding to this StructureData object

Raises

ValueError – if periodic boundary conditions does not hold in at least one dimension of real space; if there are partial occupancies together with spins (defined by kind names ending with ‘1’ or ‘2’).

Note

Requires the pymatgen module (version >= 3.0.13, usage of earlier versions may cause errors)

_internal_kind_tags = None#
_logger: Optional[Logger] = <Logger aiida.orm.nodes.data.structure.StructureData (REPORT)>#
_parse_xyz(inputstring)#

Read the structure from a string of format XYZ.

_plugin_type_string: ClassVar[str] = 'data.core.structure.StructureData.'#
_prepare_chemdoodle(main_file_name='')#

Write the given structure to a string of format required by ChemDoodle.

_prepare_cif(main_file_name='')#

Write the given structure to a string of format CIF.

_prepare_xsf(main_file_name='')#

Write the given structure to a string of format XSF (for XCrySDen).

_prepare_xyz(main_file_name='')#

Write the given structure to a string of format XYZ.

_query_type_string: ClassVar[str] = 'data.core.structure.'#
_set_incompatibilities = [('ase', 'cell'), ('ase', 'pbc'), ('ase', 'pymatgen'), ('ase', 'pymatgen_molecule'), ('ase', 'pymatgen_structure'), ('cell', 'pymatgen'), ('cell', 'pymatgen_molecule'), ('cell', 'pymatgen_structure'), ('pbc', 'pymatgen'), ('pbc', 'pymatgen_molecule'), ('pbc', 'pymatgen_structure'), ('pymatgen', 'pymatgen_molecule'), ('pymatgen', 'pymatgen_structure'), ('pymatgen_molecule', 'pymatgen_structure')]#
_validate()#

Performs some standard validation tests.

append_atom(**kwargs)#

Append an atom to the Structure, taking care of creating the corresponding kind.

Parameters
• ase – the ase Atom object from which we want to create a new atom (if present, this must be the only parameter)

• position – the position of the atom (three numbers in angstrom)

• symbols – passed to the constructor of the Kind object.

• weights – passed to the constructor of the Kind object.

• name – passed to the constructor of the Kind object. See also the note below.

Note

Note on the ‘name’ parameter (that is, the name of the kind):

• if specified, no checks are done on existing species. Simply, a new kind with that name is created. If there is a name clash, a check is done: if the kinds are identical, no error is issued; otherwise, an error is issued because you are trying to store two different kinds with the same name.

• if not specified, the name is automatically generated. Before adding the kind, a check is done. If other species with the same properties already exist, no new kinds are created, but the site is added to the existing (identical) kind. (Actually, the first kind that is encountered). Otherwise, the name is made unique first, by adding to the string containing the list of chemical symbols a number starting from 1, until an unique name is found

Note

checks of equality of species are done using the compare_with() method.

append_kind(kind)#

Append a kind to the StructureData. It makes a copy of the kind.

Parameters

kind – the site to append, must be a Kind object.

append_site(site)#

Append a site to the StructureData. It makes a copy of the site.

Parameters

site – the site to append. It must be a Site object.

property cell#

Returns the cell shape.

Returns

a 3x3 list of lists.

property cell_angles#

Get the angles between the cell lattice vectors in degrees.

property cell_lengths#

Get the lengths of cell lattice vectors in angstroms.

clear_kinds()#

Removes all kinds for the StructureData object.

Note

Also clear all sites!

clear_sites()#

Removes all sites for the StructureData object.

get_ase()#

Get the ASE object. Requires to be able to import ase.

Returns

an ASE object corresponding to this StructureData object.

Note

If any site is an alloy or has vacancies, a ValueError is raised (from the site.get_ase() routine).

get_cell_volume()#

Returns the three-dimensional cell volume in Angstrom^3.

Use the get_dimensionality method in order to get the area/length of lower-dimensional cells.

Returns

a float.

get_cif(converter='ase', store=False, **kwargs)#

New in version 1.0: Renamed from _get_cif

Parameters
• converter – specify the converter. Default ‘ase’.

• store – If True, intermediate calculation gets stored in the AiiDA database for record. Default False.

Returns
get_composition()#

Returns the chemical composition of this structure as a dictionary, where each key is the kind symbol (e.g. H, Li, Ba), and each value is the number of occurences of that element in this structure. For BaZrO3 it would return {‘Ba’:1, ‘Zr’:1, ‘O’:3}. No reduction with smallest common divisor!

Returns

a dictionary with the composition

get_description()#

Parameters

self – the StructureData node

Returns

retsrt: the description string

get_dimensionality()#

Return the dimensionality of the structure and its length/surface/volume.

Zero-dimensional structures are assigned “volume” 0.

Returns

returns a dictionary with keys “dim” (dimensionality integer), “label” (dimensionality label) and “value” (numerical length/surface/volume).

get_formula(mode='hill', separator='')#

Return a string with the chemical formula.

Parameters
• mode

a string to specify how to generate the formula, can assume one of the following values:

• ’hill’ (default): count the number of atoms of each species, then use Hill notation, i.e. alphabetical order with C and H first if one or several C atom(s) is (are) present, e.g. ['C','H','H','H','O','C','H','H','H'] will return 'C2H6O' ['S','O','O','H','O','H','O'] will return 'H2O4S' From E. A. Hill, J. Am. Chem. Soc., 22 (8), pp 478–494 (1900)

• ’hill_compact’: same as hill but the number of atoms for each species is divided by the greatest common divisor of all of them, e.g. ['C','H','H','H','O','C','H','H','H','O','O','O'] will return 'CH3O2'

• ’reduce’: group repeated symbols e.g. ['Ba', 'Ti', 'O', 'O', 'O', 'Ba', 'Ti', 'O', 'O', 'O', 'Ba', 'Ti', 'Ti', 'O', 'O', 'O'] will return 'BaTiO3BaTiO3BaTi2O3'

• ’group’: will try to group as much as possible parts of the formula e.g. ['Ba', 'Ti', 'O', 'O', 'O', 'Ba', 'Ti', 'O', 'O', 'O', 'Ba', 'Ti', 'Ti', 'O', 'O', 'O'] will return '(BaTiO3)2BaTi2O3'

• ’count’: same as hill (i.e. one just counts the number of atoms of each species) without the re-ordering (take the order of the atomic sites), e.g. ['Ba', 'Ti', 'O', 'O', 'O','Ba', 'Ti', 'O', 'O', 'O'] will return 'Ba2Ti2O6'

• ’count_compact’: same as count but the number of atoms for each species is divided by the greatest common divisor of all of them, e.g. ['Ba', 'Ti', 'O', 'O', 'O','Ba', 'Ti', 'O', 'O', 'O'] will return 'BaTiO3'

• separator – a string used to concatenate symbols. Default empty.

Returns

a string with the formula

Note

in modes reduce, group, count and count_compact, the initial order in which the atoms were appended by the user is used to group and/or order the symbols in the formula

get_kind(kind_name)#

Return the kind object associated with the given kind name.

Parameters

kind_name – String, the name of the kind you want to get

Returns

The Kind object associated with the given kind_name, if a Kind with the given name is present in the structure.

Raise

ValueError if the kind_name is not present.

get_kind_names()#

Return a list of kind names (in the same order of the self.kinds property, but return the names rather than Kind objects)

Note

This is NOT necessarily a list of chemical symbols! Use get_symbols_set for chemical symbols

Returns

a list of strings.

get_pymatgen(**kwargs)#

Get pymatgen object. Returns Structure for structures with periodic boundary conditions (in three dimensions) and Molecule otherwise. :param add_spin: True to add the spins to the pymatgen structure. Default is False (no spin added).

Note

The spins are set according to the following rule:

• if the kind name ends with 1 -> spin=+1

• if the kind name ends with 2 -> spin=-1

Note

Requires the pymatgen module (version >= 3.0.13, usage of earlier versions may cause errors).

get_pymatgen_molecule()#

Get the pymatgen Molecule object.

Note

Requires the pymatgen module (version >= 3.0.13, usage of earlier versions may cause errors).

Returns

a pymatgen Molecule object corresponding to this StructureData object.

get_pymatgen_structure(**kwargs)#

Get the pymatgen Structure object. :param add_spin: True to add the spins to the pymatgen structure. Default is False (no spin added).

Note

The spins are set according to the following rule:

• if the kind name ends with 1 -> spin=+1

• if the kind name ends with 2 -> spin=-1

Note

Requires the pymatgen module (version >= 3.0.13, usage of earlier versions may cause errors).

Returns

a pymatgen Structure object corresponding to this StructureData object.

Raises

ValueError – if periodic boundary conditions do not hold in at least one dimension of real space.

get_site_kindnames()#

Return a list with length equal to the number of sites of this structure, where each element of the list is the kind name of the corresponding site.

Note

This is NOT necessarily a list of chemical symbols! Use [ self.get_kind(s.kind_name).get_symbols_string() for s in self.sites] for chemical symbols

Returns

a list of strings

get_symbols_set()#

Return a set containing the names of all elements involved in this structure (i.e., for it joins the list of symbols for each kind k in the structure).

Returns

a set of strings of element names.

property has_vacancies#

Return whether the structure has vacancies in the structure.

Returns

a boolean, True if at least one kind has a vacancy

property is_alloy#

Return whether the structure contains any alloy kinds.

Returns

a boolean, True if at least one kind is an alloy

property kinds#

Returns a list of kinds.

property pbc#

Get the periodic boundary conditions.

Returns

a tuple of three booleans, each one tells if there are periodic boundary conditions for the i-th real-space direction (i=1,2,3)

reset_cell(new_cell)#

Reset the cell of a structure not yet stored to a new value.

Parameters

new_cell – list specifying the cell vectors

Raises

ModificationNotAllowed: if object is already stored

reset_sites_positions(new_positions, conserve_particle=True)#

Replace all the Site positions attached to the Structure

Parameters
• new_positions – list of (3D) positions for every sites.

• conserve_particle – if True, allows the possibility of removing a site. currently not implemented.

Raises

Note

it is assumed that the order of the new_positions is given in the same order of the one it’s substituting, i.e. the kind of the site will not be checked.

set_ase(aseatoms)#

Load the structure from a ASE object

set_cell(value)#

Set the cell.

set_cell_angles(value)#
set_cell_lengths(value)#
set_pbc(value)#

Set the periodic boundary conditions.

set_pymatgen(obj, **kwargs)#

Load the structure from a pymatgen object.

Note

Requires the pymatgen module (version >= 3.0.13, usage of earlier versions may cause errors).

set_pymatgen_molecule(mol, margin=5)#

Load the structure from a pymatgen Molecule object.

Parameters

margin – the margin to be added in all directions of the bounding box of the molecule.

Note

Requires the pymatgen module (version >= 3.0.13, usage of earlier versions may cause errors).

set_pymatgen_structure(struct)#

Load the structure from a pymatgen Structure object.

Note

periodic boundary conditions are set to True in all three directions.

Note

Requires the pymatgen module (version >= 3.3.5, usage of earlier versions may cause errors).

Raises

ValueError – if there are partial occupancies together with spins.

property sites#

Returns a list of sites.

__label__ = 'structures'#
__module__ = 'aiida.restapi.translator.nodes.data.structure'#
_aiida_class#
_aiida_type = 'data.core.structure.StructureData'#
_result_type = 'structures'#
static get_derived_properties(node)[source]#

Returns: derived properties of the structure.

Translator for upf data

class aiida.restapi.translator.nodes.data.upf.UpfDataTranslator(**kwargs)[source]#

Translator relative to resource ‘upfs’ and aiida class UpfData

class UpfData(file, filename=None, **kwargs)#

Data sub class to represent a pseudopotential single file in UPF format.

__abstractmethods__ = frozenset({})#
__annotations__ = {'_CLS_COLLECTION': 'Type[CollectionType]', '_export_format_replacements': typing.Dict[str, str], '_hash_ignored_attributes': 'Tuple[str, ...]', '_logger': 'Optional[Logger]', '_plugin_type_string': 'ClassVar[str]', '_query_type_string': 'ClassVar[str]', '_updatable_attributes': 'Tuple[str, ...]'}#
__module__ = 'aiida.orm.nodes.data.upf'#
__parameters__ = ()#
_abc_impl = <_abc_data object>#
_logger: Optional[Logger] = <Logger aiida.orm.nodes.data.upf.UpfData (REPORT)>#
_plugin_type_string: ClassVar[str] = 'data.core.upf.UpfData.'#
_prepare_json(main_file_name='')#

Returns UPF PP in json format.

_prepare_upf(main_file_name='')#

Return UPF content.

_query_type_string: ClassVar[str] = 'data.core.upf.'#
_validate()#

Validate the UPF potential file stored for this node.

property element#

Return the element of the UPF pseudopotential.

Returns

the element

classmethod from_md5(md5, backend=None)#

Return a list of all UpfData that match the given md5 hash.

Note

assumes hash of stored UpfData nodes is stored in the md5 attribute

Parameters

md5 – the file hash

Returns

list of existing UpfData nodes that have the same md5 hash

classmethod get_or_create(filepath, use_first=False, store_upf=True)#

Get the UpfData with the same md5 of the given file, or create it if it does not yet exist.

Parameters
• filepath – an absolute filepath on disk

• use_first – if False (default), raise an exception if more than one potential is found. If it is True, instead, use the first available pseudopotential.

• store_upf – boolean, if false, the UpfData if created will not be stored.

Returns

tuple of UpfData and boolean indicating whether it was created.

get_upf_family_names()#

Get the list of all upf family names to which the pseudo belongs.

classmethod get_upf_group(group_label)#

Return the UPF family group with the given label.

Parameters

group_label – the family group label

Returns

the Group with the given label, if it exists

classmethod get_upf_groups(filter_elements=None, user=None, backend=None)#

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. The default is None, meaning that all families are returned.

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

Returns

list of Group entities of type UPF.

property md5sum#

Return the md5 checksum of the UPF pseudopotential file.

Returns

the md5 checksum

set_file(file, filename=None)#

Store the file in the repository and parse it to set the element and md5 attributes.

Parameters
• file – filepath or filelike object of the UPF potential file to store. Hint: Pass io.BytesIO(b”my string”) to construct the file directly from a string.

• filename – specify filename to use (defaults to name of provided file).

store(*args, **kwargs)#

Store the node, reparsing the file so that the md5 and the element are correctly reset.

__label__ = 'upfs'#
__module__ = 'aiida.restapi.translator.nodes.data.upf'#
_aiida_class#
_aiida_type = 'data.core.upf.UpfData'#
_result_type = 'upfs'#
static get_derived_properties(node)[source]#
Parameters

node – node object

Returns

empty dict