Get angles from box#

Extracting periodic box angles from 3x3 box matrices.

The function molsysmt.pbc.get_angles_from_box() computes crystallographic box angles \((\alpha, \beta, \gamma)\) from a \(3\times 3\) periodic cell matrix or an array of boxes.

Added in version 1.0.0.

Basic usage#

Let’s extract the box angles from a solvated molecular system:

import molsysmt as msm
import pyunitwizard as puw
molsys = msm.convert(msm.systems['Met-enkephalin']['met_enkephalin.h5msm'])
molsys_solvated = msm.build.solvate(molsys, box_shape='truncated octahedral', clearance='14.0 angstroms', engine='PDBFixer')

We query the box vectors matrix from the solvated system and compute the angles:

box = msm.get(molsys_solvated, element='system', box=True)
box_angles = msm.pbc.get_angles_from_box(box)
print('Box angles (degrees):', puw.convert(box_angles, to_unit='degrees'))
Box angles (degrees): [[70.5287554536443 109.47120709841901 70.5287554536443]] degree

Extracting angles from different box geometries#

The function extracts angles from any valid box matrix (e.g. cubic, truncated octahedral, rhombic dodecahedral):

box_cub = msm.pbc.get_box_with_shape(shape='cubic', length='3.0 nm')
box_dod = msm.pbc.get_box_with_shape(shape='rhombic dodecahedral', length='3.0 nm')

angles_cub = msm.pbc.get_angles_from_box(box_cub)
angles_dod = msm.pbc.get_angles_from_box(box_dod)
print('Cubic angles:', puw.convert(angles_cub, to_unit='degrees'))
print('Rhombic dodecahedral angles:', puw.convert(angles_dod, to_unit='degrees'))
Cubic angles: [[89.99998127603166 89.99998127603166 89.99998127603166]] degree
Rhombic dodecahedral angles: [[60.00002571454079 60.00002571454079 89.99998127603166]] degree