FMI for Co-Simulation

This chapter defines the Functional Mock-up Interface (FMI) for the coupling of two or more simulation models in a Co-Simulation environment (FMI for Co-Simulation). Co-Simulation is a rather general approach to the simulation of coupled technical systems and coupled physical phenomena in engineering with focus on instationary (time-dependent) problems.

Transfer of Input / Output Values and Parameters

In order to enable the slave to interpolate the continuous real inputs between communication steps, the derivatives of the inputs with respect to time can be provided. Also, higher derivatives can be set to allow higher order interpolation.

FMIImport.fmi2GetRealOutputDerivativesFunction
fmi2GetRealOutputDerivatives(c::FMU2Component, vr::fmi2ValueReferenceFormat, order::AbstractArray{fmi2Integer})

Sets the n-th time derivative of real input variables.

Arguments

  • c::FMU2Component: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.
  • vr::Array{fmi2ValueReference}: Argument vr is an array of nvr value handels called "ValueReference" that t define the variables whose derivatives shall be set.
  • order::Array{fmi2Integer}: Argument order is an array of fmi2Integer values witch specifys the corresponding order of derivative of the real input variable.

Returns

  • value::AbstactArray{fmi2Integer}: Return value is an array which represents a vector with the values of the derivatives.

Source

  • FMISpec2.0.2 Link: https://fmi-standard.org/
  • FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions
  • FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
  • FMISpec2.0.2[p.104]: 4.2.1 Transfer of Input / Output Values and Parameters
source

Computation

The computation of time steps is controlled by the following function.

FMICore.fmi2DoStepFunction

Source: FMISpec2.0.2[p.104]: 4.2.2 Computation

The computation of a time step is started.

source
fmi2DoStep(c::FMU2Component, 
                currentCommunicationPoint::fmi2Real, 
                communicationStepSize::fmi2Real, 
                noSetFMUStatePriorToCurrentPoint::fmi2Boolean)

The computation of a time step is started.

Arguments

  • c::FMU2Component: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.
  • currentCommunicationPoint::fmi2Real: Argument currentCommunicationPoint contains a value of type fmi2Real which is a identifier for a variable value . currentCommunicationPoint defines the current communication point of the master.
  • communicationStepSize::fmi2Real: Argument communicationStepSize contains a value of type fmi2Real which is a identifier for a variable value. communicationStepSize defines the communiction step size.

noSetFMUStatePriorToCurrentPoint::Bool = true: Argument noSetFMUStatePriorToCurrentPoint contains a value of type Boolean. If no argument is passed the default value true is used. noSetFMUStatePriorToCurrentPoint indicates whether fmi2SetFMUState is no longer called for times before the currentCommunicationPoint in this simulation run Simulation run.

Returns

  • status::fmi2Status: Return status is an enumeration of type fmi2Status and indicates the success of the function call.

More detailed:

  • fmi2OK: all well
  • fmi2Warning: things are not quite right, but the computation can continue
  • fmi2Discard: if the slave computed successfully only a subinterval of the communication step
  • fmi2Error: the communication step could not be carried out at all
  • fmi2Fatal: if an error occurred which corrupted the FMU irreparably
  • fmi2Pending: this status is returned if the slave executes the function asynchronously

Source

  • FMISpec2.0.2 Link: https://fmi-standard.org/
  • FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions (fmi2TypesPlatform.h)
  • FMISpec2.0.2[p.16]: 2.1.3 Status Returned by Functions
  • FMISpec2.0.2[p.104]: 4.2.2 Computation

See also fmi2DoStep.

source
fmi2DoStep(c::FMU2Component, 
                communicationStepSize::Union{Real, Nothing} = nothing; 
                currentCommunicationPoint::Union{Real, Nothing} = nothing,
                noSetFMUStatePriorToCurrentPoint::Bool = true)

Does one step in the CoSimulation FMU

Arguments

  • C::FMU2Component: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.
  • communicationStepSize::Union{Real, Nothing} = nothing: Argument communicationStepSize contains a value of type Real or Nothing , if no argument is passed the default value nothing is used. communicationStepSize defines the communiction step size.

