box

mdtools.check.box(box, with_angles=None, orthorhombic=False, allow_negative=False, allow_zero=False, dim=None, dtype=None)[source]

Check if the input array satisfies the conditions for a simulation box array.

Arrays that contain the dimensions of simulation boxes must meet the following requirements:

  • Must be of an array_like type, i.e. a type that can be convertet to a numpy.ndarray.

  • Must have a data type equal to the supplied dtype.

  • If the array does not contain the box angles:

    • Must be of shape (3,) or (k, 3), where k is the number of frames.

  • If the array contains the box angles:

    • Must be of shape (6,) or (k, 6).

    • The angles must be greater than 0 and less than 180°.

Parameters
  • box (array_like) – The array to check.

  • with_angles (None or bool, optional) – If None (default), whether the box contains angles or not is inferred from the shape of the last dimension of box. If the last dimension has shape (3,), box is considered to not contain angles, if it has shape (6,), box is considered to contain angles. If with_angles is True or False the box must or must not contain angles, otherwise an exception is raised.

  • orthorhombic (bool, optional) – If True and with_angles evaluates to True, all angles of box must be 90°.

    Deprecated since version 0.0.0.dev0: This argument will be renamed to orthogonal in a future release.

  • allow_negative (bool, optional) – If True, allow negative box lengths (but not zero).

  • allow_zero (bool, optional) – If True, allow box lengths to be zero.

  • dim ({None, 1, 2}, optional) – The dimension expected for box. Default is None, which means that the dimension of box is not checked. If box should contain the box paramaters for only one frame, set dim to 1. If box should contain the box paramaters for multiple frames, set dim to 2.

  • dtype (type, optional) – The data type expected for box. Default is None, which means that the data type of box is not checked.

Returns

box – The input array as numpy.ndarray.

Return type

numpy.ndarray

Raises

ValueError – If box has an incorrect shape; incorrect dimensionality; an invalid angle; an invalid box length. Or if dim is not None and neither one or two. See mdtools.check.array() for further potentially raised exceptions.

See also

mdtools.check.array()

Check if an array meets given requirements

mdtools.check.pos_array()

Check if an array is a suitable position array