sponge.colvar.Atoms

View Source On Gitee
class sponge.colvar.Atoms(index: Union[Tensor, ndarray, List[int]], batched: bool = False, keep_in_box: bool = False, dimension: int = 3, name: str = 'atoms')[source]

Specific atoms group initialized using an array of atomic indices. It is a subclass of AtomsBase.

When initializing, the Atoms Cell accepts as input an array of atomic indices, which can either be common to all walkers or have a separate index for each walker.

To set a common atomic index, set batched to False, where the shape of the index is the same as the shape of the Atoms Cell, which is (a_1, a_2, … , a_n), while the shape of the returned Tensor is (B, a_1, a_2, … , a_n, D). B means Batchsize, i.e. number of walkers in simulation. {a_i} means Dimensions of the Atoms Cell. D means Dimension of the simulation system. Usually is 3.

To set a separate atomic index for each walker, set Batched to True. In this case, the shape of index should be (B, a_1, a_2, … , a_n), while the shape of the Atoms Cell would be (a_1, a_2, … , a_n). The batch size B of the atomic indices should be the same as the batch size of the simulation system. The shape of the returned Tensor of the Atoms Cell is (B, a_1, a_2, … , a_n, D).

Parameters
  • index (Union[Tensor, ndarray, List[int]]) – Array of the indices of specific atoms. The shape of tensor is (a_1, a_2, …, a_n) or (B, a_1, a_2, …, a_n), and the data type is int.

  • batched (bool) – Whether the first dimension of index is the batch size. Default: False.

  • keep_in_box (bool) – Whether to displace the coordinate in PBC box. Default: False.

  • dimension (int) – Spatial dimension of the simulation system. Default: 3

  • name (str) – Name of the Colvar. Default: 'atoms'

Supported Platforms:

Ascend GPU

Examples

>>> import mindspore as ms
>>> import numpy as np
>>> from mindspore import Tensor
>>> from sponge.colvar import Atoms
>>> crd = Tensor(np.random.random((4, 3)), ms.float32)
>>> crd
Tensor(shape=[4, 3], dtype=Float32, value=
[[ 2.47492954e-01,  9.78153408e-01,  1.44034222e-01],
 [ 2.36211464e-01,  3.35842371e-01,  8.39536846e-01],
 [ 8.82235169e-01,  5.98322928e-01,  6.68052316e-01],
 [ 7.17712820e-01,  4.72498119e-01,  1.69098437e-01]])
>>> atom_1 = Atoms(0)
>>> atom_1(crd)
Tensor(shape=[1, 3], dtype=Float32, value=
[[ 2.47492954e-01,  9.78153408e-01,  1.44034222e-01]])
reshape(input_shape: tuple)[source]

rearranges the shape of atoms