aiida.orm.data package

class aiida.orm.data.Data(**kwargs)[source]

Bases: aiida.orm.implementation.django.node.Node

This class is base class for all data objects.

Specifications of the Data class: AiiDA Data objects are subclasses of Node and should have

Multiple inheritance must be suppoted, i.e. Data should have methods for querying and be able to inherit other library objects such as ASE for structures.

Architecture note: The code plugin is responsible for converting a raw data object produced by code to AiiDA standard object format. The data object then validates itself according to its method. This is done independently in order to allow cross-validation of plugins.

__abstractmethods__ = frozenset([])
__module__ = 'aiida.orm.data'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 95
_abc_registry = <_weakrefset.WeakSet object>
_custom_export_format_replacements = {}
_exportstring(fileformat, main_file_name='', **kwargs)[source]

Converts a Data object to other text format.

Parameters:
  • fileformat – a string (the extension) to describe the file format.
  • main_file_name – empty by default, contains the (full) path and filename of the main file, if any. This is not used directly, but is used to infer useful unique names for the additional files, if any. For instance, if the main file for gnuplot is ‘../myplot.gnu’, the plugin could decide to store the dat file under ‘../myplot_data.dat’. It is up to the plugin to properly deal with this filename (or ignore it, if not relevant, e.g. if no additional files need to be created)
  • kwargs – any other parameter is passed down to the specific 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.

_get_converters()[source]

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

_get_exporters()[source]

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

_get_importers()[source]

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

_linking_as_output(dest, link_type)[source]

Raise a ValueError if a link from self to dest is not allowed.

An output of a data can only be a calculation

_logger = <logging.Logger object>
_plugin_type_string = 'data.Data.'
_query_type_string = 'data.'
_source_attributes = ['db_name', 'db_uri', 'uri', 'id', 'version', 'extras', 'source_md5', 'description', 'license']
_validate()[source]

Perform validation of the Data object.

Note

validation of data source checks license and requires attribution to be provided in field ‘description’ of source in the case of any CC-BY* license. If such requirement is too strict, one can remove/comment it out.

Add a link to the current node from the ‘src’ node. Both nodes must be a Node instance (or a subclass of Node) :note: In subclasses, change only this. Moreover, remember to call the super() method in order to properly use the caching logic!

Parameters:
  • src – the source object
  • label (str) – the name of the label to set the link from src. Default = None.
  • link_type – The type of link, must be one of the enum values from LinkType
convert(object_format=None, *args)[source]

Convert the AiiDA StructureData into another python object

Parameters:object_format – Specify the output format
export(path, fileformat=None, overwrite=False, **kwargs)[source]

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 _exportstring method
Returns:

the list of files created

classmethod get_export_formats()[source]

Get the list of valid export format strings

Returns:a list of valid formats
importfile(fname, fileformat=None)[source]

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)[source]

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)[source]

Sets the dictionary describing the source of Data object.

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.
  • license: a string with a type of license.

Note

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

Returns:dictionary describing the source of Data object.

Submodules

class aiida.orm.data.base.BaseType(*args, **kwargs)[source]

Bases: aiida.orm.data.Data

Store a base python type as a AiiDA node in the DB.

Provide the .value property to get the actual value.

__abstractmethods__ = frozenset([])
__eq__(other)[source]

x.__eq__(y) <==> x==y

__init__(*args, **kwargs)[source]

Initialize the object Node.

Parameters:uuid – if present, the Node with given uuid is loaded from the database. (It is not possible to assign a uuid to a new Node.)
__metaclass__

alias of abc.ABCMeta

__module__ = 'aiida.orm.data.base'
__ne__(other)[source]

x.__ne__(y) <==> x!=y

__repr__() <==> repr(x)[source]
__str__() <==> str(x)[source]
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 92
_abc_registry = <_weakrefset.WeakSet object>
_create_init_args(*args, **kwargs)[source]
_logger = <logging.Logger object>
_plugin_type_string = 'data.base.BaseType.'
_query_type_string = 'data.base.'
new(value=None)[source]
set_typevalue(typevalue)[source]
value
class aiida.orm.data.base.Bool(*args, **kwargs)[source]

Bases: aiida.orm.data.base.BaseType

Class to store booleans as AiiDA nodes

__abstractmethods__ = frozenset([])
__bool__()[source]
__int__()[source]
__module__ = 'aiida.orm.data.base'
__nonzero__()[source]
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 92
_abc_registry = <_weakrefset.WeakSet object>
_logger = <logging.Logger object>
_plugin_type_string = 'data.base.Bool.'
_query_type_string = 'data.base.'
_type

alias of __builtin__.bool

class aiida.orm.data.base.Float(*args, **kwargs)[source]

Bases: aiida.orm.data.base.NumericType

Class to store float numbers as AiiDA nodes

__abstractmethods__ = frozenset([])
__module__ = 'aiida.orm.data.base'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 92
_abc_registry = <_weakrefset.WeakSet object>
_logger = <logging.Logger object>
_plugin_type_string = 'data.base.Float.'
_query_type_string = 'data.base.'
_type

alias of __builtin__.float

class aiida.orm.data.base.Int(*args, **kwargs)[source]

Bases: aiida.orm.data.base.NumericType

Class to store integer numbers as AiiDA nodes

