# Chapter 3:Crystal planes and X-ray diffraction¶

## Example 3.2, Page number 3.5¶

In :
import math
from sympy import *

#Variable declaration
'''In a simple cubic structure, there are three types of atomic arrangement
(i)(100)
(ii)(110)
(iii)(111)'''

#Calculations and results

#Consider (100) plane
n = (1./4.)*4  #no. of atoms in this plane
#Let a be the lattice constant in mm
a = Symbol('a')
A1 = a**2
nm = n/A1     #no. of atoms per mm^2
print "The number of atoms per square millimeter for (100) plane is",nm

#Consider (110) plane
n2 = 1
A2 = math.sqrt(2)*a**2
nm2 = n2/A2
print "The number of atoms per square millimeter for (110) plane is",nm2

#Consider (111) plane
n3 = (1./360.)*60*3
EO = a*math.sqrt(2)*math.cos(math.pi/6)
A3 = (a*math.sqrt(2)*EO)/2
nm3 = n3/A3
print "The number of atoms per square millimeter for (111) plane is",nm3

The number of atoms per square millimeter for (100) plane is 1.0/a**2
The number of atoms per square millimeter for (110) plane is 0.707106781186547/a**2
The number of atoms per square millimeter for (111) plane is 0.577350269189626/a**2


## Example 3.3, Page number 3.6¶

In :
from math import sqrt

#Variable declartion

#Calculations
#For FCC structure,
a = (4*r)/sqrt(2)

#For (110) plane,
h1 = 1
k1 = 1
l1 = 0
d1 = a/((h1**2+k1**2+l1**2)**0.5)

#For (212) plane,
h2 = 2
k2 = 1
l2 = 2
d2 = a/((h2**2+k2**2+l2**2)**0.5)

#Results
print "Interplanar spacing for (110) plane =",d1/1E-9,"nm"
print "Interplanar spacing for (212) plane =",round((d2/1E-9),4),"nm"

Interplanar spacing for (110) plane = 0.2556 nm
Interplanar spacing for (212) plane = 0.1205 nm


## Example 3.4, Page number 3.7¶

In :
from sympy import *

#Variable declaration
#Let a be the lattice constant
#For calculations, let us assume a = 1
a = 1

#Calculations

#For (100) plane,
h1 = 1
k1 = 0
l1 = 0
d1 = 1/((h1**2+k1**2+l1**2)**0.5)

#For (110) plane,
h2 = 1
k2 = 1
l2 = 0
d2 = 1/((h2**2+k2**2+l2**2)**0.5)

#For (111) plane,
h3 = 1
k3 = 1
l3 = 1
d3 = 1/((h3**2+k3**2+l3**2)**0.5)

#Result
print "d100:d110:d111 =",d1,":",d2,":",d3

d100:d110:d111 = 1.0 : 0.707106781187 : 0.57735026919


## Example 3.5, Page number 3.7¶

In :
#Variable declaration
#Coefficients of intercepts along three axes
m = 1.
n = 1./2.
p = 3.

#Calculations
m_inv = 1/m
n_inv = 1/n
p_inv = 1/p

def gcd(a, b):
while b:
a, b = b, a % b
return a

def lcm(a, b):
return (a * b)/ gcd(a, b)

def lcmm(*args):
return reduce(lcm, args)

mul_fact = lcmm(1,1,3)
m1 = m_inv*mul_fact    #Clear the first fraction
m2 = n_inv*mul_fact    #Clear the second fraction
m3 = p_inv*mul_fact    #Clear the third fraction
print "The required miller indices are", m1,m2,m3

The required miller indices are 3.0 6.0 1.0


## Example 3.6, Page number 3.14¶

In :
import math

#Variable declaration
d = 0.282*10**-9   #lattice spacing(m)
n = 1              #first order
theta = 8.35       #glancing angle(degrees)

#Calculations

#For maximum value possible,
theta = 90
n = (2*d)/lamda

#Results
print "Wavelength of X-rays =",round((lamda/1E-9),4),"nm"
print "Maximum order of diffraction possible =",round(n,2)

Wavelength of X-rays = 0.0819 nm
Maximum order of diffraction possible = 6.89


## Example 3.8, Page number 3.15¶

In :
import math

#Variable declaration
lamda = 1.5418*10**-10   #wavelength(m)
theta = 30               #angle(degrees)
n = 1                    #first order
#For (111) plane
h = 1
k = 1
l = 1

#Calculations
a = d*((h**2+k**2+l**2)**0.5)

#Result
print "Interatomic spacing =",round((a/1E-10),3),"A"

Interatomic spacing = 2.67 A


## Example 3.9, Page number 3.15¶

In :
from math import sqrt, pi

#Variable declaration
d = 0.28              #lattice spacing
lamda = 0.074*10**-9  #Wavelength(m)
n = 2                 #2nd order

#Calculations
d110 = d/sqrt(2)
theta = math.asin((n*lamda)/(2*d110))*180/pi

#Result
print "Glancing angle =",round(theta/1E-9),"degrees"

Glancing angle = 21.0 degrees


## Example 3.10, Page number 3.16¶

In :
#Variable declaration
a = 0.38*10**-9  #lattice constant
h = 1
k = 1
l = 0

#Calculations
d = a/math.sqrt(h**2+k**2+l**2)

#Result
print "Distance =",round((d/1E-9),2),"nm"

Distance = 0.27 nm


## Example 3.11, Page number 3.16¶

In :
import math
from sympy import *

#Variable declaration
a = Symbol('a')

#Calculations
#For (110) plane
a1 = math.sqrt(2)*a**2  #area of plane
n1 = (1./4 )*4          #no. of atoms in this plane
rho1 = n1/a1

#For (111) plane
EO = (a*math.sqrt(3))/math.sqrt(2)
a2 = (a*EO)/math.sqrt(2)
n2 = 3*(1./6.)
rho2 = n2/a2

#Result
print "Density of lattice points (111) plane:density of lattice points (110) plane =",rho2,":",rho1

Density of lattice points (111) plane:density of lattice points (110) plane = 0.577350269189626/a**2 : 0.707106781186547/a**2