Metatensor Bindings

torch-pme calculators returning representations as metatensor.TensorMap. For using these bindings you need to install the metatensor.torch optional dependencies.

pip install .[metatensor]

For a plain torch.Tensor refer to Calculators.

Implemented Calculators

class torchpme.metatensor.Calculator(*args, **kwargs)[source]

Base calculator for the metatensor interface.

This is just a thin wrapper around the corresponding generic torch torchpme.calculators.Calculator. If you want to wrap a metatensor interface around another calculator, you can just define the class and set the static member _base_calculator to the corresponding torch calculator.

forward(system: System, neighbors: TensorBlock) TensorMap[source]

Compute the potential “energy”.

The system must contain a custom data field charges. The potential will be calculated for each "charges_channel", which will also be the properties name of the returned metatensor.torch.TensorMap.

Parameters:
  • system (System) – System to run the calculations. The system must have attached "charges" using the add_data method.

  • neighbors (TensorBlock) –

    The neighbor list. If a neighbor list is attached to a metatensor.torch.atomistic.System it can be extracted with the get_neighborlist method using a NeighborListOptions. Note to use the same full_list option for these options as provided for full_neighbor_list in the constructor.

    Note

    Although neighbors can be attached to the system, they are required to be passed explicitly here. While it’s possible to design the class to automatically extract the neighbor list by accepting a NeighborListOptions directly in the constructor, we chose explicit passing for consistency with the torch interface.

Returns:

metatensor.torch.TensorMap containing the potential

Return type:

TensorMap

class torchpme.metatensor.EwaldCalculator(*args, **kwargs)[source]

Potential computed using the Ewald sum.

Refer to torchpme.EwaldCalculator for parameter documentation.

For an example on the usage for any calculator refer to Examples.

forward(system: System, neighbors: TensorBlock) TensorMap

Compute the potential “energy”.

The system must contain a custom data field charges. The potential will be calculated for each "charges_channel", which will also be the properties name of the returned metatensor.torch.TensorMap.

Parameters:
  • system (System) – System to run the calculations. The system must have attached "charges" using the add_data method.

  • neighbors (TensorBlock) –

    The neighbor list. If a neighbor list is attached to a metatensor.torch.atomistic.System it can be extracted with the get_neighborlist method using a NeighborListOptions. Note to use the same full_list option for these options as provided for full_neighbor_list in the constructor.

    Note

    Although neighbors can be attached to the system, they are required to be passed explicitly here. While it’s possible to design the class to automatically extract the neighbor list by accepting a NeighborListOptions directly in the constructor, we chose explicit passing for consistency with the torch interface.

Returns:

metatensor.torch.TensorMap containing the potential

Return type:

TensorMap

class torchpme.metatensor.P3MCalculator(*args, **kwargs)[source]

Potential using a particle-particle particle-mesh based Ewald (P3M).

Refer to torchpme.P3MCalculator for parameter documentation.

For an example on the usage for any calculator refer to Examples.

forward(system: System, neighbors: TensorBlock) TensorMap

Compute the potential “energy”.

The system must contain a custom data field charges. The potential will be calculated for each "charges_channel", which will also be the properties name of the returned metatensor.torch.TensorMap.

Parameters:
  • system (System) – System to run the calculations. The system must have attached "charges" using the add_data method.

  • neighbors (TensorBlock) –

    The neighbor list. If a neighbor list is attached to a metatensor.torch.atomistic.System it can be extracted with the get_neighborlist method using a NeighborListOptions. Note to use the same full_list option for these options as provided for full_neighbor_list in the constructor.

    Note

    Although neighbors can be attached to the system, they are required to be passed explicitly here. While it’s possible to design the class to automatically extract the neighbor list by accepting a NeighborListOptions directly in the constructor, we chose explicit passing for consistency with the torch interface.

Returns:

metatensor.torch.TensorMap containing the potential

Return type:

TensorMap

class torchpme.metatensor.PMECalculator(*args, **kwargs)[source]

Potential using a particle mesh-based Ewald (PME).

Refer to torchpme.PMECalculator for parameter documentation.

For an example on the usage for any calculator refer to Examples.

forward(system: System, neighbors: TensorBlock) TensorMap

Compute the potential “energy”.

The system must contain a custom data field charges. The potential will be calculated for each "charges_channel", which will also be the properties name of the returned metatensor.torch.TensorMap.

Parameters:
  • system (System) – System to run the calculations. The system must have attached "charges" using the add_data method.

  • neighbors (TensorBlock) –

    The neighbor list. If a neighbor list is attached to a metatensor.torch.atomistic.System it can be extracted with the get_neighborlist method using a NeighborListOptions. Note to use the same full_list option for these options as provided for full_neighbor_list in the constructor.

    Note

    Although neighbors can be attached to the system, they are required to be passed explicitly here. While it’s possible to design the class to automatically extract the neighbor list by accepting a NeighborListOptions directly in the constructor, we chose explicit passing for consistency with the torch interface.

Returns:

metatensor.torch.TensorMap containing the potential

Return type:

TensorMap

Examples using the Metatensor Bindings