__abstractmethods__ = frozenset([])
__module__ = 'aiida.orm.data.base'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 92
_abc_registry = <_weakrefset.WeakSet object>
_logger = <logging.Logger object>
_plugin_type_string = 'data.base.Int.'
_query_type_string = 'data.base.'
_type

alias of __builtin__.int

class aiida.orm.data.base.List(**kwargs)[source]

Bases: aiida.orm.data.Data, _abcoll.MutableSequence

Class to store python lists as AiiDA nodes

_LIST_KEY = 'list'
__abstractmethods__ = frozenset([])
__delitem__(key)[source]
__getitem__(item)[source]
__len__()[source]
__module__ = 'aiida.orm.data.base'
__setitem__(key, value)[source]
__str__() <==> str(x)[source]
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 92
_abc_registry = <_weakrefset.WeakSet object>
_get_list()[source]
_logger = <logging.Logger object>
_plugin_type_string = 'data.base.List.'
_query_type_string = 'data.base.'
_set_list(list_)[source]
_using_list_reference()[source]

This function tells the class if we are using a list reference. This means that calls to self.get_list return a reference rather than a copy of the underlying list and therefore self._set_list need not be called. This knwoledge is essential to make sure this class is performant.

Currently the implementation assumes that if the node needs to be stored then it is using the attributes cache which is a reference.

Returns:True if using self._get_list returns a reference to the underlying sequence. False otherwise.
Return type:bool
append(value)[source]

S.append(object) – append object to the end of the sequence

count(value) → integer -- return number of occurrences of value[source]
extend(L)[source]

S.extend(iterable) – extend sequence by appending elements from the iterable

index(value) → integer -- return first index of value.[source]

Raises ValueError if the value is not present.

insert(i, value)[source]

S.insert(index, object) – insert object before index

pop([index]) → item -- remove and return item at index (default last).[source]

Raise IndexError if list is empty or index is out of range.

remove(value)[source]

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse()[source]

S.reverse() – reverse IN PLACE

sort(cmp=None, key=None, reverse=False)[source]
class aiida.orm.data.base.NumericType(*args, **kwargs)[source]

Bases: aiida.orm.data.base.BaseType

Specific subclass of BaseType to store numbers, overloading common operators (+, *, …)

__abstractmethods__ = frozenset([])
__add__(other)[source]
__float__()[source]
__ge__(other)[source]
__gt__(other)[source]
__int__()[source]
__le__(other)[source]
__lt__(other)[source]
__module__ = 'aiida.orm.data.base'
__mul__(other)[source]
__pow__(other)[source]
__radd__(other)[source]
__rmul__(other)[source]
__rsub__(other)[source]
__sub__(other)[source]
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 92
_abc_registry = <_weakrefset.WeakSet object>
_logger = <logging.Logger object>
_plugin_type_string = 'data.base.NumericType.'
_query_type_string = 'data.base.'
class aiida.orm.data.base.Str(*args, **kwargs)[source]

Bases: aiida.orm.data.base.BaseType

Class to store strings as AiiDA nodes

__abstractmethods__ = frozenset([])
__module__ = 'aiida.orm.data.base'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 92
_abc_registry = <_weakrefset.WeakSet object>
_logger = <logging.Logger object>
_plugin_type_string = 'data.base.Str.'
_query_type_string = 'data.base.'
_type

alias of __builtin__.str

aiida.orm.data.base._(value)[source]
aiida.orm.data.base._left_operator(func)[source]
aiida.orm.data.base._right_operator(func)[source]
aiida.orm.data.base.get_false_node()[source]

Return a Bool Data node, with value False

Cannot be done as a singleton in the module, because it would be generated at import time, with the risk that (e.g. in the tests, or at the very first use of AiiDA) a user is not yet defined in the DB (but a user is mandatory in the DB before you can create new Nodes in AiiDA).

aiida.orm.data.base.get_true_node()[source]

Return a Bool Data node, with value True

Cannot be done as a singleton in the module, because it would be generated at import time, with the risk that (e.g. in the tests, or at the very first use of AiiDA) a user is not yet defined in the DB (but a user is mandatory in the DB before you can create new Nodes in AiiDA).

aiida.orm.data.base.to_aiida_type(*args, **kw)[source]

Turns basic Python types (str, int, float, bool) into the corresponding AiiDA types.

Tools for handling Crystallographic Information Files (CIF)

class aiida.orm.data.cif.CifData(**kwargs)[source]

Bases: aiida.orm.data.singlefile.SinglefileData

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.

__abstractmethods__ = frozenset([])
__init__(**kwargs)[source]

Initialises an instance of CifData.

__module__ = 'aiida.orm.data.cif'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 95
_abc_registry = <_weakrefset.WeakSet object>
_get_aiida_structure(converter='ase', store=False, **kwargs)[source]

Creates aiida.orm.data.structure.StructureData.

Parameters:
  • converter – specify the converter. Default ‘ase’.
  • 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.
Returns:

aiida.orm.data.structure.StructureData node.

_get_object_ase()[source]

Converts CifData to ase.Atoms

Returns:an ase.Atoms object
_get_object_pycifrw()[source]

Converts CifData to PyCIFRW.CifFile

Returns:a PyCIFRW.CifFile object
_logger = <celery.utils.log.ProcessAwareLogger object>
_parse_policies = ['eager', 'lazy']
_plugin_type_string = 'data.cif.CifData.'
_prepare_cif(main_file_name='')[source]

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.

