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) and- fmi2SetXXX(FMI Version 2.0) to represent any of the methods:- fmiSetReal/- fmi2SetReal,- fmiSetInteger/- fmi2SetInteger,- fmiSetBoolean/- fmi2SetBoolean, or- fmiSetString/- fmi2SetString.
- fmiGetXXX(FMI Version 1.0) and- fmi2GetXXX(FMI Version 2.0) to represent any of the methods:- fmiGetReal/- fmi2GetReal,- fmiGetInteger/- fmi2GetInteger,- fmiGetBoolean/- fmi2GetBoolean, or- fmiGetString/- 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
- fmi2ExitInitializationMode
 
- 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: - fmi2SetTime
- 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
Co-Simulation Call Sequence for FMI Version 3.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:
- fmi3GetTypesPlatform
- fmi3GetVersion
- fmi3InstantiateCoSimulation
- For variables with start values, - fmi3SetXXX
Initialization Phase
At the start of simulation, the FMU block sets up internal states and performs other initialization activities by calling the following:
- For variables with start values, - fmi3SetXXX
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: - fmi3EnterInitializationMode
- For input, - fmi3SetXXX
- fmi3ExitInitializationMode
 
- If the call is not the first step, - fmi3DoStep
- If an event occurs: - fmi3EnterEventMode
- Set continuous and discrete inputs: - fmi3SetXXX
- fmi3UpdateDiscreteStates
 
- For output, - fmi3GetXXX
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
              fmi3SetXXX for input.
If FMU is in event mode, then enter step mode using
            fmi3EnterStepMode function.
Termination Phase
At the end of simulation, the FMU block performs activities before terminating the simulation by calling these methods:
- fmi3Terminate
- fmi3FreeModelInstance
Model Exchange Call Sequence for FMI Version 3.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:
- fmi3GetTypesPlatform
- fmi3GetVersion
- fmi3InstantiateModelExchange
- For variables with start values, - fmi3SetXXX
Initialization Phase
At the start of simulation, the FMU block sets up internal states and performs other initialization activities by calling the following:
- For tunable parameters, - fmi3SetXXX
Output Phase
The FMU block computes outputs at the current time step by calling these FMI methods:
- If the call is the first step: - fmi3EnterIntializationMode
- For input, - fmi3SetXXX
- fmi3ExitIntializationMode
 
- If the call is not the first step: - fmi3SetTime
- For continuous input, - fmi3SetXXX
- fmi3SetContinuousStates
- fmi3SetContinuousStates
- fmi3CompletedIntegratorStep
- If an event occurs: - fmi3EnterEventMode
- For input, - fmi3SetXXX
- fmi3NewDiscreteStates
- fmi3EnterContinuousTimeMode
- If an event occurs: - fmi3EnterEventMode
- For input, - fmi3SetXXX
- fmi3NewDiscreteStates
- fmi3EnterContinuousTimeMode
 
 
 
- For output, - fmi3GetXXX
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:
- fmi3SetTime
- fmi3SetContinuousStates
- fmi3GetEventIndicators
Termination Phase
At the end of simulation, the FMU block performs activities before terminating the simulation by calling these methods:
- fmi3Terminate
- fmi3FreeInstance