Keywords

  • currentCommunicationPoint::Union{Real, Nothing} = nothing: Argument currentCommunicationPoint contains a value of type Real or type Nothing. If no argument is passed the default value nothing is used. currentCommunicationPoint defines the current communication point of the master.
  • noSetFMUStatePriorToCurrentPoint::Bool = true: Argument noSetFMUStatePriorToCurrentPoint contains a value of type Boolean. If no argument is passed the default value true is used. noSetFMUStatePriorToCurrentPoint indicates whether fmi2SetFMUState is no longer called for times before the currentCommunicationPoint in this simulation run Simulation run.

Returns

  • status::fmi2Status: Return status is an enumeration of type fmi2Status and indicates the success of the function call.

More detailed:

  • fmi2OK: all well
  • fmi2Warning: things are not quite right, but the computation can continue
  • fmi2Discard: if the slave computed successfully only a subinterval of the communication step
  • fmi2Error: the communication step could not be carried out at all
  • fmi2Fatal: if an error occurred which corrupted the FMU irreparably
  • fmi2Pending: this status is returned if the slave executes the function asynchronously

Source

  • FMISpec2.0.2 Link: https://fmi-standard.org/
  • FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions (fmi2TypesPlatform.h)
  • FMISpec2.0.2[p.16]: 2.1.3 Status Returned by Functions
  • FMISpec2.0.2[p.104]: 4.2.2 Computation

See also fmi2DoStep.

source
FMICore.fmi2CancelStepFunction

Source: FMISpec2.0.2[p.105]: 4.2.2 Computation

Can be called if fmi2DoStep returned fmi2Pending in order to stop the current asynchronous execution.

source
fmi2CancelStep(c::FMU2Component)

Can be called if fmi2DoStep returned fmi2Pending in order to stop the current asynchronous execution.

Arguments

  • c::FMU2Component: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.

Returns

  • status::fmi2Status: Return status is an enumeration of type fmi2Status and indicates the success of the function call.

More detailed:

  • fmi2OK: all well
  • fmi2Warning: things are not quite right, but the computation can continue
  • fmi2Discard: if the slave computed successfully only a subinterval of the communication step
  • fmi2Error: the communication step could not be carried out at all
  • fmi2Fatal: if an error occurred which corrupted the FMU irreparably
  • fmi2Pending: this status is returned if the slave executes the function asynchronously

Source

  • FMISpec2.0.2 Link: https://fmi-standard.org/
  • FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions (fmi2TypesPlatform.h)
  • FMISpec2.0.2[p.16]: 2.1.3 Status Returned by Functions
  • FMISpec2.0.2[p.104]: 4.2.2 Computation

See also fmi2DoStep.

source

Retrieving Status Information from the Slave

Status information is retrieved from the slave by the following functions:

FMICore.fmi2GetStatus!Function

Source: FMISpec2.0.2[p.106]: 4.2.3 Retrieving Status Information from the Slave

Informs the master about the actual status of the simulation run. Which status information is to be returned is specified by the argument fmi2StatusKind.

source
fmi2GetStatus!(c::FMU2Component, 
                    s::fmi2StatusKind, 
                    value::Ref{fmi2Status})

Informs the master about the actual status of the simulation run. Which status information is to be returned is specified by the argument fmi2StatusKind.

Arguments

  • c::FMU2Component: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.
  • s::fmi2StatusKind: Argument s defines which status information is to be returned. fmi2StatusKind is an enumeration that defines which status is inquired.

