Solvers#
A Solver is a Python class that connects hklpy2 with a (backend) library that provides diffractometer capabilities, including:
definition(s) of physical diffractometer geometries
axes (angles and reciprocal space)
operating modes for the axes (angles and reciprocal space)
calculations that convert:
forward: reciprocal space coordinates into diffractometer angles
inverse: diffractometer angles into reciprocal space coordinates
support blocks include:
calculate the UB matrix
refine the crystal lattice
sample definition
name
crystal lattice parameters: \(a, b, c, \alpha, \beta, \gamma\)
list of orientation reflections
A Solver class is written as a plugin for hklpy2 and is connected by an entry point
using the "hklpy2.solver"
group. Here’s an example from hklpy2’s
pyproject.toml
file for two such Solver classes:
[project.entry-points."hklpy2.solver"]
hkl_soleil = "hklpy2.backends.hkl_soleil:HklSolver"
th_tth = "hklpy2.backends.th_tth_q:ThTthSolver"
How to select a Solver#
To list all available Solver classes (by their entry point name),
call solvers()
.
This example shows the Solver classes supplied with hklpy2:
>>> from hklpy2 import solvers
>>> solvers()
{'hkl_soleil': 'hklpy2.backends.hkl_soleil:HklSolver',
'th_tth': 'hklpy2.backends.th_tth_q:ThTthSolver'}
This is a dictionary, keyed by the solver names. To create an instance
of a specific Solver class, use solver_factory()
.
In the next example (Linux-only), the first argument, hkl_soleil, picks the
HklSolver
, the geometry keyword
picks the Eulerian 4-circle geometry with the hkl engine:
To select a Solver class without creating an instance, call
get_solver()
. This example
selects the Hkl/Soleil Solver (using its entry point name:
"hkl_soleil"
):
Solver: hkl_soleil#
Hkl (documentation), from Synchrotron Soleil, is used as a backend library to convert between real-space motor coordinates and reciprocal-space crystallographic coordinates. Here, we refer to this library as hkl_soleil to clarify and distinguish from other use of of the term hkl. Multiple source code repositories exist. hklpy2 uses the active development repository.
Caution
At this time, it is only compiled for 64-bit Linux. Not Windows, not Mac OS.
Solver: no_op#
This solver was built for testing the hklpy2 code. It provides no useful geometries for diffractometer users.
Solver: th_tth#
This solver was built as a demonstration of a minimal all Python solver. It provides basic support for $theta, 2theta$ geometry with a $Q$ pseudo axis. It can be used on any OS where Python runs.
How to write a Solver#
See also