import math
print('MACHINE DESIGN \n Timothy H. Wentzell, P.E. \n EXAMPLE-17.1 Page No.379\n');
hp=5.;
n=1750.;
T=63000.*hp/n;
##Torsional stress in the shaft
D=0.75;
Z1=math.pi*D**3/16.;
Ss=T/Z1;
print'%s %.2f %s '%('\n Torsional stress in the shaft = ',Ss,' lb/in^2.');
##Load at the gear pitch circle
Nt=40.;
Pd=10.;
Dp=Nt/Pd;
Ft=2.*T/Dp;
print'%s %.2f %s '%('\n Load at gear pitch circle = ',Ft,' lb.');
##Resultant force on the shaft
theta=20.*math.pi/180.;
Fr=Ft/math.cos(theta);
print'%s %.2f %s '%('\n Resultant force = ',Fr,' lb.');
##Maximum moment
L=15.;
Mm=Fr*L/4.;
print'%s %.2f %s '%('\n Maximum moment = ',Mm,' in-lb.');
##Stress
D2=0.75;
Z2=math.pi*D2**3/32.;
Z2=round(Z2*1000.)*10**-3;
S=Mm/Z2;
print'%s %.2f %s '%('\n Stress = ',S,' lb/in^2.');
##Note-There is an error in the answer given in textbook
import math
print('MACHINE DESIGN \n Timothy H. Wentzell, P.E. \n EXAMPLE-17.2 Page No.383\n');
##Combined stress using the maximum shear stress theorem
Ss=2170.;
S=8780.;
Sr=math.sqrt(Ss**2+(S/2.)**2);
print'%s %.2f %s '%('\n Combined stress = ',Sr,' lb/in^2.');
import math
print('MACHINE DESIGN \n Timothy H. Wentzell, P.E. \n EXAMPLE-17.3 Page No.383\n');
##Combined stress using the maximum normal stress theory
Ss=2170.;
S=8780.;
Sr=S/2.+math.sqrt(Ss**2+(S/2.)**2);
print'%s %.2f %s '%('\n Combined stress = ',Sr,' lb/in^2.');
##Note-There is an error in the answer given in textbook
import math
print('MACHINE DESIGN \n Timothy H. Wentzell, P.E. \n EXAMPLE-17.4 Page No.385\n');
##Modifying factors for Sn
Su=88000.;
Csize=0.85;
Csurface=0.88;
Ctype=1.;
Sn=Csize*Csurface*Ctype*(0.5*Su);
Kt=2.3;
S=9300.;
N=Sn/(Kt*S);
if N>2:
print('\n It would be an acceptable design.');
else:
print('\n N<2,So this is not a suitable design for long term use.');
import math
print('MACHINE DESIGN \n Timothy H. Wentzell, P.E. \n EXAMPLE-17.5 Page No.388\n');
import numpy
##Deflection
D=0.75;
E=30.*10**6;
L=15.;
F=96.;
I=math.pi*D**4/64.;
delta=F*L**4/(48.*E*I);
delta=numpy.floor(100.*delta)*10**-2;
Nc=188./math.sqrt(delta);
print'%s %.2f %s '%('\n Critical speed = ',Nc,' rpm.');