wulfric.geometry.parallelepiped_check#

wulfric.geometry.parallelepiped_check(a, b, c, alpha, beta, gamma, raise_error=False, length_tolerance=1e-08, angle_tolerance=0.0001)[source]#

Checks if parallelepiped is valid.

The conditions are

  • \(a > 0\)

  • \(b > 0\)

  • \(c > 0\)

  • \(0 < \alpha < 180\)

  • \(0 < \beta < 180\)

  • \(0 < \gamma < 180\)

  • \(\gamma < \alpha + \beta < 360 - \gamma\)

  • \(\beta < \alpha + \gamma < 360 - \beta\)

  • \(\alpha < \beta + \gamma < 360 - \alpha\)

Parameters:
afloat

Length of the \(\boldsymbol{v_1}\) vector.

bfloat

Length of the \(\boldsymbol{v_2}\) vector.

cfloat

Length of the \(\boldsymbol{v_3}\) vector.

alphafloat

Angle between vectors \(\boldsymbol{v_2}\) and \(\boldsymbol{v_3}\). In degrees.

betafloat

Angle between vectors \(\boldsymbol{v_1}\) and \(\boldsymbol{v_3}\). In degrees.

gammafloat

Angle between vectors \(\boldsymbol{v_1}\) and \(\boldsymbol{v_2}\). In degrees.

raise_errorbool, default False

Whether to raise error if parameters can not form a parallelepiped.

length_tolerancefloat, default \(10^{-8}\)

Numerical tolerance for the length variables. Default value is chosen in the contexts of condense matter physics, assuming that length is given in Angstroms. Please choose appropriate tolerance for your problem.

angle_tolerancefloat, default \(10^{-4}\)

Numerical tolerance for the angle variables. Default value is chosen in the contexts of condense matter physics, assuming that angles are in degrees. Please choose appropriate tolerance for your problem.

Returns:
result: bool

Whether the parameters could from a parallelepiped.

Raises:
ValueError

If parameters can not form a parallelepiped. Only raised if raise_error is True (it is False by default).

Examples

>>> import wulfric
>>> wulfric.geometry.parallelepiped_check(1, 1, 1, 90, 90, 90)
True
>>> wulfric.geometry.parallelepiped_check(1, 1, 1, 30, 20, 110)
False
>>> wulfric.geometry.parallelepiped_check(1, -1, 1, 90, 90, 90)
False
>>> wulfric.geometry.parallelepiped_check(1, 0, 1, 90, 90, 90)
False
>>> wulfric.geometry.parallelepiped_check(1, 1, 1, 90, 199, 90)
False