sponge.partition.IndexDistances
- class sponge.partition.IndexDistances(use_pbc: bool = None, large_dis: float = 100, keepdims: bool = False)[source]
Calculate distance between atoms by neighbour index
- Parameters
use_pbc (bool, optional) – Whether to use periodic boundary condition. Default:
None
.large_dis (float, optional) – A large value that added to the distance equal to zero to prevent them from becoming zero values after Norm operation, which could lead to auto-differentiation errors. Default:
100.0
.keepdims (bool, optional) – If this is
True
, the last axis will be left in the result as dimensions with size one. Default:False
.
- Supported Platforms:
Ascend
GPU
Examples
>>> import sponge >>> from sponge.partition import IndexDistances >>> import mindspore >>> from mindspore import Tensor >>> idx_distances = IndexDistances(use_pbc=False) >>> coordinate = Tensor([[[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]]]) >>> index = Tensor([[[1],[0]]]) >>> print(idx_distances(coordinate, index)) [[[1.] [1.]]]