Get box from lengths and angles#

Building 3x3 periodic box matrices from lengths and angles.

The function molsysmt.pbc.get_box_from_lengths_and_angles() constructs a standard \(3\times 3\) box matrix (or array of matrices) from edge lengths \((a, b, c)\) and crystallographic angles \((\alpha, \beta, \gamma)\).

Added in version 1.0.0.

Basic usage#

Let’s construct an orthorhombic periodic box matrix from specified dimensions and 90-degree angles:

import molsysmt as msm
import pyunitwizard as puw
lengths = puw.quantity([[4.0, 5.0, 6.0]], 'nm')
angles = puw.quantity([[90.0, 90.0, 90.0]], 'degrees')
box = msm.pbc.get_box_from_lengths_and_angles(lengths, angles)
print('Constructed box matrix:\n', box)
Constructed box matrix:
 [[[4.0 0.0 0.0]  [0.0 5.0 0.0]  [0.0 0.0 6.0]]] nanometer

Constructing triclinic box matrices#

Non-orthogonal angles generate corresponding triclinic/skewed cell matrices:

lengths_tri = puw.quantity([[3.0, 3.0, 3.0]], 'nm')
angles_tri = puw.quantity([[60.0, 60.0, 90.0]], 'degrees')
box_tri = msm.pbc.get_box_from_lengths_and_angles(lengths_tri, angles_tri)
print('Triclinic box matrix:\n', box_tri)
Triclinic box matrix:
 [[[3.0 0.0 0.0]  [0.0 3.0 0.0]  [1.5 1.5 2.12132]]] nanometer