sponge.colvar.Distance
- class sponge.colvar.Distance(atoms: AtomsBase = None, atoms0: AtomsBase = None, atoms1: AtomsBase = None, vector: Vector = None, use_pbc: bool = None, batched: bool = False, keepdims: bool = None, axis: int = - 2, name: str = 'distance')[source]
Colvar for distance.
- Parameters
atoms (AtomsBase) – Atoms of shape (…, 2, D) to calculate distance of shape (…) or (…, 1). Cannot be used with atoms0 or atoms1. Default:
None
. D means spatial dimension of the simulation system. Usually is 3.atoms0 (AtomsBase) – Initial point of atoms with shape (…, D) of the distance with shape (…) or (…, 1). Must be used with atoms1, and cannot be used with atoms. Default:
None
.atoms1 (AtomsBase) – Terminal point of atoms with shape (…, D) of the distance with shape (…) or (…, 1). Must be used with atoms0, and cannot be used with atoms. Default:
None
.vector (Vector) – Vector with shape (…, D) of the distance with shape (…) or (…, 1)
use_pbc (bool) – Whether to calculate distance under periodic boundary condition. Default:
None
.batched (bool) – Whether the first dimension of the input index in atoms is the batch size. Default:
False
.keepdims (bool) – If True, the last axis will be left, and the output shape will be (…, 1). If False, the shape of distance will be (…) if None, its value will be determined according to the rank of vector: False if the rank is greater than 1, otherwise True. Default:
None
.axis (int) – Axis along which the coordinate of atoms are take, of which the dimension must be 2. It only works when initialized with atoms, atoms0, or atoms1. Default: -2.
name (str) – Name of the Colvar. Default: 'distance'.
- Supported Platforms:
Ascend
GPU
Examples
>>> from sponge import Sponge >>> from sponge.colvar import Distance >>> from sponge.callback import RunInfo >>> cv_bond = Distance([0, 1]) >>> # system is the Molecule object defined by user. >>> # energy is the Energy object defined by user. >>> # opt is the Optimizer object defined by user. >>> md = Sponge(system, potential=energy, optimizer=opt, metrics={'bond': cv_bond}) >>> run_info = RunInfo(1000) >>> md.run(2000, callbacks=[run_info]) [MindSPONGE] Started simulation at 2024-02-19 15:43:11 [MindSPONGE] Step: 1000, E_pot: -117.30916, bond: 1.4806036 [MindSPONGE] Step: 2000, E_pot: -131.60872, bond: 1.4821533 [MindSPONGE] Finished simulation at 2024-02-19 15:44:03 [MindSPONGE] Simulation time: 51.27 seconds.