sponge.core.WithEnergyCell

View Source On Gitee
class sponge.core.WithEnergyCell(system: Molecule, potential: PotentialCell, bias: Union[Bias, List[Bias]] = None, cutoff: float = None, neighbour_list: NeighbourList = None, wrapper: EnergyWrapper = None, **kwargs)[source]

Cell that wraps the simulation system with the potential energy function. This Cell calculates the value of the potential energy of the system at the current coordinates and returns it.

Parameters
  • system (Molecule) – Simulation system.

  • potential (PotentialCell) – Potential energy function cell.

  • bias (Union[Bias, List[Bias]]) – Bias potential function cell. Default: None.

  • cutoff (float) – Cut-off distance for neighbour list. If None is given, it will be assigned as the cutoff value of the of potential energy. Default: None.

  • neighbour_list (NeighbourList) – Neighbour list. Default: None.

  • wrapper (EnergyWrapper) – Network to wrap and process potential and bias. Default: None.

  • kwargs (dict) – other args

Inputs:
  • *inputs (Tuple(Tensor)) - Tuple of input tensors of ‘WithEnergyCell’.

Outputs:

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

Note

B: Batchsize, i.e. number of walkers of the simulation. A: Number of the atoms in the simulation system. N: Number of the maximum neighbouring atoms. U: Number of potential energy terms. V: Number of bias potential terms.

Supported Platforms:

Ascend GPU

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_names: list

Name of bias potential energies.

Returns

list[str], the bias potential energies.

bias_pace(index: int = 0)[source]

Return the update freqenucy for bias potential.

Parameters

index (int) – Index of bias potential. Default: 0

Returns

int, update freqenucy.

property biases: mindspore.common.tensor.Tensor

Tensor of bias potential components.

Returns

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

calc_biases()[source]

Calculate the bias potential terms.

Returns

Tensor, Tensor of shape (B, V). Data type is float. Bias potential terms.

calc_energies()[source]

Calculate the energy terms of the potential energy.

Returns

Tensor, Tensor of shape (B, U). Data type is float. Energy terms.

property cutoff: mindspore.common.tensor.Tensor

Cutoff distance for neighbour list.

Returns

Tensor, cutoff distance.

property energies: mindspore.common.tensor.Tensor

Tensor of potential energy components.

Returns

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

property energy_names: list

Names of energy terms.

Returns

list[str], names of energy terms.

property energy_unit: str

Energy unit.

Returns

str, energy unit.

get_neighbour_list()[source]

Get neighbour list.

Returns

  • neigh_idx, Tensor. Tensor of shape (B, A, N). Data type is int. Index of neighbouring atoms of each atoms in system.

  • neigh_mask, Tensor. Tensor of shape (B, A, N). Data type is bool. Mask for neighbour list neigh_idx.

property length_unit: str

Length unit.

Returns

str, length unit.

property neighbour_list_pace: int

Update step for neighbour list.

Returns

int, update steps.

property num_biases: int

Number of bias potential energies \(V\).

Returns

int, number of bias potential energies.

property num_energies: int

Number of energy terms \(U\).

Returns

int, number of energy terms.

set_pbc_grad(grad_box: bool)[source]

Set whether to calculate the gradient of PBC box.

Parameters

grad_box (bool) – Whether to calculate the gradient of PBC box.

update_bias(step: int)[source]

Update bias potential.

Parameters

step (int) – Current simulation step. If it can be divided by update frequency, update the bias potential.

update_neighbour_list()[source]

Update neighbour list.

Returns

  • neigh_idx, Tensor. Tensor of shape (B, A, N). Data type is int. Index of neighbouring atoms of each atoms in system.

  • neigh_mask, Tensor. Tensor of shape (B, A, N). Data type is bool. Mask for neighbour list neigh_idx.

update_wrapper(step: int)[source]

Update energy wrapper.

Parameters

step (int) – Current simulation step. If it can be divided by update frequency, update the energy wrapper.