Quickstart#

This page verifies that hklpy2 is installed and working. If you are new to hklpy2, continue to the Tutorial: Your First Diffractometer after this page for a full guided walkthrough: sample setup, orientation reflections, UB matrix computation, and reciprocal-space scanning.

See also

Tutorial: Your First Diffractometer — start here for a complete first experience.

How to Work with a Diffractometer — how to define and work with a diffractometer.

Diffractometers — available geometries and solvers.

Guides — task-oriented how-to guides for common workflows.

Installation#

Install hklpy2 and its dependencies:

pip install hklpy2

Then confirm the installation:

import hklpy2
print(hklpy2.__version__)

Create a Simulated Diffractometer#

Use creator() to build a simulated 6-circle diffractometer (no hardware required):

>>> import hklpy2
>>> sixc = hklpy2.creator(name="sixc", geometry="E6C", solver="hkl_soleil")

Make it the default diffractometer for the interactive interface:

>>> from hklpy2.user import *
>>> set_diffractometer(sixc)

Show the brief position report:

>>> wh()  # wh: "WHere"
h=0, k=0, l=0
wavelength=1.0
mu=0, omega=0, chi=0, phi=0, gamma=0, delta=0

Show the full orientation report:

>>> pa()  # pa: "Print All"
diffractometer='sixc'
HklSolver(name='hkl_soleil', version='5.1.2', geometry='E6C', engine_name='hkl', mode='bissector_vertical')
Sample(name='sample', lattice=Lattice(a=1, system='cubic'))
Orienting reflections: []
U=[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
UB=[[6.28318530718, -0.0, -0.0], [0.0, 6.28318530718, -0.0], [0.0, 0.0, 6.28318530718]]
constraint: -180.0 <= mu <= 180.0
constraint: -180.0 <= omega <= 180.0
constraint: -180.0 <= chi <= 180.0
constraint: -180.0 <= phi <= 180.0
constraint: -180.0 <= gamma <= 180.0
constraint: -180.0 <= delta <= 180.0
h=0, k=0, l=0
wavelength=1.0
mu=0, omega=0, chi=0, phi=0, gamma=0, delta=0

Calculate angles for \(hkl=(1\ \bar{1}\ 0)\) without moving motors:

>>> cahkl(1, -1, 0)
Hklpy2DiffractometerRealPos(mu=0, omega=-45.000000066239, chi=44.999999876575, phi=-89.999999917768, gamma=0, delta=-90.000000132477)
>>> wh()
h=0, k=0, l=0
wavelength=1.0
mu=0, omega=0, chi=0, phi=0, gamma=0, delta=0

Note this was only a calculation — the motors did not move. Move now:

>>> sixc.move(1, -1, 0)
MoveStatus(done=True, pos=sixc, elapsed=0.0, success=True, settle_time=0.0)
>>> wh()
h=1.0, k=-1.0, l=0
wavelength=1.0
mu=0, omega=-45.0, chi=45.0, phi=-90.0, gamma=0, delta=-90.0

If this works, hklpy2 is installed correctly. Continue to the Tutorial: Your First Diffractometer to learn how to define a crystal sample, add orientation reflections, and compute the UB matrix.