#calculate values of R at A,B,C
##initialization of variables
import math
##case (a)
A=72.9 ##cm^2
Iy=633 ##cm^4
Ix=1199. ##cm^4
t=24./(5.*Ix)+13.5/(5.*Iy)
r=1/(A*t)
print'%s %.2f %s'%('case (a) \n r = ',r,' cm')
## case (b)
t=24./(5.*Ix)-13.5/(5.*Iy)
r=1/(A*t)
print'%s %.2f %s'%('\n case (b) \n r = ',r,' cm')
##case (c)
t=-24./(5.*Ix)+13.5/(5.*Iy)
r=1./(A*t)
print'%s %.2f %s'%('\n case (a) \n r =',r,' cm')
print'%s %.2f %s'%('\n So the load is to be placed on the leg OD, at a distance of ',r,' cm from O' )
#calculate steel height and Width
##initialization of variables
import math
b=14. ##cm
d=20. ##cm
rx=8.46 ##cm
ry=2.99 ##cm
## calculations
ex=2.*rx**2/d
ey=2*ry**2/b
h=2*ex
w=2*ey
## results
print'%s %.2f %s %.2f %s '%('for steel height=',h,' cm and width=',w,' cm')
## ISHB 225
b=22.5 ##cm
d=22.5 ##cm
rx=9.8 ##cm
ry=4.96 ##cm
## calculations
ex=2*rx**2/d
ey=2*ry**2/b
h=2*ex
w=2*ey
## results
print'%s %.2f %s %.2f %s '%('\n for an ISHB height=',h,' cm and width=',w,' cm')
#calculate Safe load
##initialization of variables
import math
t=280. ##kg/cm^2
c=840. ##kg/cm^2
xbar=7.5 ##cm from AB
A=210. ##cm^2
## calculations
e=50.+xbar ##cm
Iyy=7433. ##cm^2
k=(1./210.+e*xbar/Iyy)
P=t/k
k1=(-1./210.+e*(xbar+5.)/Iyy)
P1=c/k1
P_safe=min(P1,P)
## results
print'%s %.2f %s'%('The safe load is ',P_safe,' kg')
#calcualte compression and tension
##initialization of the variables
import math
s=1.6 ##m
s1=4. ##m
pi=28. ##degrees
w=16. ##kg/m^2
p=100. ##kg/m^2
pl=20. ##cm
pb=10. ##cm
r=500. ##kg/m^3
## calculations
pi=pi*math.pi/180 ##radians
W=w*s+(r*pl*pb/(100.*100.))
P=p*s
L=P+W*math.cos(pi)
Mx=L*s1**2*100./8.
sigma_1=Mx*6./(pb*pl**2)
My=W*math.sin(pi)*s1**2*100./8.
sigma_2=My*6./(pl*pb**2)
sigma1=sigma_1+sigma_2
## results
print'%s %.2f %s %.2f %s '%('Due to bending in the noth the planes, D experiences maximum \n compression of ',sigma1,' kg/cm^2 and B has maximum tension of ',sigma1,' kg/cm^2')
#calculate maximum stresses
##initialization of the problems
import math
s=1.6 ##m
s1=4. ##m
pi=28. ##degrees
w=16. ##kg/m^2
p=100. ##kg/m^2
pl=20. ##cm
pb=10. ##cm
r=500. ##kg/m^3
Zx=54.8 ##cm^3
Zy=3.9 ##cm^3
## calculations
pi=pi*math.pi/180. ##radians
W=w*s+8.1
P=p*s
L=P+W*math.cos(pi)
Mx=L*s1**2*100./8.
sigma_1=Mx/Zx
My=W*math.sin(pi)*s1**2*100./8.
sigma_2=My/Zy
sigma=sigma_1+sigma_2
## results
print'%s %.2f %s'%('Maximum stresses are ',sigma,' kg/cm^2, tension or compression')
#calculate strain gauge
##initialization of variables
import math
s=1.6 ##m
s1=4. ##m
pi=28. ##degrees
w=16. ##kg/m^2
p=100. ##kg/m^2
pl=20. ##cm
pb=10. ##cm
r=500. ##kg/m^3
sg=5. ##cm
E=12*10**4
pi=pi*math.pi/180 ##radians
## calculations
W=w*s+(r*pl*pb/(100.*100.))
P=p*s
L=P+W*math.cos(pi)
Mx=L*s1**2*100/8.
sigma_1=Mx*6./(pb*pl**2)
My=W*math.sin(pi)*s1**2*100/8.
sigma_2=My*6./(pl*pb**2)
st=sigma_1*sg/10.
Ts=st-sigma_2
ez=Ts/E
## results
print'%s %.2e %s'%('The strain gauge, aligned to the z axis will give compression strain of ',ez,'')
#calcualte bending stress and shearing stress
##initialization of variables
import math
P=3. ##tonne/m
s=6. ##m
l=50. ##cm
b=20. ##cm
k=0.5 ##m
##calculations
R=P*s/2.
sf=R-k*P
bm=R*k-P*k**2/2.
tau_xy=1.5*sf*1000./(l*b)
tau_max=tau_xy
str=bm*s*10**5/(b*l*l)
## consider the line a-a
sigma_x=str*12.5/25.
sigma_y=0.
tau_xy=tau_xy*(1.-(12.5/25.)**2)
sigma_1=(sigma_x+sigma_y)/2.+math.sqrt((1/2*(sigma_x-sigma_y))**2+tau_xy**2)
sigma_2=(sigma_x+sigma_y)/2.-math.sqrt((1/2*(sigma_x-sigma_y))**2+tau_xy**2)
print'%s %.2f %s %.2f %s '%('For the line a-a the bending stress and shearing stress are \n respectively ',sigma_x,' kg/cm^2'and'',tau_xy,'kg/cm^2 ')
print'%s %.2f %s %.2f %s '%('\n The principal stresses are ',sigma_1,' kg/cm^2 (tension)' and '',sigma_2,'kg/cm^2 (compression) ')
##consider the line c-c
print'%s %.2f %s %.2f %s '%('\n For the line c-c the bending stress and shearing stress are \n respectively ',sigma_x,' kg/cm^2'and '',tau_xy,' kg/cm^2 ')
print'%s %.2f %s %.2f %s '%('\n The principal stresses are ',sigma_2,' kg/cm^2 (compression)'and '',sigma_1,' kg/cm^2 (tension) ')
##for the line b-b
tau_xy=tau_max
sigma_x=0.
sigma_y=0.
sigma_1=(sigma_x+sigma_y)/2.+math.sqrt((1./2.*(sigma_x-sigma_y))**2+tau_xy**2)
sigma_2=(sigma_x+sigma_y)/2.-math.sqrt((1./2.*(sigma_x-sigma_y))**2+tau_xy**2)
## results
print'%s %.7f %s %.2f %s '%('\n For the line b-b the bending stress and shearing stress are \n respectively ',sigma_x,' kg/cm^2'and '',tau_xy,' kg/cm^2 ')
print'%s %.2f %s %.2f %s '%('\n The principal stresses are ',sigma_1,' kg/cm^2 (tension)'and'',sigma_2,' kg/cm^2 (compression) ')
#calculate tension and principal stress
##initialization of variables
import math
P=3. ##tonne/m
s=6. ##m
l=50. ##cm
b=20. ##cm
k=0.5 ##m
##calculations
R=P*s/2.
sf=R-k*P
bm=R*k-P*k**2/2.
tau_xy=1.5*sf*1000./(l*b) ##max shear stress
tau_max=tau_xy
str=bm*s*10**5/(b*l*l) ##max bending stress
## consider the line a-a
sigma_x=str*12.5/25.
sigma_y=0.
tau_xy=tau_xy*(1.-(12.5/25.)**2)
sigma_1=(sigma_x+sigma_y)/2.+math.sqrt((1/2.*(sigma_x-sigma_y))**2+tau_xy**2)
sigma_2=(sigma_x+sigma_y)/2-math.sqrt((1/2.*(sigma_x-sigma_y))**2+tau_xy**2)
theta=1/2.*math.atan(2.*tau_xy/(sigma_x-sigma_y))*57.3
sigma_p=sigma_1/math.cos(theta)
P=sigma_p*2.*l*b/(3.*1000.)
print'%s %.2f %s'%('A prestressing force of ',P,' Tonne must be applied to balance the tension at a-a')
##At bottom point D or C
pre_str=P*2.*1000./(l*b)
net=str-pre_str
print('\n At bottom point D or C')
print'%s %.2f %s'%('\n Net tension = ',net,' kg/cm^2 ')
##consider the line b-b
pre_str=P
sigma_x=pre_str
sigma_y=0.
tau_xy=tau_max
sigma_1=(sigma_x+sigma_y)/2.+math.sqrt((1./2.*(sigma_x-sigma_y))**2+tau_xy**2)
sigma_2=(sigma_x+sigma_y)/2.-math.sqrt((1./2.*(sigma_x-sigma_y))**2+tau_xy**2)
print('\n At section b-b')
print'%s %.2f %s '%('\n pre-stress=',pre_str,' kg/cm^2')
print'%s %.2f %s %.2f %s '%('\n principal stresses are ',sigma_1,''and'',sigma_2,' kg/cm^2 ')
##for the line c-c
sigma_x=str*12.5/25.
sigma_y=0.
tau_xy=tau_xy*(1-(12.5/25.)**2)
sigma_1=(sigma_x+sigma_y)/2.+math.sqrt((1./2.*(sigma_x-sigma_y))**2+tau_xy**2)
sigma_2=(sigma_x+sigma_y)/2.-math.sqrt((1./2.*(sigma_x-sigma_y))**2+tau_xy**2)
pre_str=pre_str/2.
net=sigma_1+pre_str
sigma_x=net
sigma_y=0.
sigma_1=(sigma_x+sigma_y)/2.+math.sqrt((1./2.*(sigma_x-sigma_y))**2+tau_xy**2)
sigma_2=(sigma_x+sigma_y)/2.-math.sqrt((1./2.*(sigma_x-sigma_y))**2+tau_xy**2)
## results
print('\n At section c-c')
print'%s %.2f %s'%('\n the direct stress is ',net,' kg/cm^2')
print'%s %.2f %s'%('\n pre-stress =',pre_str,' kg/cm^2')
print'%s %.2f %s %.2f %s '%('\n principal stresses are',sigma_1,'kg/cm^2'and '',sigma_2,'kg/cm^2')
print('wrong calculations in the thext for some parts')
#calculate sigma and Tau
##initialization of variables
import math
b=2. ##cm
h=2. ##cm
T=2000. ##kg-cm
V=250. ##kg
M=2000. ##kg-cm
## calculations
Mmax=M*6./(b*h*b)
Vmax=3.*V/(2.*b*h)
Zt=0.208*b**2*h
Tmax=T/(Zt)
sigma=Mmax
print('points A,B,')
print'%s %.2f %s'%('\n sigma=',sigma,' kg/cm^2 (tension)')
print('\n points C,D,')
print'%s %.2f %s'%('\n sigma=',sigma,' kg/cm^2 (cmpression)')
tau=Vmax+Tmax
print('\n point E')
print'%s %.2f %s'%('\n tau=',tau,'kg/cm^2 shear')
tau=Vmax-Tmax
print'%s %.2f %s'%('\n tau=',tau,' kg/cm^2 shear')
## at G
sigma_x=sigma
sigma_y=0.
tau_xy=Tmax
sigma_1=(sigma_x+sigma_y)/2.+math.sqrt((1./2.*(sigma_x-sigma_y))**2+tau_xy**2)
sigma_2=(sigma_x+sigma_y)/2.-math.sqrt((1./2.*(sigma_x-sigma_y))**2+tau_xy**2)
## results
print('\n at point G')
print'%s %.2f %s'%('\n sigma_1 = ',sigma_1,' kg/cm^2 (tension)')
print'%s %.2f %s'%('\n sigma_2 = ',sigma_2,' kg/cm^2 (compression)')
print('Question was asked only to find out at A,B,C,D,E,F and G')
print(' And in book Ans worng')
#calculate total shear and bending stress and principal stress
##initialization of variables
import math
w=10. ##cm
s=2.8 ##m
P=1. ##tonne
Ft=1.4 ##cm
Wt=0.8 ##cm
Ix=13989.5 ##cm^4
Z=699.5 ##cm^3
## calculations
BM= 2.8
T=P*1000*8.21
SF=P*1000.
BS=BM*10**5/(Z)
sigmaXA=BS*18.6/20.
K=w*Ft*19.3+18.6*Wt*9.3
tau_xy_C=SF/(Ix*Wt)*K
tau_xy_A=tau_xy_C*(w*Ft*19.3)/K
tau_xy_B=tau_xy_A*0.5*Wt/w
sigmaXB=sigmaXA*19.3/20.
tau_max=3*Ft*8210./(w*Ft**3+37.2*Wt**3)
tau_A=3*Wt*8210./(w*Ft**3+37.2*Wt**3)
##For point A
Shear=tau_xy_A-tau_A
sigma_x=sigmaXA
sigma_y=0.
tau_xy=Shear
sigma_1=(sigma_x+sigma_y)/2.+math.sqrt((1./2.*(sigma_x-sigma_y))**2+tau_xy**2)
sigma_2=(sigma_x+sigma_y)/2.-math.sqrt((1./2.*(sigma_x-sigma_y))**2+tau_xy**2)
print('For point A')
print'%s %.2f %s'%('\n Total shear= ',Shear,' kg/cm^2 ')
print'%s %.2f %s'%('\n Bending stress = ',sigma_x,' kg/cm^2 (Compr.)')
print'%s %.2f %s %.2f %s '%('\n Principal stresses are ',sigma_1,'(tension)kg/cm^2 'and'' ,sigma_2,'(comp.) kg/cm^2 ')
##For point B
print('\n FOr point B')
print'%s %.2f %s'%('\n Bending shear stress is ',tau_xy_B,' k/cm^2')
sigmaXB=BS*19.3/20.
sigma_x=sigmaXB
sigma_y=0.
tau_xy=tau_max
sigma_1=(sigma_x+sigma_y)/2.+math.sqrt((1./2.*(sigma_x-sigma_y))**2+tau_xy**2)
sigma_2=(sigma_x+sigma_y)/2.-math.sqrt((1./2.*(sigma_x-sigma_y))**2+tau_xy**2)
print'%s %.2f %s %.2f %s '%('\n Principal stresses are ',sigma_1,' (tension) kg/cm^2'and'',sigma_2,' (comp.) kg/cm^2 ')
print('Answers in the text are approximations')
#calcualte permissible stress and developed stress
##initialization of variables
import math
b=10. ##cm
h=10. ##cm
P=5. ##tonne
e=1. ##cm
E=12*10**4 ##kg/cm^2
str=130. ## kg/cm^2
n=3.
L=2. ##m
## calculations
L=L*100. ##cm
Pcr=math.pi**2*E*b*h**3/(12.*L**2.)
Pcr=Pcr/1000.
Smax=-P*1000./(b*h)-(P*1000.*1.*5.*12./10**4)*1./(1.-(n*P/Pcr))
## results
print'%s %.2f %s'%('permissible stress = ',str,' kg/cm^2')
print'%s %.2f %s'%('\n develoed stress = ',Smax,' kg/cm^2')
print('\n Since it is below the permissible stress, the design is safe')
import math
##initializatio of variables
#calculate Smax and percentage error
## linked to 9.13
b=10. ##cm
h=10. ##cm
P=5. ##tonne
e=1. ##cm
E=12.*10**4 ##kg/cm^2
str=130. ## kg/cm^2
n=3.
L=2. ##m
## calculations
L=L*100. ##cm
Pcr=math.pi**2*E*b*h**3/(12*L**2)
Pcr=Pcr/1000.
Smax=-P*1000./(b*h)-(P*1000.*1.*5.*12./10**4)*1./(1.-(n*P/Pcr))
Smax=abs(Smax)
rr=b*h**3/(12.*100.)
Smax_se=P*1000./(b*h)*(1+e*5/rr*(1./math.cos(math.pi/2.*math.sqrt(n*P/Pcr))))
Perror=(Smax-Smax_se)/Smax
Perror=Perror*100.
Perror=abs(Perror)
## results
print'%s %.2f %s'%('Using secent formula, stress obtained is ',Smax_se,' kg/cm^2')
print'%s %.2f %s'%('\n hence, the percentage error ',Perror,'')
## approximate answees in the text
import math
##initialization of variables
#calculate maximum stress developed
P=400. ##kg/m
L=10. ##m
F=10. ##tonne
n=3.
Ixx=5943.1 ##cm^4
A=52.03 ##cm^2
rx=10.69 ##cm
E=2*10**6 ##kg/cm^2
## calculations
Pcr=math.pi**2*E*Ixx/((L*100.)**2.)
Pcr=Pcr/1000.
e=P*L**2/(8*F*1000.)
g=e*12.5*100./rx**2
Smax=F*1000./A*(1.+g*1./(1-n*(F/Pcr)))
## results
print'%s %.2f %s'%('The maximum stress developed is ',Smax,' kg/cm^2')
print('approximate calculations involved in the text book')
#calculate maximum stress developed
##initialization of variables
import math
## linked to 9_14
## calculations
P=400. ##kg/m
L=10. ##m
F=10. ##tonne
n=3.
Ixx=5943.1 ##cm^4
A=52.03 ##cm^2
rx=10.69 ##cm
E=2*10**6 ##kg/cm^2
Pcr=math.pi**2.*E*Ixx/((L*100.)**2)
Pcr=Pcr/1000.
e=P*L**2./(8.*F*1000.)
g=e*12.5*100./rx**2.
Smax=F*1000./A*(1+g*1./(1.+n*(F/Pcr)))
## results
print'%s %.2f %s'%('The maximum stress developed is ',Smax,' kg/cm^2')
print('approximate answer in the text')