#Molecular Diffusion of Helium in Nitrogen
#Variable declaration
z1 = 0.0 #Location of one end of pipe, m
z2 = 0.2 #Location of other end of pipe, m
T = 298 #Temeperature of gas, K
pA1 = 0.6 #Partial pressure of Helium at end 1, atm
pA2 = 0.2 #Partial pressure of Helium at end 2, atm
DAB = 0.687e-4 #Diffusivity of Helium in Nitrogen, m2/s
P = 1. #Total pressure, atm
R = 82.057e-3 #Gas Constant,m3.atm/(kmol.K)
#Calculation SI Units
JAz = DAB*(pA1-pA2)/(R*T*(z2-z1))
#Result
print 'Flux of Helium through the Nitrogen in SI units: %5.2e'%(JAz), "kmol/(m2.s)"
#Variable declaration cgs Units
z1 = 0.0 #Location of one end of pipe, m
z2 = 20 #Location of other end of pipe, m
DAB = 0.687 #Diffusivity of Helium in Nitrogen, cm2/s
R = 82.057 #Gas Constant,cm3.atm/(gmol.K)
#Calculation cgs Units
JAz = DAB*(pA1-pA2)/(R*T*(z2-z1))
#Result
print 'Flux of Helium through the Nitrogen in cgs units: %5.2e'%(JAz), "gmol/(cm2.s)"
#Equimolar Counterdiffusion
#Variable declaration
z1 = 0.0 #Location of one end of pipe, m
z2 = 0.1 #Location of other end of pipe, m
T = 298 #Temeperature of gas, K
pA1 = 1.013e4 #Partial pressure of Ammonia at end 1, Pa
pA2 = 0.507e4 #Partial pressure of Ammonia at end 2, Pa
DAB = 0.23e-4 #Diffusivity of Ammonia in Nitrogen, m2/s
P = 1.0132e5 #Total pressure, Pa
R = 8314.3 #Gas Constant,m3.Pa/(kmol.K)
#Calculation
JAz = DAB*(pA1-pA2)/(R*T*(z2-z1))
pB1 = P - pA1
pB2 = P - pA2
JBz = DAB*(pB1-pB2)/(R*T*(z2-z1))
#Result
print 'Flux of Ammonia through the Nitrogen:%10.2e '%(JAz), "kmolA/(m2.s)"
print 'Flux of Nitrogen through the Ammonia:%10.2e '%(JBz), "kmolB/(m2.s)"
#Diffusion of Water Through Stagnant, Nondiffusing Air
from math import log
#Variable declaration English Units
z1 = 0.0 #Location of one end of pipe, ft
z2 = 0.5 #Location of other end of pipe, ft
T = 68 #Temeperature of gas, °F
DAB = 0.25e-4 #Diffusivity of Water in Air, m2/s
p0w = 17.54 #Vapor pressure of Water at 68 °F, mmHg
R = 0.73 #Gas Constant, ft3.atm/(lbmol.°R)
P = 1.
#Calculation English units
DAB = DAB*3.875e4
p0w = p0w/760
pA1 = p0w
pA2 = 0.
T = T + 460.
pB1 = P - pA1
pB2 = P - pA2
pBM = (pB2-pB1)/log(pB2/pB1)
NA = DAB*P*(pA1-pA2)/(R*T*(z2-z1)*pBM)
#Result
print 'Rate of evaporation of water at steady state:English Units %10.3e'%(NA), "lbmol/(ft2.hr)"
#Variable declaration SI Units
z1 = 0.0 #Location of one end of pipe, m
z2 = 0.1524 #Location of other end of pipe, m
T = 293 #Temeperature of gas, K
p0w = 17.54 #Vapor pressure of Water at 293 K, mmHg
DAB = 0.25e-4 #Diffusivity of Water in Air, m2/s
P = 1.01325e5 #Total pressure, Pa
R = 8314.3 #Gas Constant,m3.Pa/(kmol.K)
#Calculation SI units
p0wSI = p0w*P/760
pA1 = p0wSI
pA2 = 0.
JAz = DAB*(pA1-pA2)/(R*T*(z2-z1))
pB1 = P - pA1
pB2 = P - pA2
pBM = (pB2-pB1)/log(pB2/pB1)
NA = DAB*P*(pA1-pA2)/(R*T*(z2-z1)*pBM)
#Result
print 'Rate of evaporation of water at steady state SI Units:%10.3e'%(NA), "kmol/(m2.s)"
#Evaporation of Napthalene Sphere
# Variable declaration
r = 2. #Radius of Napthalene ball, mm
Tair = 318. #Ambient temperature of air, K
Tball = 318. #Temperature of the Napthalene ball, K
p0N = 0.555 #Vapor pressure of Napthalene at 318K, mmHg
DAB = 6.92e-6 #Diffusion Coefficient, m2/s
P = 101325. #Atmospheric pressure, Pa
R = 8314. #Gas constant, m3.Pa/(kmol.K)
# Calculation
pA1 = p0N*P/760
r = r/1000
pA2 = 0.
pB1 = P - pA1
pB2 = P- pA2
pBM = (pB1+pB2)/2.
NA = DAB*P*(pA1-pA2)/(R*Tair*r*pBM)
#Result
print 'Rate of evaporation of Napthalene from surface is:%10.3e'%(NA),"kmol A/(m2.s)"
#Estimation of diffusivity of a Gas Mixture
from math import sqrt
# Variable declaration
P = 1. #Pressure in atmosphere
MA = 74.1 #Molecular weight of Butanol
MB = 29. #Molecular weight of Air
T1 = 0. #Temperature, deg C
T2 = 25.9 #Temperature, deg C
T3 = 0. #Temperature, deg C
P3 = 2.
# Calculation
def BinaryDiffusivity(P,T):
dab = 1.0e-7*T**1.75*sqrt(1./MA+1./MB)/(P*(SvA**(1./3)+ SvB**(1./3))**2)
print "The binary diffusivity Butanol in Air at",round(P,2),"&",T,'K is %5.3e'%(dab),"m2/s"
return dab
#Atomic Diffusion volumes using table 6.2-2 pp-396
SvA = 4*16.5+10*1.98+1*5.48
SvB = 20.1
T1 = 273 + T1
DAB1 = BinaryDiffusivity(P,T1)
T2 = 273 + T2
DAB2 = BinaryDiffusivity(P,T2)
DAB3 = DAB1*(1./2.)
print 'The binary diffusivity Butanol in Air at %3.1f & %4.1f K is %5.3e m2/s'%(P3,T1,DAB3)
#OR
#DAB3 = BinaryDiffusivity(P3,T1)
#Result
print 'The answers different than book because of book uses rounded numbers'
#Diffusion of Ethanol(A) through Water(B)
#Variable declaration
T = 298 #Temperature of solution, K
rho1 = 972.8 #Density of solution at 16.8% wt, kg/m3
rho2 = 998.1 #Density of solution at 6.8% wt, kg/m3
DAB = 0.740e-9 #Diffusivity of Ethanol, m2/s
MA = 46.05 #Molecular wt of ethanol
MB = 18.02 #Molecular wt of Water
xw1 = 16.8 #weight % of Ethanol at 1
xw2 = 6.8 #weight % of Ethanol at 2
z1 = 0. #Location 1, m
z2 = 2.e-3 #Location 2, m
#Calculation
xmA1 = xw1/MA/(xw1/MA+(100-xw1)/MB)
xmA2 = xw2/MA/(xw2/MA+(100-xw2)/MB)
xmB1 = 1. - xmA1
xmB2 = 1. - xmA2
MW1 = MA*xmA1 + MB*xmB1
MW2 = MA*xmA2 + MB*xmB2
Cav = (rho1/MW1+rho2/MW2)/2.
xBM = (xmB1+xmB2)/2.
NA = DAB*Cav*(xmA1-xmA2)/(xBM*(z2-z1))
#Result
print 'Steady State flux of Ethanol: %4.3e'%(NA), "kgmol/(m2.s)"
#Prediction of Liquid Diffusivity
from math import sqrt
#Variable declaration
T1 = 25 #Temperature of solution, degC
T2 = 50 #Temperature of solution, degC
mu25B = 0.8937e-3 #Viscosity of Water at 25 degC, Pa.s
mu50B = 0.5494e-3 #Viscosity of Water at 50 degC, Pa.s
MB = 18.02
#Calculation
mvA = 3*0.0148 + 6*0.0037 + 1*0.0074
si = 2.6
def LiquidDiffusivity(muB,T):
dab = 1.173e-16*sqrt(si*MB)*T/(muB*mvA**0.6)
print 'Liquid diffusivity of Acetone in Water at %5.3f °C is %5.3e m2/s' %(T,dab)
return
LiquidDiffusivity(mu25B,T1+273)
LiquidDiffusivity(mu50B,T2+273)
#Result
#Prediction of Diffusivity of Albumin
#Variable declaration
T = 298 #Temperature, K
MA = 67500 #Molecular Weight of Albumin
muw298 = 0.8937e-3 #Viscosity of water at 298 K, Pa.s
#Calculations
DAB = 9.4e-15*T/(muw298*MA**(1./3))
#Result
print 'Diffusivity of Albumin in Water at 298 K %3.2e m2/s'%(DAB)
#Diffusion of urea in Agar
#Variable Declaration
CA1 = 0.2 #Concentration at one end of tube
CA2 = 0.0 #Concentration at other end of tube
z1 = 0.0
z2 = 0.04 #Location of other end of tube from end 1
DAB = 0.727e-9 #Diffusivity of urea
#Calculation
NA = DAB*(CA1-CA2)/(z2-z1)
#Result
print 'Steady State Flux of urea through agar solution:%4.3e kgmol/(m2.s)'%(NA)
#Diffusion of H2 through Neoprene Membrance
#Variable Declaration
T = 17 #Temnperature of hydrogen, deg C
pH21 = 0.01 #Partial pressure of H2 on one end of membrane, atm
z = 0.5 #Membrane thickness, mm
pH22 = 0.0 #Partial pressure of H2 on other end of membrane, atm
S = 0.051 #Solubility of H2 in Neoprene, [m3 at STP/(m3solid.atm)]
DAB = 1.03e-10 #Diffusivity at 17 deg C, m2/s
#Calculations
cA1 = S*pH21/22.414
cA2 = S*pH22/22.414
NA = DAB*(cA1-cA2)/(z/1000.)
#Results
print 'concentrations at face 1 and face 2 are %3.2e and %3.2e kgmol H2/m3 solid respectively'%(cA1,cA2)
print 'Steady State Flux of Hydrogen through Neoprene membrane:%5.2e'%(NA),"kgmol H2/(m2.s)"
#Diffusion through a Packaging Film using Permeability
#Variable Declaration
z = 0.00015 #Thickness of the pkg film, m
T = 30. #Temperature of the film, deg C
pO21 = 0.21 #Partial pressure of O2 outside the film, atm
pO22 = 0.01 #Partial pressure of O2 inside the film, atm
PM = 4.17e-12 #Permeability of the film m3 solute STP/(s.m2.atm/m)
#Calcualtions
NA = PM*(pO21-pO22)/(22.414*z)
#Result
print 'Diffusional flux of the Oxygen through the polyethylene film:%10.3e kgmol/(m2.s)'%(NA)
#Diffusion of KCl in porous Silica
#Variable Declaration
z = 0.002 #Thickness of Silica, m
DAB = 1.87e-9 #Diffusivity of KCl in water, m2/s
cA1 = 0.1 #Concentration of KCl, kmol/m3
cA2 = 0.0 #Concentration of KCl on other side of Silica
epps = 0.3 #Porosity of Silica
tau = 4.0 #Tortuosity
#Calculation
NA = epps*DAB*(cA1-cA2)/(tau*z)
#Results
print 'Diffusional flux of the KCl through the Porous Silica: %5.2e kmol/(m2.s)'%(NA)
#Numerical Method for Convection and Steady State Diffusion
import numpy as np
#Variable Declaration
ci = 6.00e-3 #Inside concentration, kmol/m3
kc = 2.0e-7 #Outside convective coefficient, m/s
cinf = 2.00e-3 #Outside concentration, kmol/m3
DAB = 1.0e-9 #Diffusivity in solid, m2/s
dx = dy = 0.005 #Grid size in x and y directions, m
K = 1.0 #Distribution coefficient
#Calculations
kdxbyD = kc*dx/DAB
#Index used are one less as in book
c1 = np.zeros(5)
c2 = np.zeros(5)
c3 = np.zeros(5)
cinf = cinf*1e3
ci = ci*1e3
np.set_printoptions(precision=2)
#Initializations
c1[2] = c1[3] = ci
c2[1] = 3.8
c1[1] = c2[2] = c2[4] = 4.2
c2[3] = 4.4
c3[0] = 2.5
c3[1] = c2[0] = 2.7
c3[2] = c3[4] = 3.0
c3[3] = 3.2
for j in range(3):
N22 = c1[1]+c3[1]+c2[0]+c2[2]-4*c2[1]
c2[1] = (c1[1]+ c3[1]+c2[0]+c2[2])/4
N23 = c2[1]+c2[3]+c1[2]+c3[2]-4*c2[2]
c2[2] = c2[4] = c1[1] = (c2[1]+c2[3]+c1[2]+c3[2])/4
N24 = c2[2]+c2[4]+c1[3]+c3[3]-4*c2[3]
c2[3] = (c2[2]+c2[4]+c1[3]+c3[3])/4
N31 = kdxbyD*cinf + (c2[0]+c3[1])/2 - (kdxbyD+1)*c3[0]
c3[0] = (kdxbyD*cinf + (c2[0]+c3[1])/2)/(kdxbyD+1)
N32 = kdxbyD*cinf + (2*c2[1]+c3[0]+c3[2])/2 - (kdxbyD+2)*c3[1]
c3[1] = c2[0] =(kdxbyD*cinf + (2*c2[1]+c3[0]+c3[2])/2)/(kdxbyD+2)
N33 = kdxbyD*cinf + (2*c2[2]+c3[1]+c3[3])/2-(kdxbyD+2)*c3[2]
c3[2] = c3[4] = (kdxbyD*cinf + (2*c2[2]+c3[1]+c3[3])/2)/(kdxbyD+2)
N34 = kdxbyD*cinf + (2*c2[3]+c3[2]+c3[4])/2 -(kdxbyD+2)*c3[3]
c3[3] = (kdxbyD*cinf + (2*c2[3]+c3[2]+c3[4])/2)/(kdxbyD+2)
c1[0] = c3[2]
c1[4] = c1[2]
No = kc*(dx*1.)*((c3[0]-cinf)/2+(c3[1]-cinf)+(c3[2]-cinf)+(c3[3]-cinf)/2)*1e-3
Ni = DAB*(dx*1.)*((c1[2]-c2[2])+(c1[3]-c2[3])/2)*1e-3/dy
#Results
print "Concentration Values at nodes are as follows"
print "C 1 2 3 4 "
print 1,c1[:4]
print 2,c2[:4]
print 3,c3[:4]
print '\nThe average flux is %6.3e kmol/s'%((Ni+No)*.5)