You are on page 1of 13

Module 1: Open-loop Simulation of Continuous Stirred Tank Heater

and Isothermal Continuous Stirred Tank Reactor (CSTR)

Hello Everyone,
Welcome to the simulation part of Process Control Course (TKK 3262). Throughout the course, we
are going to have at least 3 modules to work with. Here, you are expected to work in a group of 3
students. Despite the need of good team work, we are going to have individual scoring (we call it
peer scoring) to evaluate each individual’s contribution in the group. We will do it later in the final
week of the course. Hence, your contribution as well as your positive attitude towards your team
are strongly required. The course is not only about simulation, it also emphasizes on your skill to
prepare good figures as well as your critical thinking to interpret and discuss the simulation results.
I will appreciate your creativity to solve and expand the problems beyond the scope. Finally, we
would like to encourage you to practice your English and thus the report must be answered in
English. Have fun!

Cheers,
Muh Mufti Azis, Ph.D

Part 1. Simulation of Continuous Stirred Tank Heater

A continuous stirred tank heater has been designed to heat water temperature with the aid of an
electric heater. Here, we would like to simulate the dynamics of outlet temperature by varying the Fin
,Tin and Q values. Note that the change in Fin affects the volume of the water inside the tank and thus
will affect the outlet temperature. The system is considered as an ideal system (well mixed) with
constant density and heat capacity.

1. Derive total mass balance equation showing the dynamic of liquid level in the tank.

(Rate of Mass In)-(Rate of Masas Out)=Mass Accumulation


𝑑(𝜌𝑉)
(𝜌. 𝐹𝑖𝑛) − (𝜌. 𝐹𝑜𝑢𝑡) =
𝑑𝑡
𝑑𝑉
(𝜌. 𝐹𝑖𝑛) − (𝜌. 𝛼. ℎ) = 𝜌
𝑑𝑡
Constant density

1
𝑑(𝐴ℎ)
(𝐹𝑖𝑛) − (𝛼. ℎ) =
𝑑𝑡
𝑑ℎ
(𝐹𝑖𝑛) − (𝛼. ℎ) = 𝐴
𝑑𝑡

The dynamic of liquid level in tank is


𝑑ℎ 𝐹𝑖𝑛 𝛼. ℎ
= −
𝑑𝑡 𝐴 𝐴

