sponge.core.RunOneStepCell
- class sponge.core.RunOneStepCell(energy: WithEnergyCell = None, force: WithForceCell = None, optimizer: Optimizer = None, steps: int = 1, sens: float = 1.0, **kwargs)[source]
Cell to run one step simulation.
This Cell wraps the energy and force with the optimizer. The backward graph will be created in the construct function to update the atomic coordinates of the simulation system.
- Parameters
energy (
sponge.core.WithEnergyCell
) – Cell that wraps the simulation system with the potential energy function. Default:None
.force (
sponge.core.WithForceCell
) – Cell that wraps the simulation system with the atomic force function. Default:None
.optimizer (mindspore.nn.Optimizer) – Optimizer for simulation. Default:
None
.steps (int, optional) – Steps for JIT. Default:
1
.sens (float, optional) – The scaling number to be filled as the input of backpropagation. Default:
1.0
.kwargs (dict) – Other arguments.
- Inputs:
*inputs (Tuple(Tensor)) - Tuple of input tensors of WithEnergyCell.
- Outputs:
energy (Tensor) - with shape of \((B, 1)\). Total potential energy. Here \(B\) is the number of walkers in simulation. Data type is float.
force (Tensor) - with shape of \((B, A, D)\). Atomic force. Here \(A\) is the number of atoms in the simulation system, \(D\) is the spatial dimension of the simulation system, which is usually 3. Data type is float.
- Supported Platforms:
Ascend
GPU
Examples
>>> from sponge import WithEnergyCell, RunOneStepCell, Sponge >>> from sponge.system import Molecule >>> from sponge.potential.forcefield import ForceField >>> from sponge.optimizer import Updater >>> system = Molecule(template='water.tip3p.yaml') >>> potential = ForceField(system, parameters='SPCE') >>> optimizer = Updater(system, controller=None, time_step=1e-3) >>> sys_with_ene = WithEnergyCell(system, potential) >>> one_step = RunOneStepCell(sys_with_ene, optimizer=optimizer) md = Sponge(one_step)
- property bias: mindspore.common.tensor.Tensor
Tensor of the total bias potential.
- Returns
Tensor, Tensor of shape (B, 1). Data type is float.
- property bias_function: mindspore.nn.cell.Cell
Cell of bias potential function.
- Returns
Cell, bias potential function.
- property bias_names: List[str]
Name of bias potential energies.
- Returns
list[str], the bias potential energies.
- property biases: mindspore.common.tensor.Tensor
Tensor of bias potential components.
- Returns
Tensor, Tensor of shape (B, V). Data type is float.
- property energies: mindspore.common.tensor.Tensor
Tensor of potential energy components.
- Returns
Tensor, Tensor of shape (B, U). Data type is float.
- property energy_cutoff: mindspore.common.tensor.Tensor
Cutoff distance for neighbour list in WithEnergyCell.
- Returns
Tensor, cutoff distance for neighbour list in WithEnergyCell.
- property energy_names
Names of energy terms.
- Returns
list[str], names of energy terms.
- property force_cutoff: mindspore.common.tensor.Tensor
Cutoff distance for neighbour list in WithForceCell.
- Returns
Tensor, cutoff distance for neighbour list in WithForceCell.
- property neighbour_list_pace: int
Update step for neighbour list.
- Returns
int, the number of steps needed for neighbour list updating.
- property num_biases: int
Number of bias potential energies \(V\).
- Returns
int, number of bias potential energies.
- set_pbc_grad(value: bool)[source]
Set whether to calculate the gradient of PBC box.
- Parameters
value (bool) – Flag to judge whether to calculate the gradient of PBC box.
- update_bias(step: int)[source]
Update bias potential.
- Parameters
step (int) – Simulation step to update bias potential.