The following status information can be retrieved from a slave:

  • fmi2DoStepStatus::fmi2Status: Can be called when the fmi2DoStep function returned fmi2Pending. The function delivers fmi2Pending if the computation is not finished. Otherwise the function returns the result of the asynchronously executed fmi2DoStep call.
  • fmi2PendingStatus::fmi2String: Can be called when the fmi2DoStep function returned fmi2Pending. The function delivers a string which informs about the status of the currently running asynchronous fmi2DoStep computation
  • fmi2LastSuccessfulTime:: fmi2Real: Returns the end time of the last successfully completed communication step. Can be called after fmi2DoStep(..) returned fmi2Discard.
  • fmi2Terminated::fmi2Boolean: Returns fmi2True, if the slave wants to terminate the simulation. Can be called after fmi2DoStep(..) returned fmi2Discard. Use fmi2LastSuccessfulTime to determine the time instant at which the slave terminated.
  • value::Ref{fmi2Status}: The value argument points to a status flag that was requested.

Returns

  • status::fmi2Status: Return status is an enumeration of type fmi2Status and indicates the success of the function call.

More detailed:

  • fmi2OK: all well
  • fmi2Warning: things are not quite right, but the computation can continue
  • fmi2Discard: if the slave computed successfully only a subinterval of the communication step
  • fmi2Error: the communication step could not be carried out at all
  • fmi2Fatal: if an error occurred which corrupted the FMU irreparably
  • fmi2Pending: this status is returned if the slave executes the function asynchronously

Source

  • FMISpec2.0.2 Link: https://fmi-standard.org/
  • FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions (fmi2TypesPlatform.h)
  • FMISpec2.0.2[p.16]: 2.1.3 Status Returned by Functions
  • FMISpec2.0.2[p.106]: 4.2.3 Retrieving Status Information from the Slave

See also fmi2GetStatus!.

source
FMICore.fmi2GetRealStatus!Function

Source: FMISpec2.0.2[p.106]: 4.2.3 Retrieving Status Information from the Slave

Informs the master about the actual status of the simulation run. Which status information is to be returned is specified by the argument fmi2StatusKind.

source
fmi2GetRealStatus!(c::FMU2Component, 
                        s::fmi2StatusKind, 
                        value::Ref{fmi2Real})

Informs the master about the actual status of the simulation run. Which status information is to be returned is specified by the argument fmi2StatusKind.

Arguments

  • c::FMU2Component: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.
  • s::fmi2StatusKind: Argument s defines which status information is to be returned. fmi2StatusKind is an enumeration that defines which status is inquired.

The following status information can be retrieved from a slave:

  • fmi2DoStepStatus::fmi2Status: Can be called when the fmi2DoStep function returned fmi2Pending. The function delivers fmi2Pending if the computation is not finished. Otherwise the function returns the result of the asynchronously executed fmi2DoStep call.
  • fmi2PendingStatus::fmi2String: Can be called when the fmi2DoStep function returned fmi2Pending. The function delivers a string which informs about the status of the currently running asynchronous fmi2DoStep computation
  • fmi2LastSuccessfulTime:: fmi2Real: Returns the end time of the last successfully completed communication step. Can be called after fmi2DoStep(..) returned fmi2Discard.
  • fmi2Terminated::fmi2Boolean: Returns fmi2True, if the slave wants to terminate the simulation. Can be called after fmi2DoStep(..) returned fmi2Discard. Use fmi2LastSuccessfulTime to determine the time instant at which the slave terminated.
  • value::Ref{fmi2Real}: Argument value points to the return value (fmi2Real) which was requested. fmi2Real is a alias type for Real data type.

Returns

  • status::fmi2Status: Return status is an enumeration of type fmi2Status and indicates the success of the function call.

More detailed:

  • fmi2OK: all well
  • fmi2Warning: things are not quite right, but the computation can continue
  • fmi2Discard: if the slave computed successfully only a subinterval of the communication step
  • fmi2Error: the communication step could not be carried out at all
  • fmi2Fatal: if an error occurred which corrupted the FMU irreparably
  • fmi2Pending: this status is returned if the slave executes the function asynchronously

Source

  • FMISpec2.0.2 Link: https://fmi-standard.org/
  • FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions (fmi2TypesPlatform.h)
  • FMISpec2.0.2[p.16]: 2.1.3 Status Returned by Functions
  • FMISpec2.0.2[p.106]: 4.2.3 Retrieving Status Information from the Slave

