Solvers Guide#
See also
Solvers for a concept overview.
How to list available Solvers#
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'}
How to select a Solver#
To create an instance of a specific Solver class, use
solver_factory(). The first argument is the entry point
name; the geometry keyword picks the geometry. In the next example
(Linux-only), hkl_soleil picks the
HklSolver and "E4CV" selects the
Eulerian 4-circle geometry with the hkl engine:
>>> from hklpy2 import solver_factory
>>> solver = solver_factory("hkl_soleil", "E4CV")
>>> print(solver)
HklSolver(name='hkl_soleil', version='v5.0.0.3434', geometry='E4CV', engine='hkl')
To select a Solver class without creating an instance, call
get_solver():
>>> from hklpy2 import get_solver
>>> Solver = get_solver("hkl_soleil")
>>> print(f"{Solver=}")
Solver=<class 'hklpy2.backends.hkl_soleil.HklSolver'>
How to register a new Solver#
A Solver class is registered as a plugin via an entry point
using the "hklpy2.solver" group. Here is an example from hklpy2’s
pyproject.toml:
[project.entry-points."hklpy2.solver"]
hkl_soleil = "hklpy2.backends.hkl_soleil:HklSolver"
th_tth = "hklpy2.backends.th_tth_q:ThTthSolver"
See also
Solver descriptions#
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 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, 2\theta\) geometry with a \(Q\) pseudo axis. It can be used on any OS where Python runs.