Simulator calls the Computational function for performing
different tasks:
Initialization The simulator calls the Computational function once
at the start for state and output initialization (inputs
are not available then). Other tasks such as file opening, graphical window
initialization, etc..., can also be performed at this point.
Re-initialization The simulator can call the block a number of times for
re-initialization. This is another opportunity to initialize
states and outputs. But this time, the inputs are
available.
Outputs update The simulator calls for the value of
the outputs. Thus the Computational function should evaluate
(4).
States update One or more events have arrived and the
simulator calls the Computational function to update the
states x and z according to (2) and
(3).
State derivative computation
The simulator is in a continuous phase; the
solver requires dx/dt. This means that the Computational function
must evaluate (1).
Output events timing The simulator calls the Computational
function about the timing of its output events. The
Computational function should evaluate (5).
Ending The simulator calls
the Computational function once at the end (useful for closing files, free allocated
memory, etc...).
The simulator uses a flag to specify which task should be performed
(see Table 1).
Table 1:
Tasks of Computational function and their corresponding flags