from __future__ import division
import math
#Given
#Variable declaration
P=9*1000 #Axial pull in N
F=4.5*1000 #Shear force in N
sigmat_star=225 #Elastic limit in tension in N/sq.mm
Sf=3 #Factor of safety
mu=0.3 #Poisson's ratio
sigma3=0 #third principle stress
#Calculation
sigmat=sigmat_star/Sf
sigma=(P/(math.pi/4))
tau=float(str(F/(math.pi/4))[:6])
sigma1=float(str((tau)+int(round(math.sqrt((sigma/2)**2+tau**2),0)))[:7])
sigma2=float(str((tau)-int(round(math.sqrt((sigma/2)**2+tau**2),0)))[:8])
d=round(((((sigma1-sigma2)**2+(sigma2-sigma3)**2+(sigma3-sigma1)**2)/(2*(sigmat**2)))**(1/4)),3)
#Result
print"Diameter of the bolt =",d,"mm"
from __future__ import division
import math
#Given
#Variable declaration
d=1.2 #Diameter in m
p=1.5 #Internal pressure in MN/sq.m
sigmat_star=200 #Yield stress in MN/sq.m
Sf=3 #Factor of safety
#Calculation
sigmat=sigmat_star/Sf #Permissible stress in simple tension in MN/sq.m
#case(i):Thickness on the basis of Maximum principal stress theory
t1=((p*d)/2)/sigmat*1e3
#case(ii):Thickness on the basis of Maximum shear stress theory
t2=((p*d)/2)/sigmat*1e3
#case(iii):Thickness on the basis of Maximum shear strain energy theory
t3=round(math.sqrt((((p*d/2)**2)+((p*d/4)**2)-((p*d/2)*(p*d/4)))/(sigmat**2)),4)
#Result
print "Thickness of plate on the basis of maximum principal stress theory =","%.1fmm"%t1
print "Thickness of plate on the basis of maximum shear stress theory =","%.1fmm"%t2
print "Thickness of plate on the basis of maximum shear strain energy theory =","%.4fmm"%t3