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) – System whose coordinates will be rotated.
selection (str, list, tuple or numpy.ndarray, default 'all') – Atoms to rotate.
principal_axes_of_selection (str, list, tuple or numpy.ndarray, optional) – Atoms used to compute principal axes; defaults to selection.
principal_axes_type ({'inertia', 'geometric'}, default 'inertia') – Type of principal axes to compute.
structure_indices ('all' or array-like, default 'all') – Structures/frames to align.
weights (array-like, quantity, 'masses' or None, default None) – Non-negative weights used for both the axes and center.
Noneuses unit weights. Use'masses'for physical inertia axes.axes (array-like shape (3,3), default identity) – Target axes to align to.
center (bool, default False) – If True, recenter coordinates after rotation.
syntax (str, default 'MolSysMT') – Selection syntax when using strings.
engine ({'MolSysMT'}, default 'MolSysMT') – Backend.
in_place (bool, default False) – If True, modify the input system; otherwise return a rotated copy.
- 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 >>> molsys = msm.convert( ... msm.systems['alanine dipeptide']['alanine_dipeptide.h5msm'] ... ) >>> aligned = msm.structure.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
Added in version 1.0.0.