_prepare_tcod(main_file_name='', **kwargs)[source]

Write the given CIF to a string of format TCOD CIF.

_query_type_string = 'data.cif.'
_scan_types = ['standard', 'flex']
_set_defaults

Add defaults for some attributes.

_set_incompatibilities = [('ase', 'file'), ('ase', 'values'), ('file', 'values')]
_validate()[source]

Validates MD5 hash of CIF file.

ase

ASE object, representing the CIF.

Note

requires ASE module.

classmethod from_md5(md5)[source]

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()[source]

Computes and returns MD5 hash of the CIF file.

get_ase(**kwargs)[source]

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')[source]

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)[source]

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()[source]

Get the spacegroup international number.

has_attached_hydrogens()[source]

Check if there are hydrogens without coordinates, specified as attached to the atoms of the structure. :return: True if there are attached hydrogens, False otherwise.

has_partial_occupancies()[source]

Check if there are float values in the atom occupancies. :return: True if there are partial occupancies, False otherwise.

parse(scan_type=None)[source]

Parses CIF file and sets attributes.

Parameters:scan_type – See set_scan_type
static read_cif(index=-1, **kwargs)[source]

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.

set_ase(aseatoms)[source]

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

Parameters:aseatoms – the ASE atoms object
set_file(filename)[source]

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.

set_parse_policy(parse_policy)[source]

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)[source]

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)[source]

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)[source]

Store the node.

values

PyCifRW structure, representing the CIF datablocks.

Note

requires PyCifRW module.

aiida.orm.data.cif.cif_from_ase(ase, full_occupancies=False, add_fake_biso=False)[source]

Construct a CIF datablock from the ASE structure. The code is taken from https://wiki.fysik.dtu.dk/ase/epydoc/ase.io.cif-pysrc.html#write_cif, as the original ASE code contains a bug in printing the Hermann-Mauguin symmetry space group symbol.

Parameters:ase – ASE “images”
Returns:array of CIF datablocks
aiida.orm.data.cif.has_pycifrw()[source]
Returns:True if the PyCifRW module can be imported, False otherwise.
aiida.orm.data.cif.parse_formula(formula)[source]

Parses the Hill formulae, written with spaces for separators.

aiida.orm.data.cif.pycifrw_from_cif(datablocks, loops=None, names=None)[source]

Constructs PyCifRW’s CifFile from an array of CIF datablocks.

Parameters:
  • datablocks – an array of CIF datablocks
  • loops – optional list of lists of CIF tag loops.
  • names – optional list of datablock names
Returns:

CifFile

aiida.orm.data.cif.symop_string_from_symop_matrix_tr(matrix, tr=(0, 0, 0), eps=0)[source]

Construct a CIF representation of symmetry operator plus translation. See International Tables for Crystallography Vol. A. (2002) for definition.

Parameters:
  • matrix – 3x3 matrix, representing the symmetry operator
  • tr – translation vector of length 3 (default 0)
  • eps – epsilon parameter for fuzzy comparison x == 0
Returns:

CIF representation of symmetry operator

class aiida.orm.data.error.Error(**kwargs)[source]

Bases: aiida.orm.data.Data

__abstractmethods__ = frozenset([])
__module__ = 'aiida.orm.data.error'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 120
_abc_registry = <_weakrefset.WeakSet object>
_logger = <celery.utils.log.ProcessAwareLogger object>
_plugin_type_string = 'data.error.Error.'
_query_type_string = 'data.error.'
class aiida.orm.data.folder.FolderData(**kwargs)[source]

Bases: aiida.orm.data.Data

Stores a folder with subfolders and files.

No special attributes are set.

__abstractmethods__ = frozenset([])
__module__ = 'aiida.orm.data.folder'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 120
_abc_registry = <_weakrefset.WeakSet object>
_logger = <celery.utils.log.ProcessAwareLogger object>
_plugin_type_string = 'data.folder.FolderData.'
_query_type_string = 'data.folder.'
get_file_content(path)[source]

Return the content of a path stored inside the folder as a string.

Raises:NotExistent – if the path does not exist.
replace_with_folder(folder, overwrite=True)[source]

Replace the data with another folder, always copying and not moving the original files.

Args:
folder: the folder to copy from overwrite: if to overwrite the current content or not
class aiida.orm.data.frozendict.FrozenDict(**kwargs)[source]

Bases: aiida.orm.data.Data, _abcoll.Mapping

An immutable dictionary containing only Data nodes as values.

Note

All values must be stored before being passed to constructor.

__abstractmethods__ = frozenset([])
__getitem__(key)[source]
__init__(**kwargs)[source]

Initialize the object Node.

Parameters:uuid – if present, the Node with given uuid is loaded from the database. (It is not possible to assign a uuid to a new Node.)
__iter__()[source]
__len__()[source]
__module__ = 'aiida.orm.data.frozendict'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 120
_abc_registry = <_weakrefset.WeakSet object>
_get(key)[source]
_logger = <celery.utils.log.ProcessAwareLogger object>
_plugin_type_string = 'data.frozendict.FrozenDict.'
_query_type_string = 'data.frozendict.'
set_dict(dict)[source]
class aiida.orm.data.orbital.OrbitalData(**kwargs)[source]

Bases: aiida.orm.data.Data

Used for storing collections of orbitals, as well as providing methods for accessing them internally.

