Move away#
Translating a molecular selection away from a reference center by a fixed distance.
The function molsysmt.structure.move_away() translates a target selection of atoms or an entire molecular system away from a reference center by a specified Euclidean distance along an automatic or user-defined 3D direction vector.
Added in version 1.0.0.
API documentation
Follow this link for a detailed description of the input arguments, raised errors, and returned objects of this function: molsysmt.structure.move_away().
Basic usage#
Let’s show how to translate one alanine dipeptide molecule away from another by a specified distance:
import molsysmt as msm
import numpy as np
import pyunitwizard as puw
molsys_A = msm.convert(msm.systems['alanine dipeptide']['alanine_dipeptide.h5msm'])
molsys_A = msm.structure.center(molsys_A)
molsys_B = msm.convert(msm.systems['alanine dipeptide']['alanine_dipeptide.h5msm'])
molsys_B = msm.structure.center(molsys_B)
Note
Demo Systems Catalog
This tutorial uses demonstration datasets provided by MolSysMT. To explore the full catalog of bundled systems, forms, and file paths, visit the Demo Systems guide.
We translate molsys_B away from molsys_A by 2.0 nm along the X-axis using molsysmt.structure.move_away():
molsys_B_moved = msm.structure.move_away(molsys_B, reference_molecular_system=molsys_A, distance='2.0 nm', direction=[1.0, 0.0, 0.0])
center_A = msm.structure.get_center(molsys_A)
center_B = msm.structure.get_center(molsys_B_moved)
print('Center of molsys A:', center_A)
print('Center of molsys B after displacement:', center_B)
Center of molsys A: [[[5.0464682937507114e-17 -1.5139404881252134e-17 -2.523234146875356e-18]]] nanometer
Center of molsys B after displacement: [[[2.0000000000000004 -1.5139404881252134e-17 -2.523234146875356e-18]]] nanometer
Directional displacement along arbitrary 3D vectors#
We can displace the mobile system along any arbitrary spatial direction vector (e.g. diagonal unit vector \([1, 1, 0]\)):
molsys_B_diag = msm.structure.move_away(molsys_B, reference_molecular_system=molsys_A, distance='3.0 nm', direction=[1.0, 1.0, 0.0])
center_diag = msm.structure.get_center(molsys_B_diag)
print('Center after diagonal translation:', center_diag)
Center after diagonal translation: [[[2.121320343559642 2.121320343559642 -2.523234146875356e-18]]] nanometer
Quantitative verification of spatial separation#
We verify that the Euclidean distance between the centroids matches the specified target distance:
disp_vector = puw.get_value(center_diag - center_A)
euclidean_distance = np.linalg.norm(disp_vector)
print(f'Measured Euclidean separation: {euclidean_distance:.4f} nm')
Measured Euclidean separation: 3.0000 nm
See also
Related Tools & References
Convert: Convert molecular systems between different forms with
molsysmt.basic.convert().Center: Center coordinates on the geometric origin with
molsysmt.structure.center().Get center: Compute the geometric center or center of mass with
molsysmt.structure.get_center().Get distances: Compute pairwise Euclidean distances with
molsysmt.structure.get_distances().Get principal axes: Compute the principal axes and moments of inertia with
molsysmt.structure.get_principal_axes().