Simulating dynamic tanks in EMSO (Part 3)

Posted on Updated on

Published by on February 1st, 2012 at 3:22 pm in Didactic application, HOW-TO, Process simulation, Softwares with 1 comment
Tagged with , , , , ,

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:

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253using “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”;  VARIABLESout 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”);  VARIABLESin 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

View the original article here


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s