The S-function of this CSTR model is shown below.
function [sys, x0 str, ts]=cstr_sfcn(t,x,u,flag,Cinit)
switch flag
case 0 %initialize
str=[];
ts=[0 0];
x0=Cinit;
s=simsizes;
s.NumContStates=1;
s.NumDiscStates=0;
s.NumOutputs=1;
s.NumInputs=1;
s.DirFeedthrough=0;
s.NumSampleTimes=1;
sys=simsizes(s);
case 1 % derivatives
sys=cstr(t,x,u);
case 3 %output
sys=x;
case {2 4 9}
sys=[];
otherwise
error(['unhandled flag=', num2str(flag)])
end
And below is the function of the reactor.
function dx=cstr(t, x, u)
Ca=x;
dCa=0.2*(u-Ca);
dx=dCa;
The Simulink model looks like this:
All of the three tanks has the same characteristics, except the initial concentrations were different.
C1(0)=5, C2(0)=3, and C3(0)=1. And the influent concentration was simulated by the pulse generator. The simulation results is shown below.
hi, can you post the simulink model for the cstr?
ReplyDeleteHi dkecik, all the codes are posted here. Not sure what exactly looking for.
Delete