__abstractmethods__ = frozenset([])
__module__ = 'aiida.orm.data.orbital'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 120
_abc_registry = <_weakrefset.WeakSet object>
_get_orbital_class_from_orbital_dict(orbital_dict)[source]

Gets the orbital class from the orbital dictionary stored in DB

Parameters:orbital_dict – orbital dictionary associated with the orbital
Returns:an Orbital produced using the module_name
_logger = <celery.utils.log.ProcessAwareLogger object>
_plugin_type_string = 'data.orbital.OrbitalData.'
static _prep_orbital_dict_keys_from_site()[source]

Prepares the position from an input site.

Parameters:site – a site of site class
Return out_dict:
 a dictionary of attributes parsed from the site (currently only position)
_query_type_string = 'data.orbital.'
clear_orbitals()[source]

Remove all orbitals that were added to the class Cannot work if OrbitalData has been already stored

get_orbitals(with_tags=False, **kwargs)[source]

Returns all orbitals by default. If a site is provided, returns all orbitals cooresponding to the location of that site, additional arguments may be provided, which act as filters on the retrieved orbitals.

Parameters:
  • site – if provided, returns all orbitals with position of site
  • with_tags – if provided returns all tags stored
Kwargs:

attributes than can filter the set of returned orbitals

Return list_of_outputs:
 

a list of orbitals and also tags if with_tags was set to True

set_orbitals(orbital, tag=None)[source]

Sets the orbitals into the database. Uses the orbital’s inherent set_orbital_dict method to generate a orbital dict string at is stored along with the tags, if provided.

Parameters:
  • orbital – an orbital or list of orbitals to be set
  • tag – a list of strings must be of length orbital
class aiida.orm.data.parameter.ParameterData(**kwargs)[source]

Bases: aiida.orm.data.Data

Pass as input in the init a dictionary, and it will get stored as internal attributes.

Usual rules for attribute names apply (in particular, keys cannot start with an underscore). If this is the case, a ValueError will be raised.

You can then change/delete/add more attributes before storing with the usual methods of aiida.orm.Node

__abstractmethods__ = frozenset([])
__module__ = 'aiida.orm.data.parameter'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 95
_abc_registry = <_weakrefset.WeakSet object>
_logger = <logging.Logger object>
_plugin_type_string = 'data.parameter.ParameterData.'
_query_type_string = 'data.parameter.'
add_path(*args, **kwargs)[source]

Copy a file or folder from a local file inside the repository directory. If there is a subpath, folders will be created.

Copy to a cache directory if the entry has not been saved yet.

Parameters:
  • src_abs (str) – the absolute path of the file to copy.
  • dst_filename (str) – the (relative) path on which to copy.
Todo:

in the future, add an add_attachment() that has the same meaning of a extras file. Decide also how to store. If in two separate subfolders, remember to reset the limit.

dict

To be used to get direct access to the underlying dictionary with the syntax node.dict.key or node.dict[‘key’].

Returns:an instance of the AttributeResultManager.
get_dict()[source]

Return a dict with the parameters

keys()[source]

Iterator of valid keys stored in the ParameterData object

set_dict(dict)[source]

Replace the current dictionary with another one.

Parameters:dict – The dictionary to set.
update_dict(dict)[source]

Update the current dictionary with the keys provided in the dictionary.

Parameters:dict – a dictionary with the keys to substitute. It works like dict.update(), adding new keys and overwriting existing keys.
class aiida.orm.data.remote.RemoteData(**kwargs)[source]

Bases: aiida.orm.data.Data

Store a link to a file or folder on a remote machine.

Remember to pass a computer!

__abstractmethods__ = frozenset([])
__module__ = 'aiida.orm.data.remote'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 120
_abc_registry = <_weakrefset.WeakSet object>
_clean()[source]

Remove all content of the remote folder on the remote computer

_logger = <celery.utils.log.ProcessAwareLogger object>
_plugin_type_string = 'data.remote.RemoteData.'
_query_type_string = 'data.remote.'
_validate()[source]

Perform validation of the Data object.

Note

validation of data source checks license and requires attribution to be provided in field ‘description’ of source in the case of any CC-BY* license. If such requirement is too strict, one can remove/comment it out.

add_path(src_abs, dst_filename=None)[source]

Disable adding files or directories to a RemoteData

get_computer_name()[source]
get_dbcomputer()[source]
get_remote_path()[source]
getfile(relpath, destpath)[source]

Connects to the remote folder and gets a string with the (full) content of the file.

Parameters:
  • relpath – The relative path of the file to show.
  • destpath – A path on the local computer to get the file
Returns:

a string with the file content

is_empty()[source]

Check if remote folder is empty

listdir(relpath='.')[source]

Connects to the remote folder and lists the directory content.

Parameters:relpath – If ‘relpath’ is specified, lists the content of the given subfolder.
Returns:a flat list of file/directory names (as strings).
listdir_withattributes(path='.')[source]

Connects to the remote folder and lists the directory content.

Parameters:relpath – If ‘relpath’ is specified, lists the content of the given subfolder.
Returns:a list of dictionaries, where the documentation is in :py:class:Transport.listdir_withattributes.
set_remote_path(val)[source]

Implement subclass for a single file in the permanent repository files = [one_single_file] jsons = {}

methods: * get_content * get_path * get_aiidaurl (?) * get_md5 * …

