omega_solns#

anri.diffract.omega_solns(q_sample, etasign, k_in_sample)[source]#

Compute omega angles that satisfy the Ewald condition for a given \(\vec{Q}\) in the sample frame.

Due to Friedel pairs, there are always two possible omega solutions for a given \(\vec{Q}\) (when they exist). We pass in an etasign parameter to select which solution to return.

Parameters:
  • q_sample (Array) – [3] Scattering vector in sample frame

  • etasign (float) – +1 (omega1 in ImageD11) or -1 (omega2 in ImageD11) to select which omega solution to return

  • k_in_sample (Array) – Incoming scaled normalised wave-vector in sample frame

Returns:

  • omega (jax.Array) – Omega angle in degrees

  • valid (jax.Array) – Boolean indicating if a valid solution exists

Notes

This is adapted from ImageD11.gv_general.g_to_k(). You can find a nice writeup of this in (Milch and Minor, 1974) [2].

The Ewald condition is defined by:

\(\vec{Q} = \vec{k}_{out} - \vec{k}_{in}\)

so:

\(\vec{Q} + \vec{k}_{in} = \vec{k}_{out}\)

The Ewald condition requires that the magnitudes of the incoming and outgoing wave-vectors are equal:

\(\abs{\vec{k}_{out}} = \abs{\vec{k}_{in}} = \frac{1}{\lambda}\)

So we can square both sides:

\(\abs{\vec{k}_{out}}^2 = \abs{\vec{k}_{in}}^2 = \frac{1}{\lambda^2}\)

We also square both sides here:

\(\abs{\vec{Q} + \vec{k}_{in}}^2 = \abs{\vec{k}_{out}}^2\)

Substituting the Ewald condition into this gives:

\(\abs{\vec{Q} + \vec{k}_{in}}^2 = \abs{\vec{k}_{in}}^2\)

Expanding the left-hand side:

\(\abs{\vec{Q}}^2 + 2 \vec{Q} \cdot \vec{k}_{in} + \abs{\vec{k}_{in}}^2 = \abs{\vec{k}_{in}}^2\)

Subtracting \(\abs{\vec{k}_{in}}^2\) from both sides:

\(\abs{\vec{Q}}^2 + 2 \vec{Q} \cdot \vec{k}_{in} = 0\)

Rearrange:

\(\vec{Q} \cdot \vec{k}_{in} = -\frac{\abs{\vec{Q}}^2}{2}\)

We decompose \(\vec{Q}\) into components parallel and perpendicular to the rotation axis \(\hat{n}\).

\(\vec{Q}(\omega)\) is the rotated Q vector at angle omega about axis \(\hat{n}\):

\(\vec{Q}(\omega) = \vec{Q}_{perp} \cos(\omega) + (\hat{n} \times \vec{Q}_{perp}) \sin(\omega) + \vec{Q}_{par}\)

These are formed via basis vectors:

\(\vec{Q}_{par} = (\vec{Q} \cdot \hat{n}) \hat{n}\)

\(\vec{Q}_{perp} = \vec{Q} - \vec{Q}_{par}\)

Now dot product with \(\vec{k}_{in}\):

\(\vec{Q}(\omega) \cdot \vec{k}_{in} = \vec{Q}_{perp} \cdot \vec{k}_{in} \cos(\omega) + (\hat{n} \times \vec{Q}_{perp}) \cdot \vec{k}_{in} \sin(\omega) + \vec{Q}_{par} \cdot \vec{k}_{in}\)

We define some constants here:

\(\alpha \cos(\omega) + \beta \sin(\omega) + \gamma = \vec{Q}(\omega) \cdot \vec{k}_{in}\)

where:

\[\begin{split}\begin{aligned} \alpha &= \vec{Q}_{perp} \cdot \vec{k}_{in} \\ \beta &= (\hat{n} \times \vec{Q}_{perp}) \cdot \vec{k}_{in} \\ \gamma &= \vec{Q}_{par} \cdot \vec{k}_{in} \end{aligned}\end{split}\]

Setting equal to the Ewald condition:

\(\alpha \cos(\omega) + \beta \sin(\omega) + \gamma = -\frac{\abs{\vec{Q}}^2}{2}\)

Subtracting \(\gamma\) from both sides:

\(\alpha \cos(\omega) + \beta \sin(\omega) = -\frac{\abs{\vec{Q}}^2}{2} - \gamma\)

We call the right-hand side \(\delta\):

\(\alpha \cos(\omega) + \beta \sin(\omega) = \delta\)

We now solve the harmonic addition:

\(R \sin(\omega + \phi) = \delta\)

with \(R = \sqrt{\alpha^2 + \beta^2}\) and \(\phi = \arctan2(\alpha, \beta)\).

The two solutions for \(\omega\) are:

\(\omega_1 = \arcsin\left(\frac{\delta}{R}\right) - \phi\)

\(\omega_2 = -\arcsin\left(\frac{\delta}{R}\right) - \phi - \pi\)

References