\(\renewcommand\AA{\unicode{x212B}}\)

CalculateUMatrix v1

Summary

Calculate the U matrix from a peaks workspace, given lattice parameters.

See Also

SetUB

Properties

Name

Direction

Type

Default

Description

PeaksWorkspace

InOut

IPeaksWorkspace

Mandatory

An input workspace.

a

Input

number

Mandatory

Lattice parameter a

b

Input

number

Mandatory

Lattice parameter b

c

Input

number

Mandatory

Lattice parameter c

alpha

Input

number

Mandatory

Lattice parameter alpha

beta

Input

number

Mandatory

Lattice parameter beta

gamma

Input

number

Mandatory

Lattice parameter gamma

Description

Given a set of peaks (Q in the goniometer frame, HKL values), and given lattice parameters \((a,b,c,\alpha,\beta,\gamma)\), it will try to find the U matrix, using least squares approach and quaternions 1. Units of length are in in \(\rm \AA\), angles are in degrees.

The algorithm calculates first the B matrix according to Busing and Levi.

Given a set of peaks in the reference frame of the inner axis of the goniometer, \(\rm Q_{gon}\), indexed by \((h_i, k_i, l_i)\), we want to find the U matrix that maps peaks in the reciprocal space of the sample to the peaks in the goniometer frame

(1)\[\begin{split}\rm U \rm B \left( \begin{array}{c} h_i \\ k_i \\ l_i \\ \end{array} \right) = \rm Q_{gon,i}\end{split}\]

For simplicity, we define

(2)\[\begin{split}\rm Q_{hkl,i} = \rm B \left( \begin{array}{c} h_i \\ k_i \\ l_i \\ \end{array} \right)\end{split}\]

In the real world, such a matrix is not always possible to find. Therefore we just try minimize the difference between the two sets of p

(3)\[\sum_i |\rm U \rm Q_{hkl,i} - \rm Q_{gon,i}|^2 = \sum_i \left(|\rm U \rm Q_{hkl,i}|^2 + |\rm Q_{gon,i}|^2 -2 \rm U \rm Q_{hkl,i} \cdot \rm Q_{gon,i}\right)\]

In equation (3), \(\left|\rm U \rm Q_{hkl,i}\right|^2 = |\rm Q_{hkl,i}|^2\), so the first two terms on the left side are U independent. Therefore we want to maximize

(4)\[\sum_i \left(\rm U \rm Q_{hkl,i} \cdot \rm Q_{gon,i}\right)\]

We are going to write the scalar product of the vectors in terms of quaternions 2. We define \(q_{hkl,i} = \left(0, Q_{hkl,i}\right)\), \(q_{gon,i} = \left(0, Q_{gon,i}\right)\) and the rotation U is described by quaternion \(u = \left(w,x,y,z\right)\)

Then equation (4) will be written as

(5)\[\sum_i \left(\rm U \rm Q_{hkl,i} \cdot \rm Q_{gon,i}\right) = 0.5 \cdot \left(u q_{hkl,i} u^*\right) q_{gon,i}\ + 0.5 \cdot q_{gon,i} \left(u q_{hkl,i} u^*\right)\]

We define matrices

(6)\[\begin{split}H_i= \left(\begin{array}{cccc} 0 & -q_{hkl,i,x} & -q_{hkl,i,y} & -q_{hkl,i,z} \\ q_{hkl,i,x} & 0 & q_{hkl,i,z} & -q_{hkl,i,y} \\ q_{hkl,i,y} & -q_{hkl,i,z} & 0 & q_{hkl,i,x} \\ q_{hkl,i,z} & q_{hkl,i,y} & -q_{hkl,i,x} & 0 \end{array} \right)\end{split}\]

and

(7)\[\begin{split}S_i= \left(\begin{array}{cccc} 0 & -q_{gonl,i,x} & -q_{gon,i,y} & -q_{gon,i,z} \\ q_{gon,i,x} & 0 & -q_{gon,i,z} & q_{gon,i,y} \\ q_{gon,i,y} & q_{gon,i,z} & 0 & -q_{gon,i,x} \\ q_{gon,i,z} & -q_{gon,i,y} & q_{gon,i,x} & 0 \end{array} \right)\end{split}\]

Then, we can rewrite equation (5) using matrices 3, 4:

(8)\[\begin{split}\sum_i \left(\rm U \rm Q_{hkl,i} \cdot \rm Q_{gon,i}\right) = \left(\begin{array}{cccc} w & x & y & z\end{array} \right) \sum_i H_i S_i \left( \begin{array}{c} w \\ x \\ y \\ z \end{array} \right)\end{split}\]

The problem of finding \(\left(w,x,y,z\right)\) that maximizes the sum can now be rewritten in terms of eigenvectors of \(HS= \sum_i \left(H_i S_i\right)\) . Let \(\epsilon_j\) and \(\nu_j\) be the eigenvalues and corresponding eigenvectors of \(HS\), with \(\epsilon_0 > \epsilon_1 > \epsilon_2 > \epsilon_3\). We can write any vector \((w,x,y,z)\) as a linear combination of the eigenvectors of \(HS\):

(9)\[ \left(w,x,y,z\right) = \delta_0 \nu_0 +\delta_1 \nu_1 +\delta_2 \nu_2 +\delta_3 \nu_3\]
(10)\[\begin{split} \left(\begin{array}{cccc} w & x & y & z\end{array} \right) HS \left( \begin{array}{c} w \\ x \\ y \\ z \end{array} \right) = \delta_0^2 \nu_0 HS \nu_0 + \delta_1^2 \nu_1 HS \nu_1 +\delta_2^2 \nu_2 HS \nu_2 +\delta_3 \nu_3 HS \nu_3\end{split}\]
(11)\[\begin{split} & = \delta_0^2 \epsilon_0 + \delta_1^2 \epsilon_1 +\delta_2^2 \epsilon_2 +\delta_3 ^2 \epsilon_3 \end{split}\]

where \(u\) is a unit quaternion, \(\delta_0^2 + \delta_1^2 +\delta_2^2 +\delta_3 ^2=1\) (12)

Then the sum in equation (11) is maximized for \(\epsilon_0 =1, \epsilon_1 =0, \epsilon_2 =0 \epsilon_3 =0\)

Therefore U is the rotation represented by the quaternion \(u\), which is the eigenvector corresponding to the largest eigenvalue of \(HS\).

For more information see the documentation for UB matrix.

Categories: AlgorithmIndex | Crystal\UBMatrix

Source

C++ header: CalculateUMatrix.h

C++ source: CalculateUMatrix.cpp