import math
#calculate The maximum instantaneous stress produced and corresponding strain work done on the rod and stored
d = 3./2.;##inches
l = 10.;##feet
P = 8.;##tons
E = 13500.;##tons/in^2
A = 0.25*math.pi*d**2;##in^2
p = 2.*P/A;## tons/in^2
e = p/E;
del_l = e*l*12.;##inches
W = P*del_l;##inch-ton
print'%s %.2f %s'%('The maximum instantaneous stress produced is, p =',p,'tons/in^2');
print'%s %.4f %s'%('The corresponding strain is e =',e,'')
print'%s %.2f %s'%('del_l =',del_l,'inches')
print'%s %.2f %s'%('The work done on the rod and stored by it is',W,'inch-ton.');
##there is an error in the answer given in text book
import math
#calculate Maximum instantaneous and extension stress produced
l = 6.;##feet
d = 1.;##inches
h = 4.;##inches
E = 30*10**6;##lb/in^2
A = 0.25*math.pi*d**2;##in^2
P = 50.;##lb
p = (P/A)+math.sqrt((P**2/A**2)+(2*E*P*h)/(A*l*12.));
e = p/E;
del_l = e*l*12.##inches
print'%s %.d %s'%('Maximum instantaneous stress produced is p =',p,'lb/in^2');
print'%s %.3f %s'%('Maximum instantaneous extension produced is del_l =',del_l,'lb/in^2');
##there is an error in the answer given in text book
import math
#calculate Instantaneous elongation and Height of the drop
l = 10.;##feet
d = 5./4.;##inches
p = 8.;##tons/in^2
E = 13000.;##tons/in^2
A = 0.25*math.pi*d**2;##in^2
e = p/E;
del_l = e*l*12.;##inches
W = 0.5*p**2*A*l*12./E;## inch-ton
h = W*10.-del_l;##inches
print'%s %.3f %s'%('Instantaneous elongation is del_l =',del_l,'inches')
print'%s %.2f %s'%('Height of the drop is h =',h,'inches');
import math
#calculate Maximum instantaneous extension and stress
w = 4.;##tons
v = 2.;##miles per hour
l = 150.;##feet
d = 3./2.;##inches
E = 13000.;## tons/in^2
g = 32.;## ft/sec^2
A = 0.25*math.pi*d**2;## in^2
KE = w*(v*17.6)**2/(2*g*12);## inch-tons
p = math.sqrt(KE*(2.*E)/(A*l*12.));## tons/in^2
del_l = p*l*12./E;## inches
print'%s %.2f %s'%('Maximum instantaneous stress produced is p =',p,'tons/in^2')
print'%s %.f %s'%('Maximum instantaneous extension produced is del_l =',del_l,'inch')
import math
#Maximum instantaneous stress and extension
d = 2.;##inches
l = 8.;##feet
U = 50.;## ft-lbs
E = 28.*10**6;## lb/in^2
V = 0.25*math.pi*d**2*l*12.;## in^3
p = math.sqrt(2*U*12.*E/V);## lb/in^2
e = p/E;
del_l = e*l*12.;## inches
print'%s %.1f %s'%('Maximum instantaneous stress produced is p =',p,'lb/in^2');
print'%s %.4f %s'%('Maximum instantaneous extension produced is del_l =',del_l,'inches');
##there is an error in the answer given in text book
import math
# calculate Maximum instantaneous stress and Ratio of energies stored if both bars are allowed to reach the proof stress and Ratio of energies stored at the same stress per unit volume
l = 12.;##feet
d1_A = 1.;##inch
d2_A = 2.;##inches
l1_A = 4.;##inches
l2_A = 8.;##inches
d1_B = 1.;##inch
d2_B = 2.;##inches
l1_B = 8.;##inches
l2_B = 4.;##inches
p_A = 15./2.;## tons/in^2
p_B = math.sqrt((2./3.)*p_A**2);## tons/in^2
r1 = (9*math.pi/8.)/(3*math.pi/4.);##ratio of energies if both bars are allowed to reach the proof stress
V_A = 0.25*math.pi*d1_A**2*l1_A+ 0.25*math.pi*d2_A**2*l2_A;## in^3
V_B = 0.25*math.pi*d1_B**2*l1_B+ 0.25*math.pi*d2_B**2*l2_B;## in^3
r2 = ((3./16.)*p_B**2)/((1./12.)*p_B**2);##ratio of enrgies
print'%s %.2f %s'%('Maximum instantaneous stress produced is p_B =',p_B,'tons/in^2')
print'%s %.2f %s'%('Ratio of energies stored if both bars are allowed to reach the proof stress is r1 =',r1,'');
print'%s %.2f %s'%('Ratio of energies stored at the same stress per unit volume, is r2 =',r2,'');