Spherical harmonics refinement controls in scripting
Opened this issue · 1 comments
I'm looking for assistance in adding spherical harmonics refinement parameters to a GSAS-II script (python)
I couldn't find spherical harmonics (SH) in the histogram and phase refinement parameters table in the docs
https://gsas-ii.readthedocs.io/en/latest/GSASIIscriptable.html#hap-parameters-table
So I attempted to work backwards by adjusting the SH refinement parameters using the GUI, then loading the project with gsas2script.
Refined SH parameters in GUI:
Inspecting the same project with gsas2 script (after saving gpx, closing GUI etc.), the phase dictionary ( gpx.phase('phs_name').data['General']['SH Texture']
) of SH refinement parameters has no SH coefficients.
'SH Texture': {'Order': 0,
'Model': 'cylindrical',
'Sample omega': [False, 0.0],
'Sample chi': [False, 0.0],
'Sample phi': [False, 0.0],
'SH Coeff': [False, {}],
'SHShow': False,
'PFhkl': [0, 0, 1],
'PFxyz': [0, 0, 1],
'PlotType': 'Pole figure',
'Penalty': [[''], 0.1, False, 1.0]},
I did come across this in the docs, but am unsure of how to implement it in a refinement script.
https://gsas-ii.readthedocs.io/en/latest/GSASIIutil.html#GSASIIlattice.GenRBCoeff
In case this is not already clear, there are two SH implementations in G2. One is for the case where one does multiple measurements on the same sample to characterize texture. This is done with the Texture tab and one set of coefficients are used for all histograms associated with a phase. The second variety is where one wants to treat the texture as part of a refinement. This is done on the Data tab and there is a set of coefficients for every histogram in every phase. Bob and I call such parameters that exist for every "histogram x phase" HAP parameters, because they were labeled that way in the should-be-now-long-defunct original GSAS .EXP file.
The reason you did not find the SH info in gpx.phase('phs_name').data['General']['SH Texture']
is because that is the data item associated with the texture tab. Look in gpx.phase('phs_name').data['Histograms'][h]
(see G2Phase.HAPvalue()
).
I did not tackle SH in scripting because it is not simple. As you likely know, the user sets the order, but based on the Laue group (and for the Texture tab, the processing symmetry) the correct number of terms are generated. , though to be honest I never looked to see how complex it would be to crib the code from the GUI. It depends in part on how much needs to be moved out of the GGUI.py file(s) and how much is already in computation modules. I will leave this ticket open as a reminder to look into this when I am looking for something more fun than tracking down a bug. To be honest I never looked to see how complex it would be to crib the SH setup code from the GUI. It depends in part on how much needs to be moved out of the GGUI.py file(s) and how much is already in computation modules
I don't think there would be any problems with hard coding in your script(s) for a particular space group with whatever settings you find in the appropriate section of the HAP parameters after you have set things up in the GUI.