Get center#

Getting the geometric center or center of mass of a molecular system.

The function molsysmt.structure.get_center() computes the geometric center, center of mass, or custom weighted center of a molecular system across all structures or frames.

Added in version 1.0.0.

Basic usage#

Let’s show how to calculate the center of geometry of a pentalanine trajectory:

import molsysmt as msm
import numpy as np
molsys = msm.convert(msm.systems['pentalanine']['traj_pentalanine.h5'], to_form='molsysmt.MolSys')

By default, molsysmt.structure.get_center() computes the unweighted geometric center of all atoms:

center = msm.structure.get_center(molsys)
center.shape
(5000, 1, 3)
center[0]
Magnitude
[[0.8281487274554468 1.1086905834174925 -0.007842551886795028]]
Unitsnanometer

Getting the center of mass#

Setting weights='masses' weights atom coordinates by their respective atomic masses to compute the physical center of mass:

center_of_mass = msm.structure.get_center(molsys, selection='group_index==0', weights='masses')
center_of_mass[0]
Magnitude
[[0.8584538969155568 0.3675186564482274 0.029710175156011744]]
Unitsnanometer

Custom weighted center#

Explicit non-negative weights can be supplied as an array or list:

ca_atoms = msm.select(molsys, selection='atom_name=="CA"')
weights_ca = np.ones(len(ca_atoms))
ca_center = msm.structure.get_center(molsys, selection=ca_atoms, weights=weights_ca)
ca_center[0]
Magnitude
[[0.7867356538772583 1.1155330538749695 0.047727906703948976]]
Unitsnanometer