Open jl-wynen opened 1 week ago
I believe I found a bug in the current implementation. We currently define $$y_d = \frac{g \cdot b_2}{|g|}$$ where $g$ is the gravity vector (pointing down) and $b_2$ is the scattered beam. see https://github.com/scipp/essreflectometry/blob/bddec78031ca7110b98ced1771329d6c1cb134ab/src/ess/reflectometry/conversions.py#L55 This definition means that the y axis points down. I.e., positive y values are below the incoming beam and negative values above the incoming beam. We then compute the point where the neutron would have been detected without gravity as $$y'_d = y_d + \frac{|g| m_n^2}{2 h^2} L_2^2 \lambda^2$$ This equation is identical to that in SANS (scattering_angles_with_gravity). However, in SANS, we define (note the minus sign!) $$y_d = -\frac{g \cdot b_2}{|g|}$$ see https://github.com/scipp/scippneutron/blob/1a1c86a65fb69c727f4c28bef05d8a063e66bb2f/src/scippneutron/conversion/beamline.py#L384
The definition in SANS makes sense. It means that the direction the neutron was scattered in ($y'_d$) is above where it was detected ($y_d$) where 'above' means in negative $g$-direction. But in reflectometry, we get the opposite. The gravity corrected value is below the detected position, i.e., further down along $g$. This is wrong.
This may not have been noticed before because we use an absolute value of $y'_d$ which might mask the effect. But I still think that the result is wrong. The impact on the result is significant:
Has this been compared to Mantid? @jokasimr, @arm61 do you agree with this?
Here is a comparison of IofQ
:
Yes it looks like this could be an issue.
The results have not been compared to mantid. But they have been compared to Jochens program, and there we see a clear discrepance in the form of a shift to lower $Q$. It seems the discrepancy increases with the sample rotation angle is large. See https://scipp.github.io/essreflectometry/user-guide/amor/compare-to-eos.html.
However, the (possible) gravity correction bug here is not enough to explain the discrepancy.
Similarly to https://github.com/scipp/esssans/pull/143, use some code in
scippneutron.conversion.beamline
to computetheta
. We can't just usescattering_angles_with_gravity
because in reflectometry, we define the scattering angle w.r.t. the sample plane, not the beam direction. Compared to SANS, this means that we ignore thex
component iny_prime
for two_theta.