Simulation builtins

The simulation builtins return values that are either specified in the simulation Run Specs dialog box, or that are related to the current simulation run.

This section describes the following builtins:

DT

DT is the time increment for calculations in a model simulation. You select the DT for the model in the Run Specs dialog box. For more information about DT, see Understanding DT (Delta Time).

RUNCOUNT

The RUNCOUNT builtin returns the number of complete runs prior to the current run.

When you create a new model or open an existing model and run it for the first time, RUNCOUNT equals 0 (that is, the number of runs prior to the current run equals 0).

When you run the model a second time, RUNCOUNT equals 1.

This is useful when you're building an interactive interface for your model and you want some change to take place after a few runs (for example, turn on a piece of structure).

Note To use something that counts runs, but can be reset from the interface, you can create a variable as described for ENDVAL.

SENSIRUNCOUNT

The SENSIRUNCOUNT builtin returns the number of the run in a sequence of sensitivity runs, or 0 if the current run is not part of a set of sensitivity runs.

When you start a sensitivity run SENSIRUNCOUNT will return 1, then 2, then 3 and so on up to the total number of runs being made. Each time you start a new sensitivity run, this sequence will repeat. This can be useful if you want to do something different for specific sensitivity runs. For example, using NORMAL(100,10,SENSIRUNCOUNT) would return a different random number sequence for each run in sensitivity. This value will be independent of the other sensitivity parameters and invariant across sensitivity executions.

SENSIRUNTOTALT

The SENSIRUNTOTAL builtin returns the number of runs that will will occur when sensitivity is running, or 0 if sensitivity is not running.

When you start a sensitivity run SENSIRUNTOTAL will return the total number of runs that will occur. This can be useful when displaying progress through sensitivity on the interface.

STARTTIME

The STARTTIME builtin returns the value that you've specified in the From box in the Run Specs dialog box for the model.

STOPTIME

The STOPTIME builtin returns the value that you've specified in the To box in the Run Specs dialog box for the model.

TIME

The TIME builtin returns the current time within a model simulation. TIME is often used as an argument to logical functions, trigonometric functions, and graphical functions.

Examples:

10*SIN(2*PI*TIME/12) generates a sinusoidal fluctuation with an amplitude of 10 and a period of 12.

My_Bonus = IF(TIME=5) OR (Sales>5000) THEN Bonus ELSE 0

This statement sets My Bonus to the value of Bonus at simulated time 5, or whenever the value of Sales is greater than 5000. When neither condition is met, the statement gives the value 0. Sales and Bonus are defined elsewhere in the model.

As the following graph shows, TIME can also be used as the independent variable in a graphical function which defines a set of historical data.

Because of the internal calculations associated with the Runge-Kutta methods, the TIME function won't return values equal to simulation time when you use the 2nd- or 4th-order Runge-Kutta computation methods. When your model constructs rely on the TIME function being exactly equal to simulation time, be sure to use Euler's method.

Concept Link IconSee Also