import math;
# Variable Declaration
#Copper has FCC structure
r = 1.273; # Atomic radius in angstrom
N = 6.023*10**26; # Avagadros number in atoms/kilomole
A = 63.5; # Atomic weight of copper in grams
n = 4; # No. of atoms per unit cell for FCC
# Calculations
r1 = r*10**-10; # Radius conversion from angstrom to m
a = (4*r1)/math.sqrt(2); # lattice parameter for FCC
p = (n*A)/(N*a**3); # Density of copper
# Result
print 'Lattice Constant a = %3.1e' %a,' m','\n', 'Density of copper = %3.1f' %p,' kg/m^3';
import math;
# Variable Declaration
# given intercepts 3,4 and ∞, the recipocals of intercepts is
# (1/3):(1/4):(1/∞)
# LCM = 12
# multiplying by LCM we get miller indices
# miller indices of a plane are the smallest integers of the reciprocals of its intercerpts
# therefore miller indices(h k l) is (4 3 0);
h = 4; # miller indice
k = 3; # miller indice
l = 0; # miller indice
a = 2; # primitive vector of lattice in angstrom
#Calculations
dhkl = a/math.sqrt((h**2)+(k**2)+(l**2)); #interplanar distance
# Result
print 'Miller indices = (4 3 0)';
print 'The interplanar distance d = %3.1f' %dhkl,' Å';
import math;
# Variable Declaration
# α-Iron solidifies to BCC structure
r = 1.273; # Atomic radius in angstrom
N = 6.023*10**26; # Avagadros number in atoms/kilomole
A = 55.85; # Atomic weight of α-Iron in kilograms
n = 2; # No. of atoms per unit cell for BCC
p = 7860; # density in kg/m^-3
#Calculations
# p = (n*A)/(N*a^3); density
a = ((n*A)/(N*p))**(0.333); # lattice constant
a1 = a*10**10; # m to angstrom conversion
r = (a1*math.sqrt(3))/4 # atomic radius for BCC
#Output
print 'The Radius of the atom = %3.5f' %r,' Å'
print 'Note : atomic wt taken as 55.58*10^-3 instead of 55.85 in calculation'
import math;
# Variable Declaration
lamda = 1.5418; # wavelength in Å
h = 1; # miller indice
k = 1; # miller indice
l = 1; # miller indice
n = 1; # given first order
theta = 30; # diffraction angle in degrees
# Calculations
theta1 = theta*math.pi/180; # degree to radian conversion
# d = (n*lamda)/(2*sinθ); by Braggs law ------------- 1
# d = a/sqrt((h^2)+(k^2)+(l^2)); interplanar distance ------------ 2
# equating 1 and 2
a = (n*lamda*math.sqrt((h**2)+(k**2)+(l**2))/(2*math.sin(theta1)))
# Result
print 'Interatomic spacing a = %f Å' %a;
import math;
# variable Declaration
h1 = 1; # miller indice
k1 = 1; # miller indice
l1 = 1; # miller indice
h0 = 0; # miller indice
k0 = 0; # miller indice
l0 = 0; # miller indice
# Calculations
# dhkl = a/sqrt((h^2)+(k^2)+(l^2)); // interplanar distance
# assume a = 1(constant) for easier calculation in scilab
a = 1;
d100 = a/math.sqrt((h1**2)+(k0**2)+(l0**2)); # interplanar distance
d110 = a/math.sqrt((h1**2)+(k1**2)+(l0**2)); # interplanar distance
d111 = a/math.sqrt((h1**2)+(k1**2)+(l1**2)); # interplanar distance
# Result
print 'd100 : d110 : d111 = ','%d ' %d100,':','%3.2f' %d110,':', '%3.2f' %d111;
import math;
# Variable Declaration
# Aluminium is FCC
a = 0.405*10**-9; # lattice constant of aluminium
t = 0.005*10**-2; # thickness of aluminium foil in m
s = 25*10**-2; # side of square in m
# Calculations
VUC = a**3; # volume of unit cell
Val = (s**2)*t # volume of aluminium foil (area*thickness)
N = Val/VUC # Number if unit cells
# Result
print 'Number of unit cells = %3.3e' %N
import math;
# variable declaration
# metallic iron changes from BCC to FCC form at 910 degress
rb = 0.1258*10**-9; # atomic radius of BCC iron atom
rf = 0.1292*10**-9; # atomic radius of FCC iron atom
# Calculations
ab = (4*rb)/(math.sqrt(3)); # lattice constant for BCC
Vbcc = (ab**3)/2; # volume occupied by one BCC atom
af = (4*rf)/(math.sqrt(2)) # lattice constant for FCC
Vfcc = (af**3)/4; # volume occupied by one FCC atom
dv = ((Vbcc-Vfcc)/Vbcc)*100 # percentage change in volume
# Result
print 'During the structural change the percentage change in volume = %3.4f' %dv;
import math
#variable declaration
#Copper Crystallines in FCC structure
p = 8960; # Density of copper in kg/m^3
N = 6.023*10**26; # Avagadros number in atoms/kilomole
A = 63.5; # Atomic weight of copper in kg/mol
n = 4; # No. of atoms per unit cell for FCC
# Calculations
a = ((n*A)/(N*p))**(0.333);
# Result
print 'Lattice Constant a = %3.4f' %(a*10**10),' Å';
print 'atomic wt of copper is taken as 63.5*10^-3 instead of 63.5 in textbook';
import math;
# Variable declaration
# (100) planes in rock crystal
h = 1; # miller indice
k = 0; # miller indice
l = 0; # miller indice
a = 2.814 # lattice constant in Å
# Calculations
dhkl = a/math.sqrt((h**2)+(k**2)+(l**2)); # interplanar distance
#Result
print 'd-spacing for (100) plane in rock salt = %3.3f' %dhkl,' Å';
import math;
# Variable Declaration
# FCC structured crystal
p = 6250; # Density of crystal in kg/m^3
N = 6.023*10**26; # Avagadros number in atoms/kilomole
A = 60.2; # molecular weight
n = 4; # No. of atoms per unit cell for FCC
# Calculations
a = ((n*A)/(N*p))**(0.333);
# Result
print 'Lattice Constant a = %3.3e' %a, 'm';
import math;
# Variable Declaration
# (321) plane in simple cubic lattice
h = 3; # miller indice
k = 2; # miller indice
l = 1; # miller indice
a = 4.12 # inter atomic space Å
# Calculations
dhkl = a/math.sqrt((h**2)+(k**2)+(l**2)); #interplanar distance
# Result
print 'd = %3.2f' %dhkl,' Å';
import math;
# Variable Declaration
# BCC structured crystal
p = 7860; # Density of iron in kg/m^3
N = 6.023*10**26; # Avagadros number in atoms/kilomole
A = 55.85; # Atomic weight
n = 2; # No. of atoms per unit cell for BCC
# Calculations
a = ((n*A)/(N*p))**(0.333); #lattice constant
# Result
print 'Lattice Constant of Fe = %3.3f' %(a*10**10),' Å ';
print 'Note: density of iron is taken as 7.86 instead of 7860 in calculation'
import math;
# variable Declaration
r = 0.123*10**-10; # Radius of the atom
# Calculations
a = (4*r)/math.sqrt(3); # Lattice constant in m For a BCC structure
V = a*a*a; # Volume of BCC
# Result
print 'Volume of the unit cell = %3.4e' %V,' m^3';
import math;
# Variable declaration
a = 0.05; # unit cell edge of an orthorhombic crystal in nm
b = 0.05; # unit cell edge of an orthorhombic crystal in nm
c = 0.03; # unit cell edge of an orthorhombic crystal in nm
Ia = 0.025 # intercept on 'a' in nm
Ib = 0.02 # intercept on 'b' in nm
Ic = 0.01 # intercept on 'c' in nm
# Calculations
h = a/Ia; # miller indice h
k = b/Ib; # miller indice k
l = c/Ic # miller indice l
# Result
print 'Miller indices (h k l) =', '%d' %h,'%d' %k, '%d' %l;
import math;
# Magnesium has HCP structure
# for HCF(Hexagonal closed packed structure) consider the relation between 'c' and 'a';
# c/a = sqrt(8/3) = 1.6329
# Variable Declaration
r = 0.1605*10**-9; # radius of magnesium atom in m
# Calculations
a = 2*r # lattice constant of HCP
c = a*math.sqrt(float(8)/3); # relation b/w c and a in HCP
V = (3*(3**0.5))*(a*a*c)/2; #Volume of unit cell in m^3
# Result
print 'Volume of the unit cell of magnesium = %g' %V,' m^3';
import math
# Variable Declaration
# (101),(221) planes in simple cubic lattice
h1 = 1; # miller indice
k0 = 0; # miller indice
l1 = 1; # miller indice
h2 = 2; # miller indice
k2 = 2; # miller indice
l1 = 1; # miller indice
a = 4.2 # inter atomic space Å
# Calculations
d101 = a/math.sqrt((h1**2)+(k0**2)+(l1**2)); # interplanar distance
d221 = a/math.sqrt((h2**2)+(k2**2)+(l1**2)); # interplanar distance
# Result
print 'd(101) = %3.4f' %d101,' Å','\n','d(221) = %3.1f' %d221,' Å ';
import math;
# Variable declaration
# Copper has FCC structure
a = 3.6; #lattice parameter of copper in Å
# Calculations
r = a*math.sqrt(2)/4; # atomic radius of copper
# Result
print 'Atomic Radius of copper = %3.3f' %r,'Å';
import math;
# variable Declaration
# Copper has FCC structure
r = 1.278; # Atomic radius in angstrom
N = 6.023*10**26; # Avagadros number in atoms/kilomole
A = 63.54; # Atomic weight of copper
n = 4; # No. of atoms per unit cell for FCC
# Calculations
r1 = r*10**-10; # Radius conversion from angstrom to m
a = (4*r1)/math.sqrt(2); # lattice parameter for FCC
p = (n*A)/(N*a**3); # Density of copper
# Result
print ' Density of copper = %3.2f' %p,' kg/m^3';
import math;
# Variable Declaration
ANa = 23; # atomic wt of sodiim
ACl = 35.45 # atomic wt of chlorine
N = 6.023*10**26; # Avagadros number in atoms/kilomole
n = 4 # No. of atoms per unit cell for FCC
p = 2180; # density in kg/m^-3
# Calculations
# p = (n*A)/(N*a^3); density
A = ANa+ACl; # atomic wt of NaCl
a = ((n*A)/(N*p))**(0.33333); # lattice constant
r = a/2 # Distance b/w two adjacent atoms
# Result
print 'Distance between two adjacent atoms is r = %3.2e' %r,' m';
import math;
# Variable Declaration
r = 1.273; # Atomic radius in angstrom
N = 6.023*10**26; # Avagadros number in atoms/kilomole
A = 55.85 ; # Atomic weight of Fe
n = 2; # No. of atoms per unit cell for BCC
p = 7860; # density in kg/m^-3
# Calculations
# p = (n*A)/(N*a^3); density
a = ((n*A)/(N*p))**(0.33333); # lattice constant
a1 = a*10**10; # m to angstrom conversion
r = (a1*math.sqrt(3))/4 # atomic radius for BCC
# Result
print 'The Radius of the Fe = %3.3f' %r,' Å';
import math;
# Variable Declaration
N = 6.023*10**26; # Avagadros number in atoms/kilomole
A = 119; # Atomic weight of pottasium bromide
n = 4; # No. of atoms per unit cell for FCC
p = 2700; # density in kg/m^-3
# Calculations
# p = (n*A)/(N*a^3); density
a = ((n*A)/(N*p))**(0.33333); # lattice constant
a1 = a*10**10; # m to angstrom conversion
# Output
print 'Lattice constant = %3.1f' %a1,' Å';
import math;
# Variable Declaration
a = 4.3*10**-10; # Lattice constant in Å
p = 960; # Density of crystal in kg/m^3
A = 23; # Atomic wt
N = 6.023*10**26; # avogadros no in atoms/kilomole
# Calculations
n = (p*N*(a**3))/A; # No. of atoms per unit cell
# result
print 'No. of atoms per unit cell = %3.0f' %n,' (BCC)';
import math;
# Variable Declaration
# given crystal has BCC structure
r = 1.2*10**-10; # atomic radius in m
# Calculations
a = (4*r)/math.sqrt(3); # lattice constant
V = a**3; # volume of cell
# Result
print 'Volume of the cell = %3.3e' %V,' m^3';
import math;
# Variable Declaration
a = 4*10**-10; # lattice constant of the crystal
h = 1 # miller indice
k = 0 # miller indice
l = 0 # miller indice
# Calculations
# in fig consider (100) plane. the no of atoms in plane ABCD
N = 4*(float(1)/4); # Number of atoms
p = N/(a*a); # planar atomic density in atoms/m^2
p1 = p*10**-6 # planar atomic density in atoms/mm^2
# Result
print 'planar atomic density = %3.2e' %p1,' atoms/mm^2';
import math;
# Variable Declaration
# in fig 5(b) the given plane is parallel to X and Z axes.Thus,its numerical intercepts on these axes is infinity
#The numerical intercept on y axis is 1/2. Thus the numerical intercepts of plane is (∞ 1/2 ∞)
print ' Miller indices of plane shown in fig 5.(b) = (0 2 0)';
# in fig 5(c) the given plane is parallel to Z axis.Thus its numerical intercept on z axis is infinity
# The numerical intercept on x axis is 1 and y axis is 1/2. this numerical intercepts on plane is (1 1/2 ∞ )
print ' Miller indices of plane shown in fig 5.(c) = (1 2 0)'
# in fig 5(d) the given plane is parallel to Z axis.Thus its numerical intercept on z axis is infinity
# The numerical intercept on x axis is 1/2 and y axis is 1/2. this numerical intercepts on plane is (1/2 1/2 ∞ )
print ' Miller indices of plane shown in fig 5.(d) = (2 2 0)'
import math;
# Variable Declaration
# (311) plane in simple cubic lattice
h = 3; # miller indice
k = 1; # miller indice
l = 1; # miller indice
a = 2.109*10**-10 # lattice constant in m
# Calculations
dhkl = a/math.sqrt((h**2)+(k**2)+(l**2)); # interplanar distance
# Result
print 'd = %3.3e' %dhkl,' m';
import math;
# Variable Declaration
h = 1; # miller indice
k = 1; # miller indice
l = 0; # miller indice
d = 2.86*10**-10 # interplanar distance in m
# Calculations
a = d*math.sqrt((h**2)+(k**2)+(l**2)); # interplanar distance
# Result
print 'Lattice constant a = %3.3e' %a,' m';
import math;
# Variable Declaration
h1 = 1;
h0 = 0;
k0 = 0;
l0 = 0;
l1 = 1;
# Calculations
# we know that dhkl = a/sqrt( h^2 + k^2 + l^2)
# let sqrt( h^2 + k^2 + l^2) = p
p101 = math.sqrt( h1**2 + k0**2 + l1**2);
p100 = math.sqrt( h1**2 + k0**2 + l0**2);
p001 = math.sqrt( h0**2 + k0**2 + l1**2);
# Result
print 'd101 : d100 : d001 :: a/%3.4f' %p101,' : ','a/%d' %p100,':',' a/%d ' %p001;
import math;
# if a plane cut intercepts of lengths l1,l2,l3 the on three crystal axes ,then
# l1 : l2 : l3 = pa : pq :rc
# where a,b and c are primitive vectors of the unit cell and p,q and r are numbers related to miller indices (hkl) of plane by relation
# 1/p : 1/q : 1/r = h : k : l
# since, the crystal is simple cubic a = b = c and given that h = 1, k = 1 and l = 1
# p : q : r = 1/h : 1/k : 1/l = 1/1 : 1/1 : 1/1
# p : q : r = 1 : 1 : 1
# similarly l1 : l2 : l3 = 1a : 1a : 1a
print 'ratio of intercepts on the three axes by (111) plane is l1 : l2 : l3 = 1 : 1 : 1';
import math;
# Variable Declaration
r = 1.246*10**-10; # atomic radius in m
h1 = 1 # miller indice
h2 = 2 # miller indice
k0 = 0 # miller indice
k1 = 1 # miller indice
k2 = 2 # miller indice
l0 = 0 # miller indice
l1 = 1 # miller indice
# Calculations
a = (4*r)/math.sqrt(2); # lattice constant
d111 = a/math.sqrt((h1**2)+(k1**2)+(l1**2)); # interplanar distance
d200 = a/math.sqrt((h2**2)+(k0**2)+(l0**2)); # interplanar distance
d220 = a/math.sqrt((h2**2)+(k2**2)+(l0**2)); # interplanar distance
# Result
print 'd111 = %3.3e' %d111,' m','\n' 'd200 = %3.4e' %d200,' m','\n''d220 = %3.3e' %d220,' m';
import math;
# variable Declaration
# the intercept along X-axis be c1 = a
# the intercept along Y-axis be c2 = b/2 and
# the intercept along Z-axis be c3 = 3c
# Therefore, p = c1/a = a/a = 1
# q = c2/b = (b/2)/b = 1/2
# r = c3/c = (3c)/c = 3
# therefore h = 1/p = 1
# k = 1/q = 2
# l = 1/r = 1/3
# lcm of 1 1 and 3 = 3
h = 1
k = 2
l = float(1)/3
s = 3 ; # lcm
h1= s*h
k1= s*k
l1= s*l;
# Result
print '(h k l) =', '%d' %h1,' %d' %k1,'%3.0f' %l1;
import math;
# Variable Declaration
d = 1.3*10**-10 # interplanar distance
n = 1; # given first order
theta = 23; # Bragg reflection angle in degrees
# Calculations
theta1 = theta*math.pi/180; # degree to radian conversion
# d = (n*lamda)/(2*sinθ); by Braggs law ------------- 1
lamda = (2*d*math.sin(theta1)/n)
# Result
print 'Wavelength of X-ray = %3.4f' %(lamda*10**10),' Å';