molsysmt.structure.align_principal_axes#
- molsysmt.structure.align_principal_axes(molecular_system, selection='all', principal_axes_of_selection=None, principal_axes_type='inertia', structure_indices='all', weights=None, axes=None, center=False, syntax='MolSysMT', engine='MolSysMT', in_place=False)[source]#
Aligning selected atoms to reference principal axes.
- 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.
principal_axes_of_selection (str, list, tuple, or numpy.ndarray, or None, default=None) – Atoms used to calculate the principal axes for alignment.
principal_axes_type ({'inertia', 'geometric'}, default='inertia') – Definition used to calculate the principal axes.
structure_indices (int, list, tuple, or numpy.ndarray, default='all') – Structure indices (0-based) to include or process.
weights (numpy.ndarray, list, or tuple, default=None) – Atomic mass weights array for center calculation.
axes (array-like or None, default=None) – Right-handed orthonormal target axes supplied as three row vectors.
center (bool, default=False) – Whether to leave the aligned selection centered at the origin.
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.
- Returns:
Rotated system when in_place=False, otherwise None.
- Return type:
molecular system or None
- Raises:
NotImplementedMethodError – If an unsupported engine is requested.
StructuralInconsistencyError – If target axes are not a right-handed orthonormal basis or if principal moments are degenerate and do not define three unique axes.
Notes
Target axes are supplied as rows. Alignment is intentionally rejected when two principal moments are equal within numerical tolerance because the corresponding individual axes are not uniquely defined.
See also
molsysmt.structure.get_principal_axes()Compute principal axes and moments without changing coordinates.
molsysmt.structure.least_rmsd_fit()Fit coordinates to an explicit reference structure.
Examples
>>> import molsysmt as msm >>> from molsysmt.structure.align_principal_axes import align_principal_axes >>> molsys = msm.convert( ... msm.systems['alanine dipeptide']['alanine_dipeptide.h5msm'] ... ) >>> aligned = align_principal_axes( ... molsys, structure_indices=0, weights='masses', center=True ... ) >>> axes, _ = msm.structure.get_principal_axes( ... aligned, structure_indices=0, weights='masses' ... ) >>> np.allclose(np.abs(axes[0]), np.eye(3), atol=1.0e-10) True
Tutorial with more examples
See Align principal axes.
Added in version 1.0.0.