0% found this document useful (0 votes)
33 views6 pages

Le Code Du Programme

The document contains code for calculating the stability of retaining walls. It imports math functions, defines functions for converting degrees to radians and validating float inputs. It creates a GUI with entries for wall parameters and calculates safety factors and stresses to check stability.

Uploaded by

Laila Salhami
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views6 pages

Le Code Du Programme

The document contains code for calculating the stability of retaining walls. It imports math functions, defines functions for converting degrees to radians and validating float inputs. It creates a GUI with entries for wall parameters and calculates safety factors and stresses to check stability.

Uploaded by

Laila Salhami
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

import math

from tkinter import *

from tkinter import messagebox

def to_radian(degrees):

return degrees * math.pi / 180

def click_submit():

cohesion = float(cohesion_input.get())

surcharge = float(surcharge_input.get())

gamma = float(gamma_input.get())

gamma_b = float(gamma_b_input.get())

phi = float(phi_input.get())

height = float(height_input.get())

width = float(width_input.get())

phi_b = float(phi_b_input.get())

q_adm = float(q_adm_input.get())

small_base = 0 if small_base_input.get() == '' else float(small_base_input.get())

k_a = pow(math.tan(to_radian(180 / 4 - phi / 2)), 2)

sigma_h = k_a * (gamma * height + surcharge) - 2 * cohesion * math.sqrt(k_a)

sigma_h0 = k_a * surcharge - 2 * cohesion * math.sqrt(k_a)

z = 2 * cohesion / (gamma * math.sqrt(k_a))

F1 = sigma_h0 * z / 2

y1 = height - z / 3

F2 = sigma_h * (height - z) / 2

y2 = (height - z) / 3

W = gamma_b * width * height

y3 = width / 2
if shape.get() == 2:

y3 = 2 * width / 3 - pow(small_base, 2) / (3 * small_base + width)

W = gamma_b * height * (small_base + width) / 2

M_s = W * y3

M_m = F1 * y1 + F2 * y2

M_r = M_s - M_m

e0 = M_r / W

e_c = width / 2 - e0

sigma_max = W / width * (1 + 6 * e_c / width)

sigma_min = W / width * (1 - 6 * e_c / width)

FS1 = (cohesion * width + W * math.tan(to_radian(phi_b))) / (F1 + F2)

FS2 = M_s / M_m

q = (3 * sigma_max + sigma_min) / 4

if FS1 >= 1.5 and FS2 >= 1.5 and q <= q_adm and sigma_max <= q_adm and sigma_min >= 0:

messagebox.showinfo(title="Information", message=f"Le mur est stable")

else:

B_max = 0

if shape.get() == 1:

B1 = (1.5 * (F1 + F2) - W * math.tan(to_radian(phi_b))) / cohesion

B2 = 2 * (F1 * y1 + F2 * y2) / W

B3 = (W - math.sqrt(W * (W + 12 * q_adm * e_c))) / (2 * q_adm)

B4 = (W + math.sqrt(W * (W + 12 * q_adm * e_c))) / (2 * q_adm)

B_max = max(B1, B2, B3, B4)

