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.

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)

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