SpinW / spinw

SpinW Matlab library for spin wave calculation
http://www.spinw.org
GNU General Public License v3.0
36 stars 15 forks source link

Inconsistencies in triAF model calculations #148

Open mducle opened 1 year ago

mducle commented 1 year ago

Issue

Running successive spin wave calculations on the same triAF model sometimes generates spectra which disagree in a few bins.

Issue was original found by @williamratcliff and colleagues.

To reproduce

Run the following script:

q_start = [0, 0, 0];
q_end = [1, 1, 0];
pts = 501;
evect = linspace(0.5, 5, 500);
model = 'triAF';

s = sw_model(model, 1);
spec = sw_egrid(sw_neutron(spinwave(s, {q_start, q_end, pts})), 'component', 'Sperp', 'Evect', evect);

s2 = sw_model(model, 1);
spec2 = sw_egrid(sw_neutron(spinwave(s2, {q_start, q_end, pts})), 'component', 'Sperp', 'Evect', evect);

fprintf('\nabsolute delta %f\n', max(abs(spec.swConv(:) - spec2.swConv(:))))
dd = spec.swConv - spec2.swConv; idx = find(abs(dd)>0.01);
[dd(idx) spec.swConv(idx) spec2.swConv(idx)]

figure; pcolor(dd*10+spec.swConv); shading flat; colorbar

Sometimes it reports no discrepancies, sometimes intensities are transposed between neighbouring bins (can be seen in the figure).

If the chain or squareAF model are used instead of triAF then swConv always agree between the two runs. There seems to be something to do with the incommensurate nature of the triAF model.

RichardWaiteSTFC commented 1 year ago

I'll check whether this has been fixed by #130

RichardWaiteSTFC commented 1 year ago

Yeh this is still a problem...FYI the discrepancy occurs in bins indicated with a red cross in this image image

mducle commented 1 year ago

Yeah... to be honest its small enough it usually not noticeable - except it might cause flaky tests if we didn't have such a large tolerance on the tests.

Also, I'm not entirely sure how to fix it...

So, we might have to leave this until after release 4.0