messagebox.showinfo(title="Information",
message=f"Pour que le mur soit stable il faut que la base du mur soit supérieure à
{B_max} m")

elif shape.get() == 2:

B1 = math.sqrt(81 * (F1 * y1 + F2 * y2) / (26 * gamma_b * height))

B2 = 4.5 * (F1 + F2) / (3 * cohesion + 2 * gamma_b * height * math.tan(to_radian(phi_b)))

B3 = math.sqrt((F1 * y1 + F2 * y2) / (q_adm / 3 - 23 / 108 * gamma_b * height))

B_max = max(B1, B2, B3)


b_max = 2 * B_max / 3

messagebox.showinfo(title="Information",

message=f"Pour que le mur soit stable il faut que la grande base du mur soit
supérieure à {B_max} m et la petite base à {b_max} m")

def validate_float(action, index, value_if_allowed,

prior_value, text, validation_type, trigger_type, widget_name):

if value_if_allowed:

try:

float(value_if_allowed)

return True

except ValueError:

return False

else:

return False

base = Tk()

base.geometry('700x700')

base.title("Mur de soutènement")

vcmd = (base.register(validate_float),

'%d', '%i', '%P', '%s', '%S', '%v', '%V', '%W')

labl_0 = Label(base, text="Mur de soutènement", width=20, font=("bold", 20))

labl_0.place(x=90, y=0)

shape = IntVar(None, 1)

Label(base,

text="Forme du mur",

justify=LEFT,

padx=20).place(x=90, y=60)
def set_shape():

# rectangle

if shape.get() == 1:

small_base_input.place_forget()

small_baseLabel.place_forget()

elif shape.get() == 2:

small_baseLabel.place(x=80, y=490)

small_base_input.place(x=240, y=490)

Radiobutton(base,

text="Rectangle",

padx=20,

variable=shape,

value=1,

command=set_shape).place(x=90, y=80)

Radiobutton(base,

text="Trapèze",

padx=20,

variable=shape,

value=2,

command=set_shape).place(x=90, y=100)

cohesionLabel = Label(base, text="Cohésion en KPA", width=20, font=("bold", 10))

cohesionLabel.place(x=80, y=130)

cohesion_input = Entry(base, validate='key', validatecommand=vcmd)

cohesion_input.place(x=240, y=130)

surchargeLabel = Label(base, text="Surcharge en KPA", width=20, font=("bold", 10))


surchargeLabel.place(x=80, y=170)

surcharge_input = Entry(base, validate='key', validatecommand=vcmd)

surcharge_input.place(x=240, y=170)

gammaLabel = Label(base, text="Poids volumique du sol en KN/m3", width=30, font=("bold", 10))

gammaLabel.place(x=0, y=210)

gamma_input = Entry(base, validate='key', validatecommand=vcmd)

gamma_input.place(x=240, y=210)

gamma_bLabel = Label(base, text="Poids volumique du béton en KN/m3", width=30, font=("bold",


10))

gamma_bLabel.place(x=0, y=250)

gamma_b_input = Entry(base, validate='key', validatecommand=vcmd)

gamma_b_input.place(x=240, y=250)

phiLabel = Label(base, text="Angle de frottement du sol en degré", width=30, font=("bold", 10))

phiLabel.place(x=0, y=290)

phi_input = Entry(base, validate='key', validatecommand=vcmd)

phi_input.place(x=240, y=290)

heightLabel = Label(base, text="Hauteur du mur en m", width=20, font=("bold", 10))

heightLabel.place(x=80, y=330)

height_input = Entry(base, validate='key', validatecommand=vcmd)

height_input.place(x=240, y=330)

widthLabel = Label(base, text="Base du mur en m", width=20, font=("bold", 10))

widthLabel.place(x=80, y=370)

width_input = Entry(base, validate='key', validatecommand=vcmd)

width_input.place(x=240, y=370)

phi_bLabel = Label(base, text="Frottement entre sol et béton en degré", width=30, font=("bold", 10))
phi_bLabel.place(x=0, y=410)

phi_b_input = Entry(base, validate='key', validatecommand=vcmd)

phi_b_input.place(x=240, y=410)

q_admLabel = Label(base, text="Portance du sol en KPa", width=20, font=("bold", 10))

q_admLabel.place(x=80, y=450)

q_adm_input = Entry(base, validate='key', validatecommand=vcmd)

q_adm_input.place(x=240, y=450)

small_baseLabel = Label(base, text="Petite base en mètre", width=20, font=("bold", 10))

small_base_input = Entry(base, validate='key', validatecommand=vcmd)

if shape.get() == 2:

small_baseLabel.place(x=80, y=490)

small_base_input.place(x=240, y=490)

Button(base, text='Calculer', width=20, bg='brown', fg='white', command=click_submit).place(x=180,


y=530)

def run(name):

base.mainloop()

# Press the green button in the gutter to run the script.

if _name_ == '_main_':

run('PyCharm')

# See PyCharm help at https://www.jetbrains.com/help/pycharm/

You might also like