aiida_atomistic.data.structure.models#

Classes#

StructureBaseModel

A base model representing a structure in atomistic simulations.

MutableStructureModel

A mutable structure model that extends the StructureBaseModel class.

ImmutableStructureModel

A class representing an immutable structure model.

Module Contents#

class aiida_atomistic.data.structure.models.StructureBaseModel(/, **data: Any)[source]#

Bases: pydantic.BaseModel

A base model representing a structure in atomistic simulations.

Attributes:

pbc (Optional[List[bool]]): Periodic boundary conditions in the x, y, and z directions. cell (Optional[List[List[float]]]): The cell vectors defining the unit cell of the structure.

_mutable: ClassVar[bool] = True[source]#
pbc: list[bool] = None[source]#
cell: numpy.ndarray[float] = None[source]#
sites: list[aiida_atomistic.data.structure.site.Site] = None[source]#
tot_magnetization: float | None = None[source]#
tot_charge: float | None = None[source]#
hubbard: aiida_quantumespresso.common.hubbard.Hubbard | None = None[source]#
custom: dict | None = None[source]#
class Config[source]#
from_attributes = True[source]#
frozen = False[source]#
arbitrary_types_allowed = True[source]#
classmethod validate_cell_shape(v)[source]#

Ensure cell is always a 3x3 array.

check_minimal_requirements(data)[source]#

Validate the minimal requirements of the structure.

Args:

data (dict): The input data for the structure. This is automatically passed by pydantic.

Returns:

dict: The validated input data.

Raises:

ValueError: If the structure does not meet the minimal requirements.

validate_sites(v)[source]#

Validate the list of sites.

freeze_sites(v)[source]#

Freeze the list of sites if the structure is immutable.

cell_volume() float[source]#

Compute the volume of the unit cell.

Returns:

float: The volume of the unit cell in cubic Angstroms.

dimensionality() dict[source]#

Determine the dimensionality of the structure.

Returns:

dict: A dictionary indicating the dimensionality of the structure.

formula() str[source]#

Get the chemical formula of the structure.

Returns:

str: The chemical formula of the structure.

is_alloy() dict[source]#

Computed field to determine if the structure is an alloy.

has_vacancies() bool[source]#

Computed field to determine if the structure has vacancies.

positions() numpy.ndarray[source]#

Return the positions of all sites in the structure as a numpy array.

Returns:

np.ndarray: An array of shape (N, 3) where N is the number of sites.

kind_names() List[str][source]#

Return the list of kind names for all sites in the structure.

Returns:

List[str]: A list of kind names corresponding to each site.

symbols() List[str][source]#

Return the list of chemical symbols for all sites in the structure.

Returns:

List[str]: A list of chemical symbols corresponding to each site.

masses() numpy.ndarray[source]#

Return the masses of all sites in the structure as a numpy array.

Returns:

np.ndarray: An array of masses corresponding to each site.

charges() numpy.ndarray[source]#

Return the charges of all sites in the structure as a numpy array.

Returns:

np.ndarray: An array of charges corresponding to each site.

magmoms() numpy.ndarray[source]#

Return the magnetic moments of all sites in the structure as a numpy array.

Returns:

np.ndarray: An array of magnetic moments corresponding to each site.

magnetizations() numpy.ndarray[source]#

Return the magnetizations of all sites in the structure as a numpy array.

Returns:

np.ndarray: An array of magnetizations corresponding to each site.

weights() List[Tuple[float, Ellipsis]][source]#

Return the weights of all sites in the structure as a list of tuples.

Returns:

List[Tuple[float, …]]: A list of weight tuples corresponding to each site.

kinds() aiida_atomistic.data.structure.site.FrozenList[aiida_atomistic.data.structure.kind.Kind][source]#

Return the reduced set of kinds, grouping sites that share all properties except positions and site_indices.

class aiida_atomistic.data.structure.models.MutableStructureModel(/, **data: Any)[source]#

Bases: StructureBaseModel

A mutable structure model that extends the StructureBaseModel class.

Attributes:

_mutable (bool): Flag indicating whether the structure is mutable or not. sites (List[Site]): List of immutable sites in the structure.

_mutable = True[source]#
class aiida_atomistic.data.structure.models.ImmutableStructureModel(/, **data: Any)[source]#

Bases: StructureBaseModel

A class representing an immutable structure model.

This class inherits from StructureBaseModel and provides additional functionality for handling immutable structures.

Attributes:

_mutable (bool): Flag indicating whether the structure is mutable or not. sites (List[Site]): List of immutable sites in the structure.

Config:

from_attributes (bool): Flag indicating whether to load attributes from the input data. frozen (bool): Flag indicating whether the model is frozen or not. arbitrary_types_allowed (bool): Flag indicating whether arbitrary types are allowed or not.

_mutable = False[source]#
sites: list[aiida_atomistic.data.structure.site.FrozenSite] | None = None[source]#
class Config[source]#
from_attributes = True[source]#
frozen = True[source]#
arbitrary_types_allowed = True[source]#
__setattr__(key, value)[source]#