import math
#Variable declaration
Kr=10.; #rate constant in m**3 gas/m**3 cat s
D=2E-5; #Diffusion coefficient of gas in m**2/s
dpbar=68.; #Average partilce size in micrometers
ephsilonm=0.5; #Void fraction of fixed bed
gammab=0.005; #Ratio of volume of dispersed solids to that of bubble phase
ephsilonmf=0.55; #Void fraction at minimum fluidization condition
umf=0.006; #Velocity at minimum fluidization condition in m/s
db=0.04; #Equilibrium bubble size in m
Lm=0.7; #Length of the bed in m
uo=0.1; #Superficial gas velocity in m/s
dbed=0.26; #Diameter of the bed in m
g=9.81; #Acceleration due to gravity in square m/s**2
#CALCULATION
ubr=0.711*(g*db)**0.5;#Rise velocity of bubble from Eqn.(6.7)
ub=uo-umf+ubr;#Velocity of bubbles in bubbling beds in Eqn.(6.8)
Kbc=4.5*(umf/db)+5.85*((D**0.5*g**0.25)/db**(5./4));#Gas interchange coefficient between bubble and cloud from Eqn.(10.27)
Kce=6.77*((D*ephsilonmf*0.711*(g*db)**0.5)/db**3)**0.5;#Gas interchange coefficient between emulsion and cloud from Eqn.(10.34)
delta=uo/ub;#Fraction of bed in bubbles from Eqn.(6.29)
fw=0.6;#Wake volume to bubble volume from Fig.(5.8)
gammac=(1-ephsilonmf)*((3/(ubr*ephsilonmf/umf-1))+fw);#Volume of solids in cloud to that of the bubble from Eqn.(6.36)
gammae=((1-ephsilonmf)*((1-delta)/delta))-gammab-gammac;#Volume of solids in emulsion to that of the bubble from Eqn.(6.35)
ephsilonf=1-(1-delta)*(1-ephsilonmf);#Void fraction of fixed bed from Eqn.(6.20)
Lf=(1-ephsilonm)*Lm/(1-ephsilonf);#Length of fixed bed from Eqn.(6.19)
Krtou=Kr*Lm*(1-ephsilonm)/uo;#Dimensionless reaction rate group from Eqn.(5)
Kf=gammab*Kr+1/((1/Kbc)+(1/(gammac*Kr+1/((1/Kce)+(1/(gammae*Kr))))));#Raction rate for fluidized bed from Eqn.(14)
XA=math.exp(-1*Kf*Lf/ub);#Conversion from Eqn.(16)
#OUTPUT
print 'The dimnesionless reaction rate group: %f'%Krtou
print 'The reaction rate for fluidized bed: %fs**-1'%Kf
print 'Conversion: %f'%XA
import math
#Variable declaration
umf=0.005; #Velocity at minimum fluidization condition in m/s
ephsilonm=0.52; #Void fraction of fixed bed
ephsilonmf=0.57; #Void fraction at minimum fluidization condition
DA=8.1E-6; #Diffusion coefficient of gas in m**2/s
DR=8.4E-6; #Diffusion coefficient of gas in m**2/s
Lm=5; #Length of the bed in m
dte=1; #Diameter of tube in m
Kr1=1.5; #rate constant in m**3 gas/m**3 cat s
Kr3=0.01; #rate constant in m**3 gas/m**3 cat s
gammab=0.005; #Ratio of volume of dispersed solids to that of bubble phase
uo=0.45; #Superficial gas velocity in m/s
db=0.05; #Equilibrium bubble size in m from Fig.(6.8)
ub=1.5; #Velocity of bubbles in bubbling bed in m/s from Fig.(6.11(a))
g=9.81; #Acceleration due to gravity in square m/s**2
#CALCULATION
ubr=0.711*(g*db)**0.5;#Rise velocity of bubble from Eqn.(6.7)
KbcA=4.5*(umf/db)+5.85*((DA**0.5*g**0.25)/db**(5.0/4));#Gas interchange coefficient between bubble and cloud from Eqn.(10.27)
KceA=6.77*((DA*ephsilonmf*0.711*(g*db)**0.5)/db**3)**0.5;#Gas interchange coefficient between emulsion and cloud from Eqn.(10.34)
KbcR=4.5*(umf/db)+5.85*((DR**0.5*g**0.25)/db**(5./4));#Gas interchange coefficient between bubble and cloud from Eqn.(10.27)
KceR=6.77*((DR*ephsilonmf*0.711*(g*db)**0.5)/db**3)**0.5;#Gas interchange coefficient between emulsion and cloud from Eqn.(10.34)
delta=uo/ub;#Fraction of bed in bubbles from Eqn.(6.29)
fw=0.6;#Wake volume to bubble volume from Fig.(5.8)
gammac=(1-ephsilonmf)*((3/(ubr*ephsilonmf/umf-1))+fw);#Volume of solids in cloud to that of the bubble from Eqn.(6.36)
gammae=((1-ephsilonmf)*((1-delta)/delta))-gammab-gammac;#Volume of solids in emulsion to that of the bubble from Eqn.(6.35)
ephsilonf=1-(1-delta)*(1-ephsilonmf);#Void fraction of fixed bed from Eqn.(6.20)
Lf=(1-ephsilonm)*Lm/(1-ephsilonf);#Length of fixed bed from Eqn.(6.19)
Krtou=Kr1*Lm*(1-ephsilonm)/uo;#Dimensionless reaction rate group from Eqn.(5)
Kr12=Kr1;#Since the reactions are a special case of Denbigh scheme
Kr34=Kr3;
Kf1=(gammab*Kr12+1/((1/KbcA)+(1/(gammac*Kr12+1/((1/KceA)+(1/(gammae*Kr12)))))))*(delta/(1-ephsilonf));#Rate of reaction 1 for fluidized bed from Eqn.(14)
Kf3=(gammab*Kr34+1/((1/KbcR)+(1/(gammac*Kr34+1/((1/KceR)+(1/(gammae*Kr34)))))))*(delta/(1-ephsilonf));#Rate of reaction 2 for fluidized bed from Eqn.(14)
Kf12=Kf1;
Kf34=Kf3;
KfA=((KbcR*KceA/gammac**2+(Kr12+KceA/gammac+KceA/gammae)* \
(Kr34+KceR/gammac+KceR/gammae))*delta*KbcA*Kr12*Kr34/ \
(1-ephsilonf))/(((Kr12+KbcA/gammac)*(Kr12+KceA/gammae)+Kr12*KceA/gammac) \
*((Kr34+KbcR/gammac)*(Kr34+KceR/gammae)+Kr34*KceR/gammac));
#Rate of raection with respect to A from Eqn.(35)
KfAR=Kr1/Kr12*Kf12-KfA;#Rate of reaction from Eqn.(34)
tou=Lf*(1-ephsilonf)/uo;#Residence time from Eqn.(5)
XA=1-math.exp(-Kf1*tou);#Conversion of A from Eqn.(26)
XR=1-((KfAR/(Kf12-Kf34))*(math.exp(-Kf34*tou)-math.exp(-Kf12*tou)));#Conversion of R from Eqn.(27)
SR=(1-XR)/XA;#Selectivity of R
#OUTPUT
print 'Rate of reaction 1 for fluidized bed:%.4f'%Kf1
print 'Rate of reaction 2 for fluidized bed:%.4f'%Kf3
print 'Rate of reaction 1 with respect to A:%.4f'%KfA
print 'The Conversion of Napthalene:%.0f percentage'%(XA*100);
print 'The selectivity of Phthalic anhydride:%.0f percentage'%(SR*100);
import math
#Variable declaration
Kr=3.; #rate constant in m**3 gas/m**3 cat s
db=0.12; #Equilibrium bubble size in m
D=9E-5; #Diffusion coefficient of gas in m**2/s
dpbar=68; #Average partilce size in micrometers
ephsilonm=0.42; #Void fraction of fixed bed
uo=0.4; #Superficial gas velocity in m/s
Lm=0.8; #Length of the bed in m
ephsilonmf=0.45; #Void fraction at minimum fluidization condition
umf=0.21; #Velocity at minimum fluidization condition in m/s
gammab=0; #Ratio of volume of dispersed solids to that of bubble phase
g=9.81; #Acceleration due to gravity in square m/s**2
#CALCULATION
ubr=0.711*(g*db)**0.5; #Rise velocity of bubble from Eqn.(6.7)
ub=uo-umf+ubr; #Velocity of bubbles in bubbling beds in Eqn.(6.8)
ubstar=ub+3*umf; #Rise velocity of the bubble gas from Eqn.(45)
delta=(uo-umf)/(ub+umf);#Fraction of bed in bubbles from Eqn.(6.46)
Kbe=4.5*(umf/db); #Interchange coefficient between bubble and emulsion from Eqn.(47)
Lf=Lm*(1-ephsilonm)/((1-delta)*(1-ephsilonmf));#Length of fixed bed
phi=((Kr/Kbe)**2*((1-ephsilonmf)-gammab*(umf/ubstar))**2+ \
((delta/(1-delta))+umf/ubstar)**2+2*(Kr/Kbe)*((1-ephsilonmf) \
-gammab*(umf/ubstar))*((delta/(1-delta))-umf/ubstar))**0.5;
#From Eqn.(52)
q1=0.5*Kr/umf*((1-ephsilonmf)+gammab*(umf/ubstar))+0.5*Kbe/umf* \
(((delta/(1-delta))+umf/ubstar)-phi);#From Eqn.(50)
q2=0.5*Kr/umf*((1-ephsilonmf)+gammab*(umf/ubstar))+0.5*Kbe/umf* \
(((delta/(1-delta))+umf/ubstar)+phi);#From Eqn.(50)
si1=0.5-0.5*((1-delta)/delta)*(umf/ubstar-Kr/Kbe*((1-ephsilonmf)- \
gammab*(umf/ubstar))-phi);#From Eqn.(51)
si2=0.5-0.5*((1-delta)/delta)*(umf/ubstar-Kr/Kbe*((1-ephsilonmf)- \
gammab*(umf/ubstar))+phi);#From Eqn.(51)
XA=1-(delta/(1-delta))*(1/(uo*phi))*((1-si2)*(si1*delta*ubstar+ \
(1-delta)*umf)*math.exp(-q1*Lf)+(si1-1)* \
(si2*delta*ubstar+(1-delta)*umf)*math.exp(-q2*Lf));
#Conversion from Eqn.(49)
Krtou=Kr*Lm*(1-ephsilonm)/uo;#Dimensionless reaction rate group from Eqn.(5)
#OUTPUT
print 'COmparing the values of 1-XA = %f and Krtou = %f with Fig.(6), \
we can conlcude that this operating condition is shown as point \
A in Fig.(3)'%(1-XA,Krtou);
print 'Line 2 gives the locus of conversions for different values of the \
reaction rate group for this fluidized contacting'
import math
#Variable declaration
uo=0.25; #Superficial gas velocity in m/s
db=0.025; #Equilibrium bubble size in m
Kr=1.5; #rate constant in m**3 gas/m**3 cat s
umf=0.21; #Velocity at minimum fluidization condition in m/s
Lm=0.8; #Length of the bed in m
ephsilonm=0.42; #Void fraction of fixed bed
g=9.81; #Acceleration due to gravity in square m/s**2
#CALCULATION
ubr=0.711*(g*db)**0.5;#Rise velocity of bubble from Eqn.(6.7)
ub=uo-umf+ubr;#Velocity of bubbles in bubbling beds in Eqn.(6.8)
delta=(uo-umf)/(ub+2*umf);#Fraction of bed in bubbles from Eqn.(55) since ub/umf<<1
XA=1-math.exp(-Kr*Lm*((1-ephsilonm)/uo)*(umf/uo)*(1-delta));#Conversion from Eqn.(57)
Krtou=Kr*Lm*(1-ephsilonm)/uo;#Dimensionless reaction rate group from Eqn.(5)
#OUTPUT
print 'Comparing the values of 1-XA = %f and Krtou = %f with Fig.(6), \
we can conlcude that this operating condition is shown \
as point B in Fig.(3)'%(1-XA,Krtou);
print 'Line 3 gives the locus of conversions for different values \
of the reaction rate group for this fluidized contacting'
import math
#Variable declaration
uo=0.3; #Superficial gas velocity in m/s
Lf=1.1; #Length of fixed bed in m
Hf=1.2; #Length of freeboard in m
db=0.04; #Equilibrium bubble size in m
umf=0.006; #Velocity at minimum fluidization condition in m/s
ephsilonmf=0.55; #Void fraction at minimum fluidization condition
gammab=0.005; #Ratio of volume of dispersed solids to that of bubble phase
Kr=10.; #rate constant in m**3 gas/m**3 cat s
D=2E-5; #Diffusion coefficient of gas in m**2/s
g=9.81; #Acceleration due to gravity in square m/s**2
#CALCULATION
ubr=0.711*(g*db)**0.5;#Rise velocity of bubble from Eqn.(6.7)
ub=uo-umf+ubr;#Velocity of bubbles in bubbling beds in Eqn.(6.8)
Kbc=4.5*(umf/db)+5.85*((D**0.5*g**0.25)/db**(5./4));
#Gas interchange coefficient between bubble and cloud from Eqn.(10.27)
Kce=6.77*((D*ephsilonmf*0.711*(g*db)**0.5)/db**3)**0.5;
#Gas interchange coefficient between emulsion and cloud from Eqn.(10.34)
delta=uo/ub;#Fraction of bed in bubbles from Eqn.(6.29)
ephsilonf=1-(1-delta)*(1-ephsilonmf);#Void fraction of fixed bed from Eqn.(6.20)
fw=0.6;#Wake volume to bubble volume from Fig.(5.8)
gammac=(1-ephsilonmf)*((3.0/(ubr*ephsilonmf/umf-1))+fw);
#Volume of solids in cloud to that of the bubble from Eqn.(6.36)
gammae=((1-ephsilonmf)*((1-delta)/delta))-gammab-gammac;
#Volume of solids in emulsion to that of the bubble from Eqn.(6.35)
Kf=(gammab*Kr)+1.0/((1.0/Kbc)+(1.0/(gammac*Kr+1.0/((1.0/Kce)+(1.0/(gammae*Kr))))));
#Raction rate for fluidized bed from Eqn.(14)
XA=1-math.exp(-1*Kf*Lf/ub);#Conversion at the top of dense bed from Eqn.(16)
etabed=(Kf*delta)/(Kr*(1-ephsilonf));#Reactor efficiency from Eqn.(22)
a=0.6/uo #Since uoa = 0.6s**-1 from Fig.(5)
adash=6.62; #From Fig.(5)
XA1=1-1.0/(math.exp(((1-ephsilonf)*Kr/(uo*a))*((1-math.exp(-a*Hf))- \
((1-etabed)/(1+(adash/a)))*(1-math.exp(-(a+adash)*Hf)))));#Conversion from Eqn.(64)
XA2=1-(1.0-XA1)*(1.0-XA);#Conversion at the exit from Eqn.(64)
#OUTPUT
print 'The conversion:'
print '\tAt the top pf the dense bed: %d percentage'%(XA1*100)
print '\tAt the reactor exit: %d percentage'%(XA2*100);
#Disclaimer: The value of kf deviate from the one given in textbook, where as it is close to the value obtained by manual calculation.