Skip to content

pyFAI GISAXS calculations #4

@Anas321

Description

@Anas321

The notebook https://github.com/mlexchange/react_gui_multimodal/blob/main/backend/comparing_with_pyFAI_equations_GISAXS.ipynb shows a study comparing the q matrices we are getting for GISAXS from pyFAI against the manual calculations of these matrices.

The horizontal and beam components (parallel directions) for the manual calculations match the pyFAI's parallel components. However, there is a discrepancy for the vertical component.

When investigating the equations in the pyFAI source code https://github.com/silx-kit/pyFAI/blob/main/src/pyFAI/units.py, it is found that the authors of the pyFAI library calculate the scattering matrices in what they call "lab reference frame" (q_lab) and then transform it to the "sample reference frame". Upon investigating their equations, this is what they are:

$$q_{sample} = R_{tilt} \times R_{incident} \times q_{lab}$$

the $$R_{tilt}$$ is just the identity matrix in our case as we are not considering any tile ($$\theta_{tilt} = 0$$). So, we are left with the following:

$$\begin{bmatrix} q_{beam}\\ q_{horizontal}\\ q_{vertical} \end{bmatrix} = \begin{bmatrix} \cos(\alpha_i) & 0 & \sin(\alpha_i) \\ 0 & 1 & 0 \\ \sin(-\alpha_i) & 0 & \cos(\alpha_i) \\ \end{bmatrix} \times \begin{bmatrix} \cos(\alpha_f) \cos(\psi) - 1 \\ \cos(\alpha_f) \sin(\psi) \\ \sin(\alpha_f) \end{bmatrix}$$

After doing the multiplication, this is the result:

$$\begin{bmatrix} q_{beam}\\ q_{horizontal}\\ q_{vertical} \end{bmatrix} = \begin{bmatrix} \cos(\alpha_i)[\cos(\alpha_f)\cos(\psi) - 1] + \sin(\alpha_i)\sin(\alpha_f) \\ \cos(\alpha_f)\sin(\psi) \\ \sin(-\alpha_i)[\cos(\alpha_f)\cos(\psi) - 1] + \cos(\alpha_i)\sin(\alpha_f) \end{bmatrix}$$

These are not the equations used in the manual calculations (equation (1) in https://journals.iucr.org/m/issues/2015/01/00/ed5003/ed5003.pdf)

There are two questions to be answered here:

  1. What makes the discrepancies between the vertical components?

  2. If the equations are different, how is it even possible to get a match for the horizontal and beam components?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions