-
Notifications
You must be signed in to change notification settings - Fork 6
Phonon Convolution Tutorial
All demos for the phonon resolution convolution can be found in the directory "data/demos/phonon" of the repository. To use the demos, please download the archive from here and unpack it.
(1) Open the convolution dialog using "Resolution" -> "Convolution..." in Takin's main menu.
(2) Select "File" -> "Open..." in the convolution dialog's menu and navigate to the folder where you downloaded and extracted the data archive (see above). Go to the sub-folder "data/demos/phonon" and open the file "phonon_simple_py.taz".
(3) Click the "Start Sim." button to calculate a resolution-convolution simulation.
The demo convolution uses the Python backend for creating S(Q, E) models. In the example, the model file can be found in the file "sqw_phonon.py". In there, the most important (and only mandatory) interface function for Takin is "TakinSqw(h, k, l, E)", which receives the (hkl) coordinates (in rlu) and the energy transfer E (in meV) of each random Monte-Carlo neutron events from Takin, and has to return the dynamical structure factor S(h, k, l, E) for the queried coordinate. How the structure factor is calculated is up to the user. In the example, a simple sinusoidal phonon dispersion branch with a DHO shape in energy is created.
Each parameter in the Python S(Q, E) model script (here: "sqw_phonon.py") which is global and whose name begins with "g_" is a parameter that can be changed directly from Takin and that can also be defined as a fit parameter. In the convolution dialog, they can be inspected and modified by clicking on the "Parameters..." button.
(4) Fitting a parameter is done by checking the respective "Fit" column in the parameters dialog and giving the parameter a non-zero error. Initial values for fitting can be set via the "Value" column.
(5) If at least one parameter has been declared a fit parameter, the convolution fitting can be started by clicking "Start Fit".
(6) If the curve appears to be completely at zero in the plot window, try increasing the "Scale" factor, for example to "1e4" or "1e5".
For advanced usage, fitting can be done via the command line.
(7) Select "File" -> "Export to Convofit..." to generate a job file for the command line fitter. The file should ideally be placed into the same directory with the other files.
(8) While the exporter tries to set some useful default values, it is best to check the settings for the fitter by opening the generated job file in a text editor. An explanation of most of the settings can be found here.
(9) The fitting job can be run using, where "phonon_simple_py.job" is the file generated in step 7 (this file is also already provided for comparison):
takin.sh --convofit phonon_simple_py.job
Normally, a gnuplot window should open to show the progress of the fit. If this is not the case, please check that "output/plot_term" is set to a valid output backend.
(10) The output of the fitting process in written to the files given in the section "output" of the job file. "output/log_file" contains the command line log, "output/model_file" the final convoluted theory curve, and "output/scan_file" a simplified copy of the original scan file for easier plotting. For the "phonon_simple_py.job" example, you can plot the results using:
gnuplot -p -e "plot \
\"scphonon_simple_py.dat\" u 1:2:3 w yerrorbars pt 7 title \"Data\", \
\"modphonon_simple_py.dat\" u 1:2 w lines lw 2 title \"Theory\""