Get volume from lengths and angles#

Computing periodic cell volume from edge lengths and angles.

The function molsysmt.pbc.get_volume_from_lengths_and_angles() evaluates the volume of a periodic unit cell analytically from its edge lengths \((a, b, c)\) and crystallographic angles \((\alpha, \beta, \gamma)\).

Added in version 1.0.0.

Basic usage#

Let’s compute the volume of a periodic cell defined by lengths and angles:

import molsysmt as msm
import pyunitwizard as puw
lengths = puw.quantity([[2.0, 3.0, 4.0]], 'nm')
angles = puw.quantity([[90.0, 90.0, 90.0]], 'degrees')
volume = msm.pbc.get_volume_from_lengths_and_angles(lengths, angles)
print('Calculated volume:', volume)
Calculated volume: [24.0] nanometer ** 3

Volume of a monoclinic / triclinic cell#

For non-orthogonal angles, the formula \(V = a b c \sqrt{1 - \cos^2\alpha - \cos^2\beta - \cos^2\gamma + 2\cos\alpha\cos\beta\cos\gamma}\) is evaluated:

angles_tri = puw.quantity([[90.0, 90.0, 60.0]], 'degrees')
volume_tri = msm.pbc.get_volume_from_lengths_and_angles(lengths, angles_tri)
print('Triclinic cell volume:', volume_tri)
Triclinic cell volume: [20.784609690826528] nanometer ** 3