2. Derive total heat balance equation showing the dynamic of liquid temperature in the tank
(Rate of Heat In)-(Rate of Heat Out)=Heat Accumulation
𝑑(𝜌. 𝑉. 𝑐𝑝. 𝑇)
[𝜌. 𝐹𝑖𝑛. 𝑐𝑝. (𝑇𝑖𝑛 − 𝑇𝑟𝑒𝑓) + 𝑄] − [𝜌. 𝐹𝑜𝑢𝑡. 𝑐𝑝. (𝑇𝑜𝑢𝑡 − 𝑇𝑟𝑒𝑓) =
𝑑𝑡
𝑑(𝜌. 𝐴. ℎ. 𝑐𝑝. 𝑇)
[𝜌. 𝐹𝑖𝑛. 𝑐𝑝. (𝑇𝑖𝑛 − 𝑇𝑟𝑒𝑓) + 𝑄] − [𝜌. 𝛼. ℎ. 𝑐𝑝. (𝑇𝑜𝑢𝑡 − 𝑇𝑟𝑒𝑓) =
𝑑𝑡

Constant density, heat capacity , Tref=0, well mixed (T=Tout)


𝑑(ℎ. 𝑇)
[𝜌. 𝐹𝑖𝑛. 𝑐𝑝. 𝑇𝑖𝑛 + 𝑄] − [𝜌. 𝛼. ℎ. 𝑐𝑝. 𝑇] = 𝜌. 𝐴. 𝑐𝑝
𝑑𝑡
𝑑𝑇 𝑑ℎ
[𝜌. 𝐹𝑖𝑛. 𝑐𝑝. 𝑇𝑖𝑛 + 𝑄] − [𝜌. 𝛼. ℎ. 𝑐𝑝. 𝑇] = 𝜌. 𝐴. 𝑐𝑝 (ℎ +𝑇 )
𝑑𝑡 𝑑𝑡

The dynamic of liquid temperature in the tank is


𝑑𝑇 𝐹𝑖𝑛. 𝑇𝑖𝑛 𝑄 𝛼. 𝑇 𝑇 𝑑ℎ
=( + )−( )−( )
𝑑𝑡 ℎ. 𝐴 𝜌. 𝑐𝑝. ℎ. 𝐴 𝐴 ℎ 𝑑𝑡

3. Rewrite the mass balance equation in the form of linear first order system as:
Y (t )
p   Y (t )  Kp  X (t )
t
Where: Y(t)=output variable, X(t)=input variable or forcing function, Kp=process gain and
τp=process time constant. Define the τp and Kp by setting up one output and one input
variables! Discuss the influence of τp and Kp!
𝑑ℎ
(𝐹𝑖𝑛) − (𝛼. ℎ) = 𝐴
𝑑𝑡
𝑑ℎ
𝐴 + 𝛼. ℎ(𝑡) = 𝐹𝑖𝑛(𝑡)
𝑑𝑡
𝐴 𝑑ℎ 1
+ ℎ(𝑡) = 𝐹𝑖𝑛(𝑡)
𝛼 𝑑𝑡 𝛼
Therefore,
𝐴
τp =
𝛼
1
𝐾𝑝 =
𝛼
The influence between τp and Kp is depending on output flowrate.
Kp=process gain, will increase if output decrease
τp=process time constant, will also increase if output decrease.

Both τp and Kp will influence the change in output variable, in this case, the level/height of
the water inside the tank or the water flow rate out from the tank because they consist of
α function that have a direct influence to the water level and the flow rate out.

2
4. We would like to run the open-loop dynamic simulation for the stirred tank heater system.
Describe the variation of the input variable, typically, we would like to have step changes on
input variable in this case is feed flowrate. Initially, the system is in their steady-state condition.
Calculate the steady state output values that you expect with your selected parameters.

For this simulation, you could use following parameters:

Feed flowrate 5e-3 to 10e-3 which changes every 200 s


Qheater=480 kJ/s Diameter tank = 0.3 m
Cp=4.2 kJ/kgoC Alfa=1e-2
Tfeed=30oC Rho=1e3 ; %kg/m3

The variation of the input variable (feed flowrate) is constant interval and instant changing from 5e-3
to 10e-3 and went back to 5e-3 and so on. This type of variation called step changes.
clc
clear all
close all
%% main program
%Data
load Feed.mat;
A=pi./4*(0.3)^2;
alfa=1e-2;
Tin=30;
Q=480;
rho=1e3;
Cp=4.2;

%Solver
tspan=0:1:1000;
IC=[0.5 52.86];

[t Y]=ode15s(@fun1,tspan,IC,[],A,alfa,Tin,Q,rho,Cp,Feed)

%Plotting
figure(1)
x=t;
Y=Feed(:,2);
plot(x,Y)
title('Feed Flowrate Change through Time')
xlabel('Time, second')
ylabel('Feed flowrate, m^3')

%%subroutine

function dydt=fun1(t,Y,A,alfa,Tin,Q,rho,Cp,Feed)
h=Y(1);
T=Y(2);

Fin=interp1(Feed(:,1),Feed(:,2),t);

dhdt=Fin./A-alfa.*h./A;

3
dTdt=Fin*Tin./(h.*A)+Q./(h.*rho.*Cp.*A)-alfa.*T./A-T./h.*dhdt;
dydt=[dhdt;dTdt];
end

5. It is time now to set up and run the simulation which allows simultaneous change of inlet
temperature, electric heat load and level change. Show the results of your simulation for step
changes input. Use interp1 function to aid your simulation. Discuss your results! try to describe
what factors influence the time needed to reach the new steady state conditions!

Factor influencing the time needed to reach new steady state conditions are feed flow rate and
heater load. If the flow rate is risen, then the water level inside the tank would rise linearly with the
increment in the flow rate, but since the heater load supply (Q) is constant, rising the flow rate
means make the heater heats more water than before. So the outlet temperature (Tout) would fall
because the heater only supply constant amount of energy to heats more amount of water, and vice
versa.

clc
clear all
close all
%% main program
%Data
load Feed.mat;
A=pi./4*(0.3)^2;
alfa=1e-2;

4
Tin=30;
Q=480;
rho=1e3;
Cp=4.2;

%Solver
tspan=0:1:1000;
IC=[0.5 52.86];

[t Y]=ode15s(@fun1,tspan,IC,[],A,alfa,Tin,Q,rho,Cp,Feed)

%Plotting
figure(1)
subplot(2,1,1)
x=t;
h=Y(:,1);
plot(x,h)
xlabel('Time, second')
ylabel('Liquid level, meter')
title('Change of Liquid Level through Time')

subplot(2,1,2)
x=t;
T=Y(:,2);
plot(x,T)
xlabel('Time, second')
ylabel('Temperature, ^oC')
title('Change of Temperature through Time')

%% subroutine
function dydt=fun1(t,Y,A,alfa,Tin,Q,rho,Cp,Feed)
h=Y(1);
T=Y(2);

Fin=interp1(Feed(:,1),Feed(:,2),t);

dhdt=Fin./A-alfa.*h./A;
dTdt=Fin*Tin./(h.*A)-alfa.*T./A+Q./(h.*rho.*Cp.*A)-T./h.*dhdt;

dydt=[dhdt;dTdt];
end

5
6. In reality, the value of input variable may fluctuate randomly according to the following
equation: X (t )  bottom  (top  bottom).* rand . Rerun your simulation with new
(random) input variables!

clc
clear all
close all
%% main program
%Data
load Feed.mat;

for i=1:length(Feed)
Feed(i,3)=(Feed(i,2)-1e-3)+2e-3.*rand;
end

A=pi./4*(0.3)^2;
alfa=1e-2;
Tin=30;
Q=480;
rho=1e3;
Cp=4.2;

%Solver
tspan=0:1:1000;

6
IC=[0.5 52.86];

[t Y]=ode15s(@fun1,tspan,IC,[],A,alfa,Tin,Q,rho,Cp,Feed)

%Plotting
figure(1)
subplot(2,1,1)
x=t;
h=Y(:,1);
plot(x,h)
xlabel('Time, second')
ylabel('Liquid Level, meter')
title('Change of Liquid Level through Time')

subplot(2,1,2)
x=t;
T=Y(:,2);
plot(x,T)
xlabel('Time, second')
ylabel('Temperature, ^oC')
title('Change of Temperature through Time')

%% subroutine
function dydt=fun1(t,Y,A,alfa,Tin,Q,rho,Cp,Feed)
h=Y(1);
T=Y(2);

Fin=interp1(Feed(:,1),Feed(:,3),t);

dhdt=Fin./A-alfa.*h./A;
dTdt=Fin*Tin./(h.*A)-alfa.*T./A+Q./(h.*rho.*Cp.*A)-
T./h.*dhdt;

dydt=[dhdt;dTdt];
end

7
7. It is time for reflection!. What lessons that you have learnt from the open-loop simulation of
part 1? Is it realistic? Discuss on how you may increase the complexity of the system to mimic
the real life situation! Here, you are expected to put your insights on what you have done so
far and you don’t need to run any further simulation for this question.

We have learnt to simulate the CSTR process and it’s disturbance effects the water level and
temperature changes in the CSTR. We also learnt the real case in industry that usually the
flow level would fluctuate and simulate it with random input

One of the way to increase the complexity of the system to mimic the real life situation is to
make the input temperature change (not constant), make the density and heat capacity as
a function of temperature.

8
Part 2. Simulation of Isothermal CSTR
to Describe Van de Vusse reaction

In an ideal CSTR, we would like to run a reaction scheme consisting of following irreversible reactions
namely Van de Vusse reaction:

A 
k1
 B 
k2
C

2 A 
k3
D

This scheme was presented by Van de Vusse (1964) and it was found that the production of
cyclopentinol from cyclopentadiene is based on such a reaction scheme, where A=cyclopentadiene,
B=cyclepentenol, C=cyclopentanediol and D=dicyclopentadiene. In this system, we assume that the
feedstream only contains component A. In addition, we also assume that the reactor operates under
isothermal condition. Given: k1=5/6, k2=5/3, k3=1/6 and CAfeed=10.

8. Derive total mass balance as well as component mole balance equation showing the dynamic
of volume and concentrations in the tank.
 A Component (Cyclopentadiene) Mass Balance
𝑑𝐶𝐴
𝐹𝑖𝑛 𝐶𝐴0 − 𝐹𝑜𝑢𝑡 𝐶𝐴 − 𝑘1 𝐶𝐴 𝑉 − 𝑘3 𝐶𝐴 2 𝑉 = 𝑉
𝑑𝑡
𝐹𝑖𝑛 𝐹𝑜𝑢𝑡 𝑑𝐶 𝐴
𝐶 − 𝐶 − 𝑘1 𝐶𝐴 − 𝑘3 𝐶𝐴 2 =
𝑉 𝐴0 𝑉 𝐴 𝑑𝑡
2 𝑑𝐶𝐴
𝜏(𝐶𝐴0 − 𝐶𝐴 ) − 𝑘1 𝐶𝐴 − 𝑘3 𝐶𝐴 =
𝑑𝑡
 B Component (Cyclopentenol) Mass Balance
𝑑𝐶𝐵
0 − 𝐹𝑜𝑢𝑡 𝐶𝐵 + 𝑘1 𝐶𝐴 𝑉 − 𝑘2 𝐶𝐵 𝑉 = 𝑉
𝑑𝑡
𝑑𝐶𝐵
−𝜏 𝐶𝐵 + 𝑘1 𝐶𝐴 − 𝑘2 𝐶𝐵 =
𝑑𝑡
 C Component (Cyclopentanediol) Mass Balance
𝑑𝐶𝐶
0 − 𝐹𝑜𝑢𝑡 𝐶𝐶 + 𝑘2 𝐶𝐵 𝑉 = 𝑉
𝑑𝑡
𝑑𝐶𝐶
−𝜏 𝐶𝐶 + 𝑘2 𝐶𝐵 =
𝑑𝑡
 D Component (Dicyclopentadiene) Mass Balance
𝑘3 2 𝑑𝐶𝐷
0 − 𝐹𝑜𝑢𝑡 𝐶𝐷 + 𝐶𝐴 𝑉 = 𝑉
2 𝑑𝑡
𝑘3 2 𝑑𝐶𝐷
−𝜏 𝐶𝐷 + 𝐶 =
2 𝐴 𝑑𝑡

9
9. Solve the steady-state concentrations of A,B,C and D with various space velocities. Discuss your
finding! Use space velocities between 0-10.

%Function
function F=fun(C)
Ca = C(1);
Cb = C(2);
Cc = C(3);
Cd = C(4);
F(:,1) = Sv.*(Ca0-Ca)-k1.*Ca-k3.*(Ca).^2;
F(:,2) = -Sv.*(Cb)+k1.*Ca-k2.*Cb;
F(:,3) = -Sv.*(Cc)+k2.*Cb;
F(:,4) = -Sv.*(Cd)+k3./2.*(Ca.^2);
end

%main program untuk case 1 nomor 9


clc
clear all
close all

%Data
k1 = 5/6;
k2 = 5/3;
k3 = 1/6;
Ca0 = 10;

%Solver
for i = 1:1:10
Sv = i;
x0 = [1 1 1 1];
options = optimoptions('fsolve','FunctionTolerance',1e-2);
Cs = fsolve(@fun,x0,options);
Css(:,i) = Cs;
end

Css

%Plotting
ss = 1:1:10;
figure(1)
plot(ss,Css)
title('Grafik Space Velocity versus Konsentrasi Setimbang
(Steady State)')
xlabel('Space Velocity')
ylabel('Konsentrasi Setimbang')
legend('Konsentrasi A','Konsentrasi B','Konsentrasi
C','Konsentrasi D')

10
Hasil Program

Increment in space velocity will affect all four components in the CSTR. Concentration of
Cyclopentadiene (A) will rise as the space velocity goes up. But the concentration of
Cyclopentenol (B), Cyclopentanediol (C), and Dicyclopentadiene (D) will fall as the space
velocity goes up. This happens because if the flowrate in is slow enough, the formation of
B, C, and D would be optimal. But if this goes higher, the formation of B, C, and D would be
lower than before because they cannot react fast enough in the reactor and leads to low
concentration in the reactor as the flow rate goes higher.

11
10. Simulate the dynamic model of concentrations A,B,C and D with the step change in space
velocities! Discuss your finding!

%Function
function dcdt = ssh(t,C)
Sv=interp1(Sva(:,1),Sva(:,3),t);
Ca = C(1);
Cb = C(2);
Cc = C(3);
Cd = C(4);

dcadt = Sv.*(Ca0-Ca)-k1.*Ca-k3.*(Ca.^2);
dcbdt = -Sv.*(Cb)+k1.*Ca-k2.*Cb;
dccdt = -Sv.*(Cc)+k2.*Cb;
dcddt = -Sv.*(Cd)+k3./2.*(Ca.^2);

dcdt = [dcadt;dcbdt;dccdt;dcddt];
end

%main program case 2 modul 1 dalpros


clc
clear all
close all

%Data
k1 = 5/6;
k2 = 5/3;
k3 = 1/6;
Ca0 = 10;

Sva(:,1) = 0:1:1000;
Sva(1:101,2) = 1;
for i = 1:1:9
Sva(100*i+2:100*(1+i)+1,2) = i+1;
end

for i=1:length(Sva)
Sva(i,3)=(Sva(i,2)-1e-1)+2e-1.*rand;
end

%Solver
Iter(1) = 2;
Iter(2) = 2;
Iter(3) = 2;
Iter(4) = 2;
tspan = [0 1000];
[t,C] = ode15s(@ssh,tspan,Iter);

%Plotting
plot(t,C)
legend('Ca','Cb','Cc','Cd')
xlabel('Time, Second')

12
ylabel('Concentration Level, mg/L')
title('Change of Concentration Level through Time')

Hasil Program

With the step changes in space velocity, we can see that the changes in all components
concentration level still looks the same as before. The data trend also still the same. The
difference is with step changes, in the interval time every 100s we have not-so-steady-
state concentration level of each component in the reactor

11. It is time for reflection!. What lessons that you have learnt from the open-loop simulation of
part 2? Is it realistic? Discuss on how you may increase the complexity of the system. Here,
you are expected to put your insights on what you have done so far and you don’t need to run
any further simulation for this question.
We have learnt to simulate the process in CSTR with reaction and it’s flow rate changes
affect the concentration of each components in the CSTR. We agreed that this case is
realistic. One of the way to increase the complexity of the system to mimic the real life
situation is to make the reactor isn’t isothermal. The reaction requires heat so it need heat
supply and make that heat supply changes against time.

References: B. Wayne Bequette, Process Control Modeling, Design and Simulation, Prentice Hall
Professional, 2003

13

You might also like