molsysmt.structure.get_principal_axes#
- molsysmt.structure.get_principal_axes(molecular_system, selection='all', structure_indices='all', weights=None, principal_axes_type='inertia', syntax='MolSysMT', engine='MolSysMT', use_gpu=None, skip_digestion=False)[source]#
Computing principal axes for a selection of atoms.
- Parameters:
molecular_system (molecular system) – Input system.
selection (str, list, tuple or numpy.ndarray, default 'all') – Atoms used for axis computation.
structure_indices ('all' or array-like, default 'all') – Structures/frames to evaluate.
weights (array-like, quantity, 'masses' or None, default None) – Non-negative weights per atom.
Noneassigns unit weight to every atom. Use'masses'for physical principal inertia axes.principal_axes_type ({'inertia', 'geometric'}, default 'inertia') – Kind of principal axes to compute.
syntax (str, default 'MolSysMT') – Selection syntax when using strings.
engine ({'MolSysMT'}, default 'MolSysMT') – Backend.
use_gpu (bool or 'auto', optional) – Whether to use a supported GPU backend.
skip_digestion (bool, default False) – Whether to skip argument digestion.
- Returns:
(axes, moments)whereaxeshas shape(n_structures, 3, 3)andmomentshas shape(n_structures, 3). Moments are geometric variances or inertia moments, depending onprincipal_axes_type.- Return type:
tuple
- Raises:
ArgumentError – If the atom or frame selection is empty, or weights are invalid.
ArgumentLengthError – If the number of weights does not match the selected atoms.
NotImplementedMethodError – If the engine is unsupported.
Notes
Axes are returned as rows, ordered by ascending eigenvalue, and form a right-handed orthonormal basis. Individual axis signs are mathematically arbitrary. Degenerate eigenvalues define a subspace rather than unique individual axes.
See also
molsysmt.structure.align_principal_axes()Align coordinates to a target principal-axis basis.
molsysmt.structure.get_center()Compute geometric or weighted centers.
Examples
>>> import molsysmt as msm >>> molsys = msm.systems['alanine dipeptide']['alanine_dipeptide.h5msm'] >>> axes, moments = msm.structure.get_principal_axes( ... molsys, structure_indices=0, weights='masses' ... ) >>> axes.shape, moments.shape ((1, 3, 3), (1, 3)) >>> round(float(np.linalg.det(axes[0])), 12) 1.0
Tutorial with more examples
Added in version 1.0.0.