# 12: X-ray Diffraction¶

## Example number 1, Page number 323¶

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

#Variable declaration
n=1;         #order
d=2.82*10**-10;          #spacing(m)

#Calculations
lamda=2*d*math.sin(theta)/n;    #wavelength of X-rays(m)

#Result
print "wavelength of X-rays is",round(lamda*10**10,5),"angstrom"

wavelength of X-rays is 0.97938 angstrom


## Example number 2, Page number 323¶

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

#Variable declaration
n=1;         #order
d=3.035*10**-10;          #spacing(m)

#Calculations
lamda=2*d*math.sin(theta)/n;    #wavelength of X-rays(m)

#Result
print "wavelength of X-rays is",round(lamda*10**10,3),"angstrom"

wavelength of X-rays is 1.262 angstrom


## Example number 3, Page number 323¶

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

#Variable declaration
n=1;         #order
d=2.81;          #spacing(angstrom)

#Calculations
lamda1=2*d*math.sin(theta1)/n;    #wavelength(angstrom)
lamda2=2*d*math.sin(theta2)/n;    #wavelength(angstrom)

#Result
print "their wavelengths are",round(lamda1,3),"angstrom and",round(lamda2,4),"angstrom"
print "answer in the book varies due to rounding off errors"

their wavelengths are 1.464 angstrom and 1.6525 angstrom
answer in the book varies due to rounding off errors


## Example number 4, Page number 324¶

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

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

#Calculations
d=lamda/(2*math.sin(theta));       #spacing(angstrom)

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

spacing is 4.035 angstrom


## Example number 5, Page number 324¶

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

#Variable declaration
n1=1;         #order
n2=3;         #order
lamdaB=0.92;    #wavelength(angstrom)

#Calculations
lamdaA=n2*lamdaB*math.sin(theta1)/math.sin(theta2);    #wavelength of line A(angstrom)

#Result
print "wavelength of line A is",round(lamdaA,3),"angstrom"
print "answer given in the book is wrong"

wavelength of line A is 1.593 angstrom
answer given in the book is wrong


## Example number 6, Page number 324¶

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

#Variable declaration
n=1;         #order
d=0.4086*10**-10;          #spacing(m)
m=9.1*10**-31;             #mass(kg)
h=6.6*10**-34;             #planks constant(Js)

#Calculations
lamda=2*d*math.sin(theta)/n;    #wavelength of electrons(m)
v=h/(m*lamda);                  #velocity of electrons(m/sec)

#Result
print "wavelength of electrons is",round(lamda*10**10,4),"*10**-10 m"
print "velocity of electrons is",round(v/10**6,3),"*10**6 m/sec"
print "answers given in the book are wrong"

wavelength of electrons is 0.7406 *10**-10 m
velocity of electrons is 9.793 *10**6 m/sec
answers given in the book are wrong


## Example number 7, Page number 325¶

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

#Variable declaration
n=1;         #order
d=2.82*10**-10;          #spacing(m)

#Calculations
lamdamax=2*d*sintheta/n;    #longest wavelength(m)

#Result
print "longest wavelength is",lamdamax*10**10,"angstrom"

longest wavelength is 5.64 angstrom


## Example number 8, Page number 325¶

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

#Variable declaration
n1=1;         #order
n2=3;         #order
lamda=0.842*10**-10;     #wavelength(m)

#Calculations

#Result
print "glancing order is",round(theta3*180/math.pi,3),"degrees"

glancing order is 26.599 degrees


## Example number 9, Page number 325¶

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

#Variable declaration
n=1;         #order
lamda=0.58;          #wavelength of X-rays(angstrom)

#Calculations
d1=lamda/(2*math.sin(theta1));       #spacing in 1st case(angstrom)
d2=lamda/(2*math.sin(theta2));       #spacing in 2nd case(angstrom)
d3=lamda/(2*math.sin(theta3));       #spacing in 3rd case(angstrom)

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

spacing in 1st case is 1.289 angstrom
spacing in 2nd case is 1.824 angstrom
spacing in 3rd case is 0.648 angstrom
answers given in the book are wrong


