sponge.control.Thermostat

View Source On Gitee
class sponge.control.Thermostat(system: Molecule, temperature: Union[float, ndarray, Tensor, List[float]] = 300, control_step: int = 1, time_constant: float = 0.5, **kwargs)[source]

Base class for thermostat module in MindSPONGE, which is a subclass of sponge.control.Controller.

The sponge.control.thermostat.Thermostat module is used for temperature coupling. It controls the atomic velocities and the kinetics of the system during the simulation process.

Parameters
  • system (sponge.system.Molecule) – Simulation system.

  • temperature (Union[float, ndarray, Tensor], optional) – Reference temperature \(T_{ref}\) in unit Kelvin for temperature coupling. Default: 300.0.

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

  • time_constant (float, optional) – Time constant \(\tau_T\) in unit picosecond for temperature coupling. Default: 0.5.

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 Thermostat
>>> system = Molecule(template='water.tip3p.yaml')
>>> controller = Thermostat(system)
get_ref_kinetics()[source]

Get reference kinetics.

Returns

Tensor, reference kinetics.

reconstruct_temperature(temperature: Union[float, ndarray, Tensor, List[float]])[source]

Reset the reference temperature.

Parameters

temperature (Union[float, ndarray, Tensor, List[float]]) – temperature.

property ref_kinetics: mindspore.common.tensor.Tensor

Reference kinetics.

Returns

Tensor, reference kinetics.

set_degrees_of_freedom(dofs: int)[source]

Set degrees of freedom (DOFs).

Parameters

dofs (int) – degrees of freedom.

set_temperature(temperature: Union[float, ndarray, Tensor, List[float]])[source]

Set the value of reference temperature. The size of the temperature array must be equal to current temperature.

Parameters

temperature (Union[float, ndarray, Tensor, List[float]]) – temperature.

property temperature: mindspore.common.tensor.Tensor

Reference temperature.

Returns

Tensor, reference temperature.

velocity_scale(sim_kinetics: Tensor, ref_kinetics: Tensor, ratio: float = 1)[source]

Calculate the velocity scale factor for temperature coupling.

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

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

  • ratio (float, optional) – Ratio of temperature coupling. Default: 1.

Returns

Tensor, velocity scale factor.