Model CenterVariable Views

Introduction | Class Browser | Class Window | Graphical Views | Modelica Text View | Component Browser | Variable Views | Reliability View | Messages View | Kernel Command View | Documentation Center | Functional Mock-up Interface | Keyboard Shortcuts | Kernel Commands

The bottom area of the model editor shows one or several tabs dedicated to viewing and editing parameters, variables and constants of the class in the active class window. Parameters and constants are variables with a restricted variability in Modelica. Here, the term variable will be used for all three of them, unless it is necessary to distinguish between them. If no component is selected, the variables of the class will be shown. To show the variables of a specific component, select the component in the Icon View, the Diagram View or the Component Browser.

The tabs shown depend on the class being shown. The grouping of variables in a class can be configured in the Show in Variable Views section of the Component Properties dialog for each variable. This dialog can be opened by clicking or right-clicking the name of the variable in the view at the bottom of the screen and choosing Properties. The dialog is described in more detail in this section.

For models that have replaceable classes, the replaceable classes appear as parameters in the General and Parameters views.

Variables, parameters and constants can be shown in separate tabs by opening the Variables view, Parameters view or Constants view in the View menu. In these views, all variables, parameters and constants are listed unconditionally, effectively ignoring any visibility and view/group configurations. The visibility of the tabs can also be controlled from the popup menu shown when right-clicking any of the tabs.

Default Visibility of Variables

The following determines whether or not a variable is visible in the variable views (the dedicated Parameters, Variables and Constants views excluded).

Sorting Variables

The variables in a view can be sorted by name or declaration order. By default, they are sorted by declaration order.

To sort by name, right-click an empty area of the view and choose Arrange by Name from the popup menu.


Sorting the variables by name.

Editing Variables

Before attempting to edit a variable, make sure that either the Icon View or Diagram View is the active view of the class window. Editing in the variable views is disabled while editing the class in the Modelica Text View. For read-only classes, variable values can still be edited but the changes cannot be saved. This makes it possible to test different scenarios with the example models provided in read-only libraries without worrying about changing the library permanently.

Variables have several editable attributes. To give a variable an initial value, edit the value of the corresponding Initial Value box. All attributes of variables that can be edited directly in the variable views are explained in detail following. Other attributes and properties of a variable can be edited in the Component Properties dialog. This dialog can be opened by clicking the name of the variable and choosing Properties. The dialog is described in more detail in this section.

Note that the attributes available in the variable views will depend on the type of the variable. For instance, a variable of type String has only the attribute value.

Editing a Variable for Several Components at Once

On some occasions, you may find it useful to set an attribute of a variable for several components at once. This is possible as long as the components are of the same type. Select the components whose variables you wish to edit. For those variable attributes that are the same for all components, the values will be shown in the value text boxes. If the values differ, the text boxes will show "No Common Value". When typing in a new value for a variable or editing an existing value, all of the selected components will be affected. Components that inherit from the same base class can be selected and the variables from the base class edited in the same way.

Editing Using Specially Adapted Dialogs

The values of variables can also be edited using specially adapted editing dialog by clicking the edit icon next to the edit field. Clicking this icon will bring up a dialog suitable for editing values of the variable's type, such as a color selector for variables specifying a color.

A parameter input field with an edit button.

The type of edit dialog that is shown is determined by the variable's type and if the variable has any associated standard Modelica annotation requesting a specific type of editing dialog, such as the Dialog.colorSelector annotation.

Editing Arrays

For array variables, clicking the edit icon next to the edit field will open a dedicated array editor. The array editor consists of two synchronized views: a table view and an expression view. Either view can be used to edit the array. The expression view can be used to edit any array expression, but is mostly used to edit arrays constructed by non-literal expressions. The table view is an evaluated version of the expression view and is the preferred view to edit individual elements of an array.

When editing an array in one view, it may happen that the other view becomes disabled and an error message is displayed in the bottom left of the array editor dialog. This is an indication that the array is invalid, and the cause could be, for instance, an illegal expression in the expression view or a cell with an invalid value in the table view. Correcting the error will enable the other view again.

To edit the dimensions of an array, open the Component Properties by clicking or right-clicking the name of the variable and choosing Properties from the popup menu.


