# Use of Basic Elements I – Algebraic Equation System

This first example shall be used to familiarize new users with the basic workflow of MOSAICmodeling. Hence, the solved problem is not very complex or hard to set up.

### Model description

The model consists of two equations:

Therein, and are design values, i.e., variables we know the values of. On the other hand, and are unknown quantities. We want to determine the values of these two variables given the model above and the values we will assign to and .

### Model workflow

We will now go through the model workflow within MOSAICmodeling. Of course, the software was developed to solve problems in chemical engineering, but it is virtually applicable to any mathematical problem.

#### Notation

We always begin by setting up a notation. A notation is a specification of which variables may appear in our model. Further explanations can be found in the documentation of the notation. A variable can consist of base names, superscripts and subscripts, and indices. As you can see, our model variables only consist of base names. Therefore, perform the following steps to set up your notation:

1. Go to the Notation tab in the “Model” section
2. Add a description of your notation, e.g., “This is the notation of my first MOSAIC example”
3. Add the base names , , , and by clicking on “+ Name” at the bottom, entering these names, adding a description of the variable (e.g., “parameter” or “variable”), and confirming it
4. Once you have added all four variables, click on “Save” at the top of the editor and save your notation at a suitable location in your folder structure

The notation of this example has ID 182858.

#### Equations

Go to the Equation tab. Now, we will formulate the two model equations. Proceed as follows:

1. Load the notation you just created
2. Add an informative description of the current equation, e.g., “This is the first model equation”
3. Type the first model equation in LaTeX style into the window MosaicTex: 0 = a \cdot (1 – x)
4. Save the equation at a suitable location in your folder structure
5. Click on “New” at the top of the editor and repeat the steps 1 and 2
6. Enter the second model equation: 0 = b \cdot (y – (x)^{2}). Note that you need curly brackets around exponents (and superscripts) and round brackets to specify that the base x has an exponent of 2
7. Save this second equation as well

The two equations are available in MOSAICmodeling with the IDs 182859 and 182860.

#### Equation system

Now, we will combine our equations to an equation system. To this end, go to the Equation System tab and carry on as described below:

3. Go to the tab Connected Elements and click on “+ EQU/EQS” at the bottom of the editor
4. In the opening popup window, select your two equations and confirm (you can also add them one-by-one). They will then appear in the overview of connected elements

The equation system has ID 182861 within MOSAICmodeling.

With this last step, the modeling part within MOSAICmodeling is completed. The remaining workflow will discuss the problem specification and explain the code generation and solution.

### Simulation workflow

Start by going to the “Simulation” section of MOSAICmodeling.

#### Equation system

Go to the tab Equation System and select your newly saved equation system from above.

#### Indexing

Proceed to the tab Indexing. If you had defined any indices in your notation that appear in your model equations, you could specify the maximum value of this index. For example, if you had defined as component index, you could now set 2 as maximum values for two components in your system.

#### Specification

Go to the tab Specifications and then select the tab Variables. Proceed as follows:

2. In the specification window, you can see all possible variable classifications. Select ALL VARIABLES at the top. You should now see the four variables that are part of your model
3. Change the entry in the column Type for and to Design Value. This means that they are treated as constants during the solution
4. Change the type classification of the other two variables to iteration value. Your degree of freedom should now be zero
5. Assign the values given in Table 1 to the four variables. Note that the values of and do not really matter, of course due to the mathematical structure of the problem; but this example is only intended to illustrate the basic workflow
6. Save your variable specification by clicking on the “Save” button above the calculation of the degrees of freedom
7. Save your simulation by clicking on “Save” at the top of the editor

The simulation is available with ID 182862. The associated variable specification has ID 182863.

#### Evaluation

Finally, we want to determine the solution of our model:

1. Go to the Evaluation tab, then go to the Code Generation tab
2. Select your preferred language specification, e.g., Matlab
3. Click on Generate Code
4. Go to the tab View Code and copy the code into your respective modeling environment, e.g., Matlab
5. Execute the code and analyze the solution

You can find the solution of the model in Table 1 as well.