Automating the 

Alignment of Crystals

Rohit Mandavia, Dr. William Ratcliff
Background

 The structure of crystals help scientist understand its properties

 Crystal must be aligned to determine its orientation

 These features can be hard to find for various reasons

 Strontium Titanate (SrTiO3), for example

• Simple cubic geometry

• Obtains a large dielectric constant at cold temperatures

• Becomes a superconductor at 0.35 K
Neutron Beam
Common Vocabulary

 Reflection: an instance of neutrons hitting the detector

 Diffracting Position: a specific orientation of the crystal that 

results in a reflection

 Rotation Axis: Phi (ɸ), Chi (ΧΧ) , Omega (Ѡ) → rotation 

matrix (R)

 Detector Angles: TwoTheta (2Θ)

 HKL vectors and the UB matrix

• More on these later
HKLs and Miller Indices

 Reciprocal Space: A vector describes an infinite set of 

parallel planes, repeating at some frequency in real 

space. 

 Repeats at a rate of |HKL| planes per unit

 d spacing = 1/|HKL| hence the name “reciprocal”

 Allows us to define which set of faces we are looking at
UB Matrix

 The UB Matrix allows scientist to figure out what 

motor angles (ΧΧ, ɸ, Ѡ, 2Θ) are needed to hit any 

desired reflection

 In order to calculate the UB Matrix, you need to know 

lattice parameters and two reflections

 UB Matrix depends on the orientation of the crystal 

with respect to the instrument (Eulerian cradle)
0

10

20

30

40

50

60

70

0 10 20 30 40

0

1

0 0.2 0.4 0.6 0.8 1 1.2

CHI-PHI SPACE HKL SPACE

UB Matrix

CHI (degrees)

PHI (degrees)

(h00)

(0k0)
Current Methods

 Set the crystal in Eulerian cradle

 Rotate “randomly” until a reflection is hit

 Assume where other reflections might be and search this area 

until a reflection is hit

 Once a sufficient amount of reflections are hit, the UB matrix 

can be created

 Tedious, time consuming, and requires attention
Neutron Beam

Not drawn to scale
The Solution 

 Automate the alignment process using 

machine learning

 Find the fastest and most efficient way 

to find reflections

 Make the process universal for all 

crystals, regardless of symmetry

(Hopefully)
Reinforcement Learning

 We can simulate the crystal and the instrument in a 

program

 If the crystal is moved to a diffracting position for a 

specific 2Θ:

• Give the agent a reward (reinforcement)

• The faster it gets there the more the reward

• Punish the agent by associating every move with a cost

 The agent will eventually be able to learn the fastest 

way to get into a diffracting position

• Tensorflow
Epsilon-Greedy 

 Once a reflection is hit, continue using this method as our go-to

 Every now and then, make a random move

 If the move results in less reward, don’t make that move again

 If the move results in more reward, this new path becomes our go-to

 Repeat

Reflection
Crystal Case
3.2

0.6

4.9

2.1

ΧΧɸѠ

Move ΧΧ by 

1 degree

Move ɸ by -1 

degree
General Case Triclinic Wollastonite
Results 

 Unfortunately, the simulations were unable to find reflections in a 

respectable time

 Advantages of automation are belittled by the amount of time needed

 Difference between learning to find a point and learning how to find a 

point 

 More work to be done in order to take advantage of this technique
Acknowledgements 

• CHRNS (Center for High Resolution Neutron Scattering)

• NIST SURF Program and Advisors

• Joe and Julie!

• NCNR SURFERS 

• NCNR, Stephen Pheiffer

• Mentor: William Ratcliff
Any Questions?