sponge.control.Controller

View Source On Gitee
class sponge.control.Controller(system: Molecule, control_step: int = 1, **kwargs)[source]

Base class for the controller module in MindSPONGE. The Controller used in Updater to control the values of seven variables during the simulation process: coordinate, velocity, force, energy, kinetics, virial and pbc_box.

Parameters
  • system (Molecule) – Simulation system

  • control_step (int) – Step interval for controller execution. Default: 1

  • kwargs (dict) – Other parameters for extension

Inputs:
  • coordinate (Tensor) - Tensor of shape (B, A, D). Data type is float.

  • velocity (Tensor) - Tensor of shape (B, A, D). Data type is float.

  • force (Tensor) - Tensor of shape (B, A, D). Data type is float.

  • energy (Tensor) - Tensor of shape (B, 1). Data type is float.

  • kinetics (Tensor) - Tensor of shape (B, D). Data type is float.

  • virial (Tensor) - Tensor of shape (B, D). Data type is float.

  • pbc_box (Tensor) - Tensor of shape (B, D). Data type is float.

  • step (int) - Simulation step. Default: 0

Outputs:
  • coordinate, Tensor of shape (B, A, D). Data type is float.

  • velocity, Tensor of shape (B, A, D). Data type is float.

  • force, Tensor of shape (B, A, D). Data type is float.

  • energy, Tensor of shape (B, 1). Data type is float.

  • kinetics, Tensor of shape (B, D). Data type is float.

  • virial, Tensor of shape (B, D). Data type is float.

  • pbc_box, Tensor of shape (B, D). Data type is float.

Note

B: Number of walkers in simulation. A: Number of atoms. D: Spatial dimension of the simulation system. Usually is 3.

Supported Platforms:

Ascend GPU

property boltzmann: float

Boltzmann constant in current unit.

Returns

float, Boltzmann constant in current unit.

get_com(coordinate: Tensor, keepdims: bool = True)[source]

Get coordinate of center of mass.

Parameters
  • coordinate (Tensor) – Tensor of atomic coordinates. Tensor shape is (B, A, D). Data type is float.

  • keepdims (bool) – If this is set to True, the second axis will be left in the result as dimensions with size one. Default: True.

Returns

Tensor, Tensor of the coordinate of the center of mass. Tensor shape is (B, A, D) or (B, D).

Data type is float.

get_com_velocity(velocity: Tensor, keepdims: bool = True)[source]

Calculate velocity of center of mass.

Parameters
  • velocity (Tensor) – Tensor of velocity. Tensor shape is (B, A, D). Data type is float.

  • keepdims (bool) – If this is set to True, the second axis will be left in the result as dimensions with size one. Default: True.

Returns

Tensor, Tensor of the velocity of the center of mass.

Tensor shape is (B, A, D) or (B, D). Data type is float.

get_kinetics(velocity: Tensor)[source]

Calculate kinetics according to velocity.

Parameters

velocity (Tensor) – Tensor of atomic velocities. Tensor shape is (B, A, D). Data type is float.

Returns

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

get_pressure(kinetics: Tensor, virial: Tensor, pbc_box: Tensor)[source]

Calculate pressure according to kinetics, viral and PBC box.

Parameters
  • kinetics (Tensor) – Tensor of kinetics. Tensor shape is (B, D). Data type is float.

  • virial (Tensor) – Tensor of virial. Tensor shape is (B, D). Data type is float.

  • pbc_box (Tensor) – Tensor of PBC box. Tensor shape is (B, D). Data type is float.

Returns

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

get_temperature(kinetics: Tensor = None)[source]

Calculate temperature according to velocity.

Parameters

kinetics (Tensor) – Tensor of kinetics. Tensor shape is (B, D). Data type is float. Default: None.

Returns

Tensor, Tensor of temperature. The shape of the Tensor is (B). Data type is float.

get_volume(pbc_box: Tensor)[source]

Calculate volume according to PBC box

Parameters

pbc_box (Tensor) – Tensor of PBC box. Tensor shape is (B, D). Data type is float.

Returns

Tensor, Tensor of volume. The shape of the Tensor is (B), and the data type is float.

set_degrees_of_freedom(dofs: int)[source]

Set degrees of freedom (DOFs).

Parameters

dofs (int) – Degrees of freedom.

set_time_step(dt: float)[source]

Set simulation time step.

Parameters

dt (float) – Time step.

update_coordinate(coordinate: Tensor)[source]

Update the coordinate of the simulation system.

Parameters

coordinate (Tensor) – Tensor of atomic coordinates. Tensor shape is (B, A, D). Data type is float.

Returns

Tensor, has the same data type and shape as original coordinate.

update_pbc_box(pbc_box: Tensor)[source]

Update the parameter of PBC box.

Parameters

pbc_box (Tensor) – Tensor of PBC box. Tensor shape is (B, D). Data type is float.

Returns

Tensor, has the same data type and shape as original pbc_box.