Académique Documents
Professionnel Documents
Culture Documents
import tkinter as tk
import numpy as np
import matplotlib.pyplot as plt
tk_diametres = []
tk_refus = []
def create_entries():
n = int(tk_n.get())
for i in range(n):
tk.Label(root, text="Diamètre du tamis {} (en
mm) :".format(i+1)).grid(row=i+1, column=0)
tk_diametres.append(tk.Entry(root))
tk_diametres[i].grid(row=i+1, column=1)
tk.Label(root, text="Masse du refus sur le tamis {} (en
g) :".format(i+1)).grid(row=i+1, column=2)
tk_refus.append(tk.Entry(root))
tk_refus[i].grid(row=i+1, column=3)
# Callback
def analyse():
# Récupération des données
root = tk.Tk()
n = int(tk_n.get())
diametres = np.zeros(n)
refus = np.zeros(n)
for i in range(n):
diametres[i] = float(tk_diametres[i].get())
refus[i] = float(tk_refus[i].get())
# Calcul des pourcentages de refus et de passants
masses_totales = np.sum(refus)
pourcentages_refus = refus / masses_totales * 100
pourcentages_passants = 100 - np.cumsum(pourcentages_refus)
# Calcul des diamètres caractéristiques
D10_index = np.argmin(pourcentages_passants > 10)
D10 = diametres[D10_index-1] + (diametres[D10_index] - diametres[D10_index-1])
* (10 - pourcentages_passants[D10_index-1]) / (pourcentages_passants[D10_index] -
pourcentages_passants[D10_index-1])
D30_index = np.argmin(pourcentages_passants > 30)
D30 = diametres[D30_index-1] + (diametres[D30_index] - diametres[D30_index-1])
* (30 - pourcentages_passants[D30_index-1]) / (pourcentages_passants[D30_index] -
pourcentages_passants[D30_index-1])
D60_index = np.argmin(pourcentages_passants > 60)
D60 = diametres[D60_index-1] + (diametres[D60_index] - diametres[D60_index-1])
* (60 - pourcentages_passants[D60_index-1]) / (pourcentages_passants[D60_index] -
pourcentages_passants[D60_index-1])
# Calcul des coefficients de courbure et d'uniformité
Cc = (D30 ** 2) / (D10 * D60)
Cu = D60 / D10
# Tracé de la courbe granulométrique
fig, ax = plt.subplots()
ax.semilogx(diametres, pourcentages_passants, label="Courbe granulométrique")
ax.set_xlabel("Diamètre des particules (mm)")
ax.set_ylabel("Pourcentage cumulé des passants (%)")
ax.set_title("Analyse granulométrique")
ax.legend(loc="best")
# Ajout des valeurs caractéristiques
ax.scatter(D10, 10, color="red", label="D10")
ax.scatter(D30, 30, color="red", label="D30")
ax.scatter(D60, 60, color="red", label="D60")
ax.legend(loc="best")
plt.show()
# Affichage des résultats
resultats = np.vstack((pourcentages_refus, np.cumsum(pourcentages_refus),
pourcentages_passants)).round(2)
somme_refus = 0
for i in range(n):
somme_refus += refus[i]
pourcentage_refus_partiel = round(pourcentages_refus[i], 2)
pourcentage_refus_cumule = round(pourcentages_refus[i], 2)
pourcentage_passants_cumules = round(pourcentages_passants[i], 2)
print("|{: ^20}|{: ^20}|{: ^20}|{: ^20}|{:
^20}|".format(round(diametres[i], 2), round(refus[i], 2), pourcentage_refus_cumule,
pourcentage_passants_cumules, pourcentage_refus_partiel))
print("-" * 105)
print("|{: ^20}|{: ^20}|{: ^20}|{: ^20}|{: ^20}|".format("Fonds du tamis",
round(somme_refus, 2), "100.0", "0.0", ""))
print("-" * 105)
# Calcul du pourcentage cumulé des passants sur le tamis de 0.08 mm
cumul_passants_008mm = 100 - np.sum(pourcentages_refus[diametres > 0.08])
A= 100 - cumul_passants_008mm
if A < 50 :
if A >= 50 :
Q1= A-cumul_passants_2mm
if Q1 > 50 :
if cumul_passants_008mm < 5 :
if Q1 < 50 :
if cumul_passants_008mm < 5 :
if Cu > 6 and 1 < Cc and Cc < 3 :
print("Notre sol est un sable propre bien gradué")
else :
print("Notre sol est un sable propre mal gradué")
# Boutons
tk.Button(root, text="Créer les entrées", command=create_entries).grid(row=0,
column=3)
tk.Button(root, text="Analyser", command=analyse).grid(row=0, column=4)
# Boucle principale
root.mainloop()