aiida_atomistic.data.structure.utils_kinds#

Functions#

compress_properties_by_kind(props)

Compress site-wise properties into kind-wise lists.

rebuild_site_lists_from_kind_lists(compressed)

Expand kinds into a list of site dictionaries, sorted by site_index.

classify_site_kinds(sites[, threshold])

Classify sites into groups where each group (kind) has the same properties except position.

check_kinds_match(structure, kinds_list)

sites_from_kinds(kinds)

Expand kinds into a list of site dictionaries, sorted by site_index.

generate_kinds(structure[, threshold])

Generate kinds for a given structure by classifying sites based on their properties.

to_kinds(structure[, threshold])

Return a new StructureData/StructureBuilder instance with kinds generated from the sites.

Module Contents#

aiida_atomistic.data.structure.utils_kinds.compress_properties_by_kind(props)[source]#

Compress site-wise properties into kind-wise lists. Returns a dict with properties as lists, one entry per kind.

aiida_atomistic.data.structure.utils_kinds.rebuild_site_lists_from_kind_lists(compressed)[source]#

Expand kinds into a list of site dictionaries, sorted by site_index.

aiida_atomistic.data.structure.utils_kinds.classify_site_kinds(sites: list, threshold: dict = {})[source]#

Classify sites into groups where each group (kind) has the same properties except position.

Args:

sites: List of site dictionaries exclude_props: Set of property names to exclude from grouping (default: {‘position’}) threshold: Numerical threshold for floating point comparisons (default: 1e-3)

Returns:

dict: {group_key: {‘sites’: [site_indices], ‘properties’: {prop: value}}}

aiida_atomistic.data.structure.utils_kinds.check_kinds_match(structure, kinds_list)[source]#
aiida_atomistic.data.structure.utils_kinds.sites_from_kinds(kinds)[source]#

Expand kinds into a list of site dictionaries, sorted by site_index. 1. Create a list of site indices and positions from the kinds 2. Create a list of site dictionaries by copying the kind properties

and adding the position

  1. Return the list of site dictionaries

  2. Note: the returned list is sorted by site_index

Format of kinds (basically what can be obtained by structure.generate_kinds()): [

{‘site_indices’: [0, 2], ‘positions’: [array([0., 0., 0.]), array([0., 1., 0.])], ‘symbol’: ‘H’, ‘mass’: 1.008, ‘charge’: 0.0, ‘magmom’: (0.0, 0.0, -1.0), ‘kind_name’: ‘H1’}, {‘site_indices’: [1], ‘positions’: [array([0., 0., 1.])], ‘symbol’: ‘O’, ‘mass’: 15.999, ‘charge’: -2.0, ‘magmom’: (0.0, 0.0, 1.0), ‘kind_name’: ‘O1’}

]

aiida_atomistic.data.structure.utils_kinds.generate_kinds(structure: aiida_atomistic.data.structure.structure.StructureData | aiida_atomistic.data.structure.structure.StructureBuilder, threshold: dict = {})[source]#

Generate kinds for a given structure by classifying sites based on their properties.

Args:

structure (Union[StructureData, StructureBuilder]): The structure to generate kinds for. threshold (Union[dict, float], optional): The threshold for classifying sites. Defaults to 1e-3.

If dict, keys are property names and values are thresholds.

Returns:
list[dict]: A list of kinds with their associated site indices and properties.

This can be directly used to initialize a StructureData/StructureBuilder instance.

aiida_atomistic.data.structure.utils_kinds.to_kinds(structure: aiida_atomistic.data.structure.structure.StructureData | aiida_atomistic.data.structure.structure.StructureBuilder, threshold: dict = {})[source]#

Return a new StructureData/StructureBuilder instance with kinds generated from the sites.

This function is called by the to_kinds method of StructureData and StructureBuilder GetterMixin class. It can be dressed via the calcfunction decorator to store provenance if needed (i.e. if the structure is a StructureData).

Args:

structure (Union[StructureData, StructureBuilder]): The structure to generate kinds for. threshold (Union[dict, float], optional): The threshold for classifying sites. Defaults to 1e-3.

If dict, keys are property names and values are thresholds.

Returns:
Union[StructureData, StructureBuilder]: A new instance of the same type as the input structure,

but with kinds generated from the sites.