Programme python pour déterminé une concentration inconnue par dosage spectrophotométrique, plus simulation Monte-Carlo
5 views 0 purchase
Course
Informatique/Chimie
Institution
Lycée Blaise-Pascal
Le programme définit les valeurs d'absorbance et de concentration, ainsi que les incertitudes associées, pour créer un modèle de régression linéaire en utilisant la fonction "polyfit" de NumPy. Il affiche ensuite les paramètres de la droite de régression linéaire, notamment la pente, l'ord...
#Calcule de C inconnue :
import numpy as np
import numpy.random as rd
import matplotlib as plt
import matplotlib.pyplot as plt
data=np.loadtxt('C:/Users/basti/Documents/PCSI2/TIPE/Classeur1.txt') #prend les
valeur dans le document joint en txt
C=[1,2,3,4,5] #Abscisse:concentration
absorbance=[0.1925,0.3883,0.5846,0.7948,0.9761] #Absorbance:ordonnée
Ab_c_inconnue=0.5705 #Absorbance de la concentration inconnue
uC=np.array([0.1,0.1,0.1,0.1,0.1]) #incertitude de la concentration
uab=np.array([0.02,0.02,0.02,0.02,0.02]) #incertitude de l'absorbance
p=np.polyfit(C,absorbance,1)
plt.errorbar(C,absorbance,xerr=5*uC,yerr=5*uab,fmt='o')
C_modele=np.linspace(0,13,1000) #remplire avec la valeur maximal de la
concentration au milieu
absorbance_modele=p[0]*C_modele+p[1]
r=np.corrcoef(C,absorbance)
k=p[0]
def C_inconnue(ab_c_inconnue):
return Ab_c_inconnue/k #détermination de la concentration inconnue
print("pente k = ",p[0]," / ordonnée à l'origine = ",p[1]," / coefficient de
corélation r =",r[0,1]," / concentration iconnue = ",C_inconnue)
plt.plot(C,absorbance,'+')
plt.plot(C_modele,absorbance_modele, color='red')
plt.xlabel('Concentration en mol/L')
plt.ylabel('Absorbance')
plt.title('Absorbance en fonction de la concentration')
plt.text(7.5,3,"• Droite d'équation A=k*C+b : ")
plt.text(7.75,2.5,"k = " + "{:.4}".format(p[0]) + " L/mol")
plt.text(7.75,2,"b = " + "{:.4}".format(p[1]))
plt.text(7.75,1.5,"r = " + "{:.4}".format(r[0,1]))
plt.text(7.5,1,"• Concentration inconnue : ")
plt.text(7.75,0.5,"C_inconnue = " + "{:.4}".format(C_inconnue(Ab_c_inconnue)) +
"mol/L")
plt.show()
#__________________________________________________________________________________
_______________________________________________________________
#simulation Monte-Carlo pour l'absorbance:
import numpy as np
import matplotlib.pyplot as plt
# Concentration et incertitude associée
c=0.001
u_c=0.0001
k=0.1974
# Nombre de simulations Monte-Carlo
n_simulations=3000
# Simulations Monte-Carlo de l'absorbance
absorbances=[]
for i in range(n_simulations):
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller bastienmathieu60. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $9.18. You're not tied to anything after your purchase.