def test_volume(): # Very rudimentary test box = np.array([ [5, 0, 0], [0, 8, 0], [0, 0, 2], ]) assert struc.box_volume(box) == pytest.approx(80) boxes = np.stack([box, box]) assert struc.box_volume(boxes) == pytest.approx(80, 80)
# # Depending on the source of the macromolecular structure, there might # be an associated unit cell or simulation box. # In this package such boxes are represented by *(3,3)*-shaped # :class:`ndarray` objects, where each element in the array is one of # the three vectors spanning the box or unit cell. # Let's create an orthorhombic box from the vector lengths and the # angles between the vectors. import numpy as np import biotite.structure as struc # The function uses angles in radians box = struc.vectors_from_unitcell(10, 20, 30, np.pi / 2, np.pi / 2, np.pi / 2) print("Box:") print(box) print("Box volume:", struc.box_volume(box)) print("Is orthogonal?:", struc.is_orthogonal(box)) cell = struc.unitcell_from_vectors(box) print("Cell:") print(cell) ######################################################################## # An atom array can have an associated box, which is used in functions, # that consider periodic boundary conditions. # Atom array stacks require a *(m,3,3)*-shaped :class:`ndarray`, # that contains the box vectors for each model. # The box is accessed via the `box` attribute, which is ``None`` by # default. # When loaded from a structure file, the box described in the file is # automatically used.