Convert#

Functions for converting instances into an metatensor.TensorMap.

equisolve.utils.convert.ase_to_tensormap(frames: List[Atoms], energy: str | None = None, forces: str | None = None, stress: str | None = None) TensorMap[source]#

Store informations from ase.Atoms in a metatensor.TensorMap.

Parameters:
  • frames – ase.Atoms or list of ase.Atoms

  • energy – key for extracting energy per structure

  • forces – key for extracting atomic forces

  • stress – key for extracting stress per structure

Returns:

TensorMap containing the given information

equisolve.utils.convert.properties_to_tensormap(values: List[float], positions_gradients: List[ndarray] | None = None, cell_gradients: List[ndarray] | None = None, is_structure_property: bool = True) TensorMap[source]#

Create a metatensor.TensorMap from array like properties.

Parameters:
  • values – array like object of dimension N, for example the energies for each structure

  • positions_gradients – list of length N with each entry i containing an array like objects with dimension (M_i, 3), for example the negative forces for each atom for all structures)

  • cell_gradients – array like objects of dimension (N, 3, 3), for example the virial stress of a structure

  • is_structure_property – boolean that determines if values correspond to a structure or atomic property, this property is not implemented yet.

Raises:
  • ValueError – if the length of values, positions_gradients or cell_gradients is not the same.

  • ValueError – if each element in positions_gradients does not have 3 columns

  • ValueError – if each element in cell_gradients is not a 3x3 matrix.

Returns:

TensorMap containing the given properties