SolverBase#

Caution

work-in-progress

Backend: abstract base class

SolverBase(geometry, *[, mode])

Base class for all hklpy2 Solver classes.

class hklpy2.backends.base.SolverBase(geometry: str, *, mode: str = '', **kwargs)[source]#

Bases: ABC

Base class for all hklpy2 Solver classes.

Parameters

  • geometry: (str) Name of geometry.

  • mode: (str) Name of operating mode. (default: current mode)

Example:

import hklpy2

class MySolver(hklpy2.SolverBase):
    ...

Note

SolverBase, an abstract base class, cannot not be used directly by hklpy2 users.

As the parent class for all custom Solver classes, SolverBase defines the methods and attributes to be written that will connect hklpy2 with the support library that defines specific diffractometer geometries and the computations for using them. Subclasses should implement each of these methods as best fits the underlying support library.

Python Methods

addReflection(reflection)

Add coordinates of a diffraction condition (a reflection).

calculate_UB(r1, r2)

Calculate the UB (orientation) matrix with two reflections.

extra_axis_names

Ordered list of any extra axis names (such as x, y, z).

forward(pseudos)

Compute list of solutions(reals) from pseudos (hkl -> [angles]).

geometries()

Ordered list of the geometry names.

inverse(reals)

Compute tuple of pseudos from reals (angles -> hkl).

pseudo_axis_names

Ordered list of the pseudo axis names (such as h, k, l).

real_axis_names

Ordered list of the real axis names (such as th, tth).

refineLattice(reflections)

Refine the lattice parameters from a list of reflections.

removeAllReflections()

Remove all reflections.

Python Properties

geometry

Name of selected diffractometer geometry.

lattice

Crystal lattice parameters.

mode

Diffractometer geometry operation mode for forward().

modes

List of the geometry operating modes.

sample

Crystalline sample.

UB

Orientation matrix (3x3).

property UB#

Orientation matrix (3x3).

abstract addReflection(reflection: Reflection) None[source]#

Add coordinates of a diffraction condition (a reflection).

abstract calculate_UB(r1: Reflection, r2: Reflection) list[list[float]][source]#

Calculate the UB (orientation) matrix with two reflections.

The method of Busing & Levy, Acta Cryst 22 (1967) 457.

abstract property extra_axis_names: list[str]#

Ordered list of any extra axis names (such as x, y, z).

abstract forward(pseudos: dict) list[dict[str, float]][source]#

Compute list of solutions(reals) from pseudos (hkl -> [angles]).

abstract classmethod geometries() list[str][source]#

Ordered list of the geometry names.

EXAMPLES:

>>> from hklpy2 import get_solver
>>> Solver = get_solver("no_op")
>>> Solver.geometries()
[]
>>> solver = Solver("TH TTH Q")
>>> solver.geometries()
[]
abstract property geometry: str#

Name of selected diffractometer geometry.

Cannot be changed once solver is created. Instead, make a new solver for each geometry.

abstract inverse(reals: dict) dict[str, float][source]#

Compute tuple of pseudos from reals (angles -> hkl).

property lattice: object#

Crystal lattice parameters. (Not used by this Solver.)

property mode: str#

Diffractometer geometry operation mode for forward().

A mode defines which axes will be modified by the forward() computation.

abstract property modes: list[str]#

List of the geometry operating modes.

name = 'base'#

Name of this Solver.

abstract property pseudo_axis_names: list[str]#

Ordered list of the pseudo axis names (such as h, k, l).

abstract property real_axis_names: list[str]#

Ordered list of the real axis names (such as th, tth).

abstract refineLattice(reflections: list[Reflection]) Lattice[source]#

Refine the lattice parameters from a list of reflections.

abstract removeAllReflections() None[source]#

Remove all reflections.

property sample: object#

Crystalline sample.

version = '0.0.25.dev83+gf26812c'#

Version of this Solver.