Skip to content

Dims

Dimensions of systems.

This module provides utility functions to calculate geometric properties of a molecular system such as the bounding box lengths, box vectors, and the volume of the box required to enclose the atoms.

get_box_lengths(positions)

Compute lengths of box edges.

This function calculates the lengths of the edges of a box that encompasses a set of atomic positions by finding the difference between the maximum and minimum coordinates in each dimension.

PARAMETER DESCRIPTION
positions

A 2D NumPy array of shape (N, 3), where N is the number of atoms and each row represents the Cartesian coordinates [x, y, z] of an atom.

TYPE: NDArray[float64]

RETURNS DESCRIPTION
NDArray[float64]

A 1D NumPy array of shape (3,) containing the lengths of the box in the x, y, and z directions.

Example
>>> import numpy as np
>>> from box_utils import get_box_lengths
>>> positions = np.array([[0, 0, 0], [1, 2, 3]])
>>> get_box_lengths(positions)
array([1., 2., 3.])

get_box_vectors(positions)

Construct orthogonal box vectors.

This function calculates the vectors of the edges of a box that encompasses a set of atomic positions. The vectors are represented as a diagonal matrix where the diagonal elements correspond to the lengths of the box edges.

PARAMETER DESCRIPTION
positions

A 2D NumPy array of shape (N, 3), where N is the number of atoms and each row represents the Cartesian coordinates [x, y, z] of an atom.

TYPE: NDArray[float64]

RETURNS DESCRIPTION
NDArray[float64]

A 3x3 NumPy array representing the box vectors in matrix form. The matrix is diagonal since the box is assumed to be orthorhombic.

Example
>>> import numpy as np
>>> from box_utils import get_box_vectors
>>> positions = np.array([[0, 0, 0], [1, 2, 3]])
>>> get_box_vectors(positions)
array([[1., 0., 0.],
       [0., 2., 0.],
       [0., 0., 3.]])

get_box_volume(positions)

Calculate volume of the enclosing orthorhombic box.

Computes the volume of the orthorhombic box that encapsulates all atoms. The box vectors are assumed to form an orthogonal basis.

PARAMETER DESCRIPTION
positions

A 2D NumPy array of shape (N, 3), where N is the number of atoms and each row represents the Cartesian coordinates [x, y, z] of an atom.

TYPE: NDArray[float64]

RETURNS DESCRIPTION
float

Volume of the enclosing box.

Example
>>> import numpy as np
>>> from box_utils import get_box_volume
>>> positions = np.array([[0, 0, 0], [1, 2, 3]])
>>> get_box_volume(positions)
6.0