# Example 8.1: critical resolved shear stress of silver
Ts=15;#tensile stress in Mpa
d=[1,1,0];
d1=[1,1,1];
csda=((d[0]*d1[0])+(d[1]*d1[1])+(d[2]*d1[2]))/((math.sqrt(d[0]**2+d[1]**2+d[2]**2))*math.sqrt(d1[0]**2+d1[1]**2+d1[2]**2));#angle degree
d2=[0,1,1];
csdb=((d[0]*d2[0])+(d[1]*d2[1])+(d[2]*d2[2]))/((math.sqrt(d[0]**2+d[1]**2+d[2]**2))*math.sqrt(d2[0]**2+d2[1]**2+d2[2]**2));#angle degree
t=Ts*csda*csdb;#critical resolved shear stress in MPa
print round(t,2),"= critical resolved shear stress in MPa"
# Example 8.2: yield strength of material
import numpy.linalg as lin
import math
ys1=115;# yeild strength in MN/mm**2
ys2=215;# yeild strength in MN/mm**2
d1=0.04;#diamtere in mm
d2=0.01;#diamtere in mm
A=numpy.array([[2 ,10], [1 ,10]]);
B=numpy.array([230,215]);
x=lin.solve(A,B)
si=x[0];# in MN/mm**2
k=x[1];#
d3=0.016;#in mm
sy= si +(k/math.sqrt(d3));#yeild strength for a grain size in MN/mm**2
print round(sy,1),"=yeild strength for a grain size in MN/mm**2"
# Example 8.3: yield strength of material
import numpy.linalg as lin
import math
ys1=120;# yeild strength in MN/mm**2
ys2=220;# yeild strength in MN/mm**2
d1=0.04;#diamtere in mm
d2=0.01;#diamtere in mm
A=numpy.array([[2 ,10], [1 ,10]]);
B=numpy.array([240,220]);
x=lin.solve(A,B)
si=x[0];# in MN/mm**2
k=x[1];#
d3=0.025;#in mm
sy= si +(k/math.sqrt(d3));#yeild strength for a grain size in MN/mm**2
print round(sy,1),"= yeild strength for a grain size in MN/mm**2"
#Example 8.4 : grain diameter
import math
#given data :
N=9; # ASTM number
m=8*2**N; # no. of grains [er square millimetre
grain=1/math.sqrt(m);
print round(grain,4),"=the grain diameter(mm) "