# Notations and Variables

Notations and Variables – Superscripts, Subscripts, and Indices

##### Learning goal

This tutorial will demonstrate the use of different elements of a name for a variable. The following simple flash calculation will serve as example. First the model equations are indicated:

##### Equation System

$F \cdot z_{i} = B \cdot x_{i} + D \cdot y_{i}$
$y_{i}=K^{LV}_{o,i} \cdot x_{i}$
$1 =\sum_{i=1}^{NC} x_{i}$
$1 =\sum_{i=1}^{NC} y_{i}$
$1 =\sum_{i=1}^{NC} z_{i}$

Although the reader may recognize the above equation system as a Flash Unit described by the MESH equations (without heat balance), it must be pointed out that the physical meaning of the model is not definitely clear before the notation of all symbols is given. Therefore this missing piece of information is provided here:

Notation

Base Names

Name Description
B Bottom molar flow (kmol/h)
F Feed molar flow (kmol/h)
K Constant. Phase equilibrium and others
x Bottom molar fraction (mol/mol)
z Feed molar fraction (mol/mol)

Superscripts

Name Description
LV Phase equilibrium

Subscripts

Name Description
o Reference value

Indices

Name Description
i Component index 1…NC

As you will have noticed, the equation system given above has a general character: It describes mixtures with any number of components. Furthermore, the use of the equation system depends on the choice and the value of the design variables. Proving this information is stating a simulation problem. For this tutorial we will state the following problem:

Problem Description

Use the equation system with

$NC=3$
$K^{LV}_{o,i=1} = 0.8$
$K^{LV}_{o,i=2} = 0.9$
$K^{LV}_{o,i=3} = 1.5$
$F=2$ kmol/h
$z_{i=1}= 0.3$  mol/mol
$z_{i=2}= 0.4$  mol/mol

In the following section this simulation problem is transferred into MOSAICmodeling. It is assumed that you are already logged into MOSAICmodeling and see the modeling environment.

Creating the Notation At first we need to create a notation. This is done directly as in the written statement under ‘Notation’ above. To enter the notation do the following:

• Select the Notation tab in the Editor Bar.
• Choose the tab Base Names. In this tab, all symbols that are written in the base line are entered. Use the [Add] button to enter the letters B through z using the description from the statement above.
• Now change to the Superscripts tab and enter the symbol of the corresponding section above, LV.
• Change to the Subscripts tab and enter the subscripts of the notation above.
• Enter the indices of the notation above in the correponding tab in the Notation Editor.
• Click [Save] to open the file selection dialog.
• In the dialog create a new package named ‘example_flash’ and change into it afterwards.
• Save the notation (e.g. ‘notation_flash’).

Creating the Equations In this tutorial you will create all equations by yourself. Please note that this step of modeling is not necessary in all cases, as MOSAICmodeling allows and even furthers the use of ready made equations.

The variable names in the given equations contain displacements. How they are expressed in Latex sensible to MOSAICmodeling will be explained briefly here, more information is given in other sections.

• Superscripts are described using ^{S} where S is the superscript. In this statements the curly brackets are mandatory. You can have several superscripts. Superscripts are seperated by a comma: ^{S,T} where S and T are the superscripts. Please note that in the example of this tutorial the combination LV is one single superscript.
• Subscripts and indices are described using _{S} where S is the subscript or index. Like in superscripts the curly brackets cannot be ommited. You can have up to one subscript and several indices. The fixed subscript must be the first subscripted character. Fixed subscripts and indices are separated by a comma: _{S,I,J} where S is a fixed subscript and I and J are indices.

In addition to the upper specifications you will need to know that a multiplication sign is mandatory in MOSAICmodeling. The necessary operators for this example are

• equals: =
• plus: +
•  multiply: \cdot

Now you are ready to write the formula expressions yourself while you enter the equations.

• Choose the Equation tab in the Editor Bar.
• On the editor you find a field named Notation. Click on [Change] and select the notation you just created.
• Enter a text for the equation in the field Description.
• Enter a latex expression correponding to the equation using the above guidelines. Hint: Pressing [Ctrl+Space] on the keyboard opens a list of available commands.

