Simulating dynamic tanks in EMSO (Part 1)

This post starts to our sec­tion of HOW-TO texts. My obje­tive with this spe­cific post is to intro­duce using some free tools to dif­fer­ent applications.

A clas­sic prob­lem in process engi­neer­ing is the case of a dynamic tank where the out­put flow is pro­por­tional to its level (Fig. 1). This exam­ple is part of EMSO tuto­r­ial so that more details would be to con­sult in the EMSO man­ual.

Fig. 1. Dynamic tank.

Fig. 1. Dynamic tank.

In this approach­ing, the prob­lem of dynamic tank involves 3 vari­ables and 2 para­me­ters such below:

Vari­ables:

  • Fin: Input flow (m3/h)
  • Fout: Out­put flow (m3/h)
  • h: Tank level (m)

Para­me­ters:

  • A: Tank area (m2)
  • k: Valve con­stant (m2.5/h)

This sys­tem is mod­eled as sim­ple mate­r­ial bal­ance given to:

\frac{d(h A)}{dt} = F^{in} - F^{out}

where the pro­pri­eties are con­sid­ered con­stants so that, the vol­ume that goes into tank minus the vol­ume that goes out tank are equal to accu­mu­lated volume.

The out­put flow is given to valve equation:

F^{out} = k\sqrt{h}

where Fout is pro­por­tional to square root of the tank level h and a valve con­stant k.

EMSO mod­el­ing lan­guage is based on con­cepts of object-oriented pro­gram­ing. These kinds of appli­ca­tions get us pos­si­ble to rep­re­sent the prob­lem through a code. As a result, when we are read­ing the code we are also read­ing a descrip­tion of the prob­lem. EMSO mod­el­ing lan­guage presents 3 basic enti­ties: Model, DEVICES, and Flow­Sheet. An flow­sheet of process is rep­re­sented by the entity Flow­Sheet which is con­sti­tuted by a set of com­po­nents calls DEVICES. The DEVICES are equiv­a­lent to the true units of a process. In its turn, the math­e­mat­i­cal descrip­tion of each DEVICES is rep­re­sented by the entity Model.

The Model of a sin­gle tank is given below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using "types";
 
Model tank
    PARAMETERS
    k as Real (Brief="Valve constant", Default=4, Unit='m^2.5/h');
    A as area (Brief="Tank area", Default=2);
 
    VARIABLES
in  Fin  as flow_vol(Brief="Input flow");
out Fout as flow_vol(Brief="Output flow");
    h    as length(Brief="Tank level");
 
    EQUATIONS
    "Material balance"
    diff(A*h) = Fin - Fout;
 
    "Valve equation"
    Fout = k*sqrt(h);
end

The line 1 indi­cates that Model used a exter­nal file (“types”) where con­tains all use­ful def­i­n­i­tion of unit of mea­sure­ments such as area (line 6), flow_vol (lines 9–10), length (line 11), etc. In the line 4, the para­me­ters are declared. In the line 8, the vari­ables are declared. The in and out indi­cate that are input and out­put vari­ables respectively.

Since there is a struc­ture that rep­re­sents a sin­gle tank, we can eas­ily model a set of tanks in series (Fig. 2).

Fig. 2. Dynamic tanks in series.

Fig. 2. Dynamic tanks in series.

That set of tanks in series can be rep­re­sented by Flow­Sheet below. This struc­ture requires 1 input spec­i­fi­ca­tion (line 32) and 2 ini­tial con­di­tions (line 35). The time of inte­gra­tion, step, and other spec­i­fi­ca­tions to solver are made in the sec­tion OPTIONS (line 39).

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
FlowSheet tanks
    VARIABLES
    Fin        as flow_vol;
 
    DEVICES
    tank1      as tank;
    tank2      as tank;
 
    CONNECTIONS
    Fin        to tank1.Fin;
    tank2.Fout to tank2.Fin;
 
    SPECIFY
    Fin = 10*'m^3/h';
 
    INITIAL
    tank1.h = 1*'m';
    tank2.h = 1*'m';
 
    OPTIONS
    TimeStep = 0.1;
    TimeEnd = 2;
    TimeUnit = 'h';
end

The solu­tion of prob­lem can be viewed in the own simulator’s GUI. Plots of vari­ables to an ana­lyze of the sys­tem dynam­ics are showed at Fig. 3–4.

Fig. 3. Tank input and output flows.

Fig. 3. Tank input and out­put flows.

Fig. 4. Tank levels.

Fig. 4. Tank levels.

ReactorLab

The Reac­tor Lab is a didac­tic soft­ware pro­gram that pro­vides sim­u­la­tions of a vari­ety of chem­i­cal reac­tors. Stu­dents can actively learn about chem­i­cal reac­tions and reac­tors by per­form­ing exper­i­ments and ana­lyz­ing data — quickly, safely, and inex­pen­sively. The pro­gram can be down­loaded free of charge and is avail­able for most com­put­ers and in Eng­lish, Span­ish, and Por­tuguese. The Lab is not a gen­eral pur­pose simulator.

Those who have used the Lab range from high school chem­istry stu­dents to chem­i­cal engi­neer­ing uni­ver­sity and grad­u­ate stu­dents, to pro­fes­sion­als in indus­try. Lit­tle or no train­ing is required for oper­a­tion of the lab because of its con­sis­tent design. In addi­tion, infor­ma­tion about each object is dis­played at the bot­tom of the win­dow as the cur­sor passes over that object.

Project web­site:

Screen­shot:

Sim42

Simulator42 is an open source process sim­u­la­tor project with the goal of pro­vid­ing an afford­able and acces­si­ble chem­i­cal process sim­u­la­tor to the chem­i­cal engi­neer­ing community.

Some inter­est­ing fea­tures of the project:

  • It is being writ­ten in the Python language.
  • The sim­u­la­tor core has been designed to be inde­pen­dent of both user inter­faces and thermo providers.
  • The flow sheet solver can prop­a­gate par­tial infor­ma­tion both back­ward and for­ward through the flow sheet. This fea­ture allows many com­plex prob­lems to be solved with­out iter­a­tive cal­cu­la­tion of recy­cle loops. Con­sis­tency checks are used to avoid unin­tended over spec­i­fi­ca­tion of problems.
  • A dis­til­la­tion col­umn employ­ing a Rus­sell inside/out algo­rithm and capa­ble of solv­ing com­plex pump around and side strip­per prob­lems has been implemented.
  • Sev­eral user inter­faces are already avail­able or being devel­oped for Sim42, includ­ing a basic com­mand line inter­face, a graph­i­cal inter­face based on wxWin­dows, a web browser based interface/server and a pro­fes­sional com­mer­cial interface.

Simulator42 does not have an owner thermo pack­age how­ever it makes avail­able using the com­mer­cial thermo pack­age of VMG (Vir­tual Mate­ri­als Group, Inc). VMG pack­age is free to use through Redlich-Kwong model.? In 2007 OllinTS project started the devel­op­ing of an open source ther­mo­dy­namic server that could be used by Sim42.

Unfor­tu­nately Sim42 project was aban­doned in 2005/2006. So there is not a sup­port web­site or offi­cial repos­i­tory from Sim42’s code/package (see the old orig­i­nal web­site in Inter­net Archive Way­back Machine). Nev­er­the­less, the last ver­sion (2.0.0.0) for Win­dows can be down­loaded from alter­na­tive mirrors.

Mir­rors:

Sim42 requires the instal­la­tion of Python 2.2.2+, Numer­i­cal Python 22+ pack­age and a ther­mo­dy­namic server (VMG or OllinTS).

Related Posts with Thumbnails