Get volume from box#
Computing periodic cell volume directly from 3x3 box matrices.
The function molsysmt.pbc.get_volume_from_box() computes the scalar volume of a periodic boundary condition unit cell from its \(3\times 3\) box matrix (via the scalar triple product \(\mathbf{a} \cdot (\mathbf{b} \times \mathbf{c})\)).
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.pbc.get_volume_from_box().
Basic usage#
Let’s compute the volume of cubic and truncated octahedral periodic boxes:
import molsysmt as msm
import pyunitwizard as puw
box_cub = msm.pbc.get_box_with_shape(shape='cubic', length='3.0 nm')
vol_cub = msm.pbc.get_volume_from_box(box_cub)
print('Cubic box volume (nm^3):', vol_cub)
Cubic box volume (nm^3): [27.0] nanometer ** 3
Computing volumes for non-orthogonal boxes#
The volume calculation accounts for skew angles in non-orthogonal cells:
box_oct = msm.pbc.get_box_with_shape(shape='truncated octahedral', length='3.0 nm')
vol_oct = msm.pbc.get_volume_from_box(box_oct)
print('Truncated octahedral volume (nm^3):', vol_oct)
Truncated octahedral volume (nm^3): [20.78460969082653] nanometer ** 3
See also
Related Tools & References
Get box with shape: Construct standard boxes with
molsysmt.pbc.get_box_with_shape().Get volume from lengths and angles: Compute volume from dimensions with
molsysmt.pbc.get_volume_from_lengths_and_angles().Has PBC: Check system PBC status with
molsysmt.pbc.has_pbc().