#Overall coefficient and driving force
yb = 0.04 #bulk concentration of A in the gas-phase
xbst = yb/1.2 #xb star(equilibrium value)
xb = 0.025 #actual concentration of the solute in the bulk liquid
m = 1.2 #slope of the equilibrium line
#on gas phase basis
diff1 = 0.04 - (1.2*xb)
#on liquid phase basis
diff2 = xbst - xb
ky = 7.2 #local individual mass transfer coefficients
kx = 4.6
xi = 0.03044 #interfacial concentration
yi = 1.2*xi
Ky = 1.0/((1.0/ky)+(m/kx)) #overall gas-phase coefficient
Kx = 1.0/((1.0/(m*ky) + (1.0/kx))) #overall liquid-phase coefficient
Na = ky*(yb - yi)
Mtrg = (1.0/ky)/(1.0/Ky) #fraction of the total mass transfer resistance in the gas-phase
Mtrl = (1.0/kx)/(1.0/Kx) #fraction of the total mass transfer resistance in the liquid-phase
print '(a) The interfacial concentrations are'
print ' xi = %0.5f'%xi,' and yi = %0.5f'%yi
print
print '(b) The overall gas-phase coefficient, Ky = %0.3f'%Ky,'kmol/(h)(m^2)(dy)'
print ' The overall liquid-phase coefficients, Kx = %0.3f'%Kx,'kmol/(h)(m^2)(dy)'
print
print '(c) The local mass flux, Na = %0.3f'%Na,'kmol/(h)(m^2)'
print ' Fraction of the total mass transfer resistance in the gas-phase = %0.3f'%Mtrg
print ' Fraction of the total mass transfer resistance in the liquid-phase = %0.3f'%Mtrl
#Interfacial resistance to mass transfer
#local individual mass transfer coefficients
ky = 60
kx = 35
#slope of the equilibrium line
m = 0.8
#local mass transfer flux
Nag = 1.2
yb = 0.08
xb = 0.03
ybst = m*xb
Ky = 1.0/((1.0/ky)+(m/kx)) #overall mass transfer coefficient
Na = Ky*(yb - ybst) #theoretical flux
print 'Given mass transfer flux is %0.1f'%Nag,'kmol/(h)(m^2) and Theorectical flux is %0.3f'%Na
Kytrue = (Nag)/(yb - m*xb)
resis = (1/Kytrue) - (1/Ky)
print 'The actual overall coefficient is %0.2f'%Kytrue,'kmol/(h)(m^2)(dy)'
print 'The interfacial resistance is %0.5f'%resis,'(h)(m^2)(dy)/kmol'
#Application to a gas-liquid system
P = 1.45 #Total pressure
mp = 3.318e4 #slope of the equilibrium relation given in the terms of partial pressure
xs = 0.065 #mole fraction of the solute in the bulk gas
pb = P*xs #partial pressure of the solute A in the bulk gas
T = 303 #Temperature of the falling water
R = 0.08317 #universal gas constant
kc = 90.3 #gas-phase mass transfer coefficient
ky = P*kc/(R*T) #gas-phase mass transfer coefficient
xi = 0.00201 #interfacial concentration of the solute in the liquid
yb = xs
fr = 0.136 #fraction of the gas-phase resistance
pi = mp*xi #in mmHg
pi = pi*1.013/760 #in bar
yi = pi/P
m = mp/(P*(760/1.013))
Na = ky*(yb - yi)
print '(a) Flux of the solute, Na = %0.5fkmol/(h)(m^2)'%Na
gR = (1/ky)
tmR = gR/0.136
lR = tmR*(1-0.136)
kx = m/lR
Nanew = xi - (Na/kx)
print '(b) The local flux, Na = %0.5f'%Nanew
Kx = 1/((1/kx) + (1/(m*ky)))
print '(c) The overall liquid-phase mass transfer coefficient is, Kx = %0.2fkmol/(h)(m^2)(dx)'%Kx
deltay = yb - yi
deltap = P*deltay
deltayO = yb - m*Nanew
print '(d) Individual gas-phase driving force = %0.4f mole fraction'%deltay
print ' Difference of partial pressure = %0.5f bar'%deltap
print ' Overall Gas-phase driving force = %0.4f'%deltayO
#Answers may vary very little due to round off error
#Mass transfer in a continuous-stirred cell
from sympy.solvers import solve
from sympy import Symbol
Yin = 0.142/(1 - 0.142) #14.2% SO2 was in gas flow rate
Yout = 0.11/(1 - 0.11) #As 11% SO2 is in outlet gas at steady state
Qair = 0.0535 #on SO2-free basis(flow rate)
ABspt = Qair*(Yin - Yout) #Rate of absorption
Qwater = 27 #Water flow rate(in ml/min)
Qwater = Qwater/18 #in gmol/min
xb = ABspt/1.5 #bulk concentration of the liquid
print '(a) Concentration of SO2 in the effluent solution: %0.3e mole fraction'%xb
yb = 0.11 #bulk concentration of the gas-phase
m = 31.3 #slope of the equilibrium concentratin line
ybst = m*xb
Dab = 1.51e-5 #diffusivity of SO2 in water
ky = 3.8 #gas-phase mass transfer coefficient
ABspt = ABspt*60/1000 #in kmol/h
Area = 31.5/10000 #in m^2
Ky = ABspt/(Area*(yb-ybst)) #overall mass-transfer coefficient
kx = m/((1/Ky)-(1/ky))
print ' Liquid phase mass transfer coefficient: %0.4f kmol/(h)(m^2)(dx)'%kx
#to calculate surface renewal rate
C = 1.0/(18.0/1000) #in kmol/m^3
kl = kx/C
kl = kl*100/3600
s = (kl*kl)/Dab
print ' The surface renewal rate is: %0.4f per second'%s
yb=0.1
nABspt = Qair*(Yin - (yb/0.9))
var = Symbol('var')
ybst = solve(nABspt*0.001*60 - Ky*Area*(yb-var),var)
xb = ybst[0]/m
Q = nABspt*18/xb
print '(b) New flow rate of water through the cell: %0.1f ml/min'%Q
#Answers may vary due to round-off error
#Graphical determination of interfacial concentration
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from sympy.solvers import solve
from sympy import Symbol
#equilibrium data
p = [0.6,1.7,4.7,8.1,11.8,19.7,36,52,79] #partial pressure
g = [0.02,0.05,0.1,0.15,0.2,0.3,0.5,0.7,1.0] #g SO2 per 100g water
P = 4.5 #total pressure
kx = 80 #gas-phase mass transfer coefficients
ky = 15 #liquid-phase mass transfer coefficients
P = P*760/1.013 #in mmHg
x = []
y = []
i = 0
for i in range(0,len(p)):
y.append(p[i]/P)
for i in range(0,len(g)):
x.append(((g[i]/64)/((g[i]/64)+(100/18))))
fig = plt.figure()
ax = fig.add_subplot(111)
plt.plot(x,y,label='Exact plot')
#Point P
xb = 0.0014 #the bulk concentration of two phases at the given locations
yb = 0.02
slope = -80.0/15
z = np.polyfit(x,y,2)
f = np.poly1d(z)
#calculate new x's and y's
x_new = np.linspace(x[0],x[-1],50)
y_new = f(x_new)
plt.plot(x_new,y_new,'r',label='After cuvefitting')
#finding the intersection point
xs = Symbol('xs')
x_int = solve(z[0]*xs**2 + z[1]*xs + z[2] + 5.3*xs - 0.0275,xs)
y_int = slope*x_int[1] + 0.0275
plt.plot(xb,yb,'bo')
plt.plot(x_int[1],y_int,'bo')
plt.plot((xb,x_int[1]),(yb,y_int),'b-')
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
plt.xlabel('mol fraction "x"',fontsize=16)
plt.ylabel('mol fraction "y"',fontsize=16)
plt.title('Plot of equilibrium line and calculating interfacial concentration',fontsize=14)
xy=(xb,yb)
ax.annotate('(%s, %s)' % xy, xy=xy, textcoords='data')
xint = '%0.5f'%x_int[1]
yint = '%0.4f'%y_int
xy=(xint,yint)
ax.annotate('(%s, %s)' % xy, xy=xy, textcoords='data')
print '(a) Interfacial concentration of the phases are xi = %0.5f'%x_int[1],' and yi = %0.4f.'%y_int
m = 5.65 #taking the equilibrium line almost linear near interfacial concentration
Ky = 1.0/((1.0/15)+(m/80))
Kx = 1.0/((1.0/(m*15))+(1.0/80))
Na = ky*(yb-y_int)
print '(b) Ky = %0.2f'%Ky
print ' Kx = %0.1f'%Kx
print ' Na = %0.3f'%Na
#Answers may vary due to round-off errors
#Number of trays for countercurrent contact
from math import log
from sympy import Symbol
F_C = 0.12 #feed concentration
Gs = 6000*(1-F_C) #feed rate on solute free basis
s = 6000*F_C #mass of solute entering
Yn = F_C/(1-F_C) #feed concentration
Y1 = 0.00136 #exit concentration
Xo = 0 #entering solvent does not have any solute in it
Ls = 7685 #solvent input rate
#doing mass balance
X1 = Gs*(Yn - Y1)/Ls #exit concentration of solute
Yn = Symbol('Yn+1')
sl = (Ls/Gs)
print 'Operating line is ',Yn,' = %0.3fXn'%sl,' + %f'%Y1
#Since the equilibrium line and operating lines are linear
#Therefore we can calculate the number of trays using Kremser equation
Yn = F_C/(1-F_C)
alpha = 1.32 #slope of the equilibrium line
A = Ls/(alpha*Gs) #Absorption factor
#using Kremser equation
N = log(((Yn-(alpha*Xo))/(Y1-(alpha*Xo)))*(1-(1.0/A))+(1.0/A))/log(A)
Nom = N/0.4
print 'Number of real trays = %d'%Nom
#Batch adsorption from a solution
%matplotlib inline
from math import log
from math import exp
import numpy as np
import matplotlib.pyplot as plt
cl = [15,40,60,100,135,210,325,450] #grams of clay used
pA = [9.1,7.81,6.93,5.66,4.76,3.38,2.44,1.48] #% A in the solution in equilibrium
i=0
X = []
Y = []
for i in range(0,len(cl)):
X.append(log((100-((90000/(100-pA[i]))-900))/cl[i]))
Y.append(log(((90000/(100-pA[i]))-900)/900))
#fitting the log-log data with degree 1
z = np.polyfit(X,Y,1)
f = np.poly1d(z)
print '(a) The test data fit the Freundlich adsorption isotherm in the form Y = aX^B'
print ' After fitting the data alpha is %0.3f'%exp(z[1]),' and beta is %0.3f'%z[0]
ads = 90 #amount of solute to be removed(in kg)
solv = 900 #amount of water remained(in kg)
Y = 10.0/solv
#putting in Freundlich adsorption isotherm
m = 90.0/(Y/exp(z[1]))**(1/z[0])
print '(b) Amount of adsorbent required %0.3f kg'%m
#Answers may vary due to round-off error
#Multistage crosscurrent contact
from sympy import Symbol
from sympy.solvers import solve
from math import log
Ls = 1000*(1-0.15) #amount of the carrier phase in the feed
Xo = 15.0/85 #feed concentration
e_con = 0.15*0.05/0.85 #exit concentration
Y1 = 3.75*e_con #equilibrium concentration
Yo = 0
Gs = 850*(Xo-e_con)/Y1
print '(a) Amount of solvent B required in single stage contact is %0.1f'%Gs
#an ideal three-stage crosscurrent cascade
#X1,X2,X3 are the intermediate concentrations
Gsn = Symbol('Gsn')
X1 = Symbol('X1')
X1 = solve(850*(0.1765-X1)-Gsn*3.75*X1,X1)
X2 = Symbol('X2')
X2 = solve(850*(X2-0.00882)-Gsn*3.75*0.00882,X2)
Gsn = solve(850*(X1[0]-X2[0])-Gsn*3.75*X2[0],Gsn)
nGs = 3*Gsn[0] #total amount of solvent
print '(b) The total amount of extracting solvent required is %0.0f kg'%nGs
#using material balance for nth stage and then integrating from X= Xo to X = Xf = 0.00882
Gs = (850/3.75)*log(Xo/e_con)
print '(c) Required amount of solvent is %0.2f kg'%Gs
#Answers may vary due to round-off error
#Rate of drug delivery
Cml = 0.513 #solubility of progesterone in the polymer(mg/cm^3)
beta = 0.022 #partition coefficient
Clb = 0 #drug concentration in the body fluid
Dm = 5.94e-3 #diffusivity of the drug in the polymer(in cm^2/h)
Dl = 2.08e-3 #diffudivity of the drug in the body(cm^2/h)
lm = 0.08 #thickness of the silicone membrane(cm)
dl = 0.008 #thickness of the diffusion fluid layer(cm)
Na = (beta*Cml - Clb)/((beta*lm/Dm)+(dl/Dl))
print 'Flux of the drug, Na = %0.2e mg/cm^2.h'%Na