import matplotlib.pyplot as plt """ initialisation des données""" # nombres steochiométriques des 2 réactifs sto1=1 sto2=1 # premier réactif: le réactif titré C1=0.1 V1=10 # V1 sera laissé en mL donc quantité de matière sera en mmol # 2nd réactif: le réactif titrant C2=0.1012 V2max=25 # en mL, volume max de solution titrante # Formules des ions présents: reactif1="NH4+" reactif2="HO-" spectateur3="Na+" spectateur4="Cl-" # boucle permettant de calculer la quantité de matière de chaque ion en fonction du Volume versé for V2 in range(0,V2max+1): # Pour chaque ajout de V2,calcul des quantités de matière initiales: n1_ini=C1*V1 n2_ini=C2*V2 n3=C2*V2 n4=C1*V1 # détermination de xmax if n1_ini/sto1>n2_ini/sto2: # réactif 2 limitant xmax=n2_ini/sto2 else: xmax=n1_ini/sto1 # réactif 1 limitant # Calcul des quantités finales des réactifs # si n<0, c'est que n=0 n1_fin=n1_ini-sto1*xmax if n1_fin<0: n1_fin=0 n2_fin=n2_ini-sto2*xmax if n2_fin<0: n2_fin=0 # affichage des points sur une courbe plt.plot(V2,n1_fin,"rx") plt.plot(V2,n2_fin,"bx") plt.plot(V2,n3,"gx") plt.plot(V2,n4,"yx") # FIN DE LA BOUCLE ############### # affichage à nouveau des derniers points pour pouvoir mettre une legende plt.plot(V2,n1_fin,"rx",label=reactif1) plt.plot(V2,n2_fin,"bx",label=reactif2) plt.plot(V2,n3,"gx",label=spectateur3) plt.plot(V2,n4,"yx",label=spectateur4) # axes du graphe plt.xlabel("Volume V2 de solution titrante versée en mL") plt.ylabel("Quantités de matière en mmol") plt.title("Titrage de NH4Cl par NaOH") # affichage de la legende plt.legend() # affichage de la fenêtre plt.show()