from __future__ import division
import math
# Python Code Ex6.1 Rate of diffusion of N through steel wall: Page-195 (2010)
#Variable declaration
# Diffusion coeffcient of N in steel at room temperature, metre sq per sec
D = 1e-019;
# Concentration of nitrogen at the inner surface of the tank, kg per metre cube
dc = 10;
dx = 10e-03; # Thickness of the steel wall, m
# Calculation
# Fick's first law giving outward flux of nitrogen
#through steel wall of the tank, kg per metre square per second
J = D*(dc/dx);
#Result
print"\nThe rate at which nitrogen escapes through the tank wall ="
print round((J*10**16))*10**-16,"kg per metre square per sec"
from __future__ import division
import math
#Python Code Ex6.2 Rate of diffusion of copper through pure Al sheet:Page-196
#Variable declaration
a = 4.05e-010; # Lattice parameter of fcc Al, m
N = 4; # Number of Al atoms per unit cell of fcc Al
# Diffusion coeffcient of copper in Al at 550 degree celsius,metre sq per sec
D = 5.25e-013;
c1 = 0.19e-02; # Atomic percent of copper at the surface, per unit volume
# Atomic percent of Cu at the the depth 1.2 mm from the surface,per unit volume
c2 = 0.18e-02;
dx = 1.2e-03; # Thickness of the pure Al sheet, m
#Calculation
n = N/a**3; # Number of Al atoms per unit volume, per metre cube
#Change in concentration of Cu at 1.2 mm depth of the surface,per metre cube
dc = (c2 - c1)*n;
# Fick's first law giving outward flux of copper through the Al sheet,
#Cu atoms per metre square per second
J = -D*(dc/dx);
#Result
print"\nThe outward flux of copper through the Al sheet = "
print round((J*10**-15),2)*10**15,"Cu atoms per metre square per sec"
from __future__ import division
import math
#Python Code Ex6.3 Rate of diffusion of carbon through steel bar:Page-196(2010)
#Variable declaration
a = 3.65e-010; # Lattice parameter of fcc structure of iron, m
D = 3e-011#Diffusion coeff. of C in iron at 1000degree celsius,metre sq per sec
n1 = 20; # Number of unit cells per carbon atom at the surface of steel
#Number of unit cells per C atom at a depth 1 mm from the surface of steel
n2 = 30;
dx = 1e-03; # Thickness of the steel bar, m
#Calculation
c1 = 1/(n1*a**3); # Atomic percent of carbon at the surface, per metre cube
# Atomic percent of carbon at a depth 1 mm from the surface, per metre cube
c2 = 1/(n2*a**3);
# Fick's first law giving outward flux of carbon through the Steel bar,
#C atoms per metre square per second
J = -D*((c2-c1)/dx);
# The number of carbon atoms diffusing through each unit cell per minute
J_uc = J*a**2*60;
#Result
print"\nNumber of carbon atoms diffusing through each unit cell per minute ="
print round(J_uc,2),"atoms per minute"
from __future__ import division
import math
# Python Code Ex6.4 Diffusion through a cylinder: Page-199 (2010)
#Variable declaration
r = 12; # Radius of cylindrical crystal, mm
# Assume effective thickness of the surface to be 4 angstrom
#= two atomic diameters, mm
t = 4e-07;
#Calculation
# Cross-sectional area for diffusion through the cylinder, milli-metre square
A1 = math.pi*r**2;
# Cross-sectional area for diffusion along the surface, milli-metre square
A2 = 2*math.pi*r*t;
ratio = A2/A1; # Ratio of two cross-sectional areas
#Result
print"\nThe ratio of two cross-sectional areas ="
print round( (ratio*10**8),2)*10**-8
from __future__ import division
import math
# Python Code Ex6.5 Diffusion length of Li in Ge: Page-203 (2010)
#Variable declaration
D = 1e-010; # Diffusion coefficient for Li in Ge, metre square per sec
t = 1*60*60; # Time taken by diffusing Li to travel diffusion depth, sec
T = 500+273; # absolute temperature of the system, kelvin
#Calculation
x = (D*t)**0.5; # Diffusion length of Li in Ge, m
#Result
print"\nThe diffusion length of Li in Ge =",x,"m"
from __future__ import division
import math
# Python Code Ex6.6 Diffusion time of Li in Ge: Page-203 (2010)
#Variable declaration
D = 1e-010; # Diffusion coefficient for Li in Ge, metre square per sec
T = 500+273; # Absolute temperature of the system, kelvin
x = 0.2e-03; # Diffusion length of Li in Ge, m
#Calculation
# Diffusion length is given by
# x = sqrt(D*t), solving for t
t = x**2/D;#Time taken by diffusing Li to travel diffusion depth of 0.2 mm, sec
#Result
print"\nTime taken by diffusing Li to travel diffusion depth of 0.2 mm =",t,"s"
from __future__ import division
import math
# Python Code Ex6.7 Diffusion coefficent of Cu in Al: Page 206 (2010)
#Variable declaration
# Pre-exponential diffusion constant independent of temp.,metre square per sec
D0 = 0.25e-04;
T = 550+273; # Absolute temperature of the system, kelvin
R = 8.314; # Molar gas constant, J/mol/K
Q = 121e+03; # The activation energy for diffusion, joule per mole
t = 1*60*60; # Time taken by Cu to diffuse into Al, sec
#Calculation
# Diffusion coefficient of Cu in Al at 550 degree celsius, metre square per sec
D = D0*math.exp(-Q/(R*T));
x = (D*t)**0.5; # Diffusion length of Cu in Al, m
#Result
print"\nThe diffusion coefficient of Cu in Al at 550 degree celsius ="
print round((D*10**13),2)*10**-13,"metre square per sec"
print"\nThe diffusion length of Cu in Al =", round(x*1000,3),"mm"
from __future__ import division
import math
# Python Code Ex6.8 Activation energy for diffusion of silver
# in silicon: Page 206 (2010)
#Variable declaration
R = 8.314; # Molar gas constant, J/mol/K
T1 = 1350+273; # First temp. at which difuusion of Ag into Si takes place,K
T2 = 1100+273; # Second temp. at which difuusion of Ag into Si takes place,K
DRR = 8; # Ratio of diffusion rates of Ag in Si at T1 and T2
#Calculation
# As diffusion coefficient at temperature T1 is D1 = D0*math.exp(-Q/(R*T1))
# and that at temperature T2 is D1 = D0*math.exp(-Q/(R*T2)),
#so that the diffusion rates ratio
# D1/D2 = DRR = math.exp(Q/R*(1/T2-1/T1)), solving for Q, we have
# Activation energy for diffusion of Ag in Si, kJ/mol
Q = R*math.log(DRR)/((1/T2-1/T1)*1000);
#Result
print"\nThe activation energy for diffusion of Ag in Si =",round(Q,2),"kJ/mol"
from __future__ import division
import math
# Python Code Ex6.9 Activation energy and diffusion constant of a diffusion
#system obeying Arrhenius rate law: Page 207 (2010)
#Variable declaration
R = 1.987; # Molar gas constant, cal/mol/K
D_1100 = 8e-013;#Diffusivity of Ga in Si at1100 degree celsius,cm sq per sec
D_1300 = 1e-010;# Diffusivity of Ga in Si at 1300 degree celsius,cm sq per sec
T1 = 1100+273;#First temperature at which diffusion of Ga into Si takes place,K
T2 = 1300+273;#Second temperature at which diffusion of Ga into Si takes place
T = 1200+273; # Temperature at which diffusion of Ga
# into Si is to be calculated, kelvin
#Calculation
# Arrehenius equation in math.log10 form is given by
# math.log10(D) = math.log10(D0)-Q/(2.303*R*T) --- (a)
# Thus math.log10(D_1100) = math.log10(D0)-Q/(2.303*R*T1) --- (i)
# math.log10(D_1300) = math.log10(D0)-Q/(2.303*R*T2) --- (ii),
# On subtracting (ii) from (i), we get
# math.log10(D_1100/D_1300) = -Q/(2.303*R)*(1/T2-1/T1), solving for Q
# Activation energy for diffusion of Ga in Si, cal/mol
Q = (2.303*math.log10(D_1100/D_1300)*R)/(1/T2-1/T1);
# Putting Q in (ii) and solving for D0
D0 = math.exp(2.303*math.log10(D_1100)+Q/(R*T1))
# D0 = math.exp(2.303*math.log10(D_1300)+Q/(R*T2));
# Pre-exponential diffusion constant independent of temp.,cm square per sec
# Substituting D0, Q, R and T in (a) and solving for D, we have
# Diffusivity of the system, cm square per sec
D = math.exp(2.303*math.log10(D0)-Q/(R*T));
#Result
print"\nThe activation energy for diffusion of Ga in Si ="
print round((Q/1000),2),"kcal/mol"
print"\nThe pre-exponential diffusion constant, D0 ="
print round(D0),"cm square per sec"
print"\nThe diffusivity of the system =",
print round((D*10**11),2)*10**-11,"cm square per sec"
from __future__ import division
import math
# Python Code Ex6.10 Activation energy for diffusion rates at
# different temperatures: Page 208 (2010)
#Variable declaration
R = 8.314; # Molar gas constant, J/mol/K
T1 = 500+273;# First temperature at which diffusion of A into B takes place,K
T2 = 850+273;# Second temperature at which diffusion of A into B takes place,K
PDR = 1/4;#Penetration depth ratio at 500 degree celsius and 850 degree celsius
#Calculation
# x1/x2 = sqrt(D1/D2) i.e. PDR = sqrt(DRR), DRR is the diffusion rate ratio
# solving for DRR
DRR = PDR**2; # Diffusion rate ratio D1/D2 of A in B
# As diffusion coefficient at temperature T1 is D1 = D0*math.exp(-Q/(R*T1))
# and that at temperature T2 is D1 = D0*math.exp(-Q/(R*T2)),
# so that the diffusion rates ratio
# D1/D2 = DRR = math.exp(Q/R*(1/T2-1/T1)), solving for Q, we have
# Activation energy for diffusion of A in B, kJ/mol
Q = R*math.log(DRR)/((1/T2-1/T1)*1000);
#Result
print"\nThe activation energy for diffusion of A in B =",round(Q,2),"kJ/mol"
from __future__ import division
import math
# Python Code Ex6.11 Time required for carburizing of steel: Page 209 (2010)
#Variable declaration
C0 = 0.0018; # Intial carbon concentration of steel
Cx = 0.0030;#Carbon concentration of steel at 0.60 mm below the surface
Cs = 0.01; # Carbon concentration of steel at the surface
x = 0.6e-03; # Diffusion depth below the surface of the gear, m
D_927 = 1.28e-011;#Diffusion coefficient for carbon in iron,metre square per sec
Z1 = 1.0
Z2 = 1.1; # Preceding and succeeding values about Z from error function table
erf_Z1 = 0.8427
# Preceding and succeeding values about erf_Z from error function table
erf_Z2 = 0.8802;
#Calculation
erf_Z = (Cs-Cx)/(Cs-C0);#Error function of Z as a solution to Fick's second law
Z=Z1+((Z2-Z1)*(erf_Z-erf_Z1)/(erf_Z2-erf_Z1));
# As Z = x/(2*sqrt(D_927*t)),
#where Z is a constant argument of error function as erf(Z)
# Solving for t, we have
# Time necessary to increase the carbon content of steel, sec
t = (x/(2*Z))**2/D_927;
#Result
print"\nThe time necessary to increase the carbon content of steel ="
print round(t/60,2),"minutes"
from __future__ import division
import math
# Python Code Ex6.12 Carbon concentration
#of carburized steel at certain depth: Page 210 (2010)
#Variable declaration
C0 = 0.0020; # Initial carbon concentration of steel
Cs = 0.012; # Carbon concentration of steel at the surface
t = 10*60*60; # Carburizing time of steel, sec
x = 0.06*25.4*1e-03; # Diffusion depth below the surface of the gear, mm
D_927 = 1.28e-011;#Diffusion coeff. for carbon in iron,metre square per sec
Z1 = 1.1
Z2 = 1.2; # Preceding and succeeding values about Z from error function table
erf_Z1 = 0.8802
# Preceding and succeeding values about erf_Z from error function table
erf_Z2 = 0.9103;
#Calculation
Z = x/(2*(D_927*t)**0.5) # A constant argument of error function as erf(Z)
# Error function of Z as a solution to Fick's second law
efZ=(erf_Z1)+((erf_Z2-erf_Z1)*((Z-Z1)/(Z2-Z1)));
# Carbon concentration of carburized steel at 0.06 inch depth
Cx =-(efZ*(Cs-C0)-Cs)
#Result
print"\nThe carbon concentration of carburized steel at 0.06 inch depth ="
print round(Cx*100,2),"percent"
from __future__ import division
import math
# Python Code Ex6.13 Depth of decarburization below
#the surface of steel: Page 211 (2010)
#Variable declaration
C2 = 0.012; # Initial carbon concentration of steel
Cx = 0.008; # Carbon concentration of carburized steel at x metre depth
Cs = 0; # Carbon concentration of steel at the surface
t = 5*60*60; # Carburizing time of steel, sec
D_927 = 1.28e-011; # Diffusion coefficient for carbon in iron,metre sq per sec
Z1 = 0.65
Z2 = 0.70; # Preceding and succeeding values about Z from error function table
erf_Z1 = 0.6420
# Preceding and succeeding values about erf_Z from error function table
erf_Z2 = 0.6778;
#Calculation
erf_Z = abs((Cs-Cx)/(C2-Cs));#Error function of Z as solution to Fick's 2nd law
Z=Z1+(Z2-Z1)*((erf_Z-erf_Z1)/(erf_Z2-erf_Z1))
# As Z = x/(2*sqrt(D_927*t)),
#where Z is a constant argument of error function as erf(Z)
# Solving for x, we have
x = Z*2*(D_927*t)**0.5;# Depth of decarburization below the surface of steel,m
#Result
print "The minimum depth upto which post machining is to be done ="
print round(x*1000,2),"mm"
from __future__ import division
import math
#Python Code Ex6.14 Diffusion depth of P-type semiconductor B into Si:Page 212
#Variable declaration
C0 = 0; # Initial boron concentration of silicon
Cx = 1e+17; # Boron concentration at depth x below the silicon surface
Cs = 1e+18; # Boron concentration of silicon at the surface
T = 1100+273; # Absolute temperature of the system, kelvin
t = 2*60*60; # Time taken to diffuse boron into silicon, sec
D_1100 = 4e-013;# Diffusion coefficient for boron in silicon, cm square per sec
Z1 = 1.1; # Preceding and succeeding values about Z from error function table
Z2 = 1.2;
# Preceding and succeeding values about erf_Z from error function table
erf_Z1 = 0.8802;
erf_Z2 = 0.9103;
#Calculation
# Error function of Z as a solution to Fick's second law
erf_Z = abs((Cs-Cx)/(Cs-C0));
Z=Z1+((Z2-Z1)*(erf_Z-erf_Z1)/(erf_Z2-erf_Z1));
# As Z = x/(2*sqrt(D_927*t)),
#where Z is a constant argument of error function as erf(Z)
# Solving for x, we have
x = Z*2*(D_1100*t)**0.5; # Diffusion depth of boron into silicon
#Result
print"\nThe diffusion depth of boron into silicon =",round(x,6),"cm"