Working with equations : Equation dialogue window


Equation dialogue window

The equation dialogue window is used to identify the data source used to calculate a value for a model element, as well as to set various other properties of the model element. The same dialogue window is used forcompartments,flows andvariables, as well as the control symbols iterations and conditions, and the population symbols. (Note that three other model elements,submodels, influence arrows, androle arrows each have their own dialogue box).

The equation dialogue contains the following panels which help you create the equation for your component:

Functions:

This panel displays a tree diagram containing all Simile’s built-in functions, plus any user-defined functions that have been added on your system. They are grouped into categories, and have popups giving a brief description of each function. Doubleclicking on a function name will insert the function into the equation at the cursor position, and leave the cursor between the brackets ready for argument expressions to be entered there if needed.

Indices:

If your component is inside a multiple instance submodel you can use the index(n)function to get the identity of the submodel instance currently being evaluated. However if you are inside many such submodels, or particularly association submodels where you can also use index(n) to get the indices of the current base model instances, it can be confusing working out which nesting level you want. So this panel contains a list of all the available index arguments with popups explaining which index each one gives. Again, doubleclicking them inserts them into the equation text.

Keypad:

This panel contains an array of buttons which insert text into whichever entry field has the cursor. They include buttons for moving the cursor back and forth, deleting a character and deleting all the text.

The second to right button on the top row inserts customizable text. By default it is set to µ since this character might otherwise be hard to find (it represents the micro- prefix for units) but you can set it to other characters or strings using the entry under the Edit tab in the Preferences dialogue window. Another useful setting for this might be ‘e’ if you are entering a lot of numbers in scientific notation.

Data source:

These three radio buttons set the data source to one of the following options:

  1. Variable parameter: the value for the model element is set when the model is built and can change during the simulation. The value can be displayed and set through a user-operated slider control. This option is only relevant if the model element is at the beginning of a chain of influences. It cannot be used to alter the value of a model element that is calculated from the values of other model elements. The minimum and maximum values that the parameter can accept must be entered in the neighbouring text boxes. For a full explanation of working with variable parameters, see the help section “Variable parametersâ€, and for a full explanation of working with sliders, see the help section “Slidersâ€.

  1. Fixed parameter: the value for the model element is set when the model is built and does not change. The value can be set using a scenario file. This option is only relevant if the model element is at the beginning of a chain of influences. It cannot be used to alter the value of a model element that is calculated from the values of other model elements. For a full explanation of working with fixed parameters, see the help section on “Fixed parameters†an for a full explanation of working with scenario files, see the help section “Working with external dataâ€.

  1. Equation: the value for the model element is calculated using the expression given in the text box. The expression is first evaluated when the model is built, and subsequently re-evaluated at each time step. For a full explanation of equations, see the help section “Components of an equationâ€. In brief, equations consist of functions operating on the values of the other model elements that influence this one. A list of functions is provided. Double-click on any of the function names to insert it into the equation text box. A list of the indices of the model element is also given. One index is listed for each level of nesting of the submodel(s) containing the model element. Double-click on any of the index names to insert the corresponding index() function into the equation text. Finally, a list of the other model elements (if any) that influence this one is presented. Double-click on any of the model element names to insert the name into the equation text.

Notes:

  • Graph: This button enables the user to sketch a graph for a mathematical relationship. The relationship is sketched in a window opened up by clicking on this button. Having done this, a reference to a function graph() is automatically added to the expression in the Equation box. This function is evaluated at run time by linear interpolation of the graph sketched by the model developer. See the help entry for the graph function for more information.

  • Table: This button enables a user to specify a tabulated relationship. The tabulated values are held in a data file, and clicking on this button enables you to browse through your file system for the data file, which must be in comma-separated value (CSV) format, and then choose the particular column of data you require from this file. Having done this, a reference to a function table(…) is automatically added to the expression in the Equation box. The function is evaluated at run time by doing a table look-up on the values provided. See the help entry for the table function for more information.

  • Default: By default, the data source is an equation. For this reason, the equation bar is commonly used to enter simple equations. It is necessary to invoke the equation dialogue box only when changing the data source to File or Slider, or if you wish to use the list boxes to construct complex equations more easily.

The data source panel also contains entry fields for minimum and maximum values and for units. It also shows the current array dimensions of the model element. The minimum and maximum values do not actually constrain the component’s value but they are used when attaching I/O tools to set the range of values which can be displayed. Since the I/O tools have access to these values it would be possible to create an I/O tool that would display a warning if a value goes outside its minimum/maximum range. Minimum and maximum must be entered for variable parameters in order to set the range of values for their slider controls when the model runs.

Influences

If the component has influence arrows connected to it from other components in the diagram, these will be listed in the Influences panel, along with their units and array dimensions. Doubleclicking on an influence’s name will insert it into the equation text at the cursor position.

Hover the mouse over the local name of a model element listed in the influences list box to see the full path name of the model element. The local name is automatically composed from the full path name by replacing characters that are illegal in equations (such as spaces and carriage returns) with underscores. If you would prefer to use a different local name to refer to the full path name, the local name can be edited. Right-click on the name in the list box to edit it. Each other model element can have only one local name in this one (though the other model element might be referred to using a different local name in further other model elements expressions). For this reason, if you edit the local name, you may also need to edit the expression itself to update the corresponding references.

Documentation

Documentation appears on a separate tab in the dialogue box. You can enter a short title for the component and/or a longer description. For components with complex equations you can put comments directly into the equation text by enclosing them in /* ... */ symbols.




 

In: Contents >> Working with equations