How-to Guides#

Step-by-step guides for common tasks. Each guide assumes you have installed the package and are familiar with the concepts.

Choose a Coordinate Basis

Understand how basis vectors map physical directions to Cartesian axes, and how to define a custom basis.

Choose and Understand Basis Vectors
Build a Custom Geometry

Define a diffractometer that is not one of the 10 presets: axis signs, parent chains, roles, modes, and verification.

Build a Custom Diffractometer Geometry
Set Wavelength / Energy

Set the radiation wavelength or energy on a geometry, and convert between wavelength, energy, d-spacing, and Q.

Set Wavelength / Energy
Define the Sample Lattice

Specify unit-cell parameters for any crystal system and inspect the resulting B matrix and reciprocal lattice.

Define the Sample Lattice
Orient a Crystal

Compute the U and UB matrices from one, two, or three orienting reflections.

Orient a Crystal
Solve the Forward Problem

Find the motor angles that satisfy the Bragg condition for a given reflection (hkl → motor angles).

Forward and Inverse Computations
Switch Diffraction Modes

Choose which stages are free, fixed, or coupled during a forward calculation.

Switch Diffraction Modes
Work with Constraints

Understand the constraint framework: DOF rule, constraint categories, custom modes, and the extras dict for advanced modes.

Work with Constraints and Diffraction Modes
Surface Geometry and Reference Vector

Set the surface normal and azimuthal reference vector; compute incidence angle, exit angle, ψ, and naz.

Surface Geometry and the Reference Vector
Plan a Trajectory

Compute motor-angle sequences along a path through reciprocal space, or for a ψ scan.

Plan a Trajectory
Refine Lattice Constants

Refine unit-cell parameters from measured Bragg peak positions using Busing & Levy (1967) least-squares or the Nelder-Mead simplex method, with and without crystal-system constraints.

Refine the Lattice Constants
Save and Restore Configuration

Save the complete diffractometer state to JSON or YAML and restore it in a later session.

Save and Restore a Diffractometer Configuration
Set Diffractometer Inclination

Account for a diffractometer mounted at a non-zero angle relative to the incident beam.

Set Diffractometer Inclination
Measure Performance

Benchmark forward/inverse throughput and round-trip accuracy across all geometries and modes.

Measure Forward/Inverse Performance
Align a Crystal

Full worked example: orient a sapphire crystal on a four-circle diffractometer (APS 7-ID-C session).

Align a Four-Circle Diffractometer (fourcv)