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.





Tuesday, December 13, 2011

Set marker edge width in Matlab figures

A couple of days ago, I plotted about twenty figures and was trying to set the markers with thicker edge. This would be very easy if it was in Excel: just change the 'Marker Line Style' in the 'Format data series' tab. However, it was kind difficult to do in Matlab. At least I didn't get a good solution from the google results on that day.

Today I happened to find the solution when I was playing with Matalb just for fun. The fact is that the 'Marker Edge Width' is actually defined by the 'LineWidth', even when the plot does not use a line to connect the markers..

t=[1:5];
plot(t,sin(t), 's', 'Markersize', 20,'LineWidth', 5)  



Thursday, December 8, 2011

Concatenate text and convert to numbers in Excel

I have a long Excel file which keep the date, month, year, hour, minute, and second in separate columns (figure 1). I want to use only one column to present the time, so it would be easier to plot the time as x-axis. Here is the function I used in cell G2:

=VALUE(CONCATENATE(A2,"/",B2,"/",C2," ",D2,":",E2,":", F2))


The Value function convert the text into numbers.
The Concatenate function connects all the text and convert them into one string.

my-alpine and docker-compose.yml

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