Vincent Foriel - 07/11/2021
- Fortran 90
- Python 3.9 & pip
- Placez vous dans le dossier de votre choix, puis clonez le répertoire git via la commande :
git clone https://gitlab.com/LeiRoF/fitting-spectra
- Déplacez vous dans le dossier du projet
cd fitting-spectra/
- Installez les dépendances du program Python permettant l'affichage des résultats sous la forme d'un graphique
pip install -r ./requirements.txt
- En utilisant GFortran, compilez les fichiers fortran
gfortran -o fit_spectra ./fit_spectra.f90
gfortran -o fit_omega ./fit_omega.f90
Ce projet contient 2 programmes indépendants :
- Fit Spectra a pour but de déterminer une fonction lorentzienne à partir d'un ensemble de points donnés via un fichier dans [./data/]{.title-ref}
- Fit Omega permet ensuite de faire une régression linéaire, ce qui permet, dans le contexte de ce projet, de déterminer l'énergie fondamentale de rotation du gaz.
Vous pouvez éditez les fichiers [fit_spectra.f90]{.title-ref} et [fit_omega.f90]{.title-ref} afin d'y modifier le fichier considéré. Une fois édité, ré-effectuez l'étape 3 de l'installation (compilation des fichiers Fortran)
Lancer Fit Spectra
./fit_spectra
Lancer Fit Omega
./fit_omega
Si une erreur apparait à la fin de l'execution du programme et qu'aucune fenêtre ne s'affiche, vous pouvez l'ouvrir manuellement en utilisant votre navigateur pour ouvrir le fichier
plot\_spectra.hmtl
ouplot\_omega.html
The objective is to fit a theoretical spectrum shape, which takes the form of a Lorentzian to a point cloud.
The Lorentzian is defined by :
Where$\omega$ is the emission frequency;
In order to perform this theoretical fit, we need to transform this function so that it takes the form of a polynomial. We therefore take its inverse:
For the program, the values of omega are likely to be too large. We then define :
This gives us :
Which can be rewritten as:
The objective is to find the combination
To find a minimum, we therefore look for the points where the derivative cancels, which gives us:
Which when decomposed gives us:
\begin{cases} \sum_{i=1}^N W_i y_i \ \sum_{i=1}^N W_i y_i x_i \ \sum_{i=1}^N W_i y_i x_i^2 \end{cases} \end{aligned}$$
If we divide everything by
\begin{cases} \langle W \rangle \langle y \rangle \ \langle W \rangle \langle y x \rangle \ \langle W \rangle \langle y x^2 \rangle \end{cases} \end{aligned}$$
Thus, we can divide everything by
So we can determine the coefficients
Once these coefficients have been calculated, the values of gamma$ and $
bar{\omega}$ can be found. Their expression can be
recovered from the expressions of
With these 3 parameters, we then have a complete description of
The program reads a file containing on each line a value of
With this information, we have the coordinates of each point. However,
we want to invert the coordinate
Also, we calculate for each value of
At this point, we have a new set of coordinates that can be exploited.
We then calculate the average values of the different elements (
Once this is done, we can now calculate the coefficients
From this we can calculate the values of
Using the first spectrum corresponding to a pressure of 1 atm, we obtain the following result:
However, we notice that the curve we obtain does not totally coincide with our initial data. Indeed, here, we have given an equal weight to each of the experimental values. However, the high values are more significant than the low values because the noise becomes relatively negligible. So, to avoid trying to adjust the curve to the ambient noise, and thus having this kind of error, we give a weight proportional to the squared intensity of each measurement.
In this way, we obtain the following result:
The operation can be repeated for the other spectra, thus for other pressures, which gives us:
Like the fit for a Lorentzian, the idea here is also to apply the least squares method. However, we now have a simpler equation:
The objective is therefore to find the combination
The rest of the development is therefore very similar to that done to fit the Lorentzian. To find a minimum, we look for the points where the derivative cancels, which gives us:
Which when decomposed gives us:
If we divide everything by
Thus, we can divide everything by
We can therefore determine the coefficients
The program reads a file containing on each line a value of
Here we do not need to modify the data because the function
We then directly calculate the sums of the different elements (
Once this step is done, we can now calculate the coefficients
We thus obtain a line of expression