# FRIDA1 quick tutorial

Frida1 quick tutorial
##### Introduction

Frida1 is a nice data treatment software to deal with neutrons data mainly, and this page is about how to work with it, hands to dough. A new version is also available here

This tutorial aims to show typical workflows. It is not thought to be thoughtlessly copied but rather to show how some of the commands in Frida-1 can be used. Hopefully, one feels eager to further explore this powerful program...

## Some Basic Relations in Neutron Scattering

That is not an extensive document about all the possible relationships in neutron scattering, the relationships are written here, as the users need them...

• From meV to frequency: 1meV=240GHz
• Resolution function with = maximum accesible time τ(ps)=0.658/Res(meV)
• Wavelength of Thermal Neutrons: 1.8Å
• Bose Factor 1/(exp(h·f/kBT)-1). If h·f=E(meV), then the Boltzmann constant kB = 0.08617373 meV/K
• If you get ω from the quasielastic line, plotted as a function of Q2, the slope is the diffusion coeficient in meV·Å2. To get it in 10-4 cm2/s, multiply it by 1.519
• To calculate the susceptibility from s(q,w): chi’‘=s(q,w)*hw/(KbT)
• Niquist Shannon: If you have S(q,w) in mev, the minimum time you can observe (because of NS sampling theorem) is Δt=0.658*π/(Emax).

## Self Absorption Correction

First the good news: if you have a sample whose transmission is bigger than 0.9 (of course 0.9 is some kind of arbitrary limit!!!), the shading of the walls by the sample is minor, and you can say in a first approximation that your signal is that of your sample plus that of your container.

Now the bad news: if your sample has a transmission smaller than 0.9, there will be more neutrons that will “see” the first wall they found than the last wall of the container, because the sample has decreased the number of neutrons going through. The signal of your container is overestimated in the measurement of the pure empty can compared to the measurement of the sample+container. This overestimation depends on the scattering angle. One way to correct that is to use the ideas of Paalman and Pings wrote down in a classical paper (see J. App. Phys. 33 (8)2635, from 1962, when was usual not to perform simulations, but work out nice and long formulas ). This is implemented in IDA by the formula (see also Bee p 142 where the notation is taken from):

Ssample(2θ,ω)=1/Assc * (Ssample+container(2θ,ω)-Arel*Scontainer(2θ,ω))

IDA will give you the 2θ dependent values of Assc and Arel. The first one corrects the absolute intensity, and the second the relative contribution of your container related to that of your sample, therefore if you get a number bigger than 1, you made something wrong... In case you set the transmission of the inner and outer can to 1 (which is the case for “normal” Al-cans at large wavelengths), Assc=Arel – in this case, Arel is not calculated by the routine. Now let’s put hands into dough (Spanish expression . Let’s do the case of a cylindrical sample. We start with file 1, where your data are (no prior background subtraction):

You should now have two files with Assc, and Arel. Now we perform the calculations to obtain the corrected intensity, and now:

First step : dividing the S sample + container file by the *.Assc file 1) select the S sample + container file 2) type : oy (for operation on y) 3) type : / or 55 4) 2nd argument ? y2 5) choose the *.Assc file

Then you have the S sample + container / Assc

Second step : dividing the *.Arel file by the *.Assc file : 1) select the *.Arel 2) type: oy (for operation on y) 3) type : / or 55 4) 2nd argument ? y2 5) choose the *.Assc file

Then I have Arel / Assc

Third step : multiplying the S container file by the (Arel / Assc) file created in the second step : 1) select the S container file 2) type : oy (for operation on y) 3) type : * or 54 4) 2nd argument ? y2 5) choose the file created in the second step

Then we have S container * (Arel / Assc)

Fourth step : subtraction of the (S sample + container / Assc) file from the S container * (Arel / Assc) file : 1) select S sample + container / Assc file 2) type : oy 3) type : – or 52 4) 2nd argument ? y2 5) choose (S sample + container / Assc)
Then we have the S sample file after subtraction of the empty can with self absorption correction.

