# Variables
# given
v = 1.; #[cm/sec] - volume velocity or bulk velocity
vol = 1.; #[cm**3] - volume
na = 2.; # moles of a
nb = 3.; # moles of b
nc = 4.; # moles of c
mma = 2.; #molecular weight of a
mmb = 3.; #molecular weight of b
mmc = 4.; #molecular weight of c
ma = na*mma; #[g] weight of a
mb = nb*mmb; #[g] weight of b
mc = nc*mmc; #[g] weight of c
NabyA = 2.+2; #[mol/cm**2*s] - molar flux = diffusing flux +convected flux
NbbyA = -1.+3; #[mol/cm**2*s] - molar flux = diffusing flux +convected flux
NcbyA = 0.+4; #[mol/cm**2*s] - molar flux = diffusing flux +convected flux
NtbyA = NabyA+NbbyA+NcbyA; #[mol/cm**2*s] - total molar flux
# Calculations
# on a mass basis,these corresponds to
nabyA = 4.+4; #[g/cm**2*s]; - mass flux = diffusing flux +convected flux
nbbyA = -3.+9; #[g/cm**2*s]; - mass flux = diffusing flux +convected flux
ncbyA = 0.+16; #[g/cm**2*s]; - mass flux = diffusing flux +convected flux
ntbyA = nabyA+nbbyA+ncbyA; #[g/cm**2*s] - total mass flux
# concentrations are expressed in molar basis
CA = na/vol; #[mol/cm**3]
CB = nb/vol; #[mol/cm**3]
CC = nc/vol; #[mol/cm**3]
CT = CA+CB+CC; #[mol/cm**3] - total concentration
# densities are on a mass basis
pa = ma/vol; #[g/cm**3]
pb = mb/vol; #[g/cm**3]
pc = mc/vol; #[g/cm**3]
pt = pa+pb+pc; #[g/cm**3]
Ua = NabyA/CA; #[cm/sec];
Ub = NbbyA/CB; #[cm/sec];
Uc = NcbyA/CC; #[cm/sec];
# the same result will be obtained from dividing mass flux by density
Uz = (pa*Ua+pb*Ub+pc*Uc)/(pa+pb+pc);
# Results
print " Uz = %.3f cm/sec"%(Uz);
Uzstar = (NtbyA/CT);
print " Uz* = %.2f cm/sec"%(Uzstar);
print " For this Example both Uz and Uz* are slightly greater than the volume \
velocity of 1cm/sec, because there is a net molar and \n mass diffusion in the positive direction."
# Variables
# given (from Example 5.9)
na = 2.; # moles of a
nb = 3.; # moles of b
nc = 4.; # moles of c
mma = 2.; #molecular weight of a
mmb = 3.; #molecular weight of b
mmc = 4.; #molecular weight of c
ma = na*mma; #[g] weight of a
mb = nb*mmb; #[g] weight of b
mc = nc*mmc; #[g] weight of c
NabyA = 2.+2; #[mol/cm**2*s] - molar flux = diffumath.sing flux +convected flux
NbbyA = -1.+3; #[mol/cm**2*s] - molar flux = diffusing flux +convected flux
NcbyA = 0.+4; #[mol/cm**2*s] - molar flux = diffusing flux +convected flux
NtbyA = NabyA+NbbyA+NcbyA; #[mol/cm**2*s] - total molar flux
vol= 1.
# Calculations
# on a mass basis,these corresponds to
nabyA = 4+4; #[g/cm**2*s]; - mass flux = diffusing flux +convected flux
nbbyA = -3+9; #[g/cm**2*s]; - mass flux = diffusing flux +convected flux
ncbyA = 0+16; #[g/cm**2*s]; - mass flux = diffusing flux +convected flux
# concentrations are expressed in molar basis
CA = na/vol; #[mol/cm**3]
CB = nb/vol; #[mol/cm**3]
CC = nc/vol; #[mol/cm**3]
CT = CA+CB+CC; #[mol/cm**3] - total concentration
# densities are on a mass basis
pa = ma/vol; #[g/cm**3]
pb = mb/vol; #[g/cm**3]
pc = mc/vol; #[g/cm**3]
Ua = NabyA/CA; #[cm/sec];
Ub = NbbyA/CB; #[cm/sec];
Uc = NcbyA/CC; #[cm/sec];
U = (pa*Ua+pb*Ub+pc*Uc)/(pa+pb+pc);
Ustar = (NtbyA/CT);
# the fluxes relative to mass average velocities are found as follows
JabyA = CA*(Ua-U); #[mol/cm**2*sec]
JbbyA = CB*(Ub-U); #[mol/cm**2*sec]
JcbyA = CC*(Uc-U); #[mol/cm**2*sec]
# Results
print " fluxes relative to mass average velocities are-";
print " Ja/A = %.4f mol/cm**2*sec"%(JabyA);
print " Jb/A = %.4f mol/cm**2*sec"%(JbbyA);
print " Jc/A = %.4f mol/cm**2*sec"%(JcbyA);
jabyA = pa*(Ua-U); #[g/cm**2*sec]
jbbyA = pb*(Ub-U); #[g/cm**2*sec]
jcbyA = pc*(Uc-U); #[g/cm**2*sec]
print " ja/A = %.4f g/cm**2*sec"%(jabyA);
print " jb/A = %.4f g/cm**2*sec"%(jbbyA);
print " jc/A = %.4f g/cm**2*sec"%(jcbyA);
# the fluxes relative to molar average velocity are found as follows
JastarbyA = CA*(Ua-Ustar); #[mol/cm**2*sec]
JbstarbyA = CB*(Ub-Ustar); #[mol/cm**2*sec]
JcstarbyA = CC*(Uc-Ustar); #[mol/cm**2*sec]
print " fluxes relative to molar average velocities are-";
print " Ja*/A = %.4f mol/cm**2*sec"%(JastarbyA);
print " Jb*/A = %.4f mol/cm**2*sec"%(JbstarbyA);
print " Jc*/A = %.4f mol/cm**2*sec"%(JcstarbyA);
jastarbyA = pa*(Ua-Ustar); #[g/cm**2*sec]
jbstarbyA = pb*(Ub-Ustar); #[g/cm**2*sec]
jcstarbyA = pc*(Uc-Ustar); #[g/cm**2*sec]
print " ja*/A = %.4f g/cm**2*sec"%(jastarbyA);
print " jb*/A = %.4f g/cm**2*sec"%(jbstarbyA);
print " jc*/A = %.4f g/cm**2*sec"%(jcstarbyA);
import math
# Variables
# given
T = 0+273.15; #[K] - temperature in Kelvins
pa2 = 1.5; #[atm] - partial presuure of a at point2
pa1 = 0.5; #[atm] - partial pressure of a at point 1
z2 = 20.; #[cm] - position of point 2 from reference point
z1 = 0.; #[cm] - position of point1 from reference point
p = 2.; #[atm] - total pressure
d = 1.; #[cm] - diameter
D = 0.275; #[cm**2/sec] - diffusion coefficient
A = (math.pi*((d)**2))/4.;
R = 0.082057; #[atm*m**3*kmol**-1*K**-1] - gas constant
# Calculations
# (a) using the formula Na/A = -(D/(R*T))*((pa2-pa1)/(z2-z1))
Na = (-(D/(R*T))*((pa2-pa1)/(z2-z1)))*(A)/(10.**6);
print " Na = %.2e kmol/sec \n The negative sign indicates diffusion from point 2 to point 1"%(Na);
pb2 = p-pa2;
pb1 = p-pa1;
# (b) using the formula Na/A = ((D*p)/(R*T*(z2-z1)))*ln(pb2/pb1)
Na = (((D*p)/(R*T*(z2-z1)))*math.log(pb2/pb1))*(A)/(10**6);
# Results
print " Na = %.2e kmol/sec"%(Na);
print " The induced velocity increases the net transport of A by the ratio of 10.6*10**-10 \
to 4.82*10**-10 or 2.2 times.This increse is equivalent to 120 percent"
# Variables
# given
T = 0+273.15; #[K] - temperature in Kelvins
pa2 = 1.5; #[atm] - partial presuure of a at point2
pa1 = 0.5; #[atm] - partial pressure of a at point 1
z2 = 20.; #[cm] - position of point 2 from reference point
z1 = 0.; #[cm] - position of point1 from reference point
p = 2.; #[atm] - total pressure
d = 1.; #[cm] - diameter
D = 0.275; #[cm**2/sec] - diffusion coefficient
# Calculations
A = (math.pi*((d)**2.))/4;
R = 0.082057; #[atm*m**3*kmol**-1*K**-1] - gas consmath.tant
k = 0.75;
# umath.sing the formula (Na/A) = -(D/(R*T*(z2-z1)))*ln((1-(pa2/p)*(1-k))/(1-(pa1/p)*(1-k)))
NabyA = -(D/(R*T*(z2-z1)))*(2*0.7854)*math.log((1-(pa2/p)*(1-k))/(1-(pa1/p)*(1-k)))/(10**6);
# Results
print " Na/A = %.2e kmol/sec"%(NabyA);
print " Note that this answer is larger than the rate for equimolar counter diffusion \
but smaller tahn the rate for diffusion through a stagnant film. \nSometimes the\
rate for diffusin through a stagnant film can be considered as an upper bound\
if k ties between zero and one"
# Variables
# given
l = 4.; #[m] - length of the tube
id_ = 1.6*10**-3; #[m] - insid_e diameter
Nkn = 10.; # - knudsen no.
Ma = 92.; # - molecular weight of gas
mu = 6.5*10**-4; #[kg/m*sec] - vismath.cosity
T = 300.; #[K] - temperature
R = 8314.; #[kPa*m**3*kmol**-1*K**-1] - gas consmath.tant
lambdaA = Nkn*id_; #[m] mean free path
# Calculations
# for calculating pressure umath.sing the formula lamdaA = 32*(mu/p)*((R*T)/(2*pi*Ma))**(1/2)
p = 32*(mu/lambdaA)*((R*T)/(2*math.pi*Ma))**(1/2.);
patm = p/(1.01325*10**5);
# Results
print " p = %.2f kg/m*sec**2 = %.2f Pa = %.2e atm"%(p,p,patm);
print " The value of 10 for the knudsen number is on the border \
between Knudsen diffusion and transition flow";