sponge.function.coordinate_in_pbc

View Source On Gitee
sponge.function.coordinate_in_pbc(position: Tensor, pbc_box: Tensor, offset: float = 0)[source]

get coordinate in main PBC box

Parameters
  • position (Tensor) – Tensor of shape (B, …, D). Data type is float. Position coordinate \(R\) B means batchsize, i.e. number of walkers in simulation. D means spatial dimension of the simulation system. Usually is 3.

  • pbc_box (Tensor) – Tensor of shape (B, D). Data type is float. Size of PBC box \(\vec{L}\)

  • offset (float) – Offset ratio \(c\) relative to box size \(\vec{L}\). Default: 0

Returns

coordinate (Tensor), Tensor of shape (B, …, D). Data type is float.

Supported Platforms:

Ascend GPU

Examples

>>> 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]])