wulfric.cell.niggli#

wulfric.cell.niggli(cell, eps_relative=1e-05, max_iterations=100000, return_transformation_matrix=False)[source]#

Computes reduced Niggli cell. Implements algorithm from [2].

Details of the implementation are written in Niggli reduction.

Parameters:
cell(3, 3) array-like

Matrix of a cell, rows are interpreted as vectors.

eps_relativefloat, default \(10^{-5}\)

Relative epsilon as defined in [2].

max_iterationsint, default 100000

Maximum number of iterations.

return_transformation_matrixbool, default False

Whether to return a transformation matrix from given cell to the niggli_cell.

Returns:
niggli_cell(3, 3) numpy.ndarray

Matrix of a niggli reduced cell, rows are interpreted as vectors.

niggli_cell = [[a1_x, a1_y, a1_z],
               [a2_x, a2_y, a2_z],
               [a3_x, a3_y, a3_z]]
transformation_matrix(3, 3) numpy.ndarray

Returned only if return_transformation_matrix is True.

Raises:
wulfric.exceptions.NiggliReductionFailed

If the niggli cell is not found in max_iterations iterations.

ValueError

If the volume of cell is zero.

References

[1]

Křivý, I. and Gruber, B., 1976. A unified algorithm for determining the reduced (Niggli) cell. Acta Crystallographica Section A: Crystal Physics, Diffraction, Theoretical and General Crystallography, 32(2), pp.297-298.

[2] (1,2)

Grosse-Kunstleve, R.W., Sauter, N.K. and Adams, P.D., 2004. Numerically stable algorithms for the computation of reduced unit cells. Acta Crystallographica Section A: Foundations of Crystallography, 60(1), pp.1-6.

Examples

>>> import wulfric as wulf
>>> wulf.cell.niggli([[1, -0.5, 0],[-0.5, 1, 0],[0, 0, 1]])
array([[ 0.5,  0.5,  0. ],
       [ 0. ,  0. , -1. ],
       [-1. ,  0.5,  0. ]])

Example from [1] (parameters are reproducing \(A=9\), \(B=27\), \(C=4\), \(\xi\) = -5, \(\eta\) = -4, \(\zeta = -22\)):

>>> import wulfric as wulf
>>> from wulfric.constants import TODEGREES
>>> from math import sqrt, acos
>>> a = 3
>>> b = sqrt(27)
>>> c = 2
>>> alpha = acos(-5 / 2 / b / c) * TODEGREES
>>> beta = acos(-4 / 2 / a / c) * TODEGREES
>>> gamma = acos(-22 / 2 / a / b) * TODEGREES
>>> cell = wulf.cell.from_params(a, b, c, alpha, beta, gamma)
>>> niggli_cell = wulf.cell.niggli(cell)
>>> niggli_cell @ niggli_cell.T
array([[4. , 2. , 1.5],
       [2. , 9. , 4.5],
       [1.5, 4.5, 9. ]])