import math
print('MACHINE DESIGN \n Timothy H. Wentzell, P.E. \n EXAMPLE-7.1 Page No.137\n');
D=2.; ##[in] Diameter of bar
W=500.; ##[lb] Weight
h=1.; ##[in] Height from which the weight falls
A=math.pi*D**2/4.; ##[in^2] Area of cross section of bar
L=10.; ##[in] Length of bar
E=30*10**6; ##[lb/in^2] Modulus of elasticity
S=(W/A)+(W/A)*(1.+(2.*h*E*A/(L*W)))**(0.5); ##[lb/in^2] Stress in the bar
print'%s %.2f %s '%('\n Stress in the bar is ',S,' lb/in^2.');
Delta=S*L/E; ##[in] Deflection
print'%s %.2f %s '%('\n Deflecton in the bar is ',Delta,' in.');
import math
print('MACHINE DESIGN \n Timothy H. Wentzell, P.E. \n EXAMPLE-7.2 Page No.139\n');
W=2000.; ##[lb] Weight of automobile
L=36.; ##[in] Length of stop
D=2.; ##[in] Diameter of steel bar
V=5.*5280.*12./3600.; ##[in/s] Velocity of automobile
A=math.pi*D**2/4.; ##[in^2] Area of cross section of bar
E=30.*10**6; ##[lb/in^2] Modulus of elasticity
k=A*E/L; ##[lb/in] Stiffness of the bar
g=386.; ##[in/s^2] Acceleration due to gravity
Delta=math.sqrt(2./k*W*(V**2./(2.*g)+0.)); ##[in] Deflection
print'%s %.2f %s '%('\n The deflection in the bar is ',Delta,' in.');
S=Delta*E/L; ##[in] Stress in the bar
##Note-In the book Delta=0.124 is used instead of Delta=0.123800
print'%s %.2f %s '%('\n The stress in the bar is ',S,' lb/in^2.');
import math
print('MACHINE DESIGN \n Timothy H. Wentzell, P.E. \n EXAMPLE-7.3 Page No.141\n');
W=3000.; ##[lb] Weight of automobile
L=40*12; ##[in] Length of the beam
I=64.2; ##[in^4] Moment of inertia of the beam
Sy=48000.; ##[lb/in^2] Yield strength of the beam
c=8/2.; ##[in] Distance from the outermost fiber to neutral axis
E=30.*10**6; ##[lb/in^2] Modulus of elasticity
g=32.2; ##[ft/s^2] Acceleration due to gravity
M=I*Sy/c; ##[lb*in] Moment at which beam will yield
F=4.*M/L; ##[lb] Force at which beam will yield
Delta=F*L**3/(48.*E*I); ##[in] Deflection
KE=F*Delta/2.; ##[lb*in] Kinetic energy
V=math.sqrt(2.*g*KE/W); ##[in/s] Velocity
V=V/5280.*3600.; ##[miles/hr] Velocity
print'%s %.2f %s '%('\n At ',V,' miles/hr velocity the beam will yield.');
import math
import numpy
print('MACHINE DESIGN \n Timothy H. Wentzell, P.E. \n EXAMPLE-7.4 Page No.143\n');
D=3/4.; ##[in] Diameter of the bolt
At=0.334; ##[in^2] Area of thread
As=math.pi*D**2/4.; ##[in^2] Area of shank
##Note-In the book As=0.442 in^2 is used instead of As=0.4417865 in.
E=30*10**6; ##[lb/in^2] Modulus of elasticity
Lt=2.; ##[in] Length of the thread
Ls=6.; ##[in] Length of the shank
h=0.03; ##[in] Height from which the weight falls
W=500.; ##[lb] Falling load
Kt=At*E/Lt; ##[lb/in] Stiffness of threaded portion
Ks=As*E/Ls; ##[lb/in] Stiffness of shank
K=Kt*Ks/(Kt+Ks); ##[lb/in] Overall stiffness
Delta=(W/K)+(W/K)*math.sqrt(1.+2.*h*K/W); ##[in] Deflection
A=numpy.matrix([[Ls/E, Lt/E], [0.442, -0.334]]);
b=numpy.matrix([[Delta] ,[0]]);
S=A/b
Ln=8.; ##[in] Length when shank has same area as threads
Kn=At*E/Ln; ##[lb/in] Stiffness
Deltan=(W/Kn)+(W/Kn)*math.sqrt(1.+2.*h*Kn/W); ##[in] Deflection
S=Deltan*E/Ln; ##[ln/in^2] Stress
print'%s %.2f %s %.2f %s '%('\n If shank has the same area as threads then stress is ',S,' lb/in^2 and deflection is ',Deltan,' in.');