# 3: Crystal Planes,X-ray Diffraction and Defects in Solids¶

## Example number 1, Page number 3-19¶

In [1]:
#importing modules
import math
from __future__ import division

#Variable declaration
a=0.28;         #lattice spacing(nm)
lamda=0.071;    #wavelength of X-rays(nm)
h=1;
k=1;
l=0;
n=2;

#Calculation
d=a/math.sqrt(h**2+k**2+l**2);
sintheta=n*lamda/(2*d);
theta=math.asin(sintheta)*180/math.pi;           #glancing angle(degrees)

#Result
print "glancing angle is",int(theta),"degrees"

glancing angle is 21 degrees


## Example number 2, Page number 3-19¶

In [2]:
#importing modules
import math
from __future__ import division

#Variable declaration
d=0.282;       #lattice spacing(nm)
n=1;           #order

#Calculation
lamda=2*d*math.sin(theta)/n;    #wavelength of X-rays(nm)
n=2*d/lamda;                    #maximum order of diffraction

#Result
print "wavelength of X-rays is",round(lamda,4),"nm"
print "maximum order of diffraction is",int(round(n))

wavelength of X-rays is 0.0842 nm
maximum order of diffraction is 7


## Example number 3, Page number 3-20¶

In [3]:
#importing modules
import math
from __future__ import division

#Variable declaration
T1=773;            #temperature(K)
T2=1273;           #temperature(K)
f=10**-10;         #fraction of vacant sites

#Calculation
x=round(T1*math.log(f)/T2,3);
N=math.exp(x);    #fraction of vacancy sites

#Result
print "fraction of vacancy sites is",round(N*10**7,3),"*10**-7"

fraction of vacancy sites is 8.466 *10**-7


## Example number 4, Page number 3-21¶

In [3]:
#importing modules
import math
from __future__ import division

#Variable declaration
h1=1;
k1=0;
l1=0;    #miller indices of (100)
h2=1;
k2=1;
l2=0;    #miller indices of (110)
h3=1;
k3=1;
l3=1;    #miller indices of (111)
a=1;     #assume

#Calculation
d100=a/math.sqrt(h1**2+k1**2+l1**2);    #spacing(nm)
d110=a/math.sqrt(h2**2+k2**2+l2**2);    #spacing(nm)
d111=a/math.sqrt(h3**2+k3**2+l3**2);    #spacing(nm)
x=int(1/d100)**2;
y=int((1/d110)**2);
z=int(round((1/d111)**2));       #taking squares of the value of spacing since lcm function doesnt work on square root

def lcm(y, z):
if y > z:
greater = y
else:
greater = z
while(True):
if((greater % y == 0) and (greater % z == 0)):
lcm = greater
break
greater += 1

return lcm

l=lcm(y,z);
l=math.sqrt(l);
d1=d100*l;
d10=d110*l;
d11=d111*l;      #ratio d100:d110:d111
d1=int(d1/math.sqrt(6));
d10=int(round(d10/math.sqrt(3)));
d11=int(d11/math.sqrt(2));

#Result
print "ratio d100:d110:d111 is",d1,"*math.sqrt(6) :",d10,"*math.sqrt(3) :",d11,"*math.sqrt(2)"

ratio d100:d110:d111 is 1 *math.sqrt(6) : 1 *math.sqrt(3) : 1 *math.sqrt(2)


## Example number 5, Page number 3-21¶

In [2]:
#importing modules
import math
from __future__ import division

#Variable declaration
n=1;     #order
lamda=1.54;                 #wavelength(angstrom)
h=2;
k=2;
l=0;

#Calculation
a=math.sqrt(h**2+k**2+l**2);
d=n*lamda*a/(2*math.sin(theta));       #lattice parameter(angstrom)

#Result
print "lattice parameter is",round(d,3),"angstrom"

lattice parameter is 3.522 angstrom


## Example number 6, Page number 3-22¶

In [1]:
#importing modules
import math
from __future__ import division

#Variable declaration
d=1.6;       #lattice spacing(angstrom)
lamda=1.5;    #wavelength of X-rays(angstrom)

#Calculation
n=2*d*math.sin(theta)/lamda;       #maximum order of diffraction

#Result
print "maximum order of diffraction is",int(n)

maximum order of diffraction is 2


## Example number 7, Page number 3-22¶

In [26]:
#importing modules
import math
from __future__ import division

#Variable declaration
d=0.203*10**-9;       #lattice spacing(m)
h=1;
k=1;
l=0;          #miller indices of (110)
lamda=1.5;    #wavelength of X-rays(angstrom)

#Calculation
a=d*math.sqrt(h**2+k**2+l**2);     #length(m)
V=a**3;       #volume of unit cell(m**3)

