FMU Block Calling Sequences
During simulation of models containing FMU blocks, as Simulink® passes through different Simulink engine phases, the FMU blocks call FMU Co-Simulation and Model Exchange methods
for FMI Versions 1.0 and 2.0 (fmi
* and fmi2
* methods).
This topic presents the FMI Standard call
sequences in those phases.
This topic uses:
fmiSetXXX
(FMI Version 1.0) andfmi2SetXXX
(FMI Version 2.0) to represent any of the methods:fmiSetReal
/fmi2SetReal
,fmiSetInteger
/fmi2SetInteger
,fmiSetBoolean
/fmi2SetBoolean
, orfmiSetString
/fmi2SetString
.fmiGetXXX
(FMI Version 1.0) andfmi2GetXXX
(FMI Version 2.0) to represent any of the methods:fmiGetReal
/fmi2GetReal
,fmiGetInteger
/fmi2GetInteger
,fmiGetBoolean
/fmi2GetBoolean
, orfmiGetString
/fmi2GetString
.
Co-Simulation Call Sequence for FMI Version 1.0
These are the call orders for the FMI methods that the S-function callback methods call.
Setup Phase
At the end of compilation, the FMU block performs setup activities by calling these FMI methods:
fmiGetTypesPlatform
fmiGetVersion
fmiInstantiateModel
fmiSetTime
For variables with start values,
fmiSetXXX
Initialization Phase
At the start of simulation, the FMU block sets up internal states and performs other
initialization activities by calling the fmiSetXXX
methods for tunable parameters.
Output Phase
During this phase, the FMU block computes outputs at the current time step by calling these FMI methods:
If the call is the first step:
fmiSetXXX
fmiInitialize
If an event occurs,
fmiEventUpdate
If the call is not the first step:
fmiSetTime
fmiSetXXX
(for input)fmiSetContinuousStates
fmiCompletedIntegratorStep
If an event occurs,
fmiEventUpdate
For output,
fmiGetXXX
Update Phase
The FMU block computes states at the current time step and performs other major time
step activities by calling the fmiSetXXX
methods for
input.
Derivatives Phase
The FMU block computes derivatives of the FMU continuous states by calling these FMI methods:
fmiSetTime
fmiSetContinuousStates
fmiGetDerivatives
Zero-Crossing Signal Phase
The FMU block computes the zero-crossing vector from the FMU event indicator by calling these FMI functions:
fmiSetTime
fmiSetContinuousStates
fmiGetEventIndicators
Termination Phase
At the end of simulation, the FMU block performs activities before terminating the simulation by calling these FMI methods:
fmiTerminate
fmiFreeModelInstance
Model Exchange Call Sequence for FMI Version 1.0
These are the call orders for the FMI methods that the S-function callback methods call.
Setup Phase
At the end of compilation, the FMU block performs setup activities by calling these FMI functions:
fmiGetTypesPlatform
fmiGetVersion
fmiInstantiateModel
fmiSetTime
For variables with start values,
fmiSetXXX
Initialization Phase
At the start of simulation, the FMU block sets up internal states and performs other
initialization activities by calling these fmiSetXXX
methods for tunable parameters.
Output Phase
The FMU block computes outputs at the current time step by calling these FMI functions:
If the call is the first step:
fmiSetXXX
fmiInitialize
If an event occurs,
fmiEventUpdate
If the call is not the first step,
fmiDoStep
,For output,
fmiGetXXX
Update Phase
The FMU block computes states at the current time step and performs other major time
step activities by calling the fmiSetXXX
methods for
input.
Termination Phase
At the end of simulation, the FMU block performs activities before terminating the simulation. This method calls these methods:
fmiTerminate
fmiFreeModelInstance
Co-Simulation Call Sequence for FMI Version 2.0
These are the call orders for the FMI methods that the S-function callback methods call.
Setup Phase
At the end of compilation, the FMU block performs setup activities by calling these FMI methods:
fmi2GetTypesPlatform
fmi2GetVersion
fmi2Instantiate
For variables with start values,
fmi2SetXXX
Initialization Phase
At the start of simulation, the FMU block sets up internal states and performs other initialization activities by calling these FMI methods:
For variables with start values,
fmi2SetXXX
fmi2SetupExperiment
Output Phase
During this phase, the FMU block computes outputs at the current time step by calling these FMI methods:
If the call is the first step:
fmi2EnterInitializationMode
For input,
fmi2SetXXX
fmi2InitializationMode
If the call is not the first step,
fmi2DoStep
For output,
fmi2GetXXX
Update Phase
During this phase, the FMU block computes states at the current time step and performs
other major time step activities. This method calls the
fmi2SetXXX
for input.
Termination Phase
At the end of simulation, the FMU block performs activities before terminating the simulation by calling these methods:
fmi2Terminate
fmi2FreeModelInstance
Model Exchange Call Sequence for FMI Version 2.0
These are the call orders for the FMI methods that the S-function callback methods call.
Setup Phase
At the end of compilation, the FMU block performs setup activities by calling these FMI methods:
fmi2GetTypesPlatform
fmi2GetVersion
fmi2Instantiate
For variables with start values,
fmi2SetXXX
Initialization Phase
At the start of simulation, the FMU block sets up internal states and performs other initialization activities by calling these FMI methods.
For tunable parameters,
fmi2SetXXX
fmi2SetupExperiment
Output Phase
The FMU block computes outputs at the current time step by calling these FMI methods:
If the call is the first step:
fmi2EnterIntializationMode
For input,
fmi2SetXXX
fmi2ExitIntializationMode
If the call is not the first step:
fmi1SetTime
For continuous input,
fmi2SetXXX
fmi2SetContinuousStates
fmi2SetContinuousStates
fmi2CompletedIntegratorStep
If an event occurs:
fmi2EnterEventMode
For input,
fmi2SetXXX
fmi2NewDiscreteStates
fmi2EnterContinuousTimeMode
If an event occurs:
fmi2EnterEventMode
For input,
fmi2SetXXX
fmi2NewDiscreteStates
fmi2EnterContinuousTimeMode
For output,
fmi2GetXXX
Update Phase
The FMU block computes states at the current time step and performs other major time
step activities by calling the fmi2SetXXX
methods
for input.
Derivatives Phase
The FMU block computes derivatives of the FMU continuous states by calling these FMI methods:
fmi2SetTime
fmi2SetContinuousStates
fmi2GetEventIndicators
Zero-Crossing Signal Phase
The FMU block computes the zero-crossing vector from the FMU event indicator by calling these FMI methods:
fmi2SetTime
fmi2SetContinuousStates
fmi2GetEventIndicators
Termination Phase
At the end of simulation, the FMU block performs activities before terminating the simulation by calling these methods:
fmi2Terminate
fmi2FreeInstance