hkl_soleil UB matrix : calculate from 2 reflections.#

$UB$ is the 3x3 orientation matrix used to transform coordinates between reciprocal space directions (of the crystal lattice planes) and the rotational axes of the diffractometer.

Create a diffractometer object#

First, create a diffractometer object that uses the "hkl_soleil" solver with the "hkl" computation engine. This solver provides support for many diffractometer geometries. This example will use the simulated 4-circle geometry from the solver’s "E4CV".

import hklpy2

diffractometer = hklpy2.creator(name="diffractometer")

Defaults#

The diffractometer object starts with a default sample. The structure is cubic ($a=b=c$, 90 degree corners).

diffractometer.sample
Sample(name='sample', lattice=Lattice(a=1, system='cubic'))

Add 2 reflections#

Two reflections are needed to calculate $UB$. Since we do not specify the wavelength, the support assumes the diffractometer’s current wavelength.

diffractometer.wavelength.get()
1.0

Add two non-parallel reflections. Here, just the values of the pseudos and reals are specified as Python tuples, in the exact order expected by the solver geometry.

r100 = diffractometer.add_reflection((1, 0, 0), (-145.451, 5, -5, 69.0966), name="(100)")
r010 = diffractometer.add_reflection((0, 1, 0), (-145.451, 5, 85, 69.0966), name="(010)")

Compute UB#

Compute $UB$ with these two reflections:

diffractometer.core.calc_UB(r100, r010)
[[0.545455242664, -6.239788247453, -0.49592954663],
 [-0.547615556651, -0.543471893498, 6.235636483453],
 [-6.235462715682, -0.498106806877, -0.591013170474]]

Show the calculated $UB$ matrix:

diffractometer.core.solver.UB
[[0.545455242664, -6.239788247453, -0.49592954663],
 [-0.547615556651, -0.543471893498, 6.235636483453],
 [-6.235462715682, -0.498106806877, -0.591013170474]]

Try it out#

corresponding to the $(1,0,0)$ reflection:

diffractometer.forward(1, 0, 0)
Hklpy2DiffractometerRealPos(omega=-150.000007544679, chi=4.999999954605, phi=-4.999297290893, tth=59.999984910642)

Show the (first set of computed) angles corresponding to the $(1 \bar1 1)$ reflection:

diffractometer.forward(1, -1, 1)
Hklpy2DiffractometerRealPos(omega=-120.000010083233, chi=-34.93175944456, phi=-44.822654638391, tth=119.999979833534)