#Example 7.1 : shear modulus of the material
#given data :
E=210 # youngs's modulus in GN/m**2
v=0.3 # poisson ratio
G=E/(2*(1+v)) # shear modulus
print "shear modulus,G(GN/m**2) = ",round(G,2)
#Example 7.2 : young's modulus of elasticity,yield point stress, ultimate stress and percentage elongation
#given data :
d=40.0*10**-3 #in m
W=40.0*10**3 # load in N
del_l=3.04*10**-5 # in m
L=200.0*10**-3 # in m
load_max=242.0*10**3 #in N
l=249*10.0**-3 # length of specimen in m
l0=(d+L) # in m
A=(math.pi*d**2)/4.0
b=W/A
epsilon=del_l/L
E=(b/epsilon)
print"young modulus,E(N/m**2) = ","{:.2e}".format(E)
Y_load=161*10**3
Y_stress=Y_load/A
print "yield point stress,Y_stress(N/m**2) = ","{:.2e}".format(Y_stress)
U_stress=load_max/A
print "ultimate stress,U_stress(N/m**2) = ","{:.2e}".format(U_stress)
p_elongation=((l-l0)/l0)*100
print "percentage elongation,p_elongation(%) = ",p_elongation
#percentage elongation is calculated wrong in textbook
# Example 7.3.a: yield point stress
yl=40.0 #yeild load in kN
ml=71.5 #maximum load in kN
fl=50.5 #fracture load in kN
glf=79.5 #gauge length of fratture in mm
st=7.75*10**-4 #strain at load of 20kN
d=12.5 #specimen diamtere in mm
sl=62.5 #specimen length in mm
A=(math.pi*(d*10**-3)**2)/4.0 # in meter square
ylp=((yl*10.0**3)/(A)) #yeild point stress in N/m**2
print "yeild point stress in N/m**2 is ","{:.2e}".format(ylp)
# Example 7.3.b: ultimate tensile strength
yl=40.0 #yeild load in kN
ml=71.5 #maximum load in kN
fl=50.5 #fracture load in kN
glf=79.5 #gauge length of fratture in mm
st=7.75*10**-4 #strain at load of 20kN
d=12.5 #specimen diamtere in mm
sl=62.5 #specimen length in mm
A=(math.pi*(d*10**-3)**2)/4.0 # in meter square
ylp=((yl*10.0**3)/(A)) #yeild point stress in N/m**2
uts=((ml*10.0**3)/(A)) #ultimate tensile strangth in N/m**2
print "{:.2e}".format(uts),"is ultimate tensile strangth in N/m**2"
# Example 7.3.c: percentage elongation
yl=40 #yeild load in kN
ml=71.5 #maximum load in kN
fl=50.5 #fracture load in kN
glf=79.5 #gauge length of fratture in mm
st=7.75*10**-4 #strain at load of 20kN
d=12.5 #specimen diamtere in mm
sl=62.5 #specimen length in mm
a=(math.pi*d*10**-3)**2/4 # in meter square
pel=((glf-sl)/sl)*100 #percentage elongation
print pel,"% is percentage elongation"
# Example 7.3.d:modulus of elasticity
import math
yl=40 #yeild load in kN
ml=71.5 #maximum load in kN
fl=50.5 #fracture load in kN
glf=79.5 #gauge length of fratture in mm
st=7.75*10**-4 #strain at load of 20kN
d=12.5 #specimen diamtere in mm
sl=62.5 #specimen length in mm
A=(math.pi*(d*10**-3)**2)/4.0 # in meter square
ylp=((yl*10**3)/(A)) #yeild point stress in N/m**2
uts=((ml*10**3)/(A)) #ultimate tensile strangth in N/m**2
pel=((glf-sl)/sl)*100 #percentage elongation
strss=((20*10**3)/A) #stress at 20kN in N/m**2
mel=strss/st #modulus of elasticity in N/m**2
print "{:.2e}".format(mel),"is modulus of elasticity in N/m**2"
# Example 7.3.e: yield point stress
import math
yl=40.0 #yeild load in kN
ml=71.5 #maximum load in kN
fl=50.5 #fracture load in kN
glf=79.5 #gauge length of fratture in mm
st=7.75*10**-4.0 #strain at load of 20kN
d=12.5 #specimen diamtere in mm
sl=62.5 #specimen length in mm
A=(math.pi*(d*10**-3)**2)/4.0 # in meter square
ylp=((yl*10**3)/(A)) #yeild point stress in N/m**2
uts=((ml*10**3)/(A)) #ultimate tensile strangth in N/m**2
pel=((glf-sl)/sl)*100 #percentage elongation
strss=((20*10**3)/A) #stress at 20kN in N/m**2
mel=strss/st #modulus of elasticity in N/m**2
mrs=((ylp*10**-3)**2/(2*mel)) #modulus of resilience
print round(mrs,4)," is modulus of resilience"
# Example 7.3.f: fracture stress
yl=40 #yeild load in kN
ml=71.5 #maximum load in kN
fl=50.5 #fracture load in kN
glf=79.5 #gauge length of fratture in mm
st=7.75*10**-4 #strain at load of 20kN
d=12.5#specimen diamter in mm
sl=62.5 #specimen length in mm
A=(math.pi*(d*10**-3)**2.0)/4 # in meter square
ylp=((yl*10**3)/(A)) #yeild point stress in N/m**2
uts=((ml*10**3)/(A)) #ultimate tensile strangth in N/m**2
pel=((glf-sl)/sl)*100 #percentage elongation
strss=((20*10.0**3)/A) #stress at 20kN in N/m**2
mel=strss/st #modulus of elasticity in N/m**2
mrs=((ylp*10**-3)**2.0/(2*mel)) #modulus of resilience
fs=((fl*10.0**3)/(A)) #fracture stress in N/m**2
print "{:.2e}".format(fs),"is fracture stress in N/m**2"
# Example 7.3.g: modulus of toughness
yl=40.0 #yeild load in kN
ml=71.5 #maximum load in kN
fl=50.5 #fracture load in kN
glf=79.5 #gauge length of fratture in mm
st=7.75*10**-4 #strain at load of 20kN
d=12.5 #specimen diamtere in mm
sl=62.5 #specimen length in mm
A=(math.pi*(d*10**-3)**2)/4 # in meter square
ylp=((yl*10**3)/(A)) #yeild point stress in N/m**2
uts=((ml*10**3)/(A)) #ultimate tensile strangth in N/m**2
pel=((glf-sl)/sl)*100 #percentage elongation
strss=((20*10**3)/A) #stress at 20kN in N/m**2
mel=strss/st #modulus of elasticity in N/m**2
mrs=((ylp*10**-3)**2/(2*mel)) #modulus of resilience
fs=((fl*10**3)/(A)) #fracture stress in N/m**2
mth=((ylp+uts)*(pel/100))/2 #modulus of toughness in N/m**2
print "{:.2e}".format(mth)," is modulus of toughness in N/m**2"
#percentage reduction in area is not calulated in the textbook
#Example 7.4 : true breaking stress and nominal breaking stress
#given data :
d1=12.7; # in mm
B_load=14;# in K-N
A1=(math.pi*d1**2)/4;# original cross section area
d2=7.87; # in mm
A2=(math.pi*d2**2)/4;# final cross sction area
T_stress=B_load/A2;
print round(T_stress*1000)," is true breaking stress,T_stress in (N/mm**2) "
N_stress=B_load/A1;
print int(N_stress*1000)," is nominal breaking stress,N_stress in (N/mm**2) "
#true breaking stress unit is wrong in the textbook
# Example 7.5.a: yield point stress
yl=34.0;#yeild load in kN
ul=61.0;#ultimate load in kN
fl=78.0;#final length in mm
glf=60.0;#gauge length of fratture in mm
fd=7.0;#final diamtere in mm
d=12.0;#specimen diamtere in mm
sl=62.5;#specimen length in mm
A=(math.pi*(d)**2)/4;# in meter square
ylp=((yl*10**3)/(A));# yeild point stress in N/mm**2
print floor(ylp)," is yeild point stress in N/mm**2"
# Example 7.5.b: ultimate tensile stress
yl=34.0;#yeild load in kN
ul=61.0;#ultimate load in kN
fl=78.0;#final length in mm
glf=60.0;#gauge length of fratture in mm
fd=7.0;#final diamtere in mm
d=12.0;#specimen diamtere in mm
sl=62.5;#specimen length in mm
A=(math.pi*(d)**2)/4.0;# in meter square
uts=((ul*10**3)/(A));#ultimate tensile strangth in N/mm**2
print round(uts)," is ultimate tensile strangth in N/mm**2"
# Example 7.5.c: percentage reduction
yl=34;#yeild load in kN
ul=61;#ultimate load in kN
fl=78;#final length in mm
glf=60;#gauge length of fratture in mm
fd=7;#final diamtere in mm
d=12;#specimen diamtere in mm
sl=62.5;#specimen length in mm
A=(math.pi*(d)**2)/4;# in mm square
A1=(math.pi*(fd)**2)/4;# in mm square
pr=(A-A1)/A;# reduction
print round(pr*100),"% is percentage reduction"
# Example 7.5.d: percentage elonagtion
yl=34.0;#yeild load in kN
ul=61.0;#ultimate load in kN
fl=78.0;#final length in mm
glf=60.0;#gauge length of fratture in mm
fd=7.0;#final diamtere in mm
d=12.0;#specimen diamtere in mm
sl=62.5;#specimen length in mm
A=(math.pi*(d)**2)/4;# in mm square
A1=(math.pi*(fd)**2)/4;# in mm square
pr=(fl-glf)/glf;# elongation
print round(pr*100,2),"% is percentage elongtion "
#Example 7.6 : strain
#given data :
b=44.5*10**3;#force
E=1.1*10**5;# in N/mm**2
A=15.2*19.1# in mm**2
epsilon=b/(A*E);
print "strain,epsilon (mm) = ","{:.2e}".format(epsilon)
#Example 7.7 :stress and strain
#given data :
sigma=450;#in MPa
epsilon=0.63;
sigma_t=sigma*(1+epsilon);
print "true stress,sigma_t(MPa) = ",sigma_t
epsilon_t=math.log(1+epsilon);
print "true strain,epsilon_t(MPa) = ",round(epsilon_t,3)
# Example 7.8: which part has a greater stress
l=24.0;#length in mm
b=30;#breadth in mm
ld=7000;#load in kg
sd=10;#steel bar diamtere in mm
sl=5000.0;#load in kg
al=ld/(l*b);#stress on aluminium bar in kg/mm**2
a=((math.pi*sd**2)/4.0);#area in mm**2
slb=sl/a;#stress on steel bar in kg/mm**2
print"stress on aluminium bar is ",round(al,2)," kg/mm**2 is less than stress on steel bar ",round(slb,2)," kg/mm**2 "