Metatensor API

sphericart can be used in conjunction with metatensor in order to attach metadata to inputs and outputs, as well as to naturally obtain spherical harmonics, gradients and Hessians in a single object.

Here is the API reference for the sphericart.metatensor and sphericart.torch.metatensor modules.

sphericart.metatensor

class sphericart.metatensor.SphericalHarmonics(l_max: int)

metatensor-based wrapper around the sphericart.SphericalHarmonics() class.

Parameters:

l_max – the maximum degree of the spherical harmonics to be calculated

Returns:

a spherical harmonics calculator object

compute(xyz: TensorMap) TensorMap

Computes the spherical harmonics for the given Cartesian coordinates, up to the maximum degree l_max specified during initialization.

Parameters:

xyz – a metatensor.TensorMap containing the Cartesian coordinates of the 3D points. This TensorMap should have only one TensorBlock. In this TensorBlock, the samples are arbitrary, there must be one component named "xyz" with 3 values, and one property.

Returns:

The spherical harmonics and their metadata as a metatensor.TensorMap. All samples in the output TensorMap will be the same as those of the xyz input.

compute_with_gradients(xyz: TensorMap) TensorMap

Computes the spherical harmonics for the given Cartesian coordinates, up to the maximum degree l_max specified during initialization, together with their gradients with respect to the Cartesian coordinates.

Parameters:

xyz – see compute()

Returns:

The spherical harmonics and their metadata as a metatensor.TensorMap. Each TensorBlock in the output TensorMap will have a gradient block with respect to the Cartesian positions. All samples in the output TensorMap will be the same as those of the xyz input.

compute_with_hessians(xyz: TensorMap) TensorMap

Computes the spherical harmonics for the given Cartesian coordinates, up to the maximum degree l_max specified during initialization, together with their gradients and Hessians with respect to the Cartesian coordinates.

Parameters:

xyz – see compute()

Returns:

The spherical harmonics and their metadata as a metatensor.TensorMap. Each TensorBlock in the output TensorMap will have a gradient block with respect to the Cartesian positions, which will itself have a gradient with respect to the Cartesian positions. All samples in the output TensorMap will be the same as those of the xyz input.

class sphericart.metatensor.SolidHarmonics(l_max: int)

metatensor-based wrapper around the sphericart.SolidHarmonics() class.

See SphericalHarmonics for more details.

compute(xyz: TensorMap) TensorMap

See sphericart.metatensor.SphericalHarmonics.compute().

compute_with_gradients(xyz: TensorMap) TensorMap

See sphericart.metatensor.SphericalHarmonics.compute_with_gradients().

compute_with_hessians(xyz: TensorMap) TensorMap

See sphericart.metatensor.SphericalHarmonics.compute_with_hessians().

sphericart.torch.metatensor

class sphericart.torch.metatensor.SphericalHarmonics(l_max: int, backward_second_derivatives: bool = False)

metatensor-based wrapper around the sphericart.torch.SphericalHarmonics() class.

See sphericart.metatensor.SphericalHarmonics for more details. backward_second_derivatives has the same meaning as in sphericart.torch.SphericalHarmonics.

compute(xyz: TensorMap) TensorMap

See sphericart.metatensor.SphericalHarmonics.compute().

compute_with_gradients(xyz: TensorMap) TensorMap

See sphericart.metatensor.SphericalHarmonics.compute_with_gradients().

compute_with_hessians(xyz: TensorMap) TensorMap

See sphericart.metatensor.SphericalHarmonics.compute_with_hessians().

class sphericart.torch.metatensor.SolidHarmonics(l_max: int, backward_second_derivatives: bool = False)

metatensor-based wrapper around the sphericart.torch.SolidHarmonics() class.

See sphericart.metatensor.SphericalHarmonics for more details. backward_second_derivatives has the same meaning as in sphericart.torch.SphericalHarmonics.

compute(xyz: TensorMap) TensorMap

See sphericart.metatensor.SphericalHarmonics.compute().

compute_with_gradients(xyz: TensorMap) TensorMap

See sphericart.metatensor.SphericalHarmonics.compute_with_gradients().

compute_with_hessians(xyz: TensorMap) TensorMap

See sphericart.metatensor.SphericalHarmonics.compute_with_hessians().