import math
## initialization of variables
#calculate the radial pressure and circumferential stress
E=200. ##GPa
v=0.29
Di=20. ##mm
Do=100. ##mm
a=10. ##mm
b=50. ##mm
p1=300. ##MPa
##calculations
## S_rr=p1*(a**2*(r**2-b**2))/(r**2*(b**2-a**2))
## S_th=p1*(a**2*(r**2+b**2))/(r**2*(b**2-a**2))
r=10.
S_rr=p1*(a**2.*(r**2.-b**2.))/(r**2.*(b**2.-a**2.))
S_th=p1*(a**2.*(r**2.+b**2.))/(r**2.*(b**2.-a**2.))
print'%s %.2f %s'%('r = ',r,' mm')
print'%s %.2f %s'%('\n Radial stress = ',S_rr,' MPa')
print'%s %.2f %s'%('\n circumferential stress = ',S_th,' MPa')
r=25.
S_rr=p1*(a**2.*(r**2.-b**2.))/(r**2.*(b**2.-a**2.))
S_th=p1*(a**2.*(r**2.+b**2.))/(r**2.*(b**2.-a**2.))
print'%s %.2f %s'%('r = ',r,' mm')
print'%s %.2f %s'%('\n Radial stress = ',S_rr,' MPa')
print'%s %.2f %s'%('\n circumferential stress = ',S_th,' MPa')
r=50.
S_rr=p1*(a**2.*(r**2.-b**2.))/(r**2.*(b**2.-a**2.))
S_th=p1*(a**2.*(r**2.+b**2.))/(r**2.*(b**2.-a**2.))
print'%s %.2f %s'%('r = ',r,' mm')
print'%s %.1f %s'%('\n Radial stress = ',S_rr,' MPa')
print'%s %.2f %s'%('\n circumferential stress = ',S_th,' MPa')
import math
## initialization of variables
#calculate the normal stress and radial stress and circumferentail stress
E=72. ##GPa
v=0.33
Di=200. ##mm
Do=800. ##mm
a=100. ##mm
r=a
b=Do/2. ##mm
p1=150. ##MPa
E=E*10**3.
S_rr=p1*(a**2.*(r**2.-b**2.))/(r**2.*(b**2.-a**2.))
S_th=p1*(a**2.*(r**2.+b**2.))/(r**2.*(b**2.-a**2.))
S_zz=p1*a**2./(b**2.-a**2.)
tau_max=(S_th-S_rr)/2.
u_a=p1*a/(E*(b**2-a**2))*((1-2*v)*a**2+(1+v)*b**2)
print'%s %.1f %s'%('\n Radial stress = ',S_rr,' MPa')
print'%s %.2f %s'%('\n circumferential stress = ',S_th,' MPa')
print'%s %.2f %s'%('\n Normal stress = ',S_zz,' MPa')
print'%s %.2f %s'%('\n Maximum shear stress = ',tau_max,' MPa')
print'%s %.2f %s'%('\n u|r=a = ',u_a,' mm')
import math
## initialization of variables
#calculate the how muhc temperature changes
E=200. ##GPa
a=10. ##mm
v=0.29
ci=25.072 ##mm
co=25. ##mm
b=50. ##mm
rr=0.072 ##mm
re=0.025 ##mm
alpha=0.0000117 ## per celcius
##calculations
E=E*10**3.
p1=300. ##MPa
term1=co/(E*(b**2.-co**2.))*((1.-v)*co**2.+(1.+v)*b**2.)
term2=-ci/(E*(ci**2.-a**2.))*((-(1.-v)*ci**2.)-(1.+v)*a**2.)
ps=rr/(term1+term2)
## Inner cylinder p1=0 p2=ps a=10 b=25
## outer cylinder p1=ps p2=0 a=25 b=50
## S_rr=(p1*a**2-p2*b**2)/(b**2-a**2)-(a**2*b**2)/(r**2*(b**2-a**2))*(p1-p2)
## S_th=(p1*a**2-p2*b**2)/(b**2-a**2)+(a**2*b**2)/(r**2*(b**2-a**2))*(p1-p2)
## results
## residual stresses for inner cylinder
p1=0.
p2=ps
r=10.
a=10.
b=25.
S_rri1=(p1*a**2.-p2*b**2.)/(b**2.-a**2.)-(a**2.*b**2.)/(r**2.*(b**2.-a**2.))*(p1-p2)
S_thi1=(p1*a**2.-p2*b**2.)/(b**2.-a**2.)+(a**2.*b**2.)/(r**2.*(b**2.-a**2.))*(p1-p2)
print('\n Inner cylinder')
print'%s %.2f %s'%('\n r = ',r,' mm')
print'%s %.2f %s %.2f %s '%('\n S_rr|R = ',S_rri1,' MPa'and 'S_th|R = ',S_thi1,' MPa')
r=25.
S_rri2=(p1*a**2.-p2*b**2.)/(b**2.-a**2.)-(a**2.*b**2.)/(r**2.*(b**2.-a**2.))*(p1-p2)
S_thi2=(p1*a**2.-p2*b**2.)/(b**2.-a**2.)+(a**2.*b**2.)/(r**2.*(b**2.-a**2.))*(p1-p2)
print'%s %.2f %s'%('\n r = ',r,' mm')
print'%s %.2f %s %.2f %s '%('\n S_rr|R = ',S_rri2,' MPa'and 'S_th|R = ',S_thi2,' MPa')
## residual stresses for outer cylinder
p1=ps
p2=0.
a=25.
b=50.
r=25.
S_rro1=(p1*a**2.-p2*b**2.)/(b**2.-a**2.)-(a**2.*b**2.)/(r**2.*(b**2.-a**2.))*(p1-p2)
S_tho1=(p1*a**2.-p2*b**2.)/(b**2.-a**2.)+(a**2.*b**2.)/(r**2.*(b**2.-a**2.))*(p1-p2)
print('\n Outer cylinder')
print'%s %.2f %s'%('\n r =',r,' mm')
print'%s %.2f %s %.2f %s '%('\n S_rr|R = ',S_rro1,' MPa'and ' S_th|R =',S_tho1,' MPa')
r=50.
S_rro2=(p1*a**2.-p2*b**2.)/(b**2.-a**2.)-(a**2.*b**2.)/(r**2.*(b**2.-a**2.))*(p1-p2)
S_tho2=(p1*a**2.-p2*b**2.)/(b**2.-a**2.)+(a**2.*b**2.)/(r**2.*(b**2.-a**2.))*(p1-p2)
print'%s %.2f %s'%('\n r =',r,' mm')
print'%s %.2f %s %.2f %s '%('\n S_rr|R = ',S_rro2,' MPa'and ' S_th|R =',S_tho2,' MPa')
## AN internal pressure of 300 MPa
a=10. ##mm
b=50. ##mm
p1=300. ##MPa
r=10.
S_rr=p1*(a**2.*(r**2.-b**2.))/(r**2.*(b**2.-a**2))
S_th=p1*(a**2.*(r**2.+b**2.))/(r**2.*(b**2.-a**2))
S_rr1=S_rr+S_rri1
S_th1=S_th+S_thi1
print('\n Inner cylinder')
print'%s %.2f %s'%('\n r =',r,' mm')
print'%s %.2f %s %.2f %s '%('\n S_rr|R = ',S_rr1,' MPa'and ' S_th|R =',S_th1,' MPa')
r=25.
S_rr=p1*(a**2.*(r**2.-b**2.))/(r**2.*(b**2.-a**2.))
S_th=p1*(a**2.*(r**2.+b**2.))/(r**2.*(b**2.-a**2.))
S_rr2=S_rr+S_rri2
S_th2=S_th+S_thi2
print'%s %.2f %s'%('\n r =',r,' mm')
print'%s %.2f %s %.2f %s '%('\n S_rr|R = ',S_rr2,' MPa'and ' S_th|R =',S_th2,' MPa')
## Outer Cyllinder
S_rr1=S_rr+S_rro1
S_th1=S_th+S_tho1
print('\n Outer cylinder')
print'%s %.2f %s'%('\n r = ',r,' mm')
print'%s %.2f %s %.2f %s '%('\n S_rr|R = ',S_rr1,' MPa'and ' S_th|R =',S_th1,' MPa')
r=50.
S_rr=p1*(a**2.*(r**2.-b**2.))/(r**2.*(b**2.-a**2.))
S_th=p1*(a**2.*(r**2.+b**2.))/(r**2.*(b**2.-a**2.))
S_rr2=S_rr+S_rro2
S_th2=S_th+S_tho2
print'%s %.2f %s'%('\n r =',r,' mm')
print'%s %.2f %s %.2f %s '%('\n S_rr|R = ',S_rr2,' MPa'and ' S_th|R =',S_th2,' MPa')
#delT=u/(r*alpha)
u=rr+re
r=25.
delT=u/(r*alpha)
print'%s %.2f %s'%('\n delT = ',delT,' degree Celcius')
import math
## initialization of variables
#calculate the minimum yeild stress for the steel for a factory of safety
SF=1.75
p1=300. ##MPa
S_rr=-SF*p1
S_th=SF*325.
Y=1./math.sqrt(2.)*math.sqrt((S_th-S_rr)**2.+S_rr**2.+S_th**2.)
print'%s %.2f %s'%(' Y = ',Y,'MPa')
import math
## initialization of variables
#calculate the minimum yeild stress for the steel
p1=300. ##MPa
SF=1.75
S_rr=SF*p1
S_th=SF*325.-550.2 ##Values are obtained from running Ex11_3.sce
Y1=1./math.sqrt(2)*math.sqrt((S_th-S_rr)**2+S_rr**2+S_th**2)
S_rr1=37.5
S_rre=-189.1
S_th1=62.5
S_the=315.1
## ABove values are obtained from running the codes Ex11_1 and Ex11_3.sce
S_rr=-SF*S_rr1+S_rre
S_th=SF*S_th1+S_the
Y2=1./math.sqrt(2)*math.sqrt((S_th-S_rr)**2+S_rr**2+S_th**2)
if(Y2>Y1):
Y=Y2
print'%s %.2f %s'%(' Y = ',Y,' MPa')
import math
import numpy
## initialization of variables
#calculate the fully plastic internal pressure and maximum circurmfential and axial radial stress
SF=1.8
a=20. ##mm
b=40. ##mm
Y=450. ##MPa
##part (a)
tau_Y=Y/math.sqrt(3)
Pp=2.*tau_Y*math.log(b/a)
S_th=2.*tau_Y*(1-math.log(b/a))
S_rr=-Pp
S_zz=(S_th+S_rr)/2.
print('part (a)')
print'%s %.2f %s'%('\n S_th = ',S_th,' MPa')
print'%s %.2f %s'%('\n S_zz = ',S_zz,' MPa')
## part (b)
S_thR=S_th-Pp*(b**2.+a**2.)/(b**2.-a**2.)
S_zzR=S_zz-Pp*(a**2.)/(b**2.-a**2.)
S_thR=S_thR/2.
S_zzR=S_zzR/2.
print('\n part (b)')
print'%s %.2f %s'%('\n S_th|R = ',S_thR,' MPa')
print'%s %.2f %s'%('\n S_zz|R = ',S_zzR,' MPa')
## par (c)
## We need to find out p1. To do that let it be unity
p1=1.
S_thR=-S_thR
S_zzR=-S_zzR
S_rr=-SF*p1
S_th=SF*p1*(b**2.+a**2.)/(b**2.-a**2.)
S_zz=SF*p1*a**2./(b**2.-a**2.)
## 2Y**2=(s_th-S_rr)**2+(S_rr-S_zz)**2+(S_zz-S_th)**2
## S_th=S_th*p1-S_thR
## S_zz=S_zz*p1-S_zzR
## a*p1**2+b*p+c=0
a=(S_th+SF)**2.+(-SF-S_zz)**2.+(S_zz-S_th)**2.
c=S_thR**2+S_zzR**2.+(S_thR-S_zzR)**2.
b=-2.*(S_th+SF)*S_thR+2.*S_zzR*(-SF-S_zz)+2.*(S_zz-S_th)*(S_thR-S_zzR)
c=c-2.*Y**2.
p11=numpy.roots([a, b ,c])
p12=numpy.roots([a ,0 ,-2*Y**2])
p11=p11[0]
p12=p12[0]
print'%s %.2f %s'%('\n Internal working pressure is ',p11,' MPa,')
print'%s %.2f %s'%('\n Without residual stresses ',p12,' MPa')
import math
## initialization of variables
#calculate the angular velocity
a=100. ##mm
b=300. ##mm
Y=620. ##MPa
E=200. ##GPa
S_zz=0.
v=0.29
rho=7.85e+03 ##kg/m**3
## part (a)
S_thmax=Y
Wy=math.sqrt(4.*Y/(rho*((3.+v)*b**2.+(1.-v)*a**2.)))
print('part (a)')
print'%s %.2f %s'%('\n Omega_y =',Wy*10**6,' rad/s')
## part (b)
Wp=math.sqrt(3.*Y/(rho*(b**2.+a*b+a**2.)))
ratio=Wp/Wy
print'%s %.2f %s'%('\n Omega_p = ',Wp*10**6,' rad/s')
print'%s %.2f %s'%('\n ratio =',ratio,'')
import math
## initialization of variables
#calculate the residual stress
a=100. ##mm
b=300. ##mm
v=0.29
a=a*10**-3
b=b*10**-3
print('r S_rr|R/Y S_th|R/Y (S_th/R-S_rr/R)/Y')
for i in range(1,21):
r=0.09+0.01*i
S_rrR=((r-a)/r - 3./(b**2.+a*b+a**2)*((r**3.-a**3.)/(3.*r) + (3.+v)/8.*(a**2.+b**2.-r**2-a**2.*b**2./r**2.)))
S_thR=(1.- 3./(8.*(b**2.+a*b+a**2.)) * ((3.+v)*(a**2+b**2+a**2*b**2./r**2.) - (1.+3.*v)*r**2.))
print'%s %.2f %s %.2f %s %.2f %s %.2f %s '%('',r,''and '',S_rrR,''and '',S_thR,''and '',S_rrR-S_thR,'')