Thursday, December 22, 2011

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.





2 comments:

  1. hi, can you post the simulink model for the cstr?

    ReplyDelete
    Replies
    1. Hi dkecik, all the codes are posted here. Not sure what exactly looking for.

      Delete

Any comments?

my-alpine and docker-compose.yml

 ``` version: '1' services:     man:       build: .       image: my-alpine:latest   ```  Dockerfile: ``` FROM alpine:latest ENV PYTH...