#### Self absorption correction of vanadium

We will perform the SAC for Vanadium, in order to divide by the right Q dependence our data... In file 1 is the vanadium, read WITHOUT vanadium numors.

 1 _sac 0 fully iluminated 3 hollow cylinder 1.17 outer radius of the sample, in this case vanadium without container from TOFTOF 0.06 thickness of vanadium (the TOFTOF one in this case) 1 The transmission are set to 1 because there is no sample holder 1 again 0 no backscattering 72 the number density for vanadium 5.08 scattering cross section of V 5.08 absorption xs 80 80 seems reasonable

And now you should get ONLY Assc, since there is no sample holder, there will be no Arel. And now:

 1 where our vanadium is oy / y2 2 where our Assc is 3 our divided data oi 4 integrate -0.1 0.1 this should contain the elastic peak. extract the HWHM before (another oi option) and integrate from -2*HWHM to 2*HWHM. 1 to save as a file

And now we have got the “numbers” to normalize your sample!!! Before going on, you should however check that the integral performed with and without SAC correction are not similar. If they are similar, maybe is not worth to do it for every sample... up to you!

## Read data from TOFTOF after convert:

Some words before the description of the procedure. Vanadium data are used to:

• Search for the elastic channel. This is done taking the maximum of Vanadium spectra, and assigning the origin to this channel
• Normalize of the intensity as a function of the angle (detector). That means that the program will integrate the peak of Vanadium (from the maximum, to 2*(half width at half maximum) in both directions of the peak) for every spectrum, will get a value, and afterwards it will divide each spectrum of your sample to this value. This has the problem that vanadium is NOT corrected for self absorption, and can give a slightly wrong angle dependence. You can then correct your vanadium using the self absorption correction procedure. It’s also explained below.
• The detector efficiency correction, is energy dependent and has nothing to do with Vanadium. It simply takes in to account the efficiency of detector that would be less as the energy of the neutron increases, and is implemented as a formula.

You can now perform the self absortion correction, explained here.

## Fast Fourier Transforamtion of Data

Here we will shortly explain how to Furier transform the S(Q,ω) to I(Q,t) by the Fast Fourier Transformation algorithm implemented in FRIDA1. Please do take into account a couple of things:

• The space between points in frequency space gives an upper limit in the time space, i.e., the upper limit of times will be given roughly by tmax=2*pi/Δtmin
• On the other hand the difference between the last and first frequencies will give you the lower limit in time space, given again by the same formula than before tmin=2*pi/Δtmax.

Therefore do not cut your S(Q,ω) and try to rebin your data with the lowest spacing (in w) between points (be reasonable however!!!! do not bin the data in a grid smaller than that of the experiment. That will not help at all ).

We will explain, therefore, first how to “cut” the S(Q,ω) to retain only the “gain” (positive) part of the S(Q,ω) spectra, then we will explain how to “deconvolve” with the resolution function, which in time domain reduces to a division by the I(Q,t) of the resolution function, and at last to normalize by the I(Q,t=0) value.

The notion is as follows:

 Nsqt the number of the file(s) having your I(Q,t) data Nvan the number of the file(s) having your vanadium data Nsqtv the number of the file(s) having your I(Q,t) divided by vanadium Nnorm the number of the file(s) having your normalization constant
##### Fast Fourier Transforamtion of Data. Only gain side
 mcd To delete the loss part 3 to select by x value 0-100 to keep only the positive values. Now we can do the fft... tff Fourier Transform in cosinus (we want the real part!) t Output coordinate is time ps the output unit is generally in the ps scale for TOF measurements 1e-12 a picosecond is 10-12 s S(Q,t) the output coordinate is S(Q,t) that is its unit: none
##### Deconvolve the instrumental resolution
 glx to put x axis of graphics in a log scale p Nsqt You can plot your nice s(q,t). Now we are ready to divide by the resolution oy to recalculate y / to divide by y2 to catch a value per channel Nvan the number of the file with your vanadium data.
