Showing posts with label S-function. Show all posts
Showing posts with label S-function. Show all posts

Tuesday, March 24, 2015

Simulink model of Continuous Stirred-Tank Reactor in series

This is a easy Simulink mannequin I created at the moment. This mannequin simulates the focus in three Steady Stirred-Tank Reactor (CSTR) in a row and the way these focus values affected by the influent focus. Typically the CSTR can also be referred to as properly-combined steady stream via reactor.

The S-perform of this CSTR mannequin is proven under.


perform [sys, x0 str, ts]=cstr_sfcn(t,x,u,flag,Cinit)
change flag
    case zero %initialize
        str=[];
        ts=[0 0];
        x0=Cinit;
        
        s=simsizes;
        s.NumContStates=1;
        s.NumDiscStates=zero;
        s.NumOutputs=1;
        s.NumInputs=1;
        s.DirFeedthrough=zero;
        s.NumSampleTimes=1;
        
        sys=simsizes(s);
        
    case 1 % derivatives


        sys=cstr(t,x,u);
    
    case three %output
        sys=x;
        
    case 2 four 9
        sys=[];
    in any other case
        error(['unhandled flag=', num2str(flag)])
finish


And under is the perform of the reactor.


perform dx=cstr(t, x, u)
Ca=x;
dCa=zero.2*(u-Ca);
dx=dCa;

The Simulink mannequin seems like this:



All the three tanks has the identical traits, besides the preliminary concentrations have been totally different.
C1(zero)=5, C2(zero)=three, and C3(zero)=1. And the influent focus was simulated by the heart beat generator. The simulation outcomes is proven under.





Simulink model of Continuous Stirred-Tank Reactor in series

Here's a simple Simulink model I created today. This model simulates the concentration in three Continuous Stirred-Tank Reactor (CSTR) in a row and how these concentration values affected by the influent concentration. Sometimes the CSTR is also called well-mixed continuous flow through reactor.

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.