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 ametatensor
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 fieldcharges
. The potential will be calculated for each"charges_channel"
, which will also be the properties name of the returnedmetatensor.torch.TensorMap
.- Parameters:
system (System) – System to run the calculations. The system must have attached
"charges"
using theadd_data
method.neighbors (TensorBlock) –
The neighbor list. If a neighbor list is attached to a
metatensor.torch.atomistic.System
it can be extracted with theget_neighborlist
method using aNeighborListOptions
. Note to use the samefull_list
option for these options as provided forfull_neighbor_list
in the constructor.Note
Although
neighbors
can be attached to thesystem
, they are required to be passed explicitly here. While it’s possible to design the class to automatically extract the neighbor list by accepting aNeighborListOptions
directly in the constructor, we chose explicit passing for consistency with the torch interface.
- Returns:
metatensor.torch.TensorMap
containing the potential- Return type:
- 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 fieldcharges
. The potential will be calculated for each"charges_channel"
, which will also be the properties name of the returnedmetatensor.torch.TensorMap
.- Parameters:
system (System) – System to run the calculations. The system must have attached
"charges"
using theadd_data
method.neighbors (TensorBlock) –
The neighbor list. If a neighbor list is attached to a
metatensor.torch.atomistic.System
it can be extracted with theget_neighborlist
method using aNeighborListOptions
. Note to use the samefull_list
option for these options as provided forfull_neighbor_list
in the constructor.Note
Although
neighbors
can be attached to thesystem
, they are required to be passed explicitly here. While it’s possible to design the class to automatically extract the neighbor list by accepting aNeighborListOptions
directly in the constructor, we chose explicit passing for consistency with the torch interface.
- Returns:
metatensor.torch.TensorMap
containing the potential- Return type:
- 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 fieldcharges
. The potential will be calculated for each"charges_channel"
, which will also be the properties name of the returnedmetatensor.torch.TensorMap
.- Parameters:
system (System) – System to run the calculations. The system must have attached
"charges"
using theadd_data
method.neighbors (TensorBlock) –
The neighbor list. If a neighbor list is attached to a
metatensor.torch.atomistic.System
it can be extracted with theget_neighborlist
method using aNeighborListOptions
. Note to use the samefull_list
option for these options as provided forfull_neighbor_list
in the constructor.Note
Although
neighbors
can be attached to thesystem
, they are required to be passed explicitly here. While it’s possible to design the class to automatically extract the neighbor list by accepting aNeighborListOptions
directly in the constructor, we chose explicit passing for consistency with the torch interface.
- Returns:
metatensor.torch.TensorMap
containing the potential- Return type:
- 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 fieldcharges
. The potential will be calculated for each"charges_channel"
, which will also be the properties name of the returnedmetatensor.torch.TensorMap
.- Parameters:
system (System) – System to run the calculations. The system must have attached
"charges"
using theadd_data
method.neighbors (TensorBlock) –
The neighbor list. If a neighbor list is attached to a
metatensor.torch.atomistic.System
it can be extracted with theget_neighborlist
method using aNeighborListOptions
. Note to use the samefull_list
option for these options as provided forfull_neighbor_list
in the constructor.Note
Although
neighbors
can be attached to thesystem
, they are required to be passed explicitly here. While it’s possible to design the class to automatically extract the neighbor list by accepting aNeighborListOptions
directly in the constructor, we chose explicit passing for consistency with the torch interface.
- Returns:
metatensor.torch.TensorMap
containing the potential- Return type: