Simulating dynamic tanks in EMSO (Part 3) Email This Post Print This Post

This is the last post of series simulating dynamic tanks using EMSO simulator. The first one shows the direct implementation of the dynamic tanks case using the modeling language of EMSO that applies concepts of object-oriented languages (part 1). The second one used (part 2) resources of EMSO GUI to link models to figures and create a block diagram of the process from the connection among them.

An important point on implementing of any application is its suitable documentation. Some comments in line codes or additional tags should usually be sufficient for personal purpose. However additional informations regarding to how to use the application should be required. EMSO has an internal engine to documentation generation that get specific tag of codes for HTML document creation. This tool is similar in features to the documentation generator Doxygen but particular for EMSO modeling language.

First of all some requirements must be presented:

  • LaTeX package (MiKTeX for Windows and Tex Live for Linux)
  • dvipng converter

EMSO documentation generator uses additional commands in ATTRIBUTES section and in the definition of parameters/variables to format the documentation. Let us starting from EMSO code of one dynamic tank shown in previous post. See below:

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using "types";
 
Model tank_flow
    ATTRIBUTES
    Brief = "Simple tank flow";
 
    VARIABLES
    F as flow_vol (Brief="Flow");
end
 
Model tank_source_test
    ATTRIBUTES
    Pallete = true;
    Icon = "source_icon";
    Brief = "Simple tank source";
 
    VARIABLES
out Outlet as tank_flow (Brief="Inlet stream");
end
 
Model simple_tank_test
    ATTRIBUTES
    Pallete = true;
    Icon = "tank_icon";
    Brief = "Simple tank model";
    Info = "
== Assumptions ==
* fixed tank area
* outlet flow as a function of tank level
 
== Specify ==
* inlet tank flow
* tank area
* valve constant
* initial tank level
";
 
    PARAMETERS
    k as Real (Brief="Valve constant", Unit='m^2.5/h');
    A as area (Brief="Tank area");
 
    VARIABLES
in  Inlet  as tank_flow (Brief="Input flow", Symbol="^{in}");
out Outlet as tank_flow	(Brief="Output flow", Symbol="^{out}");
    h      as length	(Brief="Tank level");
 
    EQUATIONS
    "Material balance"
    diff(A*h) = Inlet.F - Outlet.F;
 
    "Valve equation"
    Outlet.F = k*sqrt(h);
end

The lines 5, 15, and 25 use Brief command to a short description of the models. In this case we would assume it as the model’s title. On the other hand, Info command (line 26) adds a detailed description of the model. Both commands accept most of wiki markups (Formatting help) as can be seen in lines 27-35 the usage of headings and bullet lists. EMSO documentation generator converts the equations of EQUATIONS section in images using LaTeX interpreter and dvipng converter so the basic knowledge of LaTeX symbols formatting would be applicable. If nothing is done variables/parameters are presented in the equations just as they are declared. Special formatting options are available using Symbol command in parameter/variable declarations. The lines 43 and 44 add LaTeX equation markups to superscript “in” and “out” to represent Inlet and Outlet variables thus Inlet.F is shown as Fin in equations. In the same way greek symbols would be added:

    eps as Real (Brief="Parameter", Symbol="\epsilon");

So once the file is ready, the documentation can be generated selecting the directory and requesting the generation after (Tasks > Generate Documentation…). The documentation for the tank’s model is available here (open in a new window).

Related Posts with Thumbnails