Topas Simple Least Squares

Files needed: data.xy; data_fit_01.inp; gaussian.xy; gaussian_fit_01.inp; gaussian_fit_02.inp

Learning Outcomes: Topas Academic is a program designed originally for powder diffraction data. However the flexible input file format mean that it can be used for a wide range of different types of data analysis. Here we'll use it to fit the simple linear/quadratic/gaussian functions we explored in excel..

1. The file data_fit_01.inp contains the instructions needed to fit a straight line function. Save it to your working directory then open it in jedit.

2. Read through the file. The format is relatively simple. The gradient and intercept of our y=mx+c function are defined as two variables using the keyword "prm". The name of the data files is specified using XY(data.xy) (it's a simple text file, open it and look). The line "weighting 1" says to weight each data point equally. The line "fit_obj" contains the equation of the function we want to fit. The line "do_errors" tells topas to calculate errors at the end of the refinement. Start m and c at any values you like by typing over the current values.

3. Click on the "to TA" arrowed icon at the top of the screen. This tells topas the filename containing the instructions for refinement.

4. Click on the "TA" icon at the top of the screen. This launches topas.

5. In topas click on the red "run" arrow. The least squares refinement should run more or less instantly. Look at the observed and calculated lines in the graphical window. By default experimental points aren't drawn but this can be changed in the "display" tab.

6. Go back to jedit. The results of the refinement should have loaded. You'll see updated values for m and c. After the "_" you'll see the errors. At the bottom of the file you'll see the correlation matrix. Compare the values to the ones you got in excel and to the correlation matrix we determined by hand in the lecture.

7. The file "gaussian_01.inp" contains information to fit the simple Gaussian function that we used in excel. Run it using exactly the same protocol as above. We'll later use similar protocols for fitting real diffraction data.

8. The file "gaussian_02.inp" contains exactly the same information using a "built in" gaussian peak shape function in topas. Try changing positions and intensities as you did in excel to test the range of convergence. Try calculating errors.

9. Try changing the word "gauss_fwhm" to "lor_fwhm". This forces topas to fit a Lorentzian function (another function commonly used for fitting powder data) rather than a Gaussian. Note the difference in the shapes of the functions. We'll return to this later in the week.

[Modified 01-Oct-2017 by John S.O. Evans. Pages checked for Google Chrome.]