molsysmt.structure.translate#

molsysmt.structure.translate(molecular_system, translation=None, selection='all', structure_indices='all', syntax='MolSysMT', in_place=False, skip_digestion=False)[source]#

Apply a translation vector to atomic coordinates of a selection.

The function supports three translation broadcasting modes determined automatically from the shape of translation:

  • Single vector — shape (1, 1, 3): the same displacement is applied to all atoms in all frames.

  • Per-frame vector — shape (n_structures, 1, 3): each frame receives its own displacement; all atoms within a frame move by the same amount.

  • Per-atom-per-frame array — shape (n_structures, n_atoms, 3): each atom in each frame can have a different displacement.

Parameters:
  • molecular_system (molecular system) – Molecular system in any supported MolSysMT format.

  • translation (PyUnitWizard quantity or None, default=None) – Translation vector in units of length.

  • selection (str, list, tuple, or numpy.ndarray, default='all') – Selection string or boolean/integer array specifying elements.

  • structure_indices (int, list, tuple, or numpy.ndarray, default='all') – Structure indices (0-based) to include or process.

  • syntax (str, default='MolSysMT') – Selection syntax used to evaluate selection (e.g., ‘MolSysMT’, ‘MDTraj’).

  • in_place (bool, default=False) – Whether to modify the input molecular system in place.

  • skip_digestion (bool, default=False) – Whether to skip MolSysMT’s internal argument digestion mechanism.

Returns:

A new molecular system with the translated coordinates when in_place=False; None when in_place=True.

Return type:

molecular system or None

Raises:

StructuralInconsistencyError – If the shape of translation is not compatible with any of the supported broadcasting modes for the given coordinate array.

Added in version 1.0.0.