Tutorial Multitopas
Sequential Rietveld Refinement of Multiple Data Sets – Either v6+ or Command File Methods (v4, v5)
Files needed: single zip file with data and input files
Learning Outcomes: How to quickly run through multiple refinements using either the #list format of topas v6+ or command line .bat files with v4 or v5.
This tutorial shows how one input file can be used to fit multiple data sets using either the #list language of v6+ or the older command file approach used in v4 and v5. You’ll see how easy things are in v6+. The example is a 2 phase mixture of Al2O3 and Si recorded at different temperatures on the I11 beamline at Diamond. The mixture is used to calibrate the temperature of the hot air blower. If you want to compare the cells you extract with values from the literature you can use the parameterisations for Al2O3 and Si in Stinton/Evans J. Appl. Cryst. (2007).
There is a video on my YouTube page detailing that goes through the #list method in detail.
Note the difference between this “sequential” approach and the “parametric” approach of other tutorials.
Data were recorded at 30 different temperatures and saved as .xye files. A list of the dataset names and temperatures is included in the linp file.
Sequential Refinements – v6 and above #list format
1. Save zip file into your directory.
2. Open the file al2o3_si_vt_02.inp. In section 1 you’ll see commands that control the refinement. There’s a section that’s only executed for the first run of the analysis which: creates a backup; deletes any old results.txt file; writes header information to a new results.txt file; does 3 cycles of simulated annealing for the first run only.
3. Have a look at the lines in section 2. You’ll see that if “#define fit_one_test_pattern” is set then a single data set is analysed. If not, TOPAS will run through 30 files and each has a temperature defined. More information on the format is on the wiki and in the YouTube video.
3.5 There may be a slight change to syntax in some versions of topas. You may need to change the line that copies the output of one run to the input of the next. i.e. change:
out_file = Concat(String(INP_File), ".INP");
to
out_file = String(INP_File##.INP);
4. Look at the end of the file where it says “#ifdef write_out”. You’ll see that a few key parameters are written to “results.txt” for plotting.
5. Save the file and send to TOPAS. When you click “run” in TOPAS all patterns either one pattern will be fitted or all 30 depending on whether “#define fit_one_test_pattern” is included. You ought to get ~14.42% for the first data set.
6. Use the 3D viewing options to inspect the fits. Note that in planview the thermal expansion “looks strange”. This is because the data were not recorded with uniform temperature steps.
7. If you have python on your computer you can use the script plot_all.py to plot all the parameters in results.txt. You’ll need the matplotlib and pandas libraries installed (pip install matplotlib).
8. See the instructions below on how to plot the results in gnuplot.
Sequential Refinements – v4 and v5 command file format
Sequential refinements are slightly more involved with the older versions of TOPAS (v5 and earlier). The easiest method is to create a command file (.bat file) to run tc.exe from the command line and feed topas information about the filenames to be analysed and any other experimental information from the command prompt. There’s more background to this on the TOPAS wiki.
1. Open the file al2o3_si_vt_01.inp. Save it as seed.inp.
3. Look at the section of seed.inp where it says “#ifdef !GUI_LINES”. When running topas in gui mode you’ll see that the filename and temperature are defined from this part of the input file. When running in batch mode this information will come from the .bat file. This language is really useful as you can use the same input file to check the refinement in gui mode then run tc.exe in batch mode.
4. Save the file and send to TOPAS. You should get Rwp=14.42%.
5. Open the file called “run_multitopas.bat”. You’ll see a series of commands that run tc.exe using each experimental data set and then copies the output of one refinement to the input of the next. Edit this file so that the directory name is the one you’re working in. Save run_multitopas.bat to your main topas directory (c:\topas4.2 or similar).
6. Go to the main topas directory and click on “run_multitopas.bat”. You should get a command window pop up and see the Rwp values of each refinement scroll past on the screen.
7. If this doesn’t happen you probably have the directory name incorrect in your .bat file. Open a command window in the topas directory and copy/paste each of the lines in the command file sequentially. This should show you where the problem is.
8. There are various ways of creating a file like run_multitopas.bat. If you double click on the program “multitopas_files.exe” provided with this example you’ll get asked a series of questions which will produce the file. For the “list of filenames” edit “files.list” and change the directory to your working directory. When asked if there is any other information to tell topas say yes and specify the file “information.val”. This contains the temperature of each data set. Alternatively it’s easy to produce command sequences like this in excel (by dragging down columns) or python.
Plotting Data
It’s so quick to perform multiple data analyses using Topas that it often takes longer to visualise/plot results than to do the Rietveld refinements. I now use a python script like plot_all.py to do this. You will need to install matplotlib and pandas to run this.
I used to use wgnuplot. Instructions for wgnuplot are:
1. After performing either #list or command file sequential refinements save the file “results.txt” as “results_good.txt”.
2. You could add the following column headings as the first line:
Filename T Rwp a_al2o3 esd c_al2o3 esd vol_al2o3 esd a_si esd vol_si esd scale_al2o3 esd scale_si esd bval_al2o3 esd bval_si esd T
3. Depending on your gnuplot set up either click on the file “plot_results.gnu” or open gnuplot and type “load plot_results.gnu” at the command prompt. You should see plots of important parameters appear one by one. They will also be saved as .gif files in your directory.
4. If you’re interested, open “plot_results.gnu” to see how it works.
5. With a few extra commands in the INP file you can automatically delete the old results.txt file and create a new one with headings each time you analyse the data. You can see how to do this in al2o3_vt_02.inp.
Temperature Calibration
If you look at the cell parameters vs T you’ll see that their slopes flatten off at high temperature. This is because the hot air blower fails is failing to heat the sample to the set temperature. You can calibrate the temperature from the known thermal expansion of Al2O3 and Si. Some ways of doing this are in the paper by Stinton and Evans cited above. You can also use the slightly simpler approach outlined in the excel spreadsheet.