sponge.control.SETTLE
- class sponge.control.SETTLE(system: Molecule, index: Union[Tensor, ndarray, List[int]] = None, # (B, C, 3) distance: Union[Tensor, ndarray, List[float]] = None, # (B, C, 2))[source]
SETTLE constraint controller.
Reference Shuichi Miyamoto and Peter A. Kollman. SETTLE An Analytical Version of the SHAKE and RATTLE Algorithm for Rigid Water Models.
- Parameters
system (
sponge.system.Molecule
) – Simulation system.index (Union[Tensor, ndarray, List[int]], optional) – Array of settle index of shape \((C, 3)\) or \((B, C, 3)\), and the data type is int. If
None
is given, the settle_index in system will be used. Default:None
.distance (Union[Tensor, ndarray, List[float]], optional) – Array of settle distance of shape \((C, 2)\) or \((B, C, 2)\), and the type is float. If
None
is given, the settle_dis in system will be used. Default:None
.
- Inputs:
coordinate (Tensor) - Coordinate. Tensor of shape \((B, A, D)\). Data type is float. Here \(B\) is the number of walkers in simulation, \(A\) is the number of atoms and \(D\) is the spatial dimension of the simulation system, which is usually 3.
velocity (Tensor) - Velocity. Tensor of shape \((B, A, D)\). Data type is float.
force (Tensor) - Force. Tensor of shape \((B, A, D)\). Data type is float.
energy (Tensor) - Energy. Tensor of shape \((B, 1)\). Data type is float.
kinetics (Tensor) - Kinetics. Tensor of shape \((B, D)\). Data type is float.
virial (Tensor) - Virial. Tensor of shape \((B, D)\). Data type is float.
pbc_box (Tensor) - Pressure boundary condition box. Tensor of shape \((B, D)\). Data type is float.
step (int) - Simulation step. Default:
0
.
- Outputs:
coordinate, Tensor of shape \((B, A, D)\). Coordinate. Data type is float.
velocity, Tensor of shape \((B, A, D)\). Velocity. Data type is float.
force, Tensor of shape \((B, A, D)\). Force. Data type is float.
energy, Tensor of shape \((B, 1)\). Energy. Data type is float.
kinetics, Tensor of shape \((B, D)\). Kinetics. Data type is float.
virial, Tensor of shape \((B, D)\). Virial. Data type is float.
pbc_box, Tensor of shape \((B, D)\). Periodic boundary condition box. Data type is float.
- Supported Platforms:
Ascend
GPU
Examples
>>> from sponge import Molecule >>> from sponge.control import SETTLE >>> system = Molecule(template='water.tip3p.yaml') >>> controller = SETTLE(system)
- apply_transform(q: Tensor, vec: Tensor)[source]
Apply the quaternion transform q to a given vector vec.
- Parameters
q (Tensor) – The transform quaternion.
vec (Tensor) – The vector to be transformed.
- Returns
Tensor, The transformed vector.
- get_inverse(quater: Tensor)[source]
Get the inverse operation of a given quaternion.
- Parameters
quater (Tensor) – The given quaternion.
- Returns
Tensor, \(quater^{-1}\).
- get_mass_center(crd_)[source]
Get the mass center of a given molecule.
- Parameters
crd (Tensor) – The coordinates.
- Returns
Tensor, The mass center of the molecule.
- get_transform(crd_)[source]
Get the transform between A0B0C0 and a0b0c0.
- Parameters
crd (Tensor) – The given water molecular coordinates.
- Returns
This function will return the transform and inverse transform from crd_ SETTLE axis.
- get_vector_transform(vec1: Tensor, vec2: Tensor)[source]
Get the transform quaternion from a vector to another.
- Parameters
vec1 (Tensor) – The initial vector.
vec2 (Tensor) – The target vector.
- Returns
Tensor, the transform quaternion.
- get_vel_force_update(crd0_, vel0_)[source]
Get the update of velocity and force.
- Parameters
crd0 (Tensor) – The coordinate after SETTLE in the origin axis.
vel0 (Tensor) – The initial velocity.
- Returns
Tensor, The constraint velocity. Tensor, The constraint force.
- group_hamiltonian_product(q, vec)[source]
Perform hamiltonian product in a 4-dimensional vector.
- Parameters
q (Tensor) – The transform quaternion.
vec (Tensor) – The vector to be transformed.
- Returns
Tensor, The Hamiltonian product of q and v, \(q v q^{-1}\).
- hamiltonian_product(q, v)[source]
Perform Hamiltonian product.
- Parameters
q (Tensor) – The transform quaternion.
v (Tensor) – The vector to be transformed.
- Returns
Tensor, The Hamiltonian product of q and v, \(q v q^{-1}\).
- quaternion_multiply(tensor_1: Tensor, tensor_2: Tensor)[source]
Calculate the quaternion multiplication.
- Parameters
tensor_1 (Tensor) – The first quaternion, if the size of last dimension is 3, it will be padded to 4 auto.
tensor_2 (Tensor) – The second quaternion, if the size of last dimension is 3, it will be padded to 4 auto.
- Returns
Tensor, the quaternion product of tensor_1 and tensor_2.