In [1]:

```
%matplotlib inline
from numpy import *
from matplotlib.pyplot import *
import math
# Variables
T = array([0,5,10,15,20,25,30,35]) # time
Cpulse = array([0,3,5,5,4,2,1,0]) # tracer output concentration
dt = 5.;
sum1 = 0.;
sum2 = 0.;
Area = 0. #Initialization
# Calculations
for i in range(8):
sum1 = sum1+T[i]*Cpulse[i]*dt;
sum2 = sum2+Cpulse[i]*dt;
Area = Area+Cpulse[i]*dt;
t = sum1/sum2;
E = zeros(8)
for j in range(8):
E[j] = Cpulse[j]/Area;
# Results
print " The mean residence time is %.f min "%(t)
plot(T,E)
plot(T,E,"go")
xlabel("t, min")
ylabel("E")
show()
```

In [2]:

```
# Variables
M = 150. #Molecular mass(gm)
v = 5. #litre/sec
v = 5*60. #litre/min
V = 860. #litres
Cpulse = .75
# Calculations and Results
#From Material Balance
Area1 = M/v; #gm.min/litre
A1 = 0.375;
Area2 = A1*(1+1./4+1./16+1./64+1./256+1./1024+1./4096); #Taking Significant Areas
print " From material balance Area is %.1f gm.min/litre"%(Area1)
print " From Tracer Curve Area is %.1f gm.min/litre"%(Area2)
print " Part a"
print " As the two areas are equal,this is a properly done experiment "
#For the liquid,calculating t
sum1 = 0;
for i in range(10):
sum1 = sum1+2*i*A1/(4**(i-1));
t = sum1/Area1;
#liquid volume in vessel
Vl = t*v;
#Fraction of liquid
f = Vl/V;
E = Cpulse/(M/v)
print " Part b"
print " Fraction of liquid is %.f %%"%(f*100)
print " Part c"
print " The E curve is %.1f C"%E
print " Part d"
print " The vessel has a strong recirculation of liquid,probably induced by the rising bubbles"
```

In [6]:

```
# Variables
Cin = zeros(14)
E = zeros(14)
Cout = zeros(14)
Cin[0] = 0.
Cin[1] = 8.
Cin[2] = 4.
Cin[3] = 6
Cin[4] = 0
E[4] = 0
E[5] = 0.05
E[6] = 0.5
E[7] = 0.35
E[8] = 0.1
E[9] = 0.
# Calculations
for t in range(8,14):
sum1 = 0;
for p in range(5,t-1):
if p>10 or (t-p)>5:
h = 2;
else:
sum1 = sum1+Cin[t-p] * E[p];
Cout[t] = sum1;
t = linspace(1,14,14)
Cout = transpose(Cout)
# Results
plot(t,Cout)
```

Out[6]:

In [5]:

```
import math
# Variables
k = 0.307; # min**-1
t = 15.;
# Calculations and Results
fr_unconverted = math.exp(-k*t);
print " The fraction of reactant unconverted in a plug flow reactor is %.2f"%(fr_unconverted)
#For the real reactor
T = [5,10,15,20,25,30]; #given time
E = [0.03,0.05,0.05,0.04,0.02,0.01]; #given
dt = 5;
sum1 = 0;
for i in range(6):
sum1 = sum1+math.exp(-k*T[i])*E[i]*dt;
print " The fraction of reactant unconverted in a real reactor is %.3f"%(sum1)
```

In [6]:

```
import math
from scipy.integrate import quad
# Variables
k = 0.5 #litre/mol.min
CAo = 2. #mol/litre
to = 1.
t1 = 3.
E = 0.5
# Calculations
#Using eqn 13
def f2(t):
return 1./(1+t)
XA_avg = 1-(E* quad(f2,to,t1)[0])
# Results
print " Average concentration of A remaining in the droplet is %.3f"%(XA_avg)
```

In [ ]:

```
```