Equations are the basis for all models in 20-sim. You will always find equations at the lowest level of a model. Equations can be entered in the 20-sim Editor. An example equation model is shown below:
constants
real g = 9.81 {m/s2}; // gravity
parameters
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
variables
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
equations
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 begins with the declaration of parameters and variables. The equations are entered in the editor at the right. An equation is simply a variable to the left part of the equal sign and variables or functions to the right side. During a simulation, the equations are calculated over and over again, many time steps, while the resulting variable values are be displayed in plots.
You can inspect equations by opening an example model, selecting one of the blocks with the mouse pointer and selecting "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 their value during a simulation. You can check the current value of a variables in the Variable Chooser.
Parameters have a fixed value which you can change before a simulation in the Parameters/Initial Values Editor.
Constants have a fixed value that does not change during or in between simulation runs.
Some functions, such as 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.