#Result
print "length is",round(a*10**9,3),"*10**-9 m"
print "volume of unit cell is",round(V*10**27,5),"*10**-27 m**3"
print "answer for volume given in the book varies due to rounding off errors"
print "radius of atom is",round(r*10**9,4),"*10**-9 m"

length is 0.287 *10**-9 m
volume of unit cell is 0.02366 *10**-27 m**3
answer for volume given in the book varies due to rounding off errors
radius of atom is 0.1243 *10**-9 m


## Example number 8, Page number 3-22¶

In [27]:
#importing modules
import math
from __future__ import division

#Variable declaration
d=1.6;       #lattice spacing(angstrom)
lamda=1.5;    #wavelength of X-rays(angstrom)

#Calculation
n=2*d*math.sin(theta)/lamda;       #maximum order of diffraction

#Result
print "maximum order of diffraction is",int(n)

maximum order of diffraction is 2


## Example number 9, Page number 3-23¶

In [34]:
#importing modules
import math
from __future__ import division

#Variable declaration
a=0.26;         #lattice spacing(nm)
lamda=0.065;    #wavelength of X-rays(nm)
h=1;
k=1;
l=0;
n=2;

#Calculation
d=a/math.sqrt(h**2+k**2+l**2);
sintheta=n*lamda/(2*d);
theta=math.asin(sintheta)*180/math.pi;           #glancing angle(degrees)
thetas=60*(thetam-int(thetam));                  #glancing angle(seconds)

#Result
print "answer in the book is wrong"

glancing angle is 20 degrees 42 minutes 17 seconds
answer in the book is wrong


## Example number 10, Page number 3-23¶

In [36]:
#importing modules
import math
from __future__ import division

#Variable declaration
n=1;     #order
lamda=1.54;                 #wavelength(angstrom)
h=1;
k=1;
l=1;

#Calculation
d=n*lamda/(2*math.sin(theta));       #lattice parameter(angstrom)
a=d*math.sqrt(h**2+k**2+l**2);       #cube edge of unit cell(angstrom)

#Result
print "cube edge of unit cell is",round(a,3),"angstrom"

cube edge of unit cell is 4.055 angstrom


## Example number 11, Page number 3-24¶

In [42]:
#importing modules
import math
from __future__ import division

#Variable declaration
n=1;     #order
lamda=1.54;                 #wavelength(angstrom)
h=2;
k=2;
l=0;

#Calculation
d=n*lamda/(2*math.sin(theta));       #lattice parameter(angstrom)
a=d*math.sqrt(h**2+k**2+l**2);       #lattice parameter(angstrom)

#Result
print "lattice parameter is",round(a,3),"angstrom"

lattice parameter is 3.522 angstrom


## Example number 12, Page number 3-24¶

In [43]:
#importing modules
import math
from __future__ import division

#Variable declaration
a=0.36;       #cube edge of unit cell(nm)
h1=1;
k1=1;
l1=1;
h2=3;
k2=2;
l2=1;

#Calculation
d1=a/math.sqrt(h1**2+k1**2+l1**2);       #interplanar spacing for (111)(nm)
d2=a/math.sqrt(h2**2+k2**2+l2**2);       #interplanar spacing for (321)(nm)

#Result
print "interplanar spacing for (111) is",round(d1,3),"nm"
print "interplanar spacing for (321) is",round(d2,3),"nm"

interplanar spacing for (111) is 0.208 nm
interplanar spacing for (321) is 0.096 nm


## Example number 13, Page number 3-25¶

In [50]:
#importing modules
import math
from __future__ import division

#Variable declaration
lamda=0.675;   #wavelength of X-rays(angstrom)
n1=1;                  #order
n3=3;                  #order

#Calculation
d=n1*lamda/(2*math.sin(theta));       #lattice spacing(angstrom)
d=round(d,3);
theta3=math.asin(n3*lamda/(2*d))*180/math.pi;    #glancing angle for 3rd order(degrees)
theta3d=int(theta3);                             #glancing angle for 3rd order(degrees)
theta3m=(theta3-theta3d)*60;                     #glancing angle for 3rd order(minutes)

#Result
print "lattice spacing is",d,"angstrom"
print "glancing angle for 3rd order is",theta3d,"degrees",round(theta3m,1),"minutes"
print "answer for minutes given in the book varies due to rounding off errors"

lattice spacing is 3.575 angstrom
glancing angle for 3rd order is 16 degrees 27.1 minutes
answer for minutes given in the book varies due to rounding off errors


## Example number 14, Page number 3-25¶

In [60]:
#importing modules
import math
from __future__ import division

#Variable declaration
d=3.04;         #interplanar spacing(angstrom)
lamda=0.79;    #wavelength of X-rays(angstrom)
n=3;

#Calculation
sintheta=n*lamda/(2*d);

glancing angle is 23 degrees 56 minutes 31 seconds