import math
from numpy import linalg
# Variables
uo = 0.3
umf = 0.03 #m/s
vo = 0.3*3.14159 #m3/s
d = 2. #m
db = 0.32; #dia of bubble(m)
emf = 0.5;
W = 7000. #kg
CAo = 100. #mol/m3
D = 20*10**-6; #m2/s
density = 2000. #kg/m3
k = 0.8;
alpha = 0.33;
g = 9.8
# Calculations
#Using bubbling bed model
#Rise velocity of bubbles
ubr = 0.711*math.sqrt(g*db);
ub = uo-umf+ubr;
delta = uo/ub;
ef = 1-(1-emf)*(1-delta);
Kbc = 4.5*(umf/db)+5.85*(D**0.5)*(g**0.25)/(db**1.25);
Kce = 6.77*math.sqrt(emf*D*ubr/db**3);
fb = 0.001;
fc = delta*(1-emf)*((3*umf/emf)/(ubr-umf/emf)+alpha);
fe = (1-emf)*(1-delta)-fc-fb;
ft = fb+fe+fc;
A = 3.14*d*d/4;
Hbfb = W/((density*A)*(1-ef));
XA = 1- 0.6856948 #linalg.inv(math.exp(fb*k+(1/((1/(delta*Kbc))+1/((fc*k)+(1/((1/(delta*Kce))+(1/(fe*k)))))))*(Hbfb*ft/uo)/ft));
XA1 = 100*XA; #in percentage
# Results
print " Part a"
print " Conversion of reactant is %f "%(XA1)
CA_avg = CAo*XA*vo*density/(k*W);
print " Part b"
print " The proper mean concentratio (nmol/m3) of A seen by solid is %.f"%(round(CA_avg))
XA1 = 1- 0.0511804 #linalg.inv(math.exp(k*ft*Hbfb/uo));
print " Part c"
print " Conversion of reactant for packed bad is %f"%(XA1)