wulfric.cell.get_niggli#

wulfric.cell.get_niggli(cell, eps_relative=1e-05, implementation='spglib', max_iterations=100000)[source]#

Computes Niggli-reduced cell.

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].

implementationstr, default "spglib"

Which implementation of the niggli reduction to use. Supported:

  • "spglib" (default)

    Implementation of spglib.

  • "wulfric"

    Implementation of wulfric of the algorithm from [2]. Details of the implementation are written in Niggli reduction.

Ideally, both implementation should give the same result. If you find any differences, please consider contacting developers with you example (support).

max_iterationsint, default 100000

Maximum number of iterations. Ignored if implementation="spglib".

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]]
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
>>> wulfric.cell.get_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
>>> 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 = wulfric.cell.from_params(a, b, c, alpha, beta, gamma)
>>> niggli_cell = wulfric.cell.get_niggli(cell)
>>> niggli_cell @ niggli_cell.T
array([[4. , 2. , 1.5],
       [2. , 9. , 4.5],
       [1.5, 4.5, 9. ]])