sponge.function.coordinate_in_pbc

查看源文件
sponge.function.coordinate_in_pbc(position: Tensor, pbc_box: Tensor, offset: float = 0)[源代码]

在主PBC box中获取坐标

参数:
  • position (Tensor) - 张量的shape为 \((B, ..., D)\)。数据类型是float。位置坐标 \(R\) 其中,B是Batchsize。D是模拟系统的空间维度,通常为3。

  • pbc_box (Tensor) - 张量的shape为 \((B, D)\)。数据类型是float。PBC box的大小 \(\vec{L}\)

  • offset (float) - 偏移比 \(c\) 与box的大小 \(\vec{L}\) 的相对距离。默认值:0.0

返回:

Tensor。坐标。张量的shape为 \((B, ..., D)\)。数据类型是float。

支持平台:

Ascend GPU

样例:

>>> import mindspore as ms
>>> import numpy as np
>>> from mindspore import Tensor
>>> from sponge.function import coordinate_in_pbc
>>> crd = Tensor(np.random.random((4, 3)), ms.float32)
>>> pbc_box = Tensor([[0.5, 0.5, 0.5]], ms.float32)
>>> crd
Tensor(shape=[4, 3], dtype=Float32, value=
[[ 4.94492769e-01,  4.85243529e-01,  1.63403198e-01],
[ 5.60526669e-01,  6.17091954e-01,  3.65307808e-01],
[ 7.81092644e-01,  3.17117482e-01,  1.41929969e-01],
[ 9.59174633e-01,  3.53236049e-02,  4.85624045e-01]])
>>> coordinate_in_pbc(crd, pbc_box)
Tensor(shape=[4, 3], dtype=Float32, value=
[[ 4.94492769e-01,  4.85243529e-01,  1.63403198e-01],
[ 6.05266690e-02,  1.17091954e-01,  3.65307808e-01],
[ 2.81092644e-01,  3.17117482e-01,  1.41929969e-01],
[ 4.59174633e-01,  3.53236049e-02,  4.85624045e-01]])