User`s guide
Model Execution
6-5
a given simulation time step. In minor time steps, the run-time interface
integrates the derivatives to update the continuous states.
• ModelUpdate — Calling all blocks in your model that have a sample hit at
the current point in time and having them update their discrete states or
similar type objects.
• ModelDerivatives — Calling all blocks in your model that have continuous
states and having them update their derivatives. ModelDerivatives is only
called in minor time steps.
The pseudocode below shows the execution of a model for a singletasking
simulation (nonreal-time).
main()
{
Initialization
While (time < final time)
ModelOutputs -- Major time step.
LogTXY -- Log time, states and root outports.
ModelUpdate -- Major time step.
Integrate: -- Integration in minor time step for models
-- with continuous states.
ModelDerivatives
Do 0 or more:
ModelOutputs
ModelDerivatives
EndDo (Number of iterations depends upon the solver.)
Integrate derivatives to update continuous states.
EndIntegrate
EndWhile
Shutdown
}
The initialization phase begins first. This consists of initializing model states
and setting up the execution engine. The model then executes, one step at a
time. First ModelOutputs executes at time t, then the workspace I/O data is
logged, and then ModelUpdate updates the discrete states. Next, if your model
has any continuous states, ModelDerivatives integrates the continuous states’
derivatives to generate the states for time , where h is the step
size. Time then moves forward to and the process repeats.
t
new
th+=
t
new