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 in length-angle representation.

Arrays that contain the dimensions of simulation boxes in the length-angle representation must meet the following requirements:

  • Must be of an array_like type, i.e. a type that can be converted 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°. Is ignored if with_angles is False or if box does not contain angle information.

  • 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 must be either 1 or 2. If box should contain the box parameters for only one frame, set dim to 1. If box should contain the box parameters 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 (numpy.ndarray) – The input array as 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.box_mat()

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

mdtools.check.array()

Check if an array meets given requirements

mdtools.check.pos_array()

Check if an array is a suitable position array