Variables, Parameters, Initial Values and Constants

Navigation:  Quick Tour >

Variables, Parameters, Initial Values and Constants

Previous pageReturn to chapter overviewNext page

Equations are the foundation for all models in 20-sim. At the lowest level of a model you will always find equations. Equations can be entered in the 20-sim Editor. An example equation model is shown below:



 real g = 9.81 {m/s2};   // gravity


 real m = 1.0 {kg};     // mass

 real g = 9.8 {m/s2};   // gravity

 real K = 2.0 {N/m};     // spring constant

 real f = 1.0 {N.s/m};   // friction parameter


 real v {m/s};           // velocity

 real interesting x {m}; // position

 real Fm {N};           // net-force applied to the mass

 real Fs {N};           // spring force

 real Fd {N};           // damper force


 Fm = -m * g - Fs - Fd;

v = ( 1/m ) * int( Fm, 0 );

x = int( v, 0 );

Fs = K * x;

Fd = f * v;


A 20-sim equation model starts with the declaration of parameters and variables. In the Equation section, the equations are entered. An equation is simply a variable on the left part of the equal sign and variables or functions at the right side. During a simulation, the equations are calculated over and over again, many time steps, while the resulting variable values are be shown in plots.


You can inspect equations by opening an example model, select one of the blocks with you mouse pointer and select "Go Down "from the right mouse menu. If you repeat this you will always see an equation model at the lowest level.


Variables can change value during a simulation. You can inspect the current value of a variables in the Variable Chooser.


Parameters have a fixed value that you can change before a simulation in the Parameters/Initial Values Editor.


Constants are symbolic representations of numerical quantities that do not change during or in between simulation runs.

Initial Values

Some functions like an integral or a hold have an initial value. These initial values can be entered in the equation model (see int-function with a zero initial value in the example above: v = (1/m)*int(Fm, 0)) or be changed before a simulation in the the Parameters/Initial Values Editor.