# 7: X-ray Diffraction and Defects in Crystals¶

## Example number 1, Page number 239¶

In [4]:
#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);       #cube edge of unit cell(angstrom)

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

cube edge of unit cell is 4.1 angstrom


## Example number 2, Page number 240¶

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

#Variable declaration
lamda=0.58;        #wavelength(angstrom)
n=1;                #order

#Calculation
d1=lamda/(2*math.sin(theta1));     #interplanar spacing at 1st angle(angstrom)
d2=lamda/(2*math.sin(theta2));     #interplanar spacing at 2nd angle(angstrom)
d3=lamda/(2*math.sin(theta3));     #interplanar spacing at 3rd angle(angstrom)

#Result
print "interplanar spacing at 1st angle is",round(d1,3),"angstrom"
print "interplanar spacing at 2nd angle is",round(d2,3),"angstrom"
print "interplanar spacing at 3rd angle is",round(d3,3),"angstrom"
print "answers given in the book are wrong"

interplanar spacing at 1st angle is 2.582 angstrom
interplanar spacing at 2nd angle is 1.824 angstrom
interplanar spacing at 3rd angle is 1.289 angstrom
answers given in the book are wrong


## Example number 3, Page number 240¶

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

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

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

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

order of diffraction is 1


## Example number 4, Page number 240¶

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

#Variable declaration
lamda=0.58;     #wavelength of X-rays(angstrom)
n=1;            #order
h=2;
k=0;
l=0;

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

#Result
print "lattice parameter is",round(a,3),"angstrom"
print "answer given in the book varies due to rounding off errors"

lattice parameter is 3.514 angstrom
answer given in the book varies due to rounding off errors


## Example number 5, Page number 241¶

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

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

#Calculation
x=n2*lamda*math.sin(theta1)/(n1*lamda);
theta2=math.asin(x)*180/math.pi;          #glancing angle
theta2d=int(theta2);                      #glancing angle(degrees)
theta2m=(theta2-theta2d)*60;              #glancing angle(minutes)

#Result
print "glancing angle is",theta2d,"degrees",int(theta2m),"minutes"
print "answer for glancing angle in minutes given in the book is wrong"

glancing angle is 26 degrees 35 minutes
answer for glancing angle in minutes given in the book is wrong


## Example number 6, Page number 241¶

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

#Variable declaration
a=3.16;         #lattice parameter(angstrom)
lamda=1.54;        #wavelength of X-rays(angstrom)
n=1;               #order

#Calculation
d=n*lamda/(2*math.sin(theta));            #interplanar spacing(angstrom)
x=(a/d)**2;

#Result
print "interplanar spacing is",round(d,2),"angstrom"
print "answer for interplanar spacing given in the book is wrong"
print "value of h**2+k**2+l**2 is",int(x),". hence the miller indices could be (110) (011) or (101)"

interplanar spacing is 2.22 angstrom
answer for interplanar spacing given in the book is wrong
value of h**2+k**2+l**2 is 2 . hence the miller indices could be (110) (011) or (101)


## Example number 7, Page number 242¶

In [35]:
#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(nm)
N=2*d/lamda;                         #maximum order of diffraction

#Result
print "wavelength is",round(lamda,3),"nm"
print "maximum order of diffraction is",int(N)

wavelength is 0.084 nm
maximum order of diffraction is 6


## Example number 8, Page number 243¶

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

#Variable declaration
lamda=1.5;         #wavelength(AU)
d=1.6;             #lattice spacing(AU)

#Calculation
n=2*d/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 243¶

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

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

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

#Result
print "interatomic spacing is",round(a,2),"angstrom"

interatomic spacing is 2.67 angstrom


## Example number 10, Page number 243¶

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

#Variable declaration
h=1;
k=1;
l=0;
lamda=0.065;             #wavelength(nm)
n=2;                     #order
a=0.26;                  #axial length(nm)

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

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

glancing angle is 20.7 degrees


## Example number 11, Page number 244¶

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

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

#Calculation
d=n*lamda/(2*math.sin(theta));
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 12, Page number 244¶

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

#Variable declaration
lamda=1.54*10**-10;         #wavelength(m)
n=1;                        #order
h=1;
k=1;
l=1;

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

#Result
print "cube edge of unit cell is",round(a*10**10,3),"*10**-10 m"

cube edge of unit cell is 4.055 *10**-10 m


## Example number 13, Page number 244¶

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

#Variable declaration
lamda=0.12;         #wavelength(nm)
n=2;                        #order

#Calculation
d=n*lamda/(2*math.sin(theta));     #interplanar spacing(nm)

#Result
print "interplanar spacing is",round(d,2),"nm"

interplanar spacing is 0.26 nm


## Example number 14, Page number 245¶

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

#Variable declaration
lamda=97;         #wavelength(pm)
n1=1;             #order
n2=3;             #order

#Calculation
lamda1=n2*lamda*math.sin(theta1)/(n1*math.sin(theta2));     #wavelength(pm)
d=n2*lamda/(2*math.sin(theta2))            #interplanar spacing(pm)

#Result
print "wavelength is",round(lamda1,1),"pm"
print "interplanar spacing is",int(d),"pm"
print "answer for wavelength given in the book varies due to rounding off errors"

wavelength is 131.3 pm
interplanar spacing is 168 pm
answer for wavelength given in the book varies due to rounding off errors


## Example number 15, Page number 245¶

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

#Variable declaration
d=275;            #interplanar spacing(pm)
n1=3;
n2=4;

#Calculation
lamda=2*d*math.sin(theta);     #wavelength(pm)
lamda1=lamda/n1;               #wavelength for n=3
lamda2=lamda/n2;               #wavelength for n=4

#Result
print "wavelength for n=3 is",int(round(lamda1)),"pm and for n=4 is",round(lamda2,2),"pm"
print "answer for wavelength for n=4 given in the book varies due to rounding off errors"

wavelength for n=3 is 130 pm and for n=4 is 97.23 pm
answer for wavelength for n=4 given in the book varies due to rounding off errors


## Example number 17, Page number 246¶

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

#Variable declaration
lamda=0.171;                          #wavelength(nm)
h1=1;
k1=1;
l1=0;
h2=2;
k2=0;
l2=0;
h3=1;
k3=1;
l3=1;

#Calculation
d100=lamda/(2*math.sin(theta1));     #wavelength(nm)
d200=lamda/(2*math.sin(theta2));     #wavelength(nm)
a1=d100*math.sqrt(h1**2+k1**2+l1**2);
a2=d200*math.sqrt(h2**2+k2**2+l2**2);    #lattice parameter in case of bcc
a3=d100*math.sqrt(h3**2+k3**2+l3**2);
a4=d200*math.sqrt(h2**2+k2**2+l2**2);    #lattice parameter in case of bcc
d=a3/math.sqrt(2);                       #atomic diameter(nm)

#Result
print "lattice parameter in case of bcc are",round(a1,3),"nm and",round(a2,3),"nm which are not the same. hence the metal is not bcc"
print "lattice parameter in case of fcc are",round(a3,3),"nm and",round(a4,3),"nm which are the same. hence the metal is fcc"
print "atomic diameter is",round(d,5),"nm"
print "answer for atomic diameter given in the book varies due to rounding off errors"

lattice parameter in case of bcc are 0.242 nm and 0.296 nm which are not the same. hence the metal is not bcc
lattice parameter in case of fcc are 0.296 nm and 0.296 nm which are the same. hence the metal is fcc
atomic diameter is 0.20943 nm
answer for atomic diameter given in the book varies due to rounding off errors


## Example number 18, Page number 246¶

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

#Variable declaration
d=0.282*10**-9;         #lattice spacing(m)
maxtheta=90*math.pi/180;
n=1;                                 #order

#Calculation
lamda=2*d*math.sin(theta)/n;         #wavelength of x-rays(m)
N=2*d*math.sin(maxtheta)/lamda;      #maximum order of diffraction

#Result
print "wavelength of x-rays is",round(lamda*10**10,3),"angstrom"
print "maximum order of diffraction is",int(round(N))
print "answer for wavelength of x-rays given in the book is wrong"

wavelength of x-rays is 0.842 angstrom
maximum order of diffraction is 7
answer for wavelength of x-rays given in the book is wrong


## Example number 19, Page number 247¶

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

#Variable declaration
d=3.04*10**-10;         #lattice spacing(m)
lamda=0.79*10**-10;     #wavelength(m)
n=3;                    #order

#Calculation
x=n*lamda/(2*d);
theta=math.asin(x)*180/math.pi;     #glancing angle(degrees)

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

glancing angle is 22.942 degrees