## Example number 10, Page number 326¶

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

#Variable declaration
M=58.5;           #molecular weight(kg/k-mole)
rho=2.16*10**3;   #density(kg/m**3)

#Calculations

#Result
print "seperation of adjacent atoms is",round(d*10**10,3),"angstrom"

seperation of adjacent atoms is 2.823 angstrom


## Example number 11, Page number 327¶

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

#Variable declaration
M=58.454;           #molecular weight(kg/k-mole)
n=1;                #order
rho=2163;           #density(kg/m**3)
lamda=1.3922*10**-10;     #wavelength(m)

#Calculations
d=n*lamda/(2*math.sin(theta));      #lattice spacing(m)

#Result
print "lattice spacing is",round(d*10**10,4),"angstrom"
print "answer in the book varies due to rounding off errors"

lattice spacing is 2.7882 angstrom
avagadro number is 6.234 *10**26 mol/k-mole
answer in the book varies due to rounding off errors


## Example number 12, Page number 327¶

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

#Variable declaration
lamda=0.586*10**-10;      #wavelength(m)

#Calculations
a=int(10*math.sin(theta1));
b=int(10*math.sin(theta2));
c=int(10*math.sin(theta3));
d1=a*lamda/(2*math.sin(theta1));     #spacing at first order(m)
d2=b*lamda/(2*math.sin(theta2));     #spacing at second order(m)
d3=c*lamda/(2*math.sin(theta3));     #spacing at third order(m)
d=(d1+d2+d3)/3;                      #mean value of crystal lattice spacing(m)

#Result
print "orders of reflection is",a,":",b,":",c
print "spacing at first order is",round(d1*10**10,4),"*10**-10 m"
print "spacing at second order is",round(d2*10**10,4),"*10**10 m"
print "spacing at third order is",round(d3*10**10,4),"*10**-10 m"
print "mean value of crystal lattice spacing is",round(d*10**10,3),"*10**-10 m"
print "answers given in the book vary due to rounding off errors"

orders of reflection is 1 : 2 : 3
spacing at first order is 2.8187 *10**-10 m
spacing at second order is 2.7805 *10**10 m
spacing at third order is 2.8143 *10**-10 m
mean value of crystal lattice spacing is 2.804 *10**-10 m
answers given in the book vary due to rounding off errors


## Example number 13, Page number 328¶

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

#Variable declaration

#Calculations
d1=math.sin(theta1);     #spacing at first order(m)
d2=math.sin(theta2);     #spacing at second order(m)
d3=math.sin(theta3);     #spacing at third order(m)
x=d1/d1;
y=round(d2/(d1*math.sqrt(2)));
z=round(d3/(math.sqrt(3)*d1));

#Result
print "ratio of spacing is",int(x),":",int(y),"*math.sqrt(2) :",int(z),"*math.sqrt(3)"
print "the crystal is simple cubic crystal"

ratio of spacing is 1 : 1 *math.sqrt(2) : 1 *math.sqrt(3)
the crystal is simple cubic crystal


## Example number 14, Page number 328¶

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

#Variable declaration
M=58.46;           #molecular weight(kg/k-mole)
rho=2170;          #density(kg/m**3)
n=1;               #order

#Calculations
lamda=2*d*math.sin(theta)/n;     #wavelength of Kalpha(m)

#Result
print "wavelength of Kalpha is",round(lamda*10**10,3),"angstrom"
print "answer given in the book is wrong due to printing mistake"

wavelength of Kalpha is 0.589 angstrom
answer given in the book is wrong due to printing mistake


## Example number 15, Page number 329¶

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

#Variable declaration
e=1.6*10**-19;             #charge(coulomb)
E=344;                     #energy(V)
n=1;                       #order
m=9*10**-31;               #mass(kg)
h=6.62*10**-34;            #planks constant(Js)

#Calculations
lamda=h/math.sqrt(2*m*e*E);     #wavelength(m)
d=n*lamda/(2*math.sin(theta));  #spacing of crystal(m)

#Result
print "spacing of crystal is",round(d*10**10,2),"angstrom"

spacing of crystal is 0.38 angstrom