import math
#Variable Decleration
P=20*10**3 #Power in W
f=2 #Frequency in Hz
t_max=40*10**6 #Maximum shear stress in Pa
G=83*10**9 #Bulk modulus in Pa
theta=(6*pi)/180 #Angle of twist in radians
L=3 #Length in m
#Calculations
#Strength condition
T=P/(2*pi*f) #Torque in N.m
d1=((16*T)/(pi*t_max))**0.333 #Max allowable diameter in mm
#Applying torque-twist relationship
d2=((32*T*L)/(G*theta*pi))**0.25 #Diameter in mm
d=max(d1,d2)
print "To satisfy both strength and rigidity conditions d=",round(d*1000,1),"mm"
#NOTE:The fractional power leads to the discrepancy in the answer
import math
#Variable Decleration
Ga=4*10**6 #Bulk modulus of Aluminium in psi
Gs=12*10**6 #Bulk Modulus of Steel in psi
T=10**4 #Torque in lb.in
L1=3 #Length in ft of the Steel bar
L2=6 #Length in ft of the Aluminium bar
d1=3 #Diameter of the Aluminium bar in inches
d2=2 #Diameter of the Steel bar in inches
#Calculations
#Using Compatibility and equlibrium conditions
a=np.array([[1,1],[(L1*32)/(Gs*pi*d2**4),-((L2*32)/(Ga*d1**4*pi))]])
b=np.array([T,0])
y=np.linalg.solve(a,b)
#Stresses
t_max_st=(16*y[0])/(pi*d2**3) #Max shear Stress in Steel in psi
t_max_al=(16*y[1])/(pi*d1**3) #Max shear stress in aluminium in psi
print "The maximum values of Shear Stresses are as flollows"
print round(t_max_st),"psi in Steel and ",round(t_max_al),"psi in Aluminium"
#NOTE:The shear stress for steel in the txtbook is off by 3psi
import math
#Variable Decleration
d=2 #Diameter in ft
G=12*10**6 #Bulk Modulus in psi
#Torque in lb.ft
T1=500 #Torque 1
T2=900 #Torque 2
T3=1000 #Torque 3
#Length in ft
L1=4
L2=3
L3=5
#Calculations
#Applying the sum of torques we get
Tab=T1 #Torque at section AB in lb.ft
Tbc=-T2+T1 #Torque at section BC in lb.ft
Tcd=T3-T2+T1 #Torque at Section CD in lb.ft
#Summing the angle of twists
theta_r=(((Tab*12*L3*12)+(Tbc*12*L2*12)+(Tcd*12*L1*12))*32)/(pi*2**4*G)
theta=(theta_r*180)/pi #Angle in degrees
print "The angle of twist is",round(theta,3),"degrees"
import math
#Variable Decleration
L=1.5 #Length of the shaft in m
t_B=200 #Torque per unit length in N.m/m
d=0.025 #Diameter of the shaft in m
G=80*10**9 #Bulk Modulus for steel in Pa
#Calculations
#Part(1)
#After carrying out the variable integration
T_A=0.5*t_B*L #Torque about point A in N.m
#Using equation of max stress
tau_Max=(16*T_A)*(pi*d**3)**-1 #Maximum stress in the shaft in Pa
#Part(2)
J=(pi*d**4)*32**-1 #Polar moment of inertia in m^4
#After carrying out the computation for angle of twist we get
theta_r=(t_B*L**2)*(3*G*J)**-1 #Angle of twist in radians
theta=theta_r*(180*pi**-1) #Angle of twist in degrees
#Result
print "Result for part (1)"
print "Maximum Shear Stress in the shaft is",round(tau_Max/10**6,1),"MPa"
print "Result for part (2)"
print "The angle of twist in the shaft is",round(theta,2),"degrees"
import math
#Variable Decleration
L=6 #Length of the tube in ft
t=3*8**-1 #Constant wall thickness in inches
G=12*10**6 #Bulk modulus of the tube in psi
w1=6 #Width on the top in inches
w2=4 #Width at the bottom in inches
h=5 #Height in inches
theta=0.5 #Angle of twist in radians
#Calculations
#Part(1)
Ao=(w1+w2)*2**-1*h #Area enclosed by the median line in sq.in
S=w1+w2+2*(sqrt(1**2+h**2)) #Length of the median line in inches
#Using the torsional stifness formula we get
k=4*G*Ao**2*t*(L*12*S)**-1*(pi*180**-1) #tortional Stiffness in lb.in/rad
#Part(2)
T=k*theta #Torque required to produce an angle of twist of theta in lb.in
q=T*(2*Ao)**-1 #Shear flow in lb/in
tau=q/t #Shear stress in the wall in psi
#Result
print "Part(1) results"
print "Torsional stiffness is",round(k),"lb.in/deg"
print "Part(2) results"
print "The shear stress in the wall is", round(tau),"psi"
import math
#Variable Decleration
L=1.2 #Length of the tube in m
tau=40*10**6 #MAximum shear stress in MPa
t=0.002 #Thickness in m
r=0.025 #Radius of the semicircle in m
G=28*10**9 #Bulk Modulus in Pa
t1=2 #Thickness in mm
t2=3 #thickness in mm
#Calculations
#Part(1)
q=tau*t #Shear flow causing the stress in N/m
Ao=pi*r**2*0.5 #Area of the semi-circle in m^2
T=2*Ao*q #Torque causing the shear stress in N.m
#Part(2)
#After computing the median lines integration we get
S=(pi*25*t1**-1)+(2*25*t2**-1) #Length of median line
theta_r=T*L*S*(4*G*Ao**2)**-1 #Angle of twist in radians
theta=theta_r*(180*pi**-1) #Angle of twist in degrees
#Result
print "Result for part(1)"
print "The torque causing the stress of 40MPa is",round(T,2),"N.m"
print "Result for part (2)"
print "The angle of twist is",round(theta,1),"degrees"