sponge.colvar.Vector

View Source On Gitee
class sponge.colvar.Vector(atoms: AtomsBase = None, atoms0: AtomsBase = None, atoms1: AtomsBase = None, batched: bool = False, use_pbc: bool = None, keepdims: bool = None, axis: int = - 2, name: str = 'vector')[source]

Vector between specific atoms or virtual atoms.

Parameters
  • atoms (AtomsBase) – Atoms of shape (…, 2, D) to form a vector of shape (…, D) or (…, 1, D). Cannot be used with atoms0 or atoms1. Default: None. D means Spatial dimension of the simulation system. Usually is 3.

  • atoms0 (AtomsBase) – The initial point of atoms of shape (…, D) to form a vector of shape (…, D). Must be used with atoms1, and cannot be used with atoms. Default: None.

  • atoms1 (AtomsBase) – The terminal point of atoms of shape (…, D) to form a vector of shape (…, D). Must be used with atoms0, and cannot be used with atoms. Default: None.

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

  • use_pbc (bool) – Whether to calculate distance under periodic boundary condition. Default: None.

  • keepdims (bool) – If this is set to True, the axis which is take from the atoms will be left, and the shape of the vector will be (…, 1, D) If this is set to False, the shape of the vector will be (…, D) if None, its value will be determined according to the rank (number of dimension) of the input atoms: False if the rank is greater than 2, otherwise True. It only works when initialized with atoms. Default: None.

  • axis (int) – Axis along which the coordinate of atoms are take, of which the dimension must be 2. It only works when initialized with atoms. Default: -2.

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

Supported Platforms:

Ascend GPU

Examples

>>> import mindspore as ms
>>> import numpy as np
>>> from mindspore import Tensor
>>> from sponge.colvar import Vector
>>> 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]])
>>> vc02 = Vector(atoms0=[0], atoms1=[2])
>>> vc02(crd)
Tensor(shape=[1, 3], dtype=Float32, value=
[[ 6.34742200e-01, -3.79830480e-01,  5.24018109e-01]])
property ndim: int

rank (number of dimensions) of the vector

property shape: tuple

shape of the vector