reflectometry/refl1d

Magnetic profile in GUI is wrong

Closed this issue · 1 comments

from @acaruana2009:

Slightly odd one this, I have a model (see attached) which if I turn on micro slicing it inverts the mSLD plot in the GUI. Now in terms of the calculation I am confident it is doing the right thing. I think in the plotting it has just changed the "no magnetism value" to some +ve value.

Here, rhoM is supposed to be 0 in the substrate and incident medium, and 1.0 in the sample, but it is inverted and shifted:
image

This was a good catch by Andrew and is caused by a deeply buried bug in the numba implementation: in calculate_u1_u3 it is re-using the rhoM array to calculate another value that it cares about (sld_b) and it is doing it in-place

The fix is simple enough (work on a copy of rhoM in calculate_u1_u3) but it took me days to track it down. The issue is fixed in ce6e771