In [1]:

```
import math
# Variables
dp = 2.4*(10**-3);L = dp/6;
De = 5*10**-5;
Keff = 1.6;
h = 160. #heat transfer coefficient(KJ/hr.m2cat.K)
kg = 300. #mass transfer coefficient(m3/hr.m2cat)
Hr = -160. #KJ/molA
CAg = 20. #mol/m3
rA_obs = 10.**5 #mol/hr.m3cat
# Calculations and Results
kobs = rA_obs/CAg;
Vp = 3.14*(dp**3)/6;
S = 3.14*(dp**2);
ratio = kobs*Vp/(kg*S);
print " Part a"
if ratio<0.01 :
print " Resistance to mass transport to film should not influence rate of reaction"
else:
print " Resistance to mass transport to film should influence rate of reaction"
print " Part b"
Mw = rA_obs*(L**2)/(De*CAg);
print " Mw = %.f"%(Mw)
if Mw>4:
print " Pore diffusion is influencing and hence strong pore diffusion"
else:
print " Pore diffusion is not influencing and hence weak pore diffuusion"
dt_max_pellet = De*(CAg-0)*(-Hr)/Keff;
#Temp variation Across the gas film
dt_max_film = L*rA_obs*(-Hr)/h;
print " Part c"
print " dTmax,pellet is %.1f C"%(dt_max_pellet)
print " degree C dTmax,film is %.2f C"%(dt_max_film)
print " degree C"
if dt_max_pellet<1:
print " Pellet is close to uniform in temperature"
else:
print " There is a variation in temp within pellet"
if dt_max_film<1:
print " Film is close to uniform in temperature"
else:
print " There is a variation in temp within Film"
```

In [2]:

```
%matplotlib inline
from matplotlib.pyplot import *
from numpy import *
import math
from scipy import stats
# Variables
PAo = 3.2;
R = 0.082 #litre.atm/mol.k
T = 390. #k
v = 20. #litre/hr
W = 0.01 #/kg
CA_in = [0.1,0.08,0.06,0.04];
CA_out = [0.084,0.07,0.055,0.038];
# Calculations
CAo = PAo/(R*T);
FAo = CAo*v;
eA = 3;
XA_in = zeros(4)
XA_out = zeros(4)
dXA = zeros(4)
rA = zeros(4)
CA_avg = zeros(4)
for i in range(4):
XA_in[i] = (1-CA_in[i]/CAo)/(1+eA*CA_in[i]/CAo);
XA_out[i] = (1-CA_out[i]/CAo)/(1+eA*CA_out[i]/CAo);
dXA[i] = XA_out[i]-XA_in[i];
rA[i] = dXA[i]/(W/FAo);
CA_avg[i] = (CA_in[i]+CA_out[i])/2;
# Results
plot(CA_avg,rA)
xlabel("CA, mol/liter")
ylabel("-rA, mol/hr. kg cat")
coeff1 = stats.linregress(CA_avg,rA)
k = coeff1[0]
print " The rate of reaction is %.3f mol/hr.kg"%(k),
print "CA"
print ('The answer slightly differs from those given in book as regress fn is\
used for calculating slope and intercept')
```

In [3]:

```
%matplotlib inline
from numpy import zeros
from scipy import stats
# Variables
CAo = 0.1 #mol/litre
FAo = 2. #mol/hr
eA = 3.
CA = [0.074,0.06,0.044,0.029] #mol/litre
W = [0.02,0.04,0.08,0.16] #kg
XA = zeros(4)
y = zeros(4)
x = zeros(4)
W_by_FAo = zeros(4)
CAout_by_CAo = zeros(4)
XA1 = zeros(4)
# Calculations
for i in range(4):
XA[i] = (CAo-CA[i])/(CAo+eA*CA[i]);
y[i] = (1+eA)*math.log(1/(1-XA[i]))-eA*XA[i];
x[i] = CAo*W[i]/FAo;
W_by_FAo[i] = W[i]/FAo;
CAout_by_CAo[i] = CA[i]/CAo;
XA1[i] = (1-CAout_by_CAo[i])/(1+eA*CAout_by_CAo[i]);
# Results
plot(x,y)
xlabel("CA0W/FAO = W/20, hr.kg cat/liter")
ylabel("4 ln 1/(1-Xa) -3Xa")
coeff3 = stats.linregress(x,y);
k = coeff3[0];
print " Part a, using integral method of analysis"
print " The rate of reactionmol/litre is %.3f"%(k),
print "CA"
#Part b
#plotting W_by_FAo vs XA1,the calculating rA = dXA/d(W/FAo) for last 3 points,we get
rA = [5.62,4.13,2.715];
coeff2 = stats.linregress(CA[1:],rA);
print " Part b, using differential method of analysis"
print " The rate of reactionmol/litre) is %.3f"%(coeff2[0]),
print "CA"
```

In [3]:

```
import math
# Variables
# from example 18.2
XA = 0.35;
FAo = 2000. #mol/hr
eA = 3.
k = 96.
CAo = 0.1;
# Calculations
W = ((1+eA)*math.log(1./(1-XA))-eA*XA)*(FAo/(k*CAo));
# Results
print " The amount of catalyst kg needed in a packed bed reactor is %.f kg"%(W)
```

In [1]:

```
%matplotlib inline
import math
from matplotlib.pyplot import *
from numpy import *
from scipy import *
# Variables
CAo = 0.1;
eA = 3;
rA = [3.4,5.4,7.6,9.1]; # mol A/hr. kg cat
CA = [0.039,0.0575,0.075,0.092]; # mol/liter
# Calculations
XA = zeros(5);
inv_rA = zeros(5);
for i in range(4):
XA[i] = (1-CA[i]/CAo)/(1+eA*CA[i]/CAo);
inv_rA[i] = 1/rA[i];
for i in range(4):
small = XA[i];
for j in range(i,4):
next_ = XA[j];
if small>next_:
XA[i],XA[j] = XA[j],XA[i];
inv_rA[i],inv_rA[j] = inv_rA[j], inv_rA[i]
# Results
plot(XA,inv_rA)
xlabel("Xa, dimensionless")
ylabel("-1/rA, hr.kg cat/mol")
show()
XA[4] = 0.35
inv_rA[4] = 0.34;
Area = trapz(XA,inv_rA);
W = Area*2000.;
print "Amount of catalyst needed is %.f kg cat"%(W)
print ('The answer differs from those given in book as trapezoidal rule is used for calculating area')
# Note : Answer differs because python trepz function works differnt than we do manually trepezoidal method.
```

In [5]:

```
# Variables
XA = 0.35;
FAo = 2000. #mol/hr
CAo = 0.1 #mol/litre
eA = 3.
k = 96. # mol/kg cat
# Calculations
CA = CAo*((1-XA)/(1+eA*XA))
rA = k*CA;
W = FAo*XA/rA;
# Results
print "The amount of catalyst neededkg, is %.f kg"%(W)
```

In [ ]:

```
```