# 3: X-ray Diffraction¶

## Example number 3.1, Page number 3.9¶

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

#Variable declaration
d=0.313;     #lattice spacing(m)
theta=7+(48/60);    #angle(degrees)
n=1;

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

#Result
print "wavelength of X-rays is",round(lamda,5),"nm"
print "answer varies due to rounding off errors"
print "when theta=90, maximum order of diffraction possible is",int(n)

wavelength of X-rays is 0.08496 nm
answer varies due to rounding off errors
when theta=90, maximum order of diffraction possible is 7


## Example number 3.2, Page number 3.10¶

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

#Variable declaration
lamda=1.5418;      #wavelength(angstrom)
theta=30;      #angle(degrees)
n=1;    #first 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);    #interatomic spacing(angstrom)

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

interatomic spacing is 2.67 angstrom


## Example number 3.3, Page number 3.10¶

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

#Variable declaration
d100=0.28;    #spacing(nm)
lamda=0.071;    #wavelength of X rays(nm)
n=2;    #second order

#Calculation
d110=round(d100/math.sqrt(2),3);     #spacing(nm)
x=n*lamda/(2*d110);
theta=theta*180/math.pi;     #glancing angle(degrees)

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

glancing angle is 21 degrees


## Example number 3.4, Page number 3.11¶

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

#Variable declaration
a=0.38;     #lattice constant(nm)
h=1;
k=1;
l=0;

#Calculation
d=a/math.sqrt(h**2+k**2+l**2);     #distance between planes(nm)

#Result
print "distance between planes is",round(d,2),"nm"

distance between planes is 0.27 nm


## Example number 3.5, Page number 3.11¶

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

#Variable declaration
a=0.19;     #lattice constant(nm)
h=1;
k=1;
l=1;
lamda=0.058;    #wavelength of X rays(nm)
n=2;    #second order

#Calculation
d=a/math.sqrt(h**2+k**2+l**2);     #distance between planes(nm)
x=n*lamda/(2*d);

glancing angle is 32.0 degrees