To discuss: do we also need a simple directory class for full directories in the perm repo?

class aiida.orm.data.singlefile.SinglefileData(**kwargs)[source]

Bases: aiida.orm.data.Data

Pass as input a file parameter with the (absolute) path of a file on the hard drive. It will get copied inside the node.

Internally must have a single file, and stores as internal attribute the filename in the ‘filename’ attribute.

__abstractmethods__ = frozenset([])
__module__ = 'aiida.orm.data.singlefile'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 95
_abc_registry = <_weakrefset.WeakSet object>
_logger = <celery.utils.log.ProcessAwareLogger object>
_plugin_type_string = 'data.singlefile.SinglefileData.'
_query_type_string = 'data.singlefile.'
_validate()[source]

Perform validation of the Data object.

Note

validation of data source checks license and requires attribution to be provided in field ‘description’ of source in the case of any CC-BY* license. If such requirement is too strict, one can remove/comment it out.

add_path(src_abs, dst_filename=None)[source]

Add a single file

del_file(filename)[source]

Remove a file from SingleFileData :param filename: name of the file stored in the DB

filename

Returns the name of the file stored

get_file_abs_path()[source]

Return the absolute path to the file in the repository

remove_path(filename)[source]

Remove a file or directory from the repository directory. Can be called only before storing.

Parameters:path (str) – relative path to file/directory.
set_file(filename)[source]

Add a file to the singlefiledata :param filename: absolute path to the file

This module defines the classes for structures and all related functions to operate on them.

class aiida.orm.data.structure.Kind(**kwargs)[source]

Bases: object

This class contains the information about the species (kinds) of the system.

It can be a single atom, or an alloy, or even contain vacancies.

__dict__ = dict_proxy({'__module__': 'aiida.orm.data.structure', 'symbol': <property object>, 'symbols': <property object>, '__dict__': <attribute '__dict__' of 'Kind' objects>, 'get_symbols_string': <function get_symbols_string>, '__init__': <function __init__>, 'is_alloy': <function is_alloy>, 'compare_with': <function compare_with>, 'name': <property object>, 'has_vacancies': <function has_vacancies>, '__weakref__': <attribute '__weakref__' of 'Kind' objects>, 'reset_mass': <function reset_mass>, 'set_automatic_kind_name': <function set_automatic_kind_name>, '__doc__': '\n This class contains the information about the species (kinds) of the system.\n\n It can be a single atom, or an alloy, or even contain vacancies.\n ', 'get_raw': <function get_raw>, 'set_symbols_and_weights': <function set_symbols_and_weights>, 'mass': <property object>, '__repr__': <function __repr__>, 'weights': <property object>, '__str__': <function __str__>})
__init__(**kwargs)[source]

Create a site. One can either pass:

Parameters:
  • raw – the raw python dictionary that will be converted to a Kind object.
  • ase – an ase Atom object
  • kind – a Kind object (to get a copy)

Or alternatively the following parameters:

Parameters:
  • symbols – a single string for the symbol of this site, or a list of symbol strings
  • weights – (optional) the weights for each atomic species of this site. If only a single symbol is provided, then this value is optional and the weight is set to 1.
  • mass – (optional) the mass for this site in atomic mass units. If not provided, the mass is set by the self.reset_mass() function.
  • name – a string that uniquely identifies the kind, and that is used to identify the sites.
__module__ = 'aiida.orm.data.structure'
__repr__() <==> repr(x)[source]
__str__() <==> str(x)[source]
__weakref__

list of weak references to the object (if defined)

compare_with(other_kind)[source]

Compare with another Kind object to check if they are different.

Note

This does NOT check the ‘type’ attribute. Instead, it compares (with reasonable thresholds, where applicable): the mass, and the list of symbols and of weights. Moreover, it compares the _internal_tag, if defined (at the moment, defined automatically only when importing the Kind from ASE, if the atom has a non-zero tag). Note that the _internal_tag is only used while the class is loaded, but is not persisted on the database.

Returns:A tuple with two elements. The first one is True if the two sites are ‘equivalent’ (same mass, symbols and weights), False otherwise. The second element of the tuple is a string, which is either None (if the first element was True), or contains a ‘human-readable’ description of the first difference encountered between the two sites.
get_raw()[source]

Return the raw version of the site, mapped to a suitable dictionary. This is the format that is actually used to store each kind of the structure in the DB.

Returns:a python dictionary with the kind.
get_symbols_string()[source]

Return a string that tries to match as good as possible the symbols of this kind. If there is only one symbol (no alloy) with 100% occupancy, just returns the symbol name. Otherwise, groups the full string in curly brackets, and try to write also the composition (with 2 precision only).

Note

If there is a vacancy (sum of weights<1), we indicate it with the X symbol followed by 1-sum(weights) (still with 2 digits precision, so it can be 0.00)

Note

Note the difference with respect to the symbols and the symbol properties!

has_vacancies()[source]

Returns True if the sum of the weights is less than one. It uses the internal variable _sum_threshold as a threshold.

Returns:a boolean
is_alloy()[source]

To understand if kind is an alloy.

Returns:True if the kind has more than one element (i.e., len(self.symbols) != 1), False otherwise.
mass

The mass of this species kind.

Returns:a float
name

Return the name of this kind. The name of a kind is used to identify the species of a site.

Returns:a string
reset_mass()[source]

Reset the mass to the automatic calculated value.

