# Ch-7, Diffusion in solids¶

## example-7.1 page no-203¶

In :
#given
#outward flux of copper is
Jx=10**21  #per m**2 per sec
#concentration of copper at room temp on one side of aluminium which is 3 mm thickness
C1=2*10**13  # per m**3
dx=3*10**-3  #m
#concentration on the other side of aluminium
C2=4*10**6  # per m**3
#concentration gradient
M=(C1-C2)/dx  #m**4
#according to fick's law
#Jx=-Dx*dM/dx
#so Dx will be
Dx=-Jx*1/M  #m**2/s
print "the concentration gradient is %0.2e per m**4and diffusivity of copper is %0.2e m**2/s"%(M,Dx)

the concentration gradient is 6.67e+15 per m**4and diffusivity of copper is -1.50e+05 m**2/s


## example-7.2 page no-209¶

In :
from math import exp, sqrt
from scipy.special import erfinv
#given
#activation energy and constant D0 are given as
#for notation only we are using D01 and D02
Q1=83*10**3  #J/mol
Q2=157*10**3  #J/mol
D01=8*10**-7  #m**2/s
D02=700*10**-7  #m**2/s
#diffusivity of carbon in alpha-iron at 873 K (600+273) can be obtained by the equation
T=873  #K
#and
#gas constant
R=8.314  #J/mol K
Dx=D01*exp(-Q1/R/T)  #m**2/s
#concentration of carbon is given as 0.75% , therefore concentration of steel will be 0.25 %. thus
Ms=0.25  #conc. of steel
Mc=0.75  #conc. of carbon
#time of carburization is 9 hrs
t=9*3600  #sec
#so
C1=Mc
C2=C1-Ms
#carbon content on the surface
M=0.6
#we know that diffusion across a common interface is obtained by:-
#M=C1-C2*erf(x/2*sqrt(Dx/t))
#solving for X where X=erf(x/2*sqrt(Dx/t))
X=((C1-M)/C2)
#now for x
x=erfinv(X)*2*sqrt(Dx*t)*10**4   #m
print "depth of carburization is %0.2f m"%(x)

depth of carburization is 2.88 m


## example-7.3 page no-211¶

In :
from math import exp
from scipy.special import erfinv
#given
#temp
T=950+273  #K
QA1=83*10**3   #J/mole
QA2=157*10**3  #J/mole
R=8.314
D01=0.008*10**-4  #m**2/s
D02=0.7*10**-4  #m**2/s
Ms=0.8  #%
Mc=0  #%
Mx=0.6  #%
t=4*3600  #sec
D=1.38*10**-11  #m**2/s
#diffusivity at 950 degrees celcius
Dx=D01*exp(-QA2/R/T)   #m**2/s
#now we use fick's solution which is given by
#M(x,t)=C1-C2*erf(x/2/sqrt(Dt))
#first boundary condition is
#M(x,0)=0.8 for x<0
#on solving we get
#C1+C2=0.8
#second boundary condition is
#M(0,t)=0
#so we get
#C1-C2=0
#therefore we get
C1=0
C2=0.8
#so we get x as
x=erfinv((C1-Mx)/C2)*2*sqrt(D*t)
print "post machining is to be done upto %0.2e mm"%x

post machining is to be done upto -7.25e-04 mm


## example-7.4 page no-213¶

In :
from scipy.special import erfinv
#given
D0=0.002*10**-6  #m**2/s
Q=120*10**3  #J/mol
T=550+273  #K
#the condition for diffusion are
#M(x,0)=4% for x>0
#M(x,0)=0% for x<0
x=(0.25-0.10)*10**-3  #m
Mx=0.4  #%
R=8.314 #gas constant
#diffusion at 550 degrees celcius is
Dx=D0*exp(-Q/R/T)  #m**2/s
#by using
#M(x,t)=C1-C2*erf(x/2/sqrt(Dx*t))
#putting boundary conditions in above equation we get
C1=2   #%
C2=2  #%
#solving for t
#we get
t=(erfinv((C1-Mx)/C2)*2*sqrt(Dx)/x)**-2 #sec
print "the duration for which he material is kept at 550 degrees celcius is %0.2e sec"%(t)

the duration for which he material is kept at 550 degrees celcius is 1.42e+08 sec


## example-7.5 page no-215¶

In :
from __future__ import division
from scipy.special import erfinv
#given
Mx=10**22  #atoms/m**3
M0=10**24  #atoms/m**3
t=3*3600  #sec
T=1100+273  #K
D=7*10**-17   #m**2/s
#boundary cinditions are
#M(x,0)=0 for x>0 at t=0
#M(0,t)=10**24 atoms/m**3
#M(x,t)=C1-C2*erf(x/22/sqrt(D*t))
#putting boundary conditions in the above equation
#we get
C1=10**24  #atoms/m**3
C2=10**24  #atoms/m**3
#solving for x
#now for x we have
x=erfinv((C1-Mx)/C2)*2*sqrt(D*t)*10**3   #mm
print "depth below the surface at which the concentration is 10**22 atoms/m**3 is %f mm"%(x)

depth below the surface at which the concentration is 10**22 atoms/m**3 is 0.003167 mm


## example-7.6 page no-216¶

In :
#given
#temp and pressure of Nitrogen gas
T=400  #K
P=15 #atm
#Nitrogen conc at the inner surface of the tank
M=12  #kg/m**3
#constant D0 and activation energy
D0=5*10**-7  # m**2/s
Q=75*10**3  #J/mol
#thickness of tank wall
x=6*10**-3  #m
D=M/x #kg/m**4  (calculation mistake in book)
#gas constant
R=8.314  #J/mol/K
#dufusing flux
#Jx=-Dx*m/x kg/m**2/s
#Dx can be determined as follows
Dx=D0*exp(-Q/R/T)  #m**2/s
#so #diffusing flux will be
Jx=Dx*D  #kg/m**2/s  (calculation mistake in book)
print "diffusing rate of nitrogen is %0.2e kg/m**2/s"%(Jx)

diffusing rate of nitrogen is 1.61e-13 kg/m**2/s


## example-7.7 page no-217¶

In :
from math import log
from __future__ import division
#given
#ratio of rate of diffusion at 1350 and 110 degree C is 8
#so
#dM/dt at 1350 degree C(1623K)/dM/dt at 110degree C (1373K)=8
#so
Ratio=8
#we know that
#Dx=D0*exp(-Q/R/T)
#so Dx (at 1623 K)/Dx (at 1373 K)= exp(-Q/R/T1-Q/R/T2)
#where
T1=1623  #K
T2=1373  #K
#gas constant
R=8.314  #J/mol/K
#so we get
#Ratio=exp(-Q/R*(1/T1-1/T2))
#so we get Q as
Q=-log(Ratio)*R/(1/T1-1/T2)/1000  #KJ/mol
print "the activation energy for sulphur diffusion is %d KJ/mol"%(Q)

the activation energy for sulphur diffusion is 154 KJ/mol