Closed MrCrab-2019 closed 2 years ago
As we are working with Q in the lab frame, real space, by the time we have applied the UB and rotation transformations, then I think it is more correct to count only those hkls with negative Qz components. Those with a positive Qz can only be satisfied where |ki| != |kf|.
I agree with this and think it's a better way to implement the Bragg condition. I spent 30 mins going over my own code and convinced myself that what I did is essentially equivalent to this anyway (it was just needlessly complicated).
The rationale is:
lam = 2*d*sin(theta)
The relevant values of theta cannot exceed 90°, and d is always positive, therefore negative lam implies negative theta. I introduced the parameter alp. This is just the other angle in the isosceles with 2theta as the vertex and, if I cut the isosceles in half:
theta = pi/2 - alp
so, negative theta can only occur if
alp > pi/2
Since, just from geometry,
cos(alp) = Qz/Q
and Q is always > 0
(in my code it's calculated directly as the product of the Q-vector with itself)
This will only be the case if Qz<0
Your approach is simpler though.
Nice - ok glad that you agree. I went over it a few times myself, and came to the conclusion that it must be the case. I’ve made some good progress on putting together the other bits we discussed. Will update in due course.
The current function outputs negative values for lambda and ttheta for some hkl values, which are later 'filtered' out by the algorithm around line 1532. If the wavelength is less than zero, the algorithm discards it here, and builds a new array called hkl1, of only physical values.
As we are working with Q in the lab frame, real space, by the time we have applied the UB and rotation transformations, then I think it is more correct to count only those hkls with negative Qz components. Those with a positive Qz can only be satisfied where |ki| != |kf|.
In the grand scheme of things, this doesn't really matter or diamond, as the symmetry is such that there is a lot of redundancy, and it works in the end. However it is worth us checking at this point that we are discarding the correct hkls, particularly if in the future we want to correct for lower symmetry (sapphire) anvils. Malcolm, can you check if this makes sense?
I have rewritten your code a little to make it easier for me to follow (see below). If you remove the minus sign in the
alp = np.degrees(np.arccos(-Q[:,2]/magQ))
line, then it reproduces your version of the code.For convenience, the inputs are generated here:
Actual function: