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) – Molecular system in any supported MolSysMT format.
selection (str, list, tuple, or numpy.ndarray, default='all') – Selection string or boolean/integer array specifying elements.
center_of_selection (str, list, tuple, or numpy.ndarray, or None, default='all') – Atoms whose center defines the translation reference.
weights (numpy.ndarray, list, or tuple, default=None) – Atomic mass weights array for center calculation.
center_coordinates (PyUnitWizard quantity or None, default=None) – Coordinates to which the selected center is translated, in units of length.
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’).
engine (str, default='MolSysMT') – Backend used to perform the calculation.
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;Nonewhenin_place=True.- Return type:
molecular system or None
- Raises:
NotImplementedMethodError – If an unsupported engine is requested.
Added in version 1.0.0.