import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
P_e=300 #N/mm**2 #Elastic Limit in tension
FOS=3 #Factor of safety
mu=0.3 #Poissoin's ratio
P=12*10**3 #N Pull
Q=6*10**3 #N #Shear force
#Calculations
#Let d be the diameter of the shaft
#Direct stress
#P_x=P*(pi*4**-1*d**3)**-1
#After substituting values and further simplifying we get
#P_x=48*10**3
#Now shear stress at the centre of bolt
#q=4*3**-1*q_av
#After substituting values and further simplifying we get
#q=32*10**3*(pi*d**2)**-1
#Principal stresses are
#P1=P_x*2**-1+((P_x*2**-1)**2+q**2)**0.5
#After substituting values and further simplifying we get
#p1=20371.833*(d**2)**-1
#P2=P_x*2**-1-((P_x*2**-1)**2+q**2)**0.5
#After substituting values and further simplifying we get
#P2=-5092.984*(d**2)**-1
#q_max=((P_x*2**-1)**2+q**2)**0.5
#From Max Principal stress theory
#Permissible stress in Tension
P1=100 #N/mm**2
d=(20371.833*P1**-1)**0.5
#Max strain theory
#e_max=P1*E**-1-mu*P2*E**-1
#After substituting values and further simplifying we get
#e_max=21899.728*(d**2*E)**-1
#According to this theory,the design condition is
#e_max=P_e*(E*FOS)**-1
#After substituting values and further simplifying we get
d2=(21899.728*3*300**-1)**0.5 #mm
#Max shear stress theory
#e_max=shear stress at elastic*(FOS)**-1
#After substituting values and further simplifying we get
d3=(12732.421*6*300**-1)**0.5 #mm
#Result
print"Diameter of Bolt by:Max Principal stress theory",round(d,2),"mm"
print" :Max strain theory",round(d2,2),"mm"
print" :Max shear stress theory",round(d3,2),"mm"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
M=40*10**6 #N-mm #Bending moment
T=10*10**6 #N-mm #TOrque
mu=0.25 #Poissoin's ratio
P_e=200 #N/mm**2 #Stress at Elastic Limit
FOS=2
#Calculations
#Let d be the diameter of the shaft
#Principal stresses are given by
#P1=16*(pi*d**3)**-1*(M+(M**2+T**2)**0.5)
#After substituting values and further simplifying we get
#P1=4.13706*10**8*(d**3)**-1 ............................(1)
#P2=16*(pi*d**3)**-1*(M-(M**2+T**2)**0.5)
#After substituting values and further simplifying we get
#P2=-6269718*(pi*d**3)**-1 ..............................(2)
#q_max=(P1-P2)*2**-1
#After substituting values and further simplifying we get
#q_max=2.09988*10**8*(d**3)**-1
#Max Principal stress theory
#P1=P_e*(FOS)**-1
#After substituting values and further simplifying we get
d=(4.13706*10**8*2*200**-1)**0.33333 #mm
#Max shear stress theory
#q_max=shear stress at elastic limit*(FOS)**-1
#After substituting values and further simplifying we get
d2=(2.09988*10**8*4*200**-1)**0.33333
#Max strain energy theory
#P_3=0
#P1**2+P2**2-2*mu*P1*P2=P_e**2*(FOS)**-1
#After substituting values and further simplifying we get
d3=(8.62444*10**12)**0.166666
#Result
print"Diameter of shaft according to:MAx Principal stress theory",round(d,2),"mm"
print" :Max shear stress theory",round(d2,2),"mm"
print" :Max strain energy theory",round(d3,2),"mm"
import math
from math import sin, cos, tan, pi, radians
#Initilization of Variables
f_x=40 #N/mm**2 #Internal Fliud Pressure
d1=200 #mm #Internal Diameter
r1=d1*2**-1 #mm #Radius
q=300 #N/mm**2 #Tensile stress
#Calculations
#From Lame's Equation we have,
#Hoop Stress
#f_x=b*(x**2)**-1+a ..........................(1)
#Radial Pressure
#p_x=b*(x**2)**-1-a .........................(2)
#the boundary conditions are
x=d1*2**-1 #mm
#After sub values in equation 1 and further simplifying we get
#40=b*100**-1-a ..........................(3)
#Max Principal stress theory
#q*(FOS)**-1=b*100**2+a ..................(4)
#After sub values in above equation and further simplifying we get
#From Equation 3 and 4 we get
a=80*2**-1
#Sub value of a in equation 3 we get
b=(f_x+a)*100**2
#At outer edge where x=r_0 pressure is zero
r_0=(b*a**-1)**0.5 #mm
#thickness
t=r_0-r1 #mm
#Max shear stress theory
P1=b*(100**2)**-1+a #Max hoop stress
P2=-40 #pressure at int radius (since P2 is compressive)
#Max shear stress
q_max=(P1-P2)*2**-1
#According max shear theory the design condition is
#q_max=P_e*2**-1*(FOS)**-1
#After sub values in equation we get and further simplifying we get
#80=b*(100**2)**-1+a
#After sub values in equation 1 and 3 and further simplifying we get
b2=120*100**2*2**-1
#from equation(3)
a2=120*2**-1-a
#At outer radius r_0,radial pressure=0
r_02=(b2*a2**-1)**0.5
#thickness
t2=r_02-r1
#Result
print"Thickness of metal by:Max Principal stress theory",round(t,2),"mm"
print" :Max shear stress thoery",round(t2,2),"mm"