This is the second part of our text “Simulating a dynamic tank in EMSO”. The first part shows the basic theory about EMSO modeling language applied to model a dynamic tank. The code to a single tank was implemented and expanded to a set of tanks in series.
Last post did the expansion of a single tank to series using codes however, in bigger/more complex systems, it could be hard building. In this sense, it should be more interesting if there is a GUI where a flowsheet (diagram) can be built connecting blocks in a workspace such as in sequential modular simulators (Aspen Plus, HYSYS, etc.)
In EMSO we can attribute an image/icon to a Model adding a new section called ATTRIBUTES. The reserved keywords in and out are required to promote the input and output data from a model those are physically represented by the inlet and outlet flows (streams). However, in order to take the block connections actived the inlet and outlet flows must be compatible and defined by their own Model. For this purpose the “tank_flow” model was created (lines 3-6).
Thus all connections are compatible but the interface design diagram does not admit a single block for simulation. One block needs at least one input block. For this a block called “tank_source_test” (lines 8-15) was created using the “tank_flow” model. So it represents a source block that gets the flowsheet 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
Therefore “tank_source_test” (lines 8-15) and “simple_tank_test” (lines 17-37) define the blocks that would be loading on the pallete in Model tab according to their ATTRIBUTES sections. Icon gives the icon as a PNG image (source_icon.png, tank_icon.png) so that Pallete set as true means that the related icon is loaded on the EMSO pallete (Model tab). PosX and PosY guide the positions for point connections.
Adding our work folder to EMSO library (Config > Libraries > Add Library) and restarting it, we will be the new blocks loaded on the EMSO pallete of equipments.
Now let us build the flowsheet of 2 tanks as in last post. Firstly create a new file of type “Diagram” so that a “Diagram setup” window will open to editing properties. Go to “Options” tab and set start time, end time, and step time respectively as 0, 2, 0.1 hours. Hereafter it is already possible to build the flowsheet using the blocks and connections among them. After that you will be something like Fig. 2.
Double clicks on blocks in the diagram open the editing properties. For this case you must specify the inlet flowrate and the initial level for the 2 tanks.
For “tank_source”, the variable Outlet.F is specified as 10 m3/h. For “tank_1″ and “tank_2″, the variables h are initialized both as 1 m.
Checking the consistency of problem and running the plot results for the outlet tank flowrates will be as shown in Fig. 3.