Chapter 3 : Interpretation of Batch Reactor Data

Example 3.1 page no : 60

In [1]:
%matplotlib inline

import math 
from numpy import *
from matplotlib.pyplot import *
from scipy import stats

# Variables
#Given
t = [0, 20, 40 ,60, 120 ,180, 300];        # time
C_A = [10 ,8, 6, 5, 3, 2, 1];              # concentration
CAo = 10.;
k = zeros(7)
CA_inv = zeros(7)

# Calculations
#Guesmath.sing 1st order kinetics
for i in range(7):
    k[i] = math.log(CAo/C_A[i]);
    CA_inv[i] = 1/C_A[i];

T = array([18.5,23,35]);
CAo = array([10,5,2]);
CA = zeros(3)
log_Tf = zeros(3)
log_CAo = zeros(3)

for i in range(3):
    CA[i] = 0.8*CAo[i];
    log_Tf[i] = math.log10(T[i]);
    log_CAo[i] = math.log10(CAo[i]);

# Results
plot(log_CAo,log_Tf)
plot(log_CAo,log_Tf,"go")
xlabel("Ln CAO")
ylabel("log r")
#plot(log_Tf,log_CAo)
#coeff1 = linalg.lstsq(log_CAo,log_Tf);
slope, intercept, r_value, p_value, std_err = stats.linregress(log_CAo,log_Tf)
coeff1 = stats.linregress(log_CAo,log_Tf)
n = 1-coeff1[0];
print "From graph we get slope and intercept for calculating rate eqn"
k1 = ((0.8**(1-n))-1)*(10.**(1-n))/(18.5*(n-1));
print " The rate equation is given by %.3f"%(k1),
print "CA**1.4 mol/litre.sec"
Populating the interactive namespace from numpy and matplotlib
From graph we get slope and intercept for calculating rate eqn
 The rate equation is given by 0.005 CA**1.4 mol/litre.sec

Example 3.2 page no : 65

In [2]:
%matplotlib inline

import math
# Variables
CA = array([10,8,6,5,3,2,1]);              # concentration
T = array([0,20,40,60,120,180,300]);       # time
y = array([-0.1333,-0.1031,-0.0658,-0.0410,-0.0238,-0.0108,-0.0065]);     # slope

log_y = zeros(7)
log_CA = zeros(7)

# Calculations
for i in range(7):
    log_y[i] = log10(complex(y[i]));
    log_CA[i] = log10(CA[i]);


# Results
plot(log_CA,log_y)
plot(log_CA,log_y,"go")
xlabel("log10 CA")
ylabel("log10 (-dCA/dt)")
show()
coeff1 = stats.linregress(log_CA,log_y);
n = coeff1[0];
k = -10**(coeff1[1]);
print " After doing linear regression, the slope and intercept of the graph is %.0f, %.0f"%(-coeff1[1],coeff1[0])
print " The rate equation is therefore given by %.3f"%(-k),
print "CA**1.375 mol/litre.sec"
print ('The answer slightly differs from those given in book as regress fn is used for \
 calculating slope and intercept')
Populating the interactive namespace from numpy and matplotlib
WARNING: pylab import has clobbered these variables: ['draw_if_interactive']
`%pylab --no-import-all` prevents importing * from pylab and numpy
-c:14: ComplexWarning: Casting complex values to real discards the imaginary part
 After doing linear regression, the slope and intercept of the graph is 2, 1
 The rate equation is therefore given by 0.005 CA**1.375 mol/litre.sec
The answer slightly differs from those given in book as regress fn is used for  calculating slope and intercept

Example 3.4 page no : 73

In [3]:
import math 

# Variables
k1 = 2.3           # temperatures
k2 = 2.3
T1 = 400.          # K
T2 = 500.          # K

# Calculations
R = 82.06*10**-6;
R1 = 8.314
E = (math.log(k2/k1)*R)/(1./T1-1./T2)

# Results
print "using pressure units is %.0f EJ/mol"%(E)

#pA = CA*RT
#-rA = 2.3(RT)**2*CA**2
k1 = 2.3*(R*T1)**2
k2 = 2.3*(R*T2)**2
E = (math.log(k2/k1)*R1)/(1./T1-1./T2)
print "using concentration units is %.f J/mol"%(E)

# Answers might be different because of Rounding error
using pressure units is 0 EJ/mol
using concentration units is 7421 J/mol
In [ ]: