import math
T = 293. ;#[K] Temperature
Ma = 2 ;#[kg/kmol] Molecular Mass
#Table A.8 Hydrogen-Air Properties at 298 K
Dab1 = .41*math.pow(10,-4); #[m^2/s] diffusion coefficient
#Table A.8 Hydrogen-Water Properties at 298 K
Dab2 = .63*math.pow(10,-8); #[m^2/s] diffusion coefficient
#Table A.8 Hydrogen-iron Properties at 293 K
Dab3 = .26*math.pow(10,-12); #[m^2/s] diffusion coefficient
#Table A.4 Air properties at 293 K
a1 = 21.6*math.pow(10,-6); #[m^2/s] Thermal Diffusivity
#Table A.6 Water properties at 293 K
k = .603 ;#[W/m.K] conductivity
rho = 998 ;#[kg/m^3] Density
cp = 4182 ;#[J/kg] specific Heat
#Table A.1 Iron Properties at 300 K
a3 = 23.1 * math.pow(10,-6); #[m^2/s]
#calculations
#Equation 14.14
#Hydrogen-air Mixture
DabT1 = Dab1*math.pow(T/298.,1.5);# [m^2/s] mass diffusivity
J1 = -DabT1*1; #[kmol/s.m^2] Total molar concentration
j1 = Ma*J1; #[kg/s.m^2] mass Flux of Hydrogen
Le1 = a1/DabT1; # Lewis Number Equation 6.50
#Hydrogen-water Mixture
DabT2 = Dab2*math.pow(T/298.,1.5);# [m^2/s] mass diffusivity
a2 = k/(rho*cp) ;#[m^2/s] thermal diffusivity
J2 = -DabT2*1 ;#[kmol/s.m^2] Total molar concentration
j2 = Ma*J2 ;#[kg/s.m^2] mass Flux of Hydrogen
Le2 = a2/DabT2 ;# Lewis Number Equation 6.50
#Hydrogen-iron Mixture
DabT3 = Dab3*math.pow(T/298.,1.5);# [m^2/s] mass diffusivity
J3 = -DabT3*1; #[kmol/s.m^2] Total molar concentration
j3 = Ma*J3; #[kg/s.m^2] mass Flux of Hydrogen
Le3 = a3/DabT3 ;# Lewis Number Equation 6.50
#results
print '%s %.1e' %('a (m^2/s) in 1 = ',a1)
print '%s %.1e' %('\n a (m^2/s) in 2 = ',a2)
print '%s %.1e' %('\na (m^2/s) in 3 = ',a3)
print '%s %.1e' %('\nDab (m^2/s) in 1 = ',DabT1)
print '%s %.1e' %('\n Dab (m^2/s) in 2 = ',DabT2)
print '%s %.1e' %('\n Dab (m^2/s) in 3 = ',DabT3)
print '%s %.1e' %('\n Le in 1 = ',Le1)
print '%s %.1e' %('\n Le in 2 = ',Le2)
print '%s %.1e' %('\n Le in 3 = ',Le3)
print '%s %.1e' %('\n ja (kg/s.m^2) in 1 = ',j1)
print '%s %.1e' %('\n ja (kg/s.m^2) in 2 = ',j2)
print '%s %.1e' %('\n ja (kg/s.m^2) in 3 = ',j3)
#Variable Initialization
import math
import numpy
from numpy import linalg
import matplotlib
from matplotlib import pyplot
T = 298 ;#[K] Temperature
D = 10*math.pow(10,-6) ;#[m]
L = 100*math.pow(10,-6); #[m]
H = .5 ;# Moist Air Humidity
p = 1.01325 ;#[bar]
#Table A.6 Saturated Water vapor Properties at 298 K
psat = .03165; #[bar] saturated Pressure
#Table A.8 Water vapor-air Properties at 298 K
Dab = .26*math.pow(10,-4); #[m^2/s] diffusion coefficient
#calculations
C = p/(8.314/100. *298) ;#Total Concentration
#From section 6.7.2, the mole fraction at x = 0 is
xa0 = psat/p;
#the mole fraction at x = L is
xaL = H*psat/p;
#Evaporation rate per pore Using Equation 14.41 with advection
N = (math.pi*D*D)*C*Dab/(4*L)*2.303*math.log10((1-xaL)/(1-xa0)) ;#[kmol/s]
#Neglecting effects of molar averaged velocity Equation 14.32
#Species transfer rate per pore
Nh = (math.pi*D*D)*C*Dab/(4*L)*(xa0-xaL) ;#[kmol/s]
#results
print '%s %.2e %s' %('\n Evaporation rate per pore Without advection effects',Nh,'kmol/s')
print '%s %.2e %s' %('and With Advection effects',N,'kmol/s')
#Variable Initialization
import math
D = .005 ;#[m] Diameter
L = 50*math.pow(10,-6); #[m] Length
h = .003 ;#[m] Depth
Dab = 6*math.pow(10,-14) ;#[m^2/s] Diffusion coefficient
Cas1 = 4.5*math.pow(10,-3) ;#[kmol/m^3] Molar concentrations of water vapor at outer surface
Cas2 = 0.5*math.pow(10,-3) ;#[kmol/m^3] Molar concentrations of water vapor at inner surface
#calculations
#Transfer Rate through cylindrical wall Equation 14.54
Na = Dab/L*(math.pi*D*D/4. + math.pi*D*h)*(Cas1-Cas2); #[kmol/s]
#results
print '%s %.2e %s' %('\n Rate of water vapor molar diffusive ttansfer through the trough wall ',Na,'kmol/s');
#END
#Variable Initialization
import math
D = .2 ;#[m] Diameter
L = 2*math.pow(10,-3) ;#[m] Thickness
p = 4 ;#[bars] Helium Pressure
T = 20+273. ;#[K] Temperature
#Table A.8 helium-fused silica (293K) Page 952
Dab = .4*math.pow(10,-13) ;#[m^2/s] Diffusion coefficient
#Table A.10 helium-fused silica (293K)
S = .45*math.pow(10,-3) ;#[kmol/m^3.bar] Solubility
#calculations
# By applying the species conservation Equation 14.43 and 14.62
dpt = -6*(.08314)*T*(Dab)*S*p/(L*D);
#results
print '%s %.2e %s' %('\n The rate of change of the helium pressure dp/dt',dpt,' bar/s');
#END
#Variable Initialization
import math
Dab = 8.7*math.pow(10,-8) ;#[m^2/s] Diffusion coefficient
Sab = 1.5*math.pow(10,-3) ;#[kmol/m^3.bar] Solubility
L = .0003 ;#[m] thickness of bar
p1 = 3 ;#[bar] pressure on one side
p2 = 1 ;#[bar] pressure on other side
Ma = 2 ;#[kg/mol] molecular mass of Hydrogen
#calculations
#Surface molar concentrations of hydrogen from Equation 14.62
Ca1 = Sab*p1 ; #[kmol/m^3]
Ca2 = Sab*p2 ; #[kmol/m^3]
#From equation 14.42 to 14.53 for obtaining mass flux
N = Dab/L*(Ca1-Ca2) ; #[kmol/s.m^2]
n = Ma*N ; #[kg/s.m^2] on Mass basis
#results
print '%s %.2e %s' %('\n The Hydrogen mass diffusive flux n =',n,' (kg/s.m^2)');
#END
#Variable Initialization
import math
Dab = 2*math.pow(10,-12) ;#[m^2/s] Diffusion coefficient
Ca0 = 4*math.pow(10,-3) ;#[kmol/m^3] Fixed Concentration of medication
Na = -.2*math.pow(10,-3) ;#[kmol/m^3.s] Minimum consumption rate of antibiotic
k1 = .1 ;#[s^-1] Reaction Coefficient
#calculations
#For firsst order kinetic reaction Equation 14.74
m = math.pow((k1/Dab),.5);
L = math.acosh(-k1*Ca0/Na) /m;
#results
print '%s %.1f %s' %('\n Maximum Thickness of a bacteria laden biofilm, that may be siccessfully treated is ',L*math.pow(10,6), 'mu-m');
#END
#Variable Initialization
import math
Dap = .1*math.pow(10,-12) ;#[m^2/s] Diffusion coefficient of medication with patch
Das = .2*math.pow(10,-12) ;#[m^2/s] Diffusion coefficient of medication with skin
L = .05 ;#[m] patch Length
rhop = 100 ;#[kg/m^3] Density of medication on patch
rho2 = 0 ;#[kg/m^3] Density of medication on skin
K = .5 ;#Partition Coefficient
t = 3600*24*7 ;#[s] Treatment time
#calculations
#Applying Conservation of species equation 14.47b
#By analogy to equation 5.62, 5.26 and 5.58
D = 2*rhop*L*L/(math.sqrt(math.pi))*math.sqrt(Das*Dap*t)/(math.sqrt(Das)+math.sqrt(Dap)/K);
#results
print '%s %.1f %s' %('\n Total dosage of medicine delivered to the patient over a one-week time period is',D*math.pow(10,6) ,'mg');