See also fmi2GetRealStatus!.

source
FMICore.fmi2GetIntegerStatus!Function

Source: FMISpec2.0.2[p.106]: 4.2.3 Retrieving Status Information from the Slave

Informs the master about the actual status of the simulation run. Which status information is to be returned is specified by the argument fmi2StatusKind.

source
fmi2GetIntegerStatus!(c::FMU2Component, 
                            s::fmi2StatusKind, 
                            value::Ref{fmi2Integer})

Informs the master about the actual status of the simulation run. Which status information is to be returned is specified by the argument fmi2StatusKind.

Arguments

  • c::FMU2Component: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.
  • s::fmi2StatusKind: Argument s defines which status information is to be returned. fmi2StatusKind is an enumeration that defines which status is inquired.

The following status information can be retrieved from a slave:

  • fmi2DoStepStatus::fmi2Status: Can be called when the fmi2DoStep function returned fmi2Pending. The function delivers fmi2Pending if the computation is not finished. Otherwise the function returns the result of the asynchronously executed fmi2DoStep call.
  • fmi2PendingStatus::fmi2String: Can be called when the fmi2DoStep function returned fmi2Pending. The function delivers a string which informs about the status of the currently running asynchronous fmi2DoStep computation
  • fmi2LastSuccessfulTime:: fmi2Real: Returns the end time of the last successfully completed communication step. Can be called after fmi2DoStep(..) returned fmi2Discard.
  • fmi2Terminated::fmi2Boolean: Returns fmi2True, if the slave wants to terminate the simulation. Can be called after fmi2DoStep(..) returned fmi2Discard. Use fmi2LastSuccessfulTime to determine the time instant at which the slave terminated.
  • value::Ref{fmi2Integer}: Argument value points to the return value (fmi2Integer) which was requested. fmi2Integer is a alias type for Integer data type.

Returns

  • status::fmi2Status: Return status is an enumeration of type fmi2Status and indicates the success of the function call.

More detailed:

  • fmi2OK: all well
  • fmi2Warning: things are not quite right, but the computation can continue
  • fmi2Discard: if the slave computed successfully only a subinterval of the communication step
  • fmi2Error: the communication step could not be carried out at all
  • fmi2Fatal: if an error occurred which corrupted the FMU irreparably
  • fmi2Pending: this status is returned if the slave executes the function asynchronously

Source

  • FMISpec2.0.2 Link: https://fmi-standard.org/
  • FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions (fmi2TypesPlatform.h)
  • FMISpec2.0.2[p.16]: 2.1.3 Status Returned by Functions
  • FMISpec2.0.2[p.106]: 4.2.3 Retrieving Status Information from the Slave

See also fmi2GetIntegerStatus!.

source
FMICore.fmi2GetBooleanStatus!Function

Source: FMISpec2.0.2[p.106]: 4.2.3 Retrieving Status Information from the Slave

Informs the master about the actual status of the simulation run. Which status information is to be returned is specified by the argument fmi2StatusKind.

source
fmi2GetBooleanStatus!(c::FMU2Component, 
                        s::fmi2StatusKind, 
                        value::Ref{fmi2Boolean})

Informs the master about the actual status of the simulation run. Which status information is to be returned is specified by the argument fmi2StatusKind.

Arguments

  • c::FMU2Component: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.
  • s::fmi2StatusKind: Argument s defines which status information is to be returned. fmi2StatusKind is an enumeration that defines which status is inquired.

The following status information can be retrieved from a slave:

  • fmi2DoStepStatus::fmi2Status: Can be called when the fmi2DoStep function returned fmi2Pending. The function delivers fmi2Pending if the computation is not finished. Otherwise the function returns the result of the asynchronously executed fmi2DoStep call.
  • fmi2PendingStatus::fmi2String: Can be called when the fmi2DoStep function returned fmi2Pending. The function delivers a string which informs about the status of the currently running asynchronous fmi2DoStep computation
  • fmi2LastSuccessfulTime:: fmi2Real: Returns the end time of the last successfully completed communication step. Can be called after fmi2DoStep(..) returned fmi2Discard.
  • fmi2Terminated::fmi2Boolean: Returns fmi2True, if the slave wants to terminate the simulation. Can be called after fmi2DoStep(..) returned fmi2Discard. Use fmi2LastSuccessfulTime to determine the time instant at which the slave terminated.
  • value::Ref{fmi2Boolean}: Argument value points to the return value (fmi2Boolean) which was requested. fmi2Boolean is a alias type for Boolean data type.