The mass can be set manually; by default, if not provided, it is the mass of the constituent atoms, weighted with their weight (after the weight has been normalized to one to take correctly into account vacancies).

This function uses the internal _symbols and _weights values and thus assumes that the values are validated.

It sets the mass to None if the sum of weights is zero.

set_automatic_kind_name(tag=None)[source]

Set the type to a string obtained with the symbols appended one after the other, without spaces, in alphabetical order; if the site has a vacancy, a X is appended at the end too.

set_symbols_and_weights(symbols, weights)[source]

Set the chemical symbols and the weights for the site.

Note

Note that the kind name remains unchanged.

symbol

If the kind has only one symbol, return it; otherwise, raise a ValueError.

symbols

List of symbols for this site. If the site is a single atom, pass a list of one element only, or simply the string for that atom. For alloys, a list of elements.

Note

Note that if you change the list of symbols, the kind name remains unchanged.

weights

Weights for this species kind. Refer also to :func:validate_symbols_tuple for the validation rules on the weights.

class aiida.orm.data.structure.Site(**kwargs)[source]

Bases: object

This class contains the information about a given site of the system.

It can be a single atom, or an alloy, or even contain vacancies.

__dict__ = dict_proxy({'__module__': 'aiida.orm.data.structure', 'kind_name': <property object>, '__str__': <function __str__>, 'get_raw': <function get_raw>, 'get_ase': <function get_ase>, '__repr__': <function __repr__>, '__dict__': <attribute '__dict__' of 'Site' objects>, 'position': <property object>, '__weakref__': <attribute '__weakref__' of 'Site' objects>, '__doc__': '\n This class contains the information about a given site of the system.\n\n It can be a single atom, or an alloy, or even contain vacancies.\n ', '__init__': <function __init__>})
__init__(**kwargs)[source]

Create a site.

Parameters:
  • kind_name – a string that identifies the kind (species) of this site. This has to be found in the list of kinds of the StructureData object. Validation will be done at the StructureData level.
  • position – the absolute position (three floats) in angstrom
__module__ = 'aiida.orm.data.structure'
__repr__() <==> repr(x)[source]
__str__() <==> str(x)[source]
__weakref__

list of weak references to the object (if defined)

get_ase(kinds)[source]

Return a ase.Atom object for this site.

Parameters:kinds – the list of kinds from the StructureData object.

Note

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

get_raw()[source]

Return the raw version of the site, mapped to a suitable dictionary. This is the format that is actually used to store each site of the structure in the DB.

Returns:a python dictionary with the site.
kind_name

Return the kind name of this site (a string).

The type of a site is used to decide whether two sites are identical (same mass, symbols, weights, …) or not.

position

Return the position of this site in absolute coordinates, in angstrom.

class aiida.orm.data.structure.StructureData(**kwargs)[source]

Bases: aiida.orm.data.Data

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([])
__module__ = 'aiida.orm.data.structure'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 95
_abc_registry = <_weakrefset.WeakSet object>
_adjust_default_cell(vacuum_factor=1.0, vacuum_addition=10.0, pbc=(False, False, False))[source]

If the structure was imported from an xyz file, it lacks a defined cell, and the default cell is taken ([[1,0,0], [0,1,0], [0,0,1]]), leading to an unphysical definition of the structure. This method will adjust the cell

_dimensionality_label = {0: '', 1: 'length', 2: 'surface', 3: 'volume'}
_get_cif(converter='ase', store=False, **kwargs)[source]

Creates aiida.orm.data.cif.CifData.

Parameters:
  • converter – specify the converter. Default ‘ase’.
  • store – If True, intermediate calculation gets stored in the AiiDA database for record. Default False.
Returns:

aiida.orm.data.cif.CifData node.

_get_object_ase()[source]

Converts StructureData to ase.Atoms

Returns:an ase.Atoms object
_get_object_phonopyatoms()[source]

Converts StructureData to PhonopyAtoms

Returns:a PhonopyAtoms object
_get_object_pymatgen(**kwargs)[source]

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)[source]

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)[source]

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)

_logger = <celery.utils.log.ProcessAwareLogger object>
_parse_xyz(inputstring)[source]

Read the structure from a string of format XYZ.

_plugin_type_string = 'data.structure.StructureData.'
_prepare_cif(main_file_name='')[source]

Write the given structure to a string of format CIF.

_prepare_tcod(main_file_name='', **kwargs)[source]

Write the given structure to a string of format TCOD CIF.

_prepare_xsf(main_file_name='')[source]

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

_prepare_xyz(main_file_name='')[source]

Write the given structure to a string of format XYZ.

_query_type_string = 'data.structure.'
_set_defaults
_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()[source]

Performs some standard validation tests.

append_atom(**kwargs)[source]

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)[source]

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)[source]

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.
cell

Returns the cell shape.

Returns:a 3x3 list of lists.
cell_angles

Get the angles between the cell lattice vectors in degrees.

cell_lengths

Get the lengths of cell lattice vectors in angstroms.

clear_kinds()[source]

Removes all kinds for the StructureData object.

Note

Also clear all sites!

clear_sites()[source]

Removes all sites for the StructureData object.

get_ase()[source]

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()[source]

Returns the cell volume in Angstrom^3.

Returns:a float.
get_composition()[source]

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_desc()[source]