##### Normalize S(Q,t)/S(Q,t=0)
 Nsqt we go to the number of file you have your S(q,t) (already divided by vanadium!) oi I will keep a file with only one point per spectrum (the first) which is most similar to S(Q,t=0) 3 one y value 1 from the first channel of each spectrum. Now we get a file with a point for every spectrum. Nsqtv now we select the file where our data are oy we will divide by the points in the file we have just created with one point per spectra / divide i one point of file Nnorm per spectra Nnorm the file with your normalization constants (that we have calculated as the first point of our S(Q,t)

That’s all folks!

## 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

#### Plotting parameters as a function of a z coordinate, such as temperature

• After finishing fitting, how can I quickly see the fits together with the data I have already displayed?
• Type “a”, then the program will “add” the plots for the fittings...
• I get strange spikes (exactly where the exp. points are) when plotting fitted curves!
• This is a bug in the “online” convolution with the vanadium measurement. You have to convolve “by hand” using cg, then set the displaystyle to line with eg and add with a.
• I have done a fitting to several files (i.e. W as a function of Q2), I have extracted the coefficients of the fitting (therefore I have a lot of files with only one value related to the temperature) and now I want to put all them in one file, and plot them as a function of temperature... If the files with one value resulting for the fitting are from number 1 to 10:
 1-10 the files with one extracted value resulting from the fitting mfj we will put all the values in one single file. This file will have 10 “spectra” with one only value... and I want to have one spectra with all the values. Therefore msx will exchange the values of z (the spectra) and x. BUT sometimes you will get the error message: x ↔ z makes no sense if there are several z’s. Tha is because (of course) because internally the program has got several z’s Then: ez we will see if that is true, you should get only one column, if not: d to delete one z coordinate 2 the number 2, for example d sometimes you will have also to delete another one 2 which after deleting the former is now number 2 enter to go out form the menu msx and now you can at last have one nice file with your values as a function of temperature!!!!

## Calculating the diffractogram

There are more then one ways to calculate the diffractogram. We think that the correct one is the following:

#### Integration over Energy

##### Probably correct

Start with d2σ / dΩ dE (choose to generate sig(2th,w) in rtof).

 oi We want to integrate over all energies. 4 * We do exactly the same as a Diffractometer and integrate over all energies. 1

Now you have something like dσ / dΩ.

##### Alternatively

The following procedure calculates S(2θ). In a second step, it is transformed into S(Q). However, this step is not correct as the detectors (fixed at a certain angle) do not record neutrons with some special Q – Q rather depends on the energy transfer of the sample. Therefore, one would need to transform the spectra first into S(Q,ω) having the problem of a very limited ω-range.

 oi We want to integrate over all energies. 4 0 1000 Using this, we integrate over all energy-gain-neutrons. The problem with the energy-loss-side is that it depends on the incident wavelength. In other cases, the whole range («*») or the elastic line might be better. 1

This is S(2θ) = ∫-∞ dω S(2θ,ω). So far, so good. Now comes the part which is worth discussing,

#### Conversion to Q

##### Convert x-axis explicitly
 ox We want now to get S(Q), and not S(2θ) * ec 0.008726646 to multiply by 0.5*pi/180=0.008726646 (and get theta) ox sin y to take the sine of x ox * ec 5.02655 if you have lambda=2.5, we must calculate 4*pi/lambda=5.02655
##### Alternatively

Trusting a build-in which sometimes works only the second time called correctly (produces reasonably-looking output the fist time also, though):

 ox q Function? ec 2nd argument? (this argument is the incident energy) 2.2725 Its name / value? (81.81/λ2) meV Its unit
##### Convert y-axis

The x-axis is now converted to Q, next we have to convert also the y-axis to get a bit closer to the goal that ∫0180 d(2θ) S(2θ) = ∫0Qmax d(Q) S(Q)

 oy Operate on y * Multiply ec We work only on one file, therefore «ef» would be equally fine 85.944 45*λ/π (originally: 180/(4*π/λ) ) 0 no error 85.944 Its name / value 1 Its unit
DANGER DANGER DANGER DANGER DANGER DANGER DANGER DANGER DANGER DANGER DANGER DANGER

In the diffractograms created in this way there are more points than one per q. In order to get a value per q, please, do use mco in order to average points of equal q. Otherwise you can have problems with some instructions (and the graphics without mco are uglier!!!, are more noisiy, of course!)

## CALCULATE S(Q,ω)

 N write the number of file to convert to S(Q,ω) _ if you want to know the options. However our is _coq _coq 1 we want a linear grid -1.4 the first energy. if the number is too big an error wil occur and frida will tell us the maximum value 0.01 the step in energy 100 the last energy you want 1 equidistant q 0 the first q 0.1 Step in q 10 a big number... to get all the spectra 30 Number of slices 0.05 radius of arc... half the value of increment of q 0.1/2=0.05 (high level arithmetics!!!) 1 minimla number of channels
##### Obtain diffusion coefficient

Please have a look at Fitting a function

##### Plotting the two components of a two-Lorentzian fit

It goes along the lines: export all fit parameters with ci. create two new fit files to the data file. when asked for starting values, say “from file” (check help for how to do that) and use these values. only the ones for the first lorentzian in the first fit file, only the ones for the second in the other. do not fit! simply plot those fit files, convolve with the vanadium.

## To calculate the susceptibility

Susceptibility is defined as:

Xq ' ' (w)=S(q,w)/(exp(hw/KBT)-1)-1

and Xq it is expected to factorize as: X`q(w)=hq*X`(w) (see PRE 61 3 2730 (2000), Wuttke et al.), confer to Making a master curve

 _sg to convert input y(x,z) to another representation 10 option to calculate the susceptibility msa To group detectors to have less spectra with better statistics z to group by z values, i.e. by detector angle in this case 10 the tolerance: will group detectors every 10 degrees in 2*theta y proceed using channel numbers. this is done because the points in different spectra are not at the same energy. this may cause problems. alternative: put the data on a common grid beforehand using mgr. however, be also aware of mgr, it sometimes does strange things. ?? you must write the number of the file where you have the susceptibilty files tu convert axes. We use it to “translate” from meV to frequency 1 more energy = higher frquency Hz new unit of x (frida knows it) Hz-1 new unit of y

Now we will substract the empty can

 oy to act on the y axis “N1” to act in file number N#. (from now on N wiull be the number of file we are acting on) - Funtion - to substract y2 An y axis from another file N2 To substract the y axis from file number 2 (we are doing, therefore Yn1-Yn2). A lot of numbers will then appear. This is the same issue as above with the channel numbers. if it does, be aware and check the result carefully before submitting to phys rev lett. df you can se what you have done (hopefully!)

## To calculate the Density of States (alias DOS)

SECTION UNDER CONSTRUCTION DO NOT TRUST TOO MUCH WHAT IS WRITTEN!

In a liquid the density of states is defined as:

p(w)=2Mh(!/KT) w2 · lim|k|→0 Sinc(q,w)·exp(hw/KT)/q2 (Squires, Pg 102)

We will therefore, first calculate the s(q,w) in a large range of q (where the elastic line in fact dissapears). Then we will seight spectra by 1/q2, then add the spectra, and then calculate the density of states in the one phonon approximation.

 fl * we load the corrected data s(2theta,w) _coq first let’s calculate s(q,w), but fur all q values, i.e. also for long energy transfer regions (for more details see calcuate s(q,w) 1 linear 0 initial energy 0.1 step in energy 100 max energy (or any other number) 1 interp in q 0 q(1) 0.1 step in q 10 max q 30 slices 0.05 hlaf the q step 1 min num of channels

At this point you should have in 2 s(q,w) (or we will suppose it is in file 2)

 2 let’s work in file 2, where s(q,w) is saved oy we operate on y (intensity) / we want to divide (by q) z we ant to divide by z, i.e. by q. You will generate a file 2. oy again the same because we want to divide by q2 / aserejé z needs further explanations?. In file 4 we have now s(q,w)/q2 (hopefully!) mgi We put all data inthe same grid, otherwise we will run into problems when we add all spectra, because channels are not equal for each spectra! 1 linear 0 firs energy 0.1 steop of energy 100 last energy. If you had a look, the programs proposes the same numbers as when you calculated s(q,w) (isn’t it intelligent the program?) 1 linear interpolation. And in file 5 you should now have all the data niceñly in the same grid msa we add the spectra z let’s group by z value 100 a hughe number, because we want to add ALL spectra in one single spectra 1 You must add over full area. In file 6 you should now have your nice s(q,w). Let’s now calcualte g_1(w) _sg spetial options 3 to calculate g_1(w) n why not? 0 why not? 0 why not?. And we get g_1(w). Now we are going to normalize it. We therefore calculat the integtral oi to make the integral 4 option to integrate 0 40 the range to integrate (you should have had a look at your data first 1 save result as a file, and i nfile 8 you will have the integral result (one point) 7 finally we will divide by the integral value, so let’s go to 7, where g_1 is calculated oy tu divide by the integral / divide if we will divide by the value in file 8, the integtral 8 from file 8 9 here is somethng like the density of states

The procedure is not fully tested and may have errors!

## Making a master curve

I have a lot of (nice) spectra, and I would like to make a master curve, that is to say, I would like to divide (multiply) each spectra by a number, to match all the curves in one... I suppose that the spectra are in file 1

 oi to select “integral” options 9 wit this option you will “rescale” all the curves from a file in one. with option 11 you will match spectra from different files n/y do you want to “calculate” the coefficients for the rescaling using the same x-rang for all the curves? let’s asume that you answered y * all the range for average 1 the rescaling coef for curve 1 will be 1 1 I will save the coeffs in a file... then the program will generate a file (number 2 in this case)with a point per spectra, which is the rescaling factor, and now I want to dicide each spectra by this factor 1 I will operate on file 1 oy I will operate on y axis / I will divide by the factor in the file i The second argument will be one value per spectra taken from another file 2 from file 2, where I have my rescaling factors

And now a new file with your rescaled curves is created.

## Redistributing data or the joy of mgr

Once we have some file we would like to redistrivute the data and put them in a regular grid (for example from (q,w) or w in a logarithmic scala...), how to do it? As an example we will “put the data” in a x logarithmic grid.

 mgr to redistribute the data 3 because we want to redistribute in a logarithmic scala (1 for a linear one!!!), if you want to make linear for a determined range, and log for another range use option 2 1e10 for the first value (it is so big because in our case was a frequency in Hz...) 1e13 for the last value 10 I want 10 point per decade. In the case of a linear grid the increment of x axis will be asked 3 What happens if there are not enough experimental points to “fill” the grid. with option 3 the program will fill the whole grid, also if there are no experimental points, repeating the value of the closer point. Option 2 will not fill the whole grid with points... just test it!!! here you have it!!!

## Generating a function

The thing is simple: I simply want to generate a function (in my case an exponential y=exp(-x*w)) to compare with data, therfore I want to generate it in the sam x spacing as the data. In addition I want to take the values from a file with the w data (froma a fitting for example). I do NOT know if that is the easiest way to do it, but it seems to work If I am working at file 1:

 oy I will act in the y axis 50 I will copy the values of x in the y axis (I am now choosing to get the values from “somewhere”) x I copy the x data (this “somewhere” is the x data). And now I have a new file with y=x values Nx=y I will operate in the redcently new created Nx=y file with y=x, therefore all what I do with y, I do it with x oy * multiply ec -1 we multiply by -1 to get -x i second argument is a point per file (in our case w) Npar from the file with parameters, and we get -x*w oy modifiy y 3 to selsect the function exponential

and finally we get exp (-x*w)