Returns

  • status::fmi2Status: Return status is an enumeration of type fmi2Status and indicates the success of the function call.

More detailed:

  • fmi2OK: all well
  • fmi2Warning: things are not quite right, but the computation can continue
  • fmi2Discard: if the slave computed successfully only a subinterval of the communication step
  • fmi2Error: the communication step could not be carried out at all
  • fmi2Fatal: if an error occurred which corrupted the FMU irreparably
  • fmi2Pending: this status is returned if the slave executes the function asynchronously

Source

  • FMISpec2.0.2 Link: https://fmi-standard.org/
  • FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions (fmi2TypesPlatform.h)
  • FMISpec2.0.2[p.16]: 2.1.3 Status Returned by Functions
  • FMISpec2.0.2[p.106]: 4.2.3 Retrieving Status Information from the Slave

See also fmi2GetBooleanStatus!.

source
FMICore.fmi2GetStringStatus!Function

Source: FMISpec2.0.2[p.106]: 4.2.3 Retrieving Status Information from the Slave

Informs the master about the actual status of the simulation run. Which status information is to be returned is specified by the argument fmi2StatusKind.

source
fmi2GetStringStatus!(c::FMU2Component, 
                        s::fmi2StatusKind, 
                        value::Ref{fmi2String})

Informs the master about the actual status of the simulation run. Which status information is to be returned is specified by the argument fmi2StatusKind.

Arguments

  • c::FMU2Component: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.
  • s::fmi2StatusKind: Argument s defines which status information is to be returned. fmi2StatusKind is an enumeration that defines which status is inquired.

The following status information can be retrieved from a slave:

  • fmi2DoStepStatus::fmi2Status: Can be called when the fmi2DoStep function returned fmi2Pending. The function delivers fmi2Pending if the computation is not finished. Otherwise the function returns the result of the asynchronously executed fmi2DoStep call.
  • fmi2PendingStatus::fmi2String: Can be called when the fmi2DoStep function returned fmi2Pending. The function delivers a string which informs about the status of the currently running asynchronous fmi2DoStep computation
  • fmi2LastSuccessfulTime:: fmi2Real: Returns the end time of the last successfully completed communication step. Can be called after fmi2DoStep(..) returned fmi2Discard.
  • fmi2Terminated::fmi2Boolean: Returns fmi2True, if the slave wants to terminate the simulation. Can be called after fmi2DoStep(..) returned fmi2Discard. Use fmi2LastSuccessfulTime to determine the time instant at which the slave terminated.
  • value:Ref{fmi2String}: Argument value points to the return value (fmi2String) which was requested. fmi2String is a alias type for String data type.

Returns

  • status::fmi2Status: Return status is an enumeration of type fmi2Status and indicates the success of the function call.

More detailed:

  • fmi2OK: all well
  • fmi2Warning: things are not quite right, but the computation can continue
  • fmi2Discard: if the slave computed successfully only a subinterval of the communication step
  • fmi2Error: the communication step could not be carried out at all
  • fmi2Fatal: if an error occurred which corrupted the FMU irreparably
  • fmi2Pending: this status is returned if the slave executes the function asynchronously

Source

  • FMISpec2.0.2 Link: https://fmi-standard.org/
  • FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions (fmi2TypesPlatform.h)
  • FMISpec2.0.2[p.16]: 2.1.3 Status Returned by Functions
  • FMISpec2.0.2[p.106]: 4.2.3 Retrieving Status Information from the Slave

See also fmi2GetStringStatus!.

source