Simulating dynamic tanks in EMSO (Part 2)

This is the sec­ond part of our text “Sim­u­lat­ing a dynamic tank in EMSO”. The first part shows the basic the­ory about EMSO mod­el­ing lan­guage applied to model a dynamic tank. The code to a sin­gle tank was imple­mented and expanded to a set of tanks in series.

Fig. 1. Dynamic tanks in series.

Fig. 1. Dynamic tanks in series.

Last post did the expan­sion of a sin­gle tank to series using codes how­ever, in bigger/more com­plex sys­tems, it could be hard build­ing. In this sense, it should be more inter­est­ing if there is a GUI where a flow­sheet (dia­gram) can be built con­nect­ing blocks in a work­space such as in sequen­tial mod­u­lar sim­u­la­tors (Aspen Plus, HYSYS, etc.)

In EMSO we can attribute an image/icon to a Model adding a new sec­tion calls ATTRIBUTES. The reserved key­words in and out are required to pro­mote the input and out­put data from a model those are phys­i­cally rep­re­sented by the inlet and out­let flows (streams). How­ever, in order to take the block con­nec­tions actived the inlet and out­let flows must be com­pat­i­ble and defined by their own Model. For this pur­pose the “tank_flow” model was cre­ated (lines 3–6).

Thus all con­nec­tions are com­pat­i­ble but the inter­face design dia­gram does not admit a sin­gle block for sim­u­la­tion. One block needs at least one input block. For this a block calls “tank_source_test” (lines 8–15) was cre­ated using the “tank_flow” model. So it rep­re­sents a source block that gets the flow­sheet started.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using "types";
 
Model tank_flow
    VARIABLES
    F as flow_vol (Brief="Flow");
end
 
Model tank_source_test
    ATTRIBUTES
    Pallete = true;
    Icon = "source_icon";
 
    VARIABLES
out Outlet as tank_flow (Brief="Inlet stream", PosX=1, PosY=0.65);
end
 
Model simple_tank_test
    ATTRIBUTES
    Pallete = true;
    Icon = "tank_icon";
 
    PARAMETERS
    k as Real (Brief="Valve constant", Default=4, Unit='m^2.5/h');
    A as area (Brief="Tank area", Default=2);
 
    VARIABLES
in  Inlet  as tank_flow (Brief="Input flow", PosX=0, PosY=0.17);
out Outlet as tank_flow	(Brief="Output flow", PosX=1, PosY=0.94);
    h      as length	(Brief="Tank level");
 
    EQUATIONS
    "Material balance"
    diff(A*h) = Inlet.F - Outlet.F;
 
    "Valve equation"
    Outlet.F = k*sqrt(h);
end

There­fore “tank_source_test” (lines 8–15) and “simple_tank_test” (lines 17–37) define the blocks that would be load­ing on the pal­lete in Model tab accord­ing to their ATTRIBUTES sec­tions. Icon gives the icon as a PNG image (source_icon.png, tank_icon.png) so that Pal­lete set as true means that the related icon is loaded on the EMSO pal­lete (Model tab). PosX and PosY guide the posi­tions for point con­nec­tions.
Adding our work folder to EMSO library (Con­fig > Libraries > Add Library) and restart­ing it, we will be the new blocks loaded on the EMSO pal­lete of equip­ments.
Now let us build the flow­sheet of 2 tanks as in last post. Firstly cre­ate a new file of type “Dia­gram” so that a “Dia­gram setup” win­dow will open to edit­ing prop­er­ties. Go to “Options” tab and set start time, end time, and step time respec­tively as 0, 2, 0.1 hours. Here­after it already pos­si­ble to build the flow­sheet using the blocks and con­nec­tions. After that you will be some­thing like Fig. 2.

Fig. 2. Flow­sheet diagram

Dou­ble clicks on blocks in the dia­gram open the edit­ing prop­er­ties. For this case you must spec­ify the inlet flowrate and the ini­tial level for the 2 tanks.

For “tank_source”, the vari­able Outlet.F is spec­i­fied as 10 m3/h. For “tank_1” and “tank_2”, the vari­ables h are ini­tial­ized both as 1 m.

Check­ing the con­sis­tency of prob­lem and run­ning the plot results for the out­let tank flowrates will be as shown in Fig. 3.

Fig. 3. Plot results

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).

ASCEND

ASCEND is an open source mod­el­ling envi­ron­ment and solver for large or small sys­tems of non-linear equa­tions, for use in engi­neer­ing, ther­mo­dy­nam­ics, chem­istry, physics, math­e­mat­ics and biol­ogy. Solvers for both steady and dynamic (NLA & DAE) prob­lems, are pro­vided. It offers:

- An object-oriented model descrip­tion lan­guage for describ­ing your system,

- An inter­ac­tive user inter­face that allows you to solve your model and explore the effect of chang­ing the model para­me­ters, and

- A script­ing envi­ron­ment that allows you to auto­mate your more com­plex sim­u­la­tion problems.

ASCEND was orig­i­nally writ­ten at Carnegie Mel­lon Uni­ver­sity in the 1980s and includes pow­er­ful and reli­able solver rou­tines that analyse the struc­ture of your model and can solve thou­sands of simul­ta­ne­ous non­lin­ear equa­tions in a few sec­onds on every­day com­puter hard­ware. It is under active devel­op­ment and is licensed under the GNU Gen­eral Pub­lic License ensur­ing that it is free soft­ware and will remain free.

Project web­site:

Screen­shots:

PyGTK ASCEND GUI

Graphic plotting

Graphic plot­ting

Related Posts with Thumbnails