sponge.function.calc_vector

查看源文件
sponge.function.calc_vector(initial: Tensor, terminal: Tensor, pbc_box: Tensor = None)[源代码]

计算从起点到终点的向量。

参数:
  • initial (Tensor) - 起点坐标,shape为 \((..., D)\) 。其中, \(D\) 表示模拟系统的维度(通常为3)。

  • terminal (Tensor) - 终点坐标,shape为 \((..., D)\)

  • pbc_box (Tensor) - PBC box,shape为 \((D)\)\((B, D)\) 。其中,\(B\) 为batch size。默认为 None

返回:

Tensor。计算所得向量。shape为 \((..., D)\)

支持平台:

Ascend GPU

样例:

>>> import mindspore as ms
>>> import numpy as np
>>> from mindspore import Tensor
>>> from sponge.function import calc_vector
>>> crd = Tensor(np.random.random((4, 3)), ms.float32)
>>> pbc_box = Tensor([[3, 3, 3]], ms.float32)
>>> calc_vector(crd[0], crd[1])
Tensor(shape=[3], dtype=Float32, value= [ 6.60338998e-02,  1.31848425e-01,  2.01904610e-01])
>>> calc_vector(crd[0], crd[1], pbc_box)
Tensor(shape=[1, 3], dtype=Float32, value=
[[ 6.60338998e-02,  1.31848425e-01,  2.01904625e-01]])