from __future__ import division
import math
# Python Code Ex3.1 Packing of equal spheres in
#two dimensional square lattice:Page-88(2010)
#Variable declaration
#Herewemayassumesquareofunitlengthi.e.a=1suchthatradiusofsphere,R=a/2=0.5
a=1; # Length of the side of the square, unit
R = a/2; # Radius of the sphere, unit
#Calculations
# Radius of the sphere introduced within the void produced by
# the packing of equal spheres on square lattice, unit
r = ((2)**0.5-1)*R;
A = math.pi*R**2; # Area associated with a sphere, square units
FA = a**2-A;#Free area occupied by void in square lattice,square units
FA_per = FA*100; # Percentage free area in square lattice
#Result
print"\nFree area in square lattice is :",round(FA_per,2),"percent"
from __future__ import division
import math
# Python Code Ex3.2 Packing efficiency in diamond structure: Page-92 (2010)
#Variable declaration
# For simplicity we may take radius of the atom, R = 1 unit
R = 1; # Radius of the atom in bcc lattice, unit
nc = 8; # Number of corner atoms in diamond structure
nfcc = 6; # Number of face centred atoms in diamond structure
na = 4; # Number of atoms completely within the unit cell
#Calculations
n = 1/8*nc+1/2*nfcc+1*na # Effective number of atoms in the diamond structure
V_atom = 8*4/3*math.pi*R**3; # Volume of atoms within the unit cell, unit cube
# Since for a diamond cubic crystal, the space lattice is fcc,
#with two atos per lattice point, such that 8*R = sqrt(3)*a, solving for a
a = 8*R/(3)**0.5; # lattice parameter of diamond structure, unit
V_cell = a**3; # Volume of the unit cell, unit cube
eta = V_atom/V_cell*100; # Packing efficiency in diamond structure
#Result
print"\nThe packing efficiency in diamond structure is :",round(eta),"percent"
from __future__ import division
import math
# Python Code Ex3.3 Radius of largest sphere
#that can be placed at the octahedral void: Page-100 (2010)
#Variable declaration
# For simplicity we may take radius of the atom, R = 1 unit
R = 1; # Radius of the atom in bcc lattice, unit
#Calculation
# For a bcc lattice, 4*R = a*sqrt(3), solving for a
a = 4*R/(3)**0.5; # lattice parameter of bcc crystal, unit
# Since R + Rx = a/2, solving for Rx
#Radius of the largest sphere that will fit into the octahedral void, unit
Rx = a/2 - R;
#Results
print"\nThe radius of the largest sphere that"
print " will fit into the octahedral void is :",round(Rx,2),"R"
from __future__ import division
import math
# Python Code Ex3.4 Radius of largest sphere that
#can be placed at the tetrahedral void: Page-100 (2010)
#Variable declaration
# For simplicity we may take radius of the atom, RL = 1 unit
RL = 1; # Radius of the atom in bcc lattice, unit
#Calculation
# For a bcc lattice, 4*RL = a*sqrt(3), solving for a
a = 4*RL/(3)**0.5; # Lattice parameter of bcc crystal, unit
# Further RL + Rx = sqrt(5)*a/4, solving for Rx
# Radius of the largest sphere that will fit into the octahedral void, unit
Rx = (5)**0.5*a/4-RL;
#Result
print"\nThe radius of the largest sphere "
print " that will fit into the tetrahedral void is :",round(Rx,2),"RL"
from __future__ import division
import math
#Python Code Ex3.5 Diameter of the largest atom that
# would fit into the tetrahedral void:5 Page-101 (2010)
#Variable declaration
a = 3.52*10**-10; # Lattice parameter for Ni, m
#Calculations
# For an fcc lattice, sqrt(2)*a = 4*R, solving for R
R = (2)**0.5*a/4; # Radius of the atom in fcc lattice, m
R_oct = 0.414*R; #Radius of the octahedral void in fcc close packing, m
D = 2*R_oct#Diameter of the octahedral void in the fcc structure of nickel,m
#Result
print"The diameter of the octahedral void in the fcc structure of nickel,"
print" in angstrom, is : ",round(D/(1*10**-10),2)
from __future__ import division
import math
# Python Code Ex3.6 Void space in cubic close packing: Page-101 (2010)
#Variable declaration
R = 1; # For simplicity, radius of the sphere, m
n = 4; # Number of lattice points in fcc unit cell
#Calculations
# For cubic close packing, side of the unit cell
#and the radius of the sphere is related as
# sqrt(2)*a = 4*R, solving for a
a = 2*(2)**0.5*R; #Lattice parameter for cubic close packing, m
V_cell = a**3; # Volume of the unit cell
# Volume occupied by the atoms, metre cube
V_occupied = 4*4/3*math.pi*((1.000)**3+(0.414)**3+2*(0.225)**3);
void_space = V_cell - V_occupied; # Void space in the close packing
percent_void = void_space/V_cell*100; # Percentage void space
#Result
print"\nVoid space in the close packing is:",round(percent_void),"percent"
from __future__ import division
import math
#Python CodeEx3.7 The minimum value of radius ratio in AX-compound:Page-104
#Variable declaration
# For simplicity we may assume a = 1
a = 1; # Lattice parameter of the crystal, unit
# Calculation
b = 2/3*a*math.sin(math.pi/3); # Lattice parameter of the crystal, unit
# Here a = 2*Rx, where a is the lattice parameter and
# Rx is the radius of X-ions representing the bigger spheres, solving for Rx
Rx = 0.5*a;
# Also b = RA + Rx, solving for RA
RA = b - Rx; # Radius of A-ion representing teh smaller sphere, unit
Rad_ratio = RA/Rx; # Radius ratio in AX compound
#Result
print"\n Minimum value of radius ratio in AX compound is :", round(Rad_ratio,2)