Python Code for designing Doubly-reinforced Beam
# Step-1: Loads
import math
from PIL import Image, ImageDraw, ImageFont
while True:
D = input("Enter overall depth of beam in mm:")#Taking the input of overall depth
try:
val = int(D)#Checking whether its a integer or not
if val > 0:
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
try:
float(D)#Checking whether its a float or not
if float(D) > 0:#Checking whether it is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
while True:
S = input("Enter span of beam in m:")#Taking the input of span
try:
val = int(S)#Checking whether it is a integer or not
if val > 0:#Checking whether it is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
try:
float(S)#Checking whether it is float or not
if float(S) > 0:#Checking whether positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
while True:
B = input("Enter width of beam in mm:")#Asking for the value of width of the beam
try:
val = int(B)#Checking whether the number is integer or not
if val > 0:#Checking whether the number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
try:
float(B)#Checking whether the number is float or not
if float(B) > 0:#Checking whether the number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
while True:
LL = input("Enter live load of beam in kN/m:")#Asking for the live load vlaue
try:
val = int(LL)#Checking the given number is integer or not
if val > 0:#Checking whether the number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
try:
float(LL)#Checking the given number is float or not
if float(LL) > 0:#Checking whether the given number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
while True:
fs = input("Enter the type of steel Fe:")#Asking for the grade of steel
try:
val = int(fs)#Checking whether the given number is integer or not
x = [250,415,500]
if val > 0:
if int(fs) in x:# Checking whether the entered number of steel exist or not
break;
else:
print('This is not a suitable number. Please enter a valid number')
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
try:
float(fs)#Checking whether the given number is float or not
x = [250, 415, 500]
if float(fs) > 0:#Checking whether the float is positive or not
if int(fs) in x:#Checking whether the entered grade of steel exist or not
break;
else:
print('This is not a suitable number. Please enter a valid number')
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
while True:
fck = input("Enter the type of concrete M:")#Asking for grade of concrete
try:
val = int(fck)#Checking for integer
if val > 0:#Checking for positive
break;
else:
print("This is not a suitable number. Please enter a valid number")
break;
except ValueError:
try:
float(fck)#Checking for float
if float(fck) > 0:#Checking whether the float is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
self_weight = (25*float(B)*float(D))/1000000#Calculative self weight of the beam
print('Self weight of beam =',self_weight,'kN/m')
Total_load = float(LL) + self_weight#Calculating total load
print('Total load = ', Total_load,'kN/m')
Factored_load = 1.5*Total_load# Calculating factored load using factor of safety 1.5
print('Factored load =', 1.5*Total_load, 'kN/m')
#Step-2: Calculate design moment and design shear
Design_moment = (Factored_load/8)*(float(S)**2)#Calculating the design moment
print('Design Moment =', Design_moment,'kNm')
Design_shear = (Factored_load*float(S))/2#Calculating the design shear
print('Design Shear force =', Design_shear,'kN')
#Step-3: Calculate limiting MOR for singly reinforced beam section
print('Effective Cover of 50 mm')
#limiting moment of resistance
d = float(D) - 50
print('Effective depth of beam, d=', d)
if float(fs) == 415:
Mu_lim = 0.138*float(fck)*(d**2)*float(B)/1000000#Calculating the limiting moment of the beam
print('Limiting Moment:',Mu_lim,'kNm')
elif float(fs) == 250:
Mu_lim = 0.148*float(fck)*(d**2)*float(B)/1000000#Calculating the limiting moment of the beam
print('Limiting Moment:',Mu_lim,'kNm')
elif float(fs) == 500:
Mu_lim = 0.133*float(fck)*(d**2)*float(B)/1000000#Calculating the limiting moment of the beam
print('Limiting Moment:',Mu_lim,'kNm')
if Mu_lim > Design_moment:#Checking whether double reinforcement required or not
print('No need of doubly reinforced beam.')
image = Image.open('image.png')#entering the image which need to be displayed
draw = ImageDraw.Draw(image)
font1 = ImageFont.truetype('arial.ttf',40)#Entering the font size and type of text design
points = 100,300# entering the coordinate where the string need to be displayed
string = ' Warning!\n No need of doubly reinforced beam.'
draw.text(points, string,'red',font=font1)
image.show()
elif Mu_lim < Design_moment:#Checking whether double reinforcement required or not
print('There is a need of doubly reinforced beam.')
#Step 4: Calculate amount of compression reinforcement required,
DMu = Design_moment - Mu_lim
Xu_lim = {250:0.53, 415:0.48, 500:0.46}
fsc1 = (0.0035*(d*Xu_lim[float(fs)] - 50)*200000)/(d*Xu_lim[float(fs)])#Calculating the compressive force in the compression zone
fsc2 = 0.87*float(fs)
if fsc1 <= fsc2:#Checking for the limiting value
fsc = fsc1
elif fsc1 > fsc2:#Checking for the limiting value
fsc =fsc2
Asc = (DMu/(fsc*(d-50)))*1000000#calculating area of steel required in compression zone
print('Area of steel required in compression:',Asc,'mm2')
while True:
#asking for the bar diameter you want to give in compression zone
dia_pro_c = input("Enter the diameter of the bar you want to provide in compression in mm:")
try:
val = int(dia_pro_c)#Checking for integer
if val > 0:#checking whether the entered number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
try:
float(dia_pro_c)#checking for float
if float(dia_pro_c) > 0:#checking whether the number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
Ast_bar_c = (3.1416/4)*(float(dia_pro_c)**2)#Calculating the area of steel to provide
N_bar_c = 2
while N_bar_c >1:
if N_bar_c*Ast_bar_c > Asc :#Checking whether the provided reinforcement is sufficient or not
M = N_bar_c
print('Required number of bars in compression is ',M)
break
else:
N_bar_c = N_bar_c +1
#Step:5 Calculate amount of tension reinforcement required
Ast2 = (fsc*Asc)/(0.87*float(fs))
Ast1 = (0.362*float(fck)*float(B)*d*Xu_lim[float(fs)])/(0.87*float(fs))
Ast = Ast1 + Ast2#calculating area of steel required in tension zone
print('Area of steel required in tension:',Ast,'mm2')
while True:
# asking for the bar diameter you want to give in tension zone
dia_pro = input("Enter the diameter of the bar you want to provide in tension:")
try:
val = int(dia_pro)#checking for integer
if val > 0:#checking whether the entered number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
try:
float(dia_pro)#checking for float
if float(dia_pro) > 0:#checking whether the entered number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
Ast_bar = (3.1416/4)*(float(dia_pro)**2)#calculating area of bar provided in tension
N_bar = 2
while N_bar >1:
if N_bar*Ast_bar > Ast :#comparing provided and required value
N = N_bar
print('Required number of bars in tension',N)
break
else:
N_bar = N_bar +1
#Step 6: Design of shear reinforcement
pt = (100*Ast)/(float(B)*d)#calculating percentage og bar provided
beta = (0.8*float(fck))/(6.89*pt)
beta1 = (math.sqrt(1+(5*beta))-1)/(6*beta)
tc = 0.85*math.sqrt(0.8*float(fck))*beta1#calculating criting shear
print('Critical shear stress as per IS:456-2000:',tc,'N/mm2')
N_shear = (Design_shear*1000)/(float(B)*d)#calculating nominal shear
print('Nominal Shear Stress:',N_shear,'N/mm2')
if N_shear < tc:#comparing to get whether shear reinforcemnet is required or not
print('Shear reinforcement is not required.')
#displaying on the image
image = Image.open('image.png')#entering the image which need to be displayed
draw = ImageDraw.Draw(image)
font1 = ImageFont.truetype('arial.ttf',30)#Entering the font size and type of text design
points = 300,50# entering the coordinate where the string need to be displayed
string = B + 'mm'
draw.text(points, string,'black',font=font1)
string1 = D + 'mm'
point1 = 530,300# entering the coordinate where the string need to be displayed
draw.text(point1,string1,'black',font=font1)
point2 = 300,190# entering the coordinate where the string need to be displayed
string2 = str(M) +' '+ 'of' +' '+ dia_pro_c +'mm'
draw.text(point2,string2,'black',font=font1)
point3 = 300,420# entering the coordinate where the string need to be displayed
string3 = str(N) +' '+ 'of' + ' '+dia_pro + 'mm'
draw.text(point3,string3,'black',font=font1)
string4 = str('No bar required')
point4 = 620,240# entering the coordinate where the string need to be displayed
draw.text(point4,string4,'black',font=font1)
image.show()
elif N_shear > tc:
print('Shear reinforcement is required.')
Shear_req = (N_shear-tc)*float(B)*d
while True:
#asking for the diameter of the bar you want to provide for shear
dia_pro_shr = input("Enter the diameter of the bar you want to provide near the supports in mm:")
try:
val = int(dia_pro_shr)#checking for integer
if val > 0:#checking whther the given number is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
try:
float(dia_pro_shr)#checking for float
if float(dia_pro_shr) > 0:#checking whether the entered float is positive or not
break;
else:
print("This is not a suitable number. Please enter a valid number")
except ValueError:
print("This is not a number. Please enter a valid number")
Ast_bar_shr = (3.1416/4)*(float(dia_pro_shr)**2)#calculating the area of bar to be provided
Sp = (0.87*float(fs)*Ast_bar_shr*float(D))/(Shear_req)
Spac = min(300, 0.75*float(D))
N_shr = 1
while N_shr >0:
if N_shr*Sp > Spac:#comparing whether the provided area is sufficient or not
P = N_shr - 1
print('Number of bars required for shear', N_shr-1)
break
else:
N_shr = N_shr +1
#displaying on the image
image = Image.open('image.png')#entering the image which need to be displayed
draw = ImageDraw.Draw(image)
font1 = ImageFont.truetype('arial.ttf',30)#Entering the font size and type of text design
points = 300,50# entering the coordinate where the string need to be displayed
string = B + 'mm'
draw.text(points, string,'black',font=font1)
string1 = D + 'mm'
point1 = 530,300# entering the coordinate where the string need to be displayed
draw.text(point1,string1,'black',font=font1)
point2 = 300,190# entering the coordinate where the string need to be displayed
string2 = str(M) +' '+ 'of' +' '+ dia_pro_c +'mm'
draw.text(point2,string2,'black',font=font1)
point3 = 300,420# entering the coordinate where the string need to be displayed
string3 = str(N) +' '+ 'of' + ' '+dia_pro + 'mm'
draw.text(point3,string3,'black',font=font1)
string4 = str(P) +' '+ 'of' + ' '+dia_pro_shr + 'mm'
point4 = 620,240# entering the coordinate where the string need to be displayed
draw.text(point4,string4,'black',font=font1)
image.show()