About Open GDA | About Diffcalc

Diffcalc is used for controlling diffractometers within reciprical lattice space. 

Diffcalc’s core calculation code works with a six-circle geometry. It supports four-circle modes where two circles are fixed, five-circle modes where one circle is fixed and the last is used to keep the surface normal in the horizontal lab plane, and six-circle modes where the surface normal is kept parallel to the omega (theta) axis. For each of these there are five variants: the angle of the incoming or outgoing beam to the crystal surface can be fixed, the incoming and outgoing angles can be made equal, phi can be fixed, or the azimuthal angle about the momentum-transfer vector can be fixed. The azimuthal variants still need some testing and likely development.

A system of geometry plug-ins tailors the core code for specific diffractometers. A four-circle plug-in for example will hide the five and six-circle modes from the user and fix two of the angles internal to the core code. So far there is a four-circle plug-in (used by Rasor), a five-circle plug-in (used on b16) and four different six-circle geometries (two for i07 and one destined for i16).

Diffcalc does not directly move motors or perform scans: it ties into the gda through the gda’s system of scannables and depends on the gda’s scan command to perform scans. Parameters, fixed angles, energy, or hkl may be scanned over. Diffcalc adds its commands to the gda’s standard list.

Diffcalc is written in Python so it might be extended by scientists if necessary. It is very well unit tested making the code reliable and easy to modify or extend.

Example

In this example, after creating a new orientation calculation to hold the crystal parameters and reflection list, a crystal lattice is specified, and two reflections are added to the list causing a UB matrix to be calculated. A four-circle bisecting mode is selected, which for this five-circle diffractometer requires one parameter alpha to be fixed. Alpha is then scanned and at each step the 001 reflection is visited and the counter timer ct is counted for 1 second. When the hkl scannable is moved it asks diffcalc where to move fivec and then moves it. This hkl scannable also returns the two-theta angle, incoming angle and azimuthal angle. More complex scans can be easily built up.