Working with equations : Introduction



Introduction to equations

Equations are used for two purposes:

  • to provide the initial value for model elements that need to be initialised, such as compartments;
  • to enable a value for each other type of element to be calculated while the model is running.

In the first case, the equation is used only at the very start of the simulation: the element's value may change subsequently as the simulation proceeds. This use of the equation applies to just two types of model element: the compartment and the initialisation element for population submodels. For a compartment, it specifies the initial value of that compartment: the value of the compartment will change during the course of the simulation as a result of the flows into or out of it. For the initialisation element, the equation specifies how many instances of a population submodel initially exist: these may be destroyed and others created as the simulation proceeds.

In the second case, the equation is being referred to throughout the simulation. This use of the equation applies to all other types of model element.

In all cases, you (the model developer) enter the equation using the equation bar or equation dialogue window. The equation dialogue window is required for entering some more complex types of expression. This window is displayed by double-clicking on a model element (except for a submodel or an influence arrow) when you are in Pointer mode.

An equation has the general form: quantity = expression where "quantity" is some quantity in the model (such as variable or flow) and "expression" is some algebraic expression that is evaluated when the model is running to provide the value for the quantity.

Since you have clicked on the symbol for a particular quantity, you have already specified what quantity the equation is for, and thus you do not have to enter the left-hand side of the equation: all you have to do is to enter the expression.

It is sometimes not appreciated that an equation is constantly being re-evaluated during the course of a simulation run. Thus, an equation for calculating the flow rate for water out of a tank, in terms of the amount of water in the tank, might be:

outflow = 0.1*tank

i.e. the outflow is proportional to the amount of water in the tank. When the model is running, the value for the amount of water in the tank is changing, and thus the calculated outflow changes as well.

In: Contents >> Working with equations