Stefan Kuntsche, Sanam Sabeti Adibpour

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

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

D | Head molar flow (kmol/h) |

F | Feed molar flow (kmol/h) |

K | Constant. Phase equilibrium and others |

x | Bottom molar fraction (mol/mol) |

y | Head 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

kmol/h

mol/mol

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
tab in the Editor Bar.**Notation** - Choose the tab
. In this tab, all symbols that are written in the base line are entered. Use the**Base Names**button to enter the letters**[Add]***B*through*z*using the description from the statement above. - Now change to the
tab and enter the symbol of the corresponding section above,**Superscripts***LV*. - Change to the
tab and enter the subscripts of the notation above.**Subscripts** - Enter the indices of the notation above in the correponding tab in the Notation Editor.
- Click
to open the file selection dialog.**[Save]** - 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
where`^{S}`*S*is the superscript. In this statements the curly brackets are mandatory. You can have several superscripts. Superscripts are seperated by a comma:where**^{S,T}***S*and*T*are the superscripts. Please note that in the example of this tutorial the combination*LV*issuperscriptone single**.** - Subscripts and indices are described using
where**_{S}***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:where**_{S,I,J}**is a fixed subscript and`S`*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
tab in the Editor Bar.**Equation** - On the editor you find a field named
. Click on**Notation**and select the notation you just created.**[Change]** - Enter a text for the equation in the field
.`Description` - Enter a latex expression correponding to the equation using the above guidelines. Hint: Pressing
on the keyboard opens a list of available commands.**[Ctrl+Space]**

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
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**[Render]**on the keyboard.**[Shift+Enter]** - Click on
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**Keywords**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**[>>]**button.**[new]** - Save the new equation in the directory you just created for this example.
- Click
to clear the equation editor.`[New]` - 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
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.**[Render]**

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
functionality to facilitate your work.**[Save As]**

**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
in the Editor Bar.`Equation System` - First load the notation for this example in the same way it was done in the Equation Editor.
- Activate the tab
and click**Connected Elements**.**[Add]** - In the appearing dialog, click on
next to the upmost field and select the first equation for the flash example.`[Change]` - Click
. The equation should be listed in the table now.`[Submit]` - 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
from the upper bar.**Evaluate** - In the tab
click on`Equation System`and select the equation system that has been created in the last steps.`[Change]` - Activate the tab
. The table on top of the appearing area should contain exactly one line where the column**Indexing**contains the value**Name**and the column`i`contains the value`Max Symbol`. Click into the`NC`cell of this line and enter the number ‘3’. This way you give the`Max Value`Value**Maximum Generic**for`NC``i`the value ‘3’. Leave the cell or press Enter. - Click
to apply the new index specification to the equation system. (You can savely answer**[Confirm Index Data]**in the appearing dialog).**[OK]** - Now choose the tab
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.`Instance` - Go to the tab
. Here you will specify the design variables, bringing the**Variable Specification**indicated in the upper left of the operating area to zero.`Degree of Freedom` - 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
in the list of**F**and move it to the list of**Iteration Variables**by clicking`Design Variables`.`[>>]` - 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
for**Value***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
. Hint: you can again make use of the multiple selection functionality. Select all molar fractions, click into the selection with the**Iteration Variables***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
tab. If everything is ok, the**Evaluation**button should be activated. (Otherwise please have a look at the**[Generate Code]**in the middle of the editor where you find hints to solve the problem).**Status of Information** - In the drop down list Predefined Language Specification choose the code generator
.**GSL Hybrid** - To create the problem solving code press
.**[Generate Code]** - Press
to have the code executed on the server.**Evaluate** - Select the tab
to have a look at the solution.**Results**