from math import pi, sin, asin
#given
#wavelength of X-rays beams of light
lamda=0.824*10**-10 #m
#glancing angle of the incident light
theta1=(8+35/60)*(pi)/180 #radians
n1=1
#to find theta3 i.e at
n3=3
#as we know that
#2*d*sin(theta)=n*lambda
#so for n1 and n3 we get in the same way and solving together we get
theta3=asin(3*sin(theta1))
#so
d=lamda/2/sin(theta1)
print "the galncing angle for the third order diffraction is and interplanar spacing of the crystal is 2.761 A"
from math import sqrt, pi
#given
#bragg's angle of reflection
theta1=17.03*(pi)/180 #radians
#wavelength of light
lamda=0.71 #A
#according to bragg's equation
#n*lambda=2*d*sin(theta)
#for n=1
d=lamda/2/sin(theta1) #A
#given that h**2+k**2+l**2=8
#let (h**2+k**2+l**2)**1/2=H
#we get
H=sqrt(8)
a=d*H #A
print "since h**2+k**2+l**2=8 ,hence the reflecting planes will be (220). family of planes (220) include (220), (202), (022) ,etc."
#given
#lattice constant
a=1.54 #A
#wavelength of beam of light
lamda=1.54 #A
#according to bragg's equation
#n*lambda=2*d*sin(theta)
#following angles are given
theta1=20.3*(pi)/180
theta2=29.2*(pi)/180
theta3=36.7*(pi)/180
theta4=43.6*(pi)/180
#interplaner spadcing is
d1=lamda/(2*sin(theta1)) #A
d2=lamda/(2*sin(theta2)) #A
d3=lamda/(2*sin(theta3)) #A
d4=lamda/(2*sin(theta4)) #A
#magnitude of bragg's
#we have h**2+k**2+l**2=a**2/d**2
#let a**2/d**2= D for notation only
#so
D1=2
D2=4
D3=6
D4=8
#so from bragg's magnitude we can get (hkl)
#(hkl1)=(110)
#(hkl3)=(200)
#(hkl3)=(211)
#(hkl4)=(220)
print "the reflection will take from {110},{200},{211} and (220)"
#given
#wavelength of X-ray
lamda=1.54 #A
#diameter of powder camera
D=114.6 #mm
#radius of powder camera
R=D/2 #mm
#value of l
l1=86
l2=100
l3=148
l4=180
l5=188
l6=232
l7=272
#we know that
#theta=l/4
#so
theta1=l1/4*(pi)/180 #radians
theta2=l2/4*(pi)/180 #radians
theta3=l3/4*(pi)/180 #radians
theta4=l4/4*(pi)/180 #radians
theta5=l5/4*(pi)/180 #radians
theta6=l6/4*(pi)/180 #radians
theta7=l7/4*(pi)/180 #radians
#now values of sin (theta) and sin(theta2)
S1=sin(theta1)
SS1=(sin(theta1))**2
S2=sin(theta1)
SS2=(sin(theta1))**2
S3=sin(theta1)
SS3=(sin(theta1))**2
S4=sin(theta1)
SS4=(sin(theta1))**2
S5=sin(theta1)
SS5=(sin(theta1))**2
S6=sin(theta1)
SS6=(sin(theta1))**2
S7=sin(theta1)
SS7=(sin(theta1))**2
#so the ratio can be expressed as
#3:4:8:11:12:16:19
print "from the extinction rule, we notice that this is an FCC Structure"
#the lattice parameter for highest bragg's angle is
#a=lambda*sqrt(h**2+k**2+l**2)/(2*sin(theta))
#here h**2+k**2+l**2=19
#and let h**2+k**2+l**2 =M for notation
M=19
a=lamda*sqrt(M)/(2*sin(theta6)) #A
print "lattice parameter of material is %0.2f A"%(a)
#given
#ASTM number
n=12
#as we know that the number of grains N observed on photomicrograph is given by
N=2**(n-1)
#as we know that grain size diameter is given by
d=1/sqrt((N/645)*10**4) #mm because 1 square inch=645 mm**2
print "the grain diameter for an ASTM number 12 is %f mm"%(d)
from math import log
#given
#no of grains within the view of a micrograph
n1=41
#no of grains cut by circumference
n2=42
#diameter of circular area
d=1 #inch
#area
A=(pi)/4*d**2 #inch**2
#the area density of grains
N=(n1+n2/2)/A #grains/inch**2
#grain size
n=log(N)/log(2)+1
print "the area density of grains is %0.2f grains/inch**2 and grain size is 8"%(N)
from __future__ import division
#given
#ASTM no of grains
ASTM=5
#area density of grains
N=2**(ASTM-1) #grains/inch**2 at magnification of 100*
#as we know that lineal and areal magnification are related as
#*100 lineal=*10000 areal
#therefore
Nnew=N/0.01/0.01 #grains/inch**2 at 1*
#average area of one grain
A=1/Nnew*(2.54)**2 #cm**2
#now 160000 grains/inch**2 of surface is sqrt(160000)=400 grains/inch of length and this is equal to=(400)**3==6.4*10**7 grains/m**3 of volume
#surface area of each cubic surface
S=(1/400)**2 #inch**2
#there are 6 surfaces in accubic grain
#thus total surface area of each grain
T=1/2*6*S*(400)**3/2.54 #cm**2 boundary per cubic cm of steel
print "the boumdary area per cubic centimeter of steel is %0.2e cm**2 boundary per cubic centimeter of steel"%T