molsysmt.structure.get_center#

molsysmt.structure.get_center(molecular_system, selection='all', weights=None, structure_indices='all', syntax='MolSysMT', engine='MolSysMT', heavy_mode='auto', parallel=None, num_threads=None, skip_digestion=False)[source]#

Computing centers (centroids or weighted centers) of atom selections.

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.

  • weights (numpy.ndarray, list, or tuple, default=None) – Atomic mass weights array for center calculation.

  • 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.

  • heavy_mode ({'auto', 'force', 'off'}, default='auto') – Policy controlling the chunked path for memory-intensive calculations.

  • parallel (bool or None, default=None) – Whether to use CPU parallelism, or None to use the configured default.

  • num_threads (int or None, default=None) – Number of CPU worker threads, or None to use the configured default.

  • skip_digestion (bool, default=False) – Whether to skip MolSysMT’s internal argument digestion mechanism.

Returns:

Centers as a PyUnitWizard quantity in length units.

Return type:

quantity

Raises:
  • ArgumentError – If the atom or frame selection is empty, or weights are non-finite, negative, or have zero total weight.

  • ArgumentLengthError – If the number of weights does not match the selected atoms.

  • NotImplementedMethodError – If an unsupported engine is requested.

Notes

Chunked calculations use nm internally and return a quantity standardized to the session’s length unit. Native iteration reads the existing structures domain and copies only selected coordinate blocks; accumulated output still occupies memory.

Examples

>>> import molsysmt as msm
>>> from molsysmt.structure.get_center import get_center
>>> molsys = msm.convert(msm.systems['alanine dipeptide']['alanine_dipeptide.h5msm'], to_form='molsysmt.MolSys')
>>> get_center(molsys, weights='masses').shape
(1, 1, 3)

Added in version 1.0.0.