All physical variables in a Modelica model should be declared with a unit. The unit attribute of a variable is the unit used in all equations, and the equations are only correct for those particular units. However, it is possible to change the unit displayed to you as a user in the graphical user interface by specifying a displayUnit. As an example, say you have a model with a Modelica.Mechanics.Translational.Components.Mass component, and you wish to display its mass (variable m) in the unit "lb" rather than the default unit "kg". To do this, click the mass component, go to the variable view, find the parameter m and click the kg button. This opens up a drop-down menu with all the possible display units for that particular parameter.


Setting the displayUnit to lb instead of kg in the variable view.

When you click lb in the menu, the value in the Value field is converted from kilograms to pounds in the graphical user interface. At the same time, a short piece of Modelica code, namely displayUnit="g", is added to the parameter m in component mass1 in the text view of the model.


displayUnit="g" has been added to parameter m in component mass1.

Note that the top unit in the drop-down menu is also the base unit and is kept separated from the derived units with a gray divider.

When editing the value in the Value field, a different displayUnit can be chosen without automatically converting the value. Once the value and displayUnit are set, the drop-down menu is used to convert the value between different units.

Worth noting is that whenever the value of a variable is set using a drop-down menu containing predefined values, the displayUnit changes back to the base unit. The reason for this behavior is that predefined values are always specified in the base unit.

Adding Custom Unit Conversions for displayUnit

SystemModeler comes with a predefined set of unit to displayUnit conversions. This set contains conversions for many of the commonly used units and can be extended with custom conversions.

Unit conversions are managed in the Options dialog (Tools Options) under the Unit Conversion section. Predefined conversions cannot be changed but can be used as a starting point when creating custom conversions. For example, to create a new custom unit conversion for electric current, from A to uA, find the conversion from A to mA in the list and select it to fill out all the text boxes in the Add or Update Unit Conversion section. Change Scale to 1000000 and Derived Unit to uA and click the Add Unit Conversion button. The new conversion will appear right above the A to mA conversion and the derived unit uA is now available for use as a displayUnit in models.

Any custom unit conversion can be edited or removed. To edit a conversion, select it in the list and edit its values in the Add or Update Unit Conversion section. When finished, click the Update Unit Conversion button. To remove a unit conversion, click the round button with an X to the right of the conversion in the list.

To toggle between showing all unit conversions and only custom unit conversion in the list, click the Show only custom unit conversions checkbox.

Redeclaring Replaceable Classes

An advanced configuration feature allows switching out complete classes used in a model. This makes it easier to quickly reconfigure parts of your model. Classes like these are called replaceable classes. These classes are shown as parameters in your model.


A replaceable class shown as a parameter, with available choices shown in the drop-down menu.

To redeclare the replaceable class, choose one of the items in the drop-down menu.

A replaceable class can be further modified by adding modifiers to the redeclaration. These modifiers can be added in parentheses after the class name.


A replaceable class redeclared with a modifier to the tire radius R.

Lifting Variables

When building hierarchical models, a parameter, variable, constant or initial value of a variable that is of importance for the behavior of the model may be located somewhere deep down in a component of your model. To simplify the configuration of your model, variables and their values can be lifted up to the top level of your model. The operation does not modify any other model except your top-level model.

When lifting a variable, a new parameter with the same name and variability will be created in your top-level model with a binding to the lifted variable, effectively changing the value of the lifted variable whenever the value of the top-level variable is changed. Lifting an initial value of a variable as a parameter allows the initial value of a variable at a lower hierarchical level to be specified as a parameter at the top level.

To perform the lift operation, select the component that contains the variable to be lifted and click or right-click its name in the variable view. Depending on the variability of the variable, the popup menu shown will have different choices. Click the menu item that matches your need.


Lifting the parameter J inside a DCMotor component to the top-level model.

Adding Variables

To add a variable to a model, click the floating + button in the lower-right corner of the variable view, use the Insert menu, or right-click an empty area of the variable view to bring up a popup menu from which you can choose to add a variable, parameter or constant.

The button in the variable views used for adding parameters, variables or constants.

The dialog box that appears is the common dialog box for adding variables of any kind of variability.


Adding a continuous variable of the SI unit type Current to a resistor model.

The dialog box is divided into two views.

Removing Variables

To remove a variable of a class, click its name and choose Delete from the popup menu.

If multiple variables are to be deleted, this can be done more quickly using the Component Browser, which allows multiple components to be selected at once. For information on how to remove components, see this section.

Introduction | Class Browser | Class Window | Graphical Views | Modelica Text View | Component Browser | Variable Views | Reliability View | Messages View | Kernel Command View | Documentation Center | Functional Mock-up Interface | Keyboard Shortcuts | Kernel Commands