mlcolvar.core.transform.descriptors.TorsionalAngles

class mlcolvar.core.transform.descriptors.TorsionalAngles(indices: list | ndarray | Tensor, n_atoms: int, mode: str | list, PBC: bool, cell: float | list, scaled_coords: bool = False)[source]

Bases: Transform

Torsional angle defined by a set of 4 atoms from their positions. Can compute a single angle or multiple angles.

__init__(indices: list | ndarray | Tensor, n_atoms: int, mode: str | list, PBC: bool, cell: float | list, scaled_coords: bool = False) Tensor[source]
Initialize a torsional angle object.

Can compute a single angle or multiple angles based on the indices key.

Parameters:
  • indices (Union[list, np.ndarray, torch.Tensor]) – Indices of the 4 ordered atoms defining the torsional angle(s). It can be: - A single 4-element list/array: [a1, a2, a3, a4] for one angle - A list of 4-element lists: [[a1, a2, a3, a4], [b1, b2, b3, b4], …] for multiple angles

  • n_atoms (int) – Number of atoms in the positions tensor used in the forward.

  • mode (Union[str, list]) – Which quantities to return among ‘angle’, ‘sin’ and ‘cos’

  • PBC (bool) – Switch for Periodic Boundary Conditions use

  • cell (Union[float, list]) – Dimensions of the real cell, orthorombic-like cells only

  • scaled_coords (bool, optional) – Switch for coordinates scaled on cell’s vectors use, by default False

Returns:

Depending on mode selection, the torsional angle(s) in radiants, their sine and their cosine. Shape: [batch_size, n_angles * n_modes]

Return type:

torch.Tensor

Methods

__init__(indices, n_atoms, mode, PBC, cell)

Initialize a torsional angle object.

compute_torsional_angle(pos)

forward(x)

Define the computation performed at every call.

forward(x)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

setup_from_datamodule(datamodule)

Initialize parameters based on pytorch lighting datamodule.

Attributes

MODES

T_destination

call_super_init

dump_patches

training