Graphiques des pressions partielles de systèmes non-idéaux
<sxh python; title : pressions_partielles_systemes_non_ideaux.py> #!/usr/bin/env python # -*- coding: utf-8 -*- “”“ Graphiques des pressions partielles de systèmes non-idéaux Basé sur le travail de ML et VM, ba2 chimie 2013-2014 ”“”
import numpy as np import matplotlib.pyplot as plt from Tkinter import*
#données R = 0.082 #cste des gaz parfaits T = 293 # temperature cste (k) U01 = np.array([343,330,328,313,308,295,290,284,275,274,263,262,254,252,250,246,242,241,233,232,227,225,217,207,180,124,121,110,103,86,73,62,0]) #[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] #potientiel chimique standard, donnee = exemple U02 = np.array([0,110,122,191,206,259,272,284,323,328,357,361,381,382,390,394,403,405,419,420,427,428,438,447,465,490,489,491,491,495,502,501,513]) a1 = np.array([0,0.061,0.071,0.121,0.133,0.185,0.198,0.209,0.275,0.288,0.35,0.356,0.405,0.414,0.447,0.452,0.492,0.498,0.569,0.572,0.612,0.615,0.67,0.72,0.828,0.918,0.923,0.934,0.939,0.954,0.961,0.969,1])#f represente le rapport des constituants, o etant le constituant 1 et p le consituant 2 par ex a2 = np.ones(1)-a1
x1 = np.array([0,0.1891,0.3851,0.5945,0.8243,1]) x2 = np.ones(1)-x1 U03 = np.array([80]) U04 = np.array([45])
def graph1():
U1= (np.log(a1)*R*T)+U01 U2= (np.log(a2)*R*T)+U02 plt.figure(1) plt.plot(a1,U1,039;r039;039;x039;039;-039;) plt.plot(a1,U2,039;g039;039;o039;039;-039;) plt.plot(a1, U1+U2,039;b039;) plt.xlabel (039;fraction molaire des constituants039;) plt.ylabel (039;pression en mmHg039;) plt.title (039;diagramme de l acetone et du CS2039;) plt.legend(("acetone","CS2","somme des 2"),039;best039;) plt.show()
def graph2():
U3= (np.log(x1)*R*T)+U03 U4= (np.log(x2)*R*T)+U04 plt.figure(2) plt.plot(x2,U3,039;b039;039;-039;) plt.plot(x2,U4,039;g039;039;x039;039;-039;) plt.plot(x2, U3+U4,039;k039;039;o039;039;-039;) plt.xlabel (039;fraction molaire des constituants039;) plt.ylabel (039;pression en mmHg039;) plt.title (039;diagramme du benzene et du toluene039;) plt.legend(("benzene","toluene","somme des 2"),039;best039;) plt.show()
def graph3 ():
U1= (np.log(a1)*R*T)+U01
U2= (np.log(a2)*R*T)+U02
U3= (np.log(x1)*R*T)+U03
U4= (np.log(x2)*R*T)+U04
plt.figure(3)
plt.subplot(121) plt.plot(a1,U1,039;r039;039;x039;039;-039;) plt.plot(a1,U2,039;g039;039;o039;039;-039;) plt.plot(a1, U1+U2,039;b039;) plt.xlabel (039;fraction molaire des constituants039;) plt.ylabel (039;pression en mmHg039;) plt.title (039;diagramme de l acetone et du CS2039;) plt.legend(("acetone","CS2","somme des 2"),039;best039;)
plt.subplot(122) plt.plot(x2,U3,039;b039;039;-039;) plt.plot(x2,U4,039;y039;039;x039;039;-039;) plt.plot(x2, U3+U4,039;k039;039;o039;039;-039;) plt.xlabel (039;fraction molaire des constituants039;) plt.ylabel (039;pression en mmHg039;) plt.title (039;diagramme du benzene et du toluene039;) plt.legend(("benzene","toluene","somme des 2"),039;best039;)
plt.show()
def abientot ():
print "en esperant vous revoir bientôt !" fen1.destroy()
fen1 = Tk() fen1.title(“diagramme des cas non ideaux et ideaux”)
#création widget
Label(fen1, text=“choisissez votre diagramme parmis les propositions ci dessous :”, bg=“orange”, fg=“black”).grid(row=2, column=1,columnspan=2, padx=3, pady=3) Button(fen1, text=“acetone CS2”, command=graph1, bg=“yellow”, fg=“black”).grid(row=3, column=0, columnspan=2) Button(fen1, text=“benzene toluene”, command=graph2, bg=“blue”, fg=“white”).grid( row=3, column=2, columnspan=2) Button(fen1, text=“comparatif des 2 diagrammes”, command=graph3, bg=“green”,fg=“black”).grid( row=3,column=4,columnspan=2) Button(fen1, text=“quitter”, command=abientot, bg=“red”, fg=“black”).grid(row=5, column=2, columnspan=2)
fen1.mainloop()
</sxh>