Ad hoc diffractometer#

Version: 0.9.1.dev5+g024196415

ad_hoc_diffractometer is a pure-Python package for calculating multi-circle diffractometer operations in reciprocal space for X-ray and neutron crystallography. It is built around a key design principle: any multi-circle diffractometer geometry can be fully described by the caller — no geometry is hard-coded, and new geometries require no changes to the package itself.

Its only runtime dependency beyond the Python Standard Library is NumPy — no scipy, sympy, or other scientific libraries are required.

Note

The package assumes monochromatic radiation throughout. All diffraction calculations (Bragg angles, Q-vector magnitudes, forward/inverse problems) are performed at a fixed wavelength.

It provides:

  • A class-based description of diffractometer stages (rotary axes) and their stacking order

  • Predefined factory functions for standard synchrotron and laboratory diffractometer geometries (psic, fourcv, fourch, sixc, kappa families, zaxis, s2d2, fivec)

  • Crystallographic lattice calculations (B matrix, reciprocal lattice)

  • U and UB matrix computation from orienting reflections

  • Forward diffraction calculations (hkl → motor angles), with diffraction modes controlling which stages are free, fixed, or coupled

  • Wavelength, energy, d-spacing, and Q-vector conversions for X-ray and neutron sources

  • Reciprocal-space operations: Q-vector magnitude, d-spacing, two-theta, and trajectory planning along arbitrary paths in reciprocal space

Get started

Install the package and verify the installation.

Installation
User Guide

Concepts, how-to guides, and a geometry reference.

User Guide
API Reference

Complete auto-generated reference for every public class, function, and constant.

API
Release Notes

What changed in each release.

Change History
References

All literature citations — geometry papers, physical constants, and numerical methods.

References

Quick start

import ad_hoc_diffractometer as ahd

# Create a six-circle psic geometry and set the wavelength
g = ahd.psic()
g.wavelength = 1.0  # Å

# Define the sample lattice (cubic silicon)
g.sample.lattice = ahd.Lattice(a=5.431)

# Show a summary of the geometry
print(g.summary())

See the Quick Start guide to build a four-circle geometry step by step — choosing a basis, stacking stages, defining modes, and running a forward calculation — without using a factory function.

Background#

Direct Lattice

Vector mathematics and lattice vector conventions in crystallography.

direct-lattice.html
Case Study

The diffractometer problem that started this project.

problem1.html
Coordinate Convention & UB Matrix

How a basis vector assignment leads to the B, U, and UB matrices, with a worked example using the convention described by H. You (1999.

problem2.html

About#

Home

https://prjemian.github.io/ad_hoc_diffractometer/

Source

prjemian/ad_hoc_diffractometer

Version

0.9.1.dev5+g024196415

Published

2026-04-29 17:53 CDT

License

CC-BY-4.0

Index

Index