molsysmt.structure.center#
- molsysmt.structure.center(molecular_system, selection='all', center_of_selection='all', weights=None, center_coordinates=None, structure_indices='all', syntax='MolSysMT', engine='MolSysMT', in_place=False, skip_digestion=False)[source]#
Translate a selection of atoms so that a reference center lies at a target point.
The function computes the center of
center_of_selection(optionally weighted), then applies a translation toselectionso that the reference center moves tocenter_coordinates. Ifcenter_coordinatesisNonethe reference center is moved to the origin. A second-pass correction is applied when floating-point residuals exceed 1e-12 nm.- Parameters:
molecular_system (molecular system) – Input system in any form supported by MolSysMT.
selection (str, list, tuple or numpy.ndarray, default 'all') – Atoms that are physically moved by the translation.
center_of_selection (str, list, tuple or numpy.ndarray, default 'all') – Atoms whose center defines the reference point to be relocated.
weights (array-like, optional) – Per-atom weights for computing the center of
center_of_selection. WhenNone, all atoms have equal weight (centroid).center_coordinates (quantity or None, default None) – Target position for the center. Must be a PyUnitWizard length quantity with shape compatible with
(n_structures, 1, 3). WhenNonethe center is moved to the origin.structure_indices ('all' or array-like, default 'all') – Frame indices over which the operation is performed.
syntax (str, default 'MolSysMT') – Selection syntax used when
selectionorcenter_of_selectionare strings.engine ({'MolSysMT'}, default 'MolSysMT') – Backend used for center computation and translation.
in_place (bool, default False) – If
Truethe molecular system is modified in-place andNoneis returned. IfFalsea new copy is returned with the translated coordinates.skip_digestion (bool, default False) – Whether to skip argument digestion (for internal use on trusted hot paths).
- Returns:
A new molecular system with the translated coordinates when
in_place=False;Nonewhenin_place=True.- Return type:
molecular system or None
- Raises:
NotImplementedMethodError – If an unsupported engine is requested.
.. versionadded: – 1.0.0: