Using hklpy2-solvers with hklpy2#

The package registers itself automatically via the hklpy2.solver entry point once installed, so no imports from hklpy2_solvers are needed in normal use.

Installation#

pip install hklpy2-solvers

This makes all solvers provided by this package available to hklpy2 immediately.

Available solvers#

Solver name

Geometry name(s)

Description

diffcalc

diffcalc_4S_2D

You (1999) six-circle geometry via diffcalc-core. 23 operating modes.

ad_hoc

fourcv, fourch, psic, sixc, fivec, kappa4cv, kappa4ch, kappa6c, zaxis, s2d2

10 diffractometer geometries via ad_hoc_diffractometer. 2–24 modes per geometry.

See Geometries for the full description of each geometry and its operating modes.

Creating a diffractometer#

Use hklpy2.creator() to create a diffractometer object for any solver geometry provided by this package. The solver and geometry arguments select the backend:

import hklpy2

# Using the diffcalc solver (You 1999 six-circle)
psic = hklpy2.creator(
    solver="diffcalc",
    geometry="diffcalc_4S_2D",
    name="psic",
)

# Using the ad_hoc solver (Busing & Levy four-circle vertical)
fourc = hklpy2.creator(
    solver="ad_hoc",
    geometry="fourcv",
    name="fourc",
)

The resulting objects are fully-functional hklpy2 diffractometers with simulated motor positioners for all real axes and the three reciprocal-space pseudo axes (h, k, l).

See How to use the diffcalc solver and How to use the ad_hoc solver for step-by-step instructions on orienting a sample and computing positions with each solver.

Further use#

Once the diffractometer object is created, all standard hklpy2 operations apply — setting the lattice, adding orientation reflections, calculating the UB matrix, choosing an operating mode, and moving in reciprocal space. Refer to the hklpy2 documentation for the full user guide.