simlogo1

 

 

 

SimQuest 6.4 help

 

 

Modifying a compound model

 

To modify a compound model, follow these basic steps:

 

To edit the model

1.In the Application window, select the compound model you want to make changes to.
2.Click right and choose Edit. The Model Editor should pop up:

 

       compound_model_editor

       The Model Editor.

 

Adding elements to the Compound Model

The Model Editor used to create Compound Models is the same as the Model Editor for Equation Models. Into the Model Editor you can drag Compound Model Elements, Equation Models and other Compound Models. First it will be explained how to create a model from (Basic) Compound Model Elements only. In this short tutorial you will try to create a simple model, in which we are going to create a model to calculate the value of the formula result = (a * b + c) / d.

 

1.Open the Compound Model Editor if not already open.
2.In the Library window, go to Compound Model Elements folder, then click on Basic and subsequently Arithmetic.
3.Drag and drop the following elements into the Compound Model editor: one Multiply, one Add and one Divide. 

 

       compound_models2

       Dragging elements from the library to the Model Editor.

 

Creating links between elements

Now we have to create links between the different model elements. There are two basic rules for linking elements together:

 

1.A link is always created from an output to an input, and never the other way around.
2.With any compound model element, it is possible to connect multiple inputs to one output, but it is never possible to connect multiple outputs to a single input.

 

To create a link:

 

1.Left click on the small black square at the right side of a block elements (the output of that element). Tip: when a thin red line appears around the black square, and a label pops up besides it, you know you are in the right spot and you can press the left mouse button.
2.Keep the mouse button pressed, and an arrow will appear.
3.Move the mouse to one of the small black squares of the next block element (an input for that element).
4.Release the mouse. 

 

Repeat the above four steps and try to create the model that is displayed below:

       compound_models3

       Creating links in the Compound Model.

 

In this model, you can see that multiplicand1 and multiplicand2 are input for the Multiply element. The resulting output is their product (multiplicand1 · multiplicand2). This product is subsequently one of the inputs for the Add element. It will be added to the value of summand2, the other input. So now we have (multiplicand1 · multiplicand2) + summand2. Finally, the output value of the Add element is used as input for the Divide element. This element will then divide this input value (the numerator of the fraction) by the value of its other input, argument2 (the denumerator of the fraction). Effectively, we have now created a model that calculates the value of ((multiplicand1 · multiplicand2) + summand2) / argument 2. Except for the variable names, this formula is identical to the formula we specified above.

 

Changing variable names

Now, change the standard names of the variables to the ones we chose in our formula: a, b, c and d respectively.

 

1.In the column on the left you find an overview of the variables used in the model. On the top of this list, select the variable you want to change the name of.
2.On the bottom left of the model editor, type a new name in the Name box.
3.Make the following changes:

 

multiplicand1 --> a
multiplicand2 --> b
summand2 --> c
argument2 --> d

 

4.Click Accept.

 

       compound_models4

       The Model Editor with the new variable names.

 

Specifying initial values

You will have seen that some of the names of the variables are red. This indicates that no initial values were yet specified for those specific variables. You can specify initial values as follows:

 

1.Select the variable you want to set the initial value of. You only have to change the initial values of the variables a, b, c and d, which are on top of the list.
2.In the value box in the bottom left corner of the model editor, type an initial value.
3.Use (for instance) these values.

 

a = 3
b = 2
c = 4
d = 2

 

       compound_models1

       Changing initial values of variables in the Model Editor.

 

This model is now complete, and can be used in a SimQuest application. If you want, you can now create an interface for this simple model. For instance, add four Numerical Input elements for the inputs (a, b, c and d) and one Value field for the output (result). For more help on the topic of interfaces, you can follow step 2 of the Getting Started tutorial. Also step 3 (Assignments) and step 4 (Explanations) remain unchanged for applications with compound models.

 

Another example

For this second example we will try to create a Compound Model of exponential decay. For this we will have to reproduce the following equation using a Compound Model.

 

dx/dt = -k*x

 

The compound model for this equation looks like this:

 

compound_models5

       Compound model for exponential decay.

 

In this model, the output of the integrator, X, is multiplied with a constant (multiplicand2). This product is then again input for the integrator, so that a closed loop system is formed. When you create this model, you will see that the variable t does not appear in the top list of variables. This is because t is currently an internal variable, which automatically means that it will not be accessible in an interface. To make t an accessible variable, you have to export it. This is done as follows:

 

1.Select the variable t in the left column of the model editor.
2.Right click, and choose export.
3.The variable should have moved to the top of the list.
4.Remember to add an initial value.

 

       compound_models6

       Exporting an internal variable.

 

 

 

Related topics:

 

 

Copyright University of Twente 2011