User Tools

Site Tools


Fitting a function

We will now try to fit a function, once a S(Q,ω) is generated. First of all we must create with the command cc the fitting funcion, and afterwards we will fit the function convolving with a vanadium measurement which should have been generated with the same grid (Q,ω) as the data which in turn has to contain a point at zero energy transfer.

I will suppose that we have in 1 the data, and in 2 the vanadium file.

1 because we want to fit data in file 1
cc create the fitting function
enter or number (65) presing enter you will list the (almost infinite) options. Write the number to select one. as example let's fit two lorentzians with backropund (number 65)
1 initial value for a1 intensity of the first Lorentzian
1 initial value for w1 width of the first Lorentzian
0 initial value for a2 intensity of the second Lorentzian
1 initial value for w2 width of the second Lorentzian
1 initial value for c center for the lorentzian
3 I will start with only one lorentzian. Therefore I will fix the value for a2=0. Note that to not have bad surprises, w2 is set to some npn-zero value.
? if you want to get the options to fix, make the absolute value and so on…
s a2 is fixed to 0
enter to go out from the a2 parameter menu
enter to go out from the parameter fitting menu
-1 1 I will fit the quasielastic range
enter
y I will weigh with the y error
enter I will NOT weight with log
y I will convolve with Vanadium
cf Start the fitting
enter If you did everything correctly, the option is automatically correct. If not just look at the files where you have your data
2 Convolve with vanadium, which is in file 2
enter I will fit ALL the spectra. If a spectra does not contain the value zero, it will simply give an error, and will not fit this spectrum
numbers, numbers and more numbers because of the fitting process. Normally it is nice to repeat the fitting again. The first number (in brackets) is the reduced chi2. It should be around 1. The other numbers are the fitted parameters.
cp I will set the intensity of the second lorentzian free. cp is to change the parameters
3 I will change parameter 3
s Free at last!!!!
enter I do not want to change any other parameter
cf Keep on running… the fitting, and now… extract parameters
Extracting parameters

I will try to calculate the diffusion coefficient. I will extract the with of the former fitting, and plot it as a function of Q2, and fit a line…

3 We should have the results from the former fitting in file 3
ci I will extract some parameters, exactly
2,4 the widths of the lorentzians
meV units of the first width
meV units of the second width
done!! as easy as that. Now in files 4,5 you should have w1 and w2
4,5 I will work with 4 and 5, that is, the extracted widths
p+enter+enter to have a look… they look nice, then
ox we will change the x axis
^2 square
6,7 to switch to 6,7 files
p to plot the beauty of the diffusion coefficient (only if you get straight lines)
6 let's fit a line to w1
cc
1
0 zero for origin of the line
1 for the slope
5xenter standard values. Sometimes, it happens that the widths do not have errors which will result in “more free parameters than data points”. Come back to this setup with “ca” and disable “weighing with errors”.
n DANGER!!!!! if you have fitted with convolution you MUST deactivate the convolution. Anyway when the fitting asks you you can also say convolve with file 0, and it will not convolve
cf

and finally you will get the value of your diffussion coeffcient extracting the value from the slope in meV·Å2. To get it in 10-4 cm2/s, multiply it by 1.519

Fitting rotations

We eill try to fit the function a*[A0(qr)*L(c,w1)+SUM[AN(qr)*L(c,Dr)]+bg