If you had problems in entering the formula use the following code:

F \cdot z_{i} = B \cdot x_{i} + D \cdot y_{i}
• Click on [Render] to create MathML code. The rendered MathML expression is shown in the area at the bottom of the Equation Editor. Hint: Instead of clicking [Render] you may also press [Shift+Enter] on the keyboard.
• Click on Keywords tab to add a suitable keyword to the equation you just created. You can choose a keyword from the available keyword list by clicking on it and then clicking on the [>>] button to add it to the selected area. If you cannot find a suitable keyword from the list you may submit a new keyword by clicking on the [new] button.
• Save the new equation in the directory you just created for this example.
• Click [New] to clear the equation editor.
• Create the next equation loading the same notation as in the previous one.
• Again, try to enter the latex code without looking at the code below and press [Render] to have the latex expression rendered. If the translation fails, an upcoming dialog provides information about the reason of the error. That information should help you to improve the latex expression so that it can be translated.

If you had trouble entering the equation properly, you may use the following expression:

y_{i}=K^{LV}_{o,i}\cdot x_{i}
• Save the equation in the directory for this example.
• Create equations for the summation relation. The necessary latex expressions are shown below. If you like you can use the [Save As] functionality to facilitate your work.

1 =\sum_{i=1}^{NC}{x_{i}}
1 =\sum_{i=1}^{NC}{y_{i}}
1 =\sum_{i=1}^{NC}{z_{i}}

Creating the Equation System

• Choose the Equation System in the Editor Bar.
• First load the notation for this example in the same way it was done in the Equation Editor.
• Activate the tab Connected Elements and click [Add].
• In the appearing dialog, click on [Change] next to the upmost field and select the first equation for the flash example.
• Click [Submit]. The equation should be listed in the table now.
• Add the other equations in the same way. Hint: You can use multiple selection to add many equations at once.
• Go to the tab “Description” and add an explanatory text about the equation system.
• Save the equation system in the directory for this example.

Evaluation: Using the Equation System to state a Simulation Problem

• Choose Evaluate from the upper bar.
• In the tab Equation System click on [Change] and select the equation system that has been created in the last steps.
• Activate the tab Indexing. The table on top of the appearing area should contain exactly one line where the column Name contains the value i and the column Max Symbol contains the value NC. Click into the Max Value cell of this line and enter the number ‘3’. This way you give the Maximum Generic Value NC for i the value ‘3’. Leave the cell or press Enter.
• Click [Confirm Index Data] to apply the new index specification to the equation system. (You can savely answer [OK] in the appearing dialog).
• Now choose the tab Instance to have a look at the resulting instantiated equation system. Note that there are three equations for the mass balance and three equilibrium conditions and that the summation equations have changed too.
• Go to the tab Variable Specification. Here you will specify the design variables, bringing the Degree of Freedom indicated in the upper left of the operating area to zero.
• Before you proceed, however, click at the variable K^{LV}_{o,i=2} and have a look at the Notation Information Field at the bottom of the user interface. You will notice that for every selected variable listed in one of the tables the information you provided in the notation in the first step of this tutorial is presented here to assist you in your work.
• Select the variable F in the list of Iteration Variables and move it to the list of Design Variables by clicking [>>].
• Move the other variables indicated in the ‘Problem Description’ above in the same way. Hint: multiple selection is supported like in your operating system.
• Enter the Value for F by clicking into the corresponding cell. After you have entered the value (here: 2), leave the cell or press Enter.
• Enter the values for the other design variables in the same way.
• Now you need to specify guess values for the Iteration Variables. Hint: you can again make use of the multiple selection functionality. Select all molar fractions, click into the selection with the right mouse key and use the appearing dialog to enter the value 0.3 . Select B and D and set them to the value 1.
• Change to the Evaluation tab. If everything is ok, the [Generate Code] button should be activated. (Otherwise please have a look at the Status of Information in the middle of the editor where you find hints to solve the problem).
• In the drop down list Predefined Language Specification choose the code generator GSL Hybrid.
• To create the problem solving code press [Generate Code].
• Press Evaluate to have the code executed on the server.
• Select the tab Results to have a look at the solution.