mantidproject / mantid

Main repository for Mantid code
https://www.mantidproject.org
GNU General Public License v3.0
210 stars 123 forks source link

dmin setting in GSAS tab of Engineering UI not being respected #36618

Open RichardWaiteSTFC opened 9 months ago

RichardWaiteSTFC commented 9 months ago

Describe the bug Found during course of #36606.

The dmin setting is used as the lower limit for the d-spacing of the reflections to be fitted - however it appears GSAS tries to fit all reflections within the bounds of the data.

To Reproduce (0) Change dmin in the settings (cog in bottom left of UI) to 1.25 Ang (larger than default) (1) Follow the steps 1-7 of Test 11 (Note if you already have the files you may be able to skip to step 5) https://developer.mantidproject.org/Testing/EngineeringDiffraction/EngineeringDiffractionTestGuide.html#test-11

The graph displayed should look like this image

It can be seen that there are reflections (vertical blue lines below the data) predicted right down to the lowest extent of the data (which is about 0.5 Ang).

Again if you look at the reflections output file(ending _reflections_1_Fe_gamma.txt) in the GSASII folder of the save directory in the settings you can see GSAS tries to fit 26 reflections with minimum TOF 8302 mus. You can also open the .gpx file

Note the reflection generation code is working correctly, https://github.com/mantidproject/mantid/blob/8244e03cc74435334526cca82ede68cd997ba2d1/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/gsas2/model.py#L447 The variable returned generated_reflections has only 3 reflections. The reflections are added to the GSAS input dict/JSON string here https://github.com/mantidproject/mantid/blob/8244e03cc74435334526cca82ede68cd997ba2d1/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/gsas2/call_G2sc.py#L54 Which I have confirmed is called 3 times in debug.

If you open the .gpx file with GSAS yo uwill see the Pawley reflections have been set image

The dmin is retrieved here https://github.com/mantidproject/mantid/blob/8244e03cc74435334526cca82ede68cd997ba2d1/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/gsas2/model.py#L225 which gets parsed here https://github.com/mantidproject/mantid/blob/8244e03cc74435334526cca82ede68cd997ba2d1/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/gsas2/model.py#L225 but it doesn't look like it is used anywhere other than when adding the reflections here https://github.com/mantidproject/mantid/blob/8244e03cc74435334526cca82ede68cd997ba2d1/qt/python/mantidqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/gsas2/call_G2sc.py#L200

Perhaps the GSAS API requires something else - like Pawley dmin to be set? For more details on Pawley refinement options see the GUI docs here https://subversion.xray.aps.anl.gov/pyGSAS/trunk/help/gsasII-phase.html Or it needs to be told to use the Pawley reflections?

See also GSAS scriptable API docs here https://gsas-ii.readthedocs.io/en/latest/GSASIIscriptable.html#application-interface-api-summaryhttps://gsas-ii.readthedocs.io/en/latest/GSASIIscriptable.html#application-interface-api-summary

Expected behavior It would only try and fit reflections with d-spacing > dmin

RichardWaiteSTFC commented 9 months ago

GSAS also seems to create a list of reflection within the data limits image But maybe these aren't used and GSAS is using the correct Pawley reflections added and we're just loading the wrong file into mantid?

RichardWaiteSTFC commented 6 months ago

In course of investigating #37109 - I found that GSAS-II does only fit the reflections provided (i.e. respecting the dmin setting in the interface) but returns all the reflections in the data limits in the _reflections_ file - it could be that when we read these we only plot those actually fitted. Also the code reads the reflection file twice - once to fill a table, and again to plot the peak ticks - this should be addressed at the same time.