Returns a string with infos retrieved from StructureData node’s properties :param self: the StructureData node :return: retsrt: the description string

get_dimensionality()[source]

This function checks the dimensionality of the structure and calculates its length/surface/volume :return: returns the dimensionality and length/surface/volume

get_formula(mode='hill', separator='')[source]

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)[source]

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()[source]

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)[source]

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()[source]

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)[source]

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()[source]

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()[source]

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.
has_vacancies()[source]

To understand if there are vacancies in the structure.

Returns:a boolean, True if at least one kind has a vacancy
is_alloy()[source]

To understand if there are alloys in the structure.

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

Returns a list of kinds.

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)[source]

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)[source]

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)[source]

Load the structure from a ASE object

set_cell(value)[source]
set_cell_angles(value)[source]
set_cell_lengths(value)[source]
set_pbc(value)[source]
set_pymatgen(obj, **kwargs)[source]

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)[source]

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)[source]

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.
sites

Returns a list of sites.

aiida.orm.data.structure._create_symbols_tuple(symbols)[source]

Returns a tuple with the symbols provided. If a string is provided, this is converted to a tuple with one single element.

aiida.orm.data.structure._create_weights_tuple(weights)[source]

Returns a tuple with the weights provided. If a number is provided, this is converted to a tuple with one single element. If None is provided, this is converted to the tuple (1.,)

aiida.orm.data.structure._get_valid_cell(inputcell)[source]

Return the cell in a valid format from a generic input.

Raises:ValueError – whenever the format is not valid.
aiida.orm.data.structure.ase_refine_cell(aseatoms, **kwargs)[source]

Detect the symmetry of the structure, remove symmetric atoms and refine unit cell.

Parameters:
  • aseatoms – an ase.atoms.Atoms instance
  • symprec – symmetry precision, used by spglib
Return newase:

refined cell with reduced set of atoms

Return symmetry:
 

a dictionary describing the symmetry space group

aiida.orm.data.structure.calc_cell_volume(cell)[source]

Calculates the volume of a cell given the three lattice vectors.

It is calculated as cell[0] . (cell[1] x cell[2]), where . represents a dot product and x a cross product.

Parameters:cell – the cell vectors; the must be a 3x3 list of lists of floats, no other checks are done.
Returns:the cell volume.
aiida.orm.data.structure.create_automatic_kind_name(symbols, weights)[source]

Create a string obtained with the symbols appended one after the other, without spaces, in alphabetical order; if the site has a vacancy, a X is appended at the end too.

aiida.orm.data.structure.get_formula(symbol_list, mode='hill', separator='')[source]

Return a string with the chemical formula.

Parameters:
  • symbol_list – a list of symbols, e.g. ['H','H','O']
  • 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

aiida.orm.data.structure.get_formula_from_symbol_list(_list, separator='')[source]

Return a string with the formula obtained from the list of symbols. Examples: * [[1,'Ba'],[1,'Ti'],[3,'O']] will return 'BaTiO3' * [[2, [ [1, 'Ba'], [1, 'Ti'] ] ]] will return '(BaTi)2'

Parameters:
  • _list – a list of symbols and multiplicities as obtained from the function group_symbols
  • separator – a string used to concatenate symbols. Default empty.
Returns:

a string

aiida.orm.data.structure.get_formula_group(symbol_list, separator='')[source]

Return a string with the chemical formula from a list of chemical symbols. The formula is written in a compact” way, i.e. trying to group as much as possible parts of the formula.

Note

it works for instance very well if structure was obtained from an ASE supercell.

Example of result: ['Ba', 'Ti', 'O', 'O', 'O', 'Ba', 'Ti', 'O', 'O', 'O', 'Ba', 'Ti', 'Ti', 'O', 'O', 'O'] will return '(BaTiO3)2BaTi2O3'.

Parameters:
  • symbol_list – list of symbols (e.g. [‘Ba’,’Ti’,’O’,’O’,’O’])
  • separator – a string used to concatenate symbols. Default empty.
Returns:

a string with the chemical formula for the given structure.

aiida.orm.data.structure.get_pymatgen_version()[source]
Returns:string with pymatgen version, None if can not import.
aiida.orm.data.structure.get_symbols_string(symbols, weights)[source]

Return a string that tries to match as good as possible the symbols and weights. If there is only one symbol (no alloy) with 100% occupancy, just returns the symbol name. Otherwise, groups the full string in curly brackets, and try to write also the composition (with 2 precision only). If (sum of weights<1), we indicate it with the X symbol followed by 1-sum(weights) (still with 2 digits precision, so it can be 0.00)

Parameters:
  • symbols – the symbols as obtained from <kind>._symbols
  • weights – the weights as obtained from <kind>._weights

Note

Note the difference with respect to the symbols and the symbol properties!

aiida.orm.data.structure.get_valid_pbc(inputpbc)[source]

Return a list of three booleans for the periodic boundary conditions, in a valid format from a generic input.

Raises:ValueError – if the format is not valid.
aiida.orm.data.structure.group_symbols(_list)[source]

Group a list of symbols to a list containing the number of consecutive identical symbols, and the symbol itself.

Examples:

  • ['Ba','Ti','O','O','O','Ba'] will return [[1,'Ba'],[1,'Ti'],[3,'O'],[1,'Ba']]
  • [ [ [1,'Ba'],[1,'Ti'] ],[ [1,'Ba'],[1,'Ti'] ] ] will return [[2, [ [1, 'Ba'], [1, 'Ti'] ] ]]
Parameters:_list – a list of elements representing a chemical formula
Returns:a list of length-2 lists of the form [ multiplicity , element ]
aiida.orm.data.structure.has_ase()[source]
Returns:True if the ase module can be imported, False otherwise.
aiida.orm.data.structure.has_pymatgen()[source]
Returns:True if the pymatgen module can be imported, False otherwise.
aiida.orm.data.structure.has_spglib()[source]
Returns:True if the spglib module can be imported, False otherwise.
aiida.orm.data.structure.has_vacancies(weights)[source]

Returns True if the sum of the weights is less than one. It uses the internal variable _sum_threshold as a threshold. :param weights: the weights :return: a boolean

aiida.orm.data.structure.is_ase_atoms(ase_atoms)[source]

Check if the ase_atoms parameter is actually a ase.Atoms object.

Parameters:ase_atoms – an object, expected to be an ase.Atoms.
Returns:a boolean.

Requires the ability to import ase, by doing ‘import ase’.

aiida.orm.data.structure.is_valid_symbol(symbol)[source]

Validates the chemical symbol name.

Returns:True if the symbol is a valid chemical symbol (with correct capitalization), False otherwise.

Recognized symbols are for elements from hydrogen (Z=1) to lawrencium (Z=103).

aiida.orm.data.structure.symop_fract_from_ortho(cell)[source]

Creates a matrix for conversion from fractional to orthogonal coordinates.

Taken from svn://www.crystallography.net/cod-tools/trunk/lib/perl5/Fractional.pm, revision 850.

Parameters:cell – array of cell parameters (three lengths and three angles)
aiida.orm.data.structure.symop_ortho_from_fract(cell)[source]

Creates a matrix for conversion from orthogonal to fractional coordinates.

Taken from svn://www.crystallography.net/cod-tools/trunk/lib/perl5/Fractional.pm, revision 850.

Parameters:cell – array of cell parameters (three lengths and three angles)
aiida.orm.data.structure.validate_symbols_tuple(symbols_tuple)[source]

Used to validate whether the chemical species are valid.

Parameters:symbols_tuple – a tuple (or list) with the chemical symbols name.
Raises:ValueError if any symbol in the tuple is not a valid chemical symbols (with correct capitalization).

Refer also to the documentation of :func:is_valid_symbol

aiida.orm.data.structure.validate_weights_tuple(weights_tuple, threshold)[source]

Validates the weight of the atomic kinds.

Raise:

ValueError if the weights_tuple is not valid.

Parameters:
  • weights_tuple – the tuple to validate. It must be a a tuple of floats (as created by :func:_create_weights_tuple).
  • threshold – a float number used as a threshold to check that the sum of the weights is <= 1.

If the sum is less than one, it means that there are vacancies. Each element of the list must be >= 0, and the sum must be <= 1.

This module manages the UPF pseudopotentials in the local repository.

class aiida.orm.data.upf.UpfData(**kwargs)[source]

Bases: aiida.orm.data.singlefile.SinglefileData

Function not yet documented.

__abstractmethods__ = frozenset([])
__module__ = 'aiida.orm.data.upf'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 120
_abc_registry = <_weakrefset.WeakSet object>
_logger = <celery.utils.log.ProcessAwareLogger object>
_plugin_type_string = 'data.upf.UpfData.'
_query_type_string = 'data.upf.'
_validate()[source]

Perform validation of the Data object.

Note

validation of data source checks license and requires attribution to be provided in field ‘description’ of source in the case of any CC-BY* license. If such requirement is too strict, one can remove/comment it out.

element
classmethod from_md5(md5)[source]

Return a list of all UPF 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.

classmethod get_or_create(filename, use_first=False, store_upf=True)[source]

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

Parameters:
  • filename – an absolute filename 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 (bool) – If false, the UpfData objects are not stored in the database. default=True.
Return (upf, created):
 

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

get_upf_family_names()[source]

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

classmethod get_upf_group(group_name)[source]

Return the UpfFamily group with the given name.

classmethod get_upf_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).
md5sum
set_file(filename)[source]

I pre-parse the file to store the attributes.

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

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

upffamily_type_string = 'data.upf.family'
aiida.orm.data.upf.get_pseudos_dict(structure, family_name)[source]

Get a dictionary of {kind: pseudo} for all the elements within the given structure using a the given pseudo family name.

Parameters:
  • structure – The structure that will be used.
  • family_name – the name of the group containing the pseudos
aiida.orm.data.upf.get_pseudos_from_structure(structure, family_name)[source]

Given a family name (a UpfFamily group in the DB) and a AiiDA structure, return a dictionary associating each kind name with its UpfData 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.
aiida.orm.data.upf.parse_upf(fname, check_filename=True)[source]

Try to get relevant information from the UPF. For the moment, only the element name. Note that even UPF v.2 cannot be parsed with the XML minidom! (e.g. due to the & characters in the human-readable section).

If check_filename is True, raise a ParsingError exception if the filename does not start with the element name.

aiida.orm.data.upf.upload_upf_family(folder, group_name, group_description, stop_if_existing=True)[source]

Upload a set of UPF files in a given group.

Parameters:
  • folder – a path containing all UPF files to be added. Only files ending in .UPF (case-insensitive) are considered.
  • group_name – 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.