aim2dat.strct.structure_collection¶
Module implementing the StructureCollection class to handle a set of molecular or crystalline structures.
Module Contents¶
Classes¶
The StructureCollection class is a container for one or multiple atomic structures. It |
Attributes¶
-
class aim2dat.strct.structure_collection.StructureCollection(structures: list[aim2dat.strct.strct.Structure | dict] | None =
None)[source]¶ The StructureCollection class is a container for one or multiple atomic structures. It implements several
import_*andappend_*functions to add new data to the object.- Parameters:¶
structures (list) – List of
Structureor dict objects.
Overview
Properties¶ Labels assigened to the structures.
Methods¶ append(label, elements, positions, pbc, cell, is_cartesian, wrap, kinds, attributes, site_attributes, extras)Append structure.
append_from_aiida_structuredata(aiida_node, use_uuid, label)Append structure from aiida structuredata.
append_from_ase_atoms(label, ase_atoms, attributes)Append structure from ase atoms object.
append_from_file(label, file_path, attributes, backend, backend_kwargs)Append structure from file using the ase read-function.
append_from_pymatgen_structure(label, pymatgen_structure, attributes)Append structure from pymatgen structure or molecule object.
append_structure(structure, label)Append
Structureobject to collection. The label of the structure needs to becopy()Return copy of
StructureCollectionobject.create_pandas_df(exclude_columns)Create a pandas data frame of the object.
duplicate_structure(key, new_label)Duplicate structure.
Get all attribute keys.
Get the element symbols of all structures.
Get the kind strings of all structures.
Return a list of all structures.
get_structure(key, return_index_label)Get structure by key.
import_from_aiida_db(group_label, use_uuid, raise_error)Import from the AiiDA database.
import_from_hdf5_file(file_path, raise_error)Import from hdf5-file. Calculated extras are not yet supported.
import_from_pandas_df(data_frame, structure_column, exclude_columns, use_uuid, raise_error)Import from pandas data frame.
index(label)Return index of label. If the label is not present,
Noneis returned.items()Return a list of label, value tuples.
pop(key)Pop structure.
store_in_aiida_db(group_label, group_description)Store structures into the AiiDA-database.
store_in_hdf5_file(file_path)Store structures in hdf5-file. Calculated extras are not yet supported.
- property labels : list[str]¶
Labels assigened to the structures.
-
append(label: str, elements: list, positions: list, pbc: list, cell: list =
None, is_cartesian: bool =True, wrap: bool =False, kinds: list =None, attributes: dict =None, site_attributes: dict =None, extras: dict =None)[source]¶ Append structure.
- Parameters:¶
label (str) – String used to identify the structure.
elements (list) – List of element symbols or their atomic numbers.
positions (list) – List of the atomic positions, either cartesian or scaled coordinates.
pbc (list or bool) – Periodic boundary conditions.
cell (list or np.array) – Nested 3x3 list of the cell vectors.
is_cartesian (bool (optional)) – Whether the coordinates are cartesian or scaled.
wrap (bool (optional)) – Wrap atomic positions back into the unit cell.
kinds (list) – List of kind names (this allows custom kinds like Ni0, Ni1, …). If None, the elements will be used as the kind names.
attributes (dict) – Attributes stored within the structure object.
site_attributes (dict) – Site attributes stored within the structure object.
extras (dict) – Extras stored within the structure object.
-
append_from_aiida_structuredata(aiida_node: int | str | aiida.orm.StructureData, use_uuid: bool =
False, label: str =None)[source]¶ Append structure from aiida structuredata.
- Parameters:¶
aiida_node (int, str or aiida.orm.StructureData) – Primary key, UUID or AiiDA structure node.
use_uuid (bool (optional)) – Whether to use the uuid (str) to represent AiiDA nodes instead of the primary key (int).
label (str) – String used to identify the structure. Overwrites
labelproperty of the structure.
-
append_from_ase_atoms(label: str, ase_atoms: ase.Atoms, attributes: dict =
None)[source]¶ Append structure from ase atoms object.
- Parameters:¶
label (str) – String used to identify the structure.
ase_atoms (ase.Atoms) – ase Atoms object.
attributes (dict) – Additional information about the structure.
-
append_from_file(label: str, file_path: str, attributes: dict =
None, backend: str ='ase', backend_kwargs: dict =None)[source]¶ Append structure from file using the ase read-function.
- Parameters:¶
label (str) – String used to identify the structure.
file_path (str) – File path.
attributes (dict) – Additional information about the structure.
-
append_from_pymatgen_structure(label: str, pymatgen_structure: pymatgen.core.Molecule | pymatgen.core.Structure, attributes: dict =
None)[source]¶ Append structure from pymatgen structure or molecule object.
- Parameters:¶
label (str) – String used to identify the structure.
pymatgen_structure (pymatgen.core.Structure or pymatgen.core.Molecule) – pymatgen structure or molecule object.
attributes (dict) – Additional information about the structure.
-
append_structure(structure: aim2dat.strct.strct.Structure, label: str =
None)[source]¶ Append
Structureobject to collection. The label of the structure needs to be either given via the structures’s property or as keyword argument.- Parameters:¶
structure (Structure) – Structure object.
label (str (optional)) – String used to identify the structure. Overwrites
labelproperty of the structure.
- copy() StructureCollection[source]¶
Return copy of
StructureCollectionobject.
-
create_pandas_df(exclude_columns: list =
[]) pandas.DataFrame[source]¶ Create a pandas data frame of the object.
- duplicate_structure(key: str | int, new_label: str)[source]¶
Duplicate structure.
- Parameters:¶
key (str or int) – Key of the structure.
new_label (str) – Label of the copied structure.
- get_all_elements() list[str][source]¶
Get the element symbols of all structures.
- Returns:¶
list – List of all element symbols .
- get_all_kinds() list[source]¶
Get the kind strings of all structures.
- Returns:¶
list – List of all kinds.
- get_all_structures() list[aim2dat.strct.strct.Structure][source]¶
Return a list of all structures.
- Returns:¶
list – List of all structures stored in the object.
-
get_structure(key: str | int, return_index_label: bool =
False) aim2dat.strct.strct.Structure[source]¶ Get structure by key.
-
import_from_aiida_db(group_label: str =
None, use_uuid: bool =False, raise_error: bool =True)[source]¶ Import from the AiiDA database.
- Parameters:¶
group_label (str or list (optional)) – Constrains query to structures that are member of the group(s).
use_uuid (bool (optional)) – Whether to use the uuid (str) to represent AiiDA nodes instead of the primary key (int).
raise_error (bool (optional)) – Whether to raise an error if one of the constraints is not met.
-
import_from_hdf5_file(file_path: str, raise_error: bool =
True)[source]¶ Import from hdf5-file. Calculated extras are not yet supported.
- Parameters:¶
file_path (str) – File path.
raise_error (bool (optional)) – Whether to raise an error if one of the constraints is not met.
-
import_from_pandas_df(data_frame: pandas.DataFrame, structure_column: str =
'optimized_structure', exclude_columns: list =[], use_uuid: bool =False, raise_error: bool =True)[source]¶ Import from pandas data frame.
- Parameters:¶
data_frame (pd.DataFrame) – Pandas data frame containing at least one column with the AiiDA structure nodes.
structure_column (str (optional)) – Column containing AiiDA structure nodes used to determine structural and compositional properties. The default value is
'optimized_structure'.exclude_columns (list (optional)) – Columns of the data frame that are excluded. The default value is
[].use_uuid (bool (optional)) – Whether to use the uuid (str) to represent AiiDA nodes instead of the primary key (int).
raise_error (bool (optional)) – Whether to raise an error if one of the constraints is not met.
- index(label: str)[source]¶
Return index of label. If the label is not present,
Noneis returned.- Parameters:¶
str – Label of the structure.
- items() list[tuple[str, aim2dat.strct.strct.Structure]][source]¶
Return a list of label, value tuples.
- pop(key: str | int) aim2dat.strct.strct.Structure[source]¶
Pop structure.
- Parameters:¶
str – Key of the structure.
- aim2dat.strct.structure_collection.aiida¶
- aim2dat.strct.structure_collection.pymatgen¶