Global Parameters and Variables

Navigation:  Editor > Global Parameters and Variables >

Global Parameters and Variables

Previous pageReturn to chapter overviewNext page

By adding the keyword global to a parameter or variable in the Equation Editor, its value is shared all over the model. It means that various submodels can use the same parameter or variable, but you only have to assign the value once. In equation models, the keyword global is added after the definition of the data type:

 

parameters

 real global par1 = 100 {Hz};

 real global par2 ;

variables

 real global var1;

 real global var2;

..

..

 

Parameters can only be assigned a value once. The same goes for variables. In only one submodel the global variable can be assigned a value using an equation. If parameters or variables are assigned more than once, 20-sim will generate an error.

Scope

By default, global parameters and variables and valid in the entire model. However, the scope can be limited to a certain branch in your model tree.

Changing Global Parameters Values

You can change the value of a global parameter in the Parameters/Initial Values Editor. By default, global parameters and variables and valid in the entire model. In the Parameters/Initial Values Editor you will find the parameters at the top level of the hierarchy. If the parameter has a scope, you will find it in the specific branch of the model hierarchy.