Refine lattice from 3 reflections#

NOTE: work-in-progress

The lattice parameters of a sample can be computed from a set of 3 or more reflections if the solver provides such a method. The hkl_soleil solver uses a simplex. The computed lattice is likely the lowest symmetry since the parameters are refined to meet best the observed reflections.

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

[1]:
from hklpy2 import SimulatedE4CV

diffractometer = SimulatedE4CV(name="diffractometer")

Defaults#

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

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

Add 3 reflections#

At least three reflections are needed to refine the lattice parameters. Since we do not specify the wavelength, the support assumes the diffractometer’s current wavelength.

[3]:
diffractometer.wavelength.get()
[3]:
1.0

Add three 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.

[4]:
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)")
r001 = diffractometer.add_reflection((0, 0, 1), (-145.451, -85, -95, 69.0966), name="(001)")

Compute refined lattice#

Compute the lattice refined with these three reflections. Notice that the refined lattice is triclinic and not the original cubic symmetry.

[5]:
lattice = diffractometer.operator.refine_lattice([r100, r010, r001])
lattice
[5]:
Lattice(a=0.885, b=0.8953, c=0.8987, alpha=79.9999, beta=85.0196, gamma=89.5632, system='triclinic')

The refine_lattice() method returns the refined lattice but does not actually change the sample lattice:

[6]:
diffractometer.sample.lattice
[6]:
Lattice(a=1, system='cubic')

Change the sample lattice#

The sample lattice can be changed with the refined lattice:

[7]:
diffractometer.sample.lattice = lattice
diffractometer.sample.lattice
[7]:
Lattice(a=0.885, b=0.8953, c=0.8987, alpha=79.9999, beta=85.0196, gamma=89.5632, system='triclinic')