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.fmi2GetRealOutputDerivatives
— Functionfmi2GetRealOutputDerivatives(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}
: Argumentvr
is an array ofnvr
value handels called "ValueReference" that t define the variables whose derivatives shall be set.order::Array{fmi2Integer}
: Argumentorder
is an array of fmi2Integer values witch specifys the corresponding order of derivative of the real input variable.
Returns
value::AbstactArray{fmi2Integer}
: Returnvalue
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
Computation
The computation of time steps is controlled by the following function.
FMICore.fmi2DoStep
— FunctionSource: FMISpec2.0.2[p.104]: 4.2.2 Computation
The computation of a time step is started.
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
: ArgumentcurrentCommunicationPoint
contains a value of typefmi2Real
which is a identifier for a variable value .currentCommunicationPoint
defines the current communication point of the master.communicationStepSize::fmi2Real
: ArgumentcommunicationStepSize
contains a value of typefmi2Real
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
: Returnstatus
is an enumeration of typefmi2Status
and indicates the success of the function call.
More detailed:
fmi2OK
: all wellfmi2Warning
: things are not quite right, but the computation can continuefmi2Discard
: if the slave computed successfully only a subinterval of the communication stepfmi2Error
: the communication step could not be carried out at allfmi2Fatal
: if an error occurred which corrupted the FMU irreparablyfmi2Pending
: 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
.
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
: ArgumentcommunicationStepSize
contains a value of typeReal
orNothing
, if no argument is passed the default valuenothing
is used.communicationStepSize
defines the communiction step size.
Keywords
currentCommunicationPoint::Union{Real, Nothing} = nothing
: ArgumentcurrentCommunicationPoint
contains a value of typeReal
or typeNothing
. If no argument is passed the default valuenothing
is used.currentCommunicationPoint
defines the current communication point of the master.noSetFMUStatePriorToCurrentPoint::Bool = true
: ArgumentnoSetFMUStatePriorToCurrentPoint
contains a value of typeBoolean
. If no argument is passed the default valuetrue
is used.noSetFMUStatePriorToCurrentPoint
indicates whetherfmi2SetFMUState
is no longer called for times before thecurrentCommunicationPoint
in this simulation run Simulation run.
Returns
status::fmi2Status
: Returnstatus
is an enumeration of typefmi2Status
and indicates the success of the function call.
More detailed:
fmi2OK
: all wellfmi2Warning
: things are not quite right, but the computation can continuefmi2Discard
: if the slave computed successfully only a subinterval of the communication stepfmi2Error
: the communication step could not be carried out at allfmi2Fatal
: if an error occurred which corrupted the FMU irreparablyfmi2Pending
: 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
.
FMICore.fmi2CancelStep
— FunctionSource: FMISpec2.0.2[p.105]: 4.2.2 Computation
Can be called if fmi2DoStep returned fmi2Pending in order to stop the current asynchronous execution.
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
: Returnstatus
is an enumeration of typefmi2Status
and indicates the success of the function call.
More detailed:
fmi2OK
: all wellfmi2Warning
: things are not quite right, but the computation can continuefmi2Discard
: if the slave computed successfully only a subinterval of the communication stepfmi2Error
: the communication step could not be carried out at allfmi2Fatal
: if an error occurred which corrupted the FMU irreparablyfmi2Pending
: 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
.
Retrieving Status Information from the Slave
Status information is retrieved from the slave by the following functions:
FMIImport.fmi2GetStatus
— FunctionToDo
FMICore.fmi2GetStatus!
— FunctionSource: 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.
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
: Arguments
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 thefmi2DoStep
function returnedfmi2Pending
. The function deliversfmi2Pending
if the computation is not finished. Otherwise the function returns the result of the asynchronously executedfmi2DoStep
call.fmi2PendingStatus::fmi2String
: Can be called when thefmi2DoStep
function returnedfmi2Pending
. The function delivers a string which informs about the status of the currently running asynchronousfmi2DoStep
computationfmi2LastSuccessfulTime:: fmi2Real
: Returns the end time of the last successfully completed communication step. Can be called after fmi2DoStep(..) returned fmi2Discard.fmi2Terminated::fmi2Boolean
: Returnsfmi2True
, if the slave wants to terminate the simulation. Can be called after fmi2DoStep(..) returnedfmi2Discard
. Use fmi2LastSuccessfulTime to determine the time instant at which the slave terminated.value::Ref{fmi2Status}
: Thevalue
argument points to a status flag that was requested.
Returns
status::fmi2Status
: Returnstatus
is an enumeration of typefmi2Status
and indicates the success of the function call.
More detailed:
fmi2OK
: all wellfmi2Warning
: things are not quite right, but the computation can continuefmi2Discard
: if the slave computed successfully only a subinterval of the communication stepfmi2Error
: the communication step could not be carried out at allfmi2Fatal
: if an error occurred which corrupted the FMU irreparablyfmi2Pending
: 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!
.
FMICore.fmi2GetRealStatus!
— FunctionSource: 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.
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
: Arguments
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 thefmi2DoStep
function returnedfmi2Pending
. The function deliversfmi2Pending
if the computation is not finished. Otherwise the function returns the result of the asynchronously executedfmi2DoStep
call.fmi2PendingStatus::fmi2String
: Can be called when thefmi2DoStep
function returnedfmi2Pending
. The function delivers a string which informs about the status of the currently running asynchronousfmi2DoStep
computationfmi2LastSuccessfulTime:: fmi2Real
: Returns the end time of the last successfully completed communication step. Can be called after fmi2DoStep(..) returned fmi2Discard.fmi2Terminated::fmi2Boolean
: Returnsfmi2True
, if the slave wants to terminate the simulation. Can be called after fmi2DoStep(..) returnedfmi2Discard
. Use fmi2LastSuccessfulTime to determine the time instant at which the slave terminated.value::Ref{fmi2Real}
: Argumentvalue
points to the return value (fmi2Real) which was requested.fmi2Real
is a alias type forReal
data type.
Returns
status::fmi2Status
: Returnstatus
is an enumeration of typefmi2Status
and indicates the success of the function call.
More detailed:
fmi2OK
: all wellfmi2Warning
: things are not quite right, but the computation can continuefmi2Discard
: if the slave computed successfully only a subinterval of the communication stepfmi2Error
: the communication step could not be carried out at allfmi2Fatal
: if an error occurred which corrupted the FMU irreparablyfmi2Pending
: 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!
.
FMICore.fmi2GetIntegerStatus!
— FunctionSource: 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.
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
: Arguments
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 thefmi2DoStep
function returnedfmi2Pending
. The function deliversfmi2Pending
if the computation is not finished. Otherwise the function returns the result of the asynchronously executedfmi2DoStep
call.fmi2PendingStatus::fmi2String
: Can be called when thefmi2DoStep
function returnedfmi2Pending
. The function delivers a string which informs about the status of the currently running asynchronousfmi2DoStep
computationfmi2LastSuccessfulTime:: fmi2Real
: Returns the end time of the last successfully completed communication step. Can be called after fmi2DoStep(..) returned fmi2Discard.fmi2Terminated::fmi2Boolean
: Returnsfmi2True
, if the slave wants to terminate the simulation. Can be called after fmi2DoStep(..) returnedfmi2Discard
. Use fmi2LastSuccessfulTime to determine the time instant at which the slave terminated.value::Ref{fmi2Integer}
: Argumentvalue
points to the return value (fmi2Integer) which was requested.fmi2Integer
is a alias type forInteger
data type.
Returns
status::fmi2Status
: Returnstatus
is an enumeration of typefmi2Status
and indicates the success of the function call.
More detailed:
fmi2OK
: all wellfmi2Warning
: things are not quite right, but the computation can continuefmi2Discard
: if the slave computed successfully only a subinterval of the communication stepfmi2Error
: the communication step could not be carried out at allfmi2Fatal
: if an error occurred which corrupted the FMU irreparablyfmi2Pending
: 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!
.
FMICore.fmi2GetBooleanStatus!
— FunctionSource: 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.
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
: Arguments
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 thefmi2DoStep
function returnedfmi2Pending
. The function deliversfmi2Pending
if the computation is not finished. Otherwise the function returns the result of the asynchronously executedfmi2DoStep
call.fmi2PendingStatus::fmi2String
: Can be called when thefmi2DoStep
function returnedfmi2Pending
. The function delivers a string which informs about the status of the currently running asynchronousfmi2DoStep
computationfmi2LastSuccessfulTime:: fmi2Real
: Returns the end time of the last successfully completed communication step. Can be called after fmi2DoStep(..) returned fmi2Discard.fmi2Terminated::fmi2Boolean
: Returnsfmi2True
, if the slave wants to terminate the simulation. Can be called after fmi2DoStep(..) returnedfmi2Discard
. Use fmi2LastSuccessfulTime to determine the time instant at which the slave terminated.value::Ref{fmi2Boolean}
: Argumentvalue
points to the return value (fmi2Boolean) which was requested.fmi2Boolean
is a alias type forBoolean
data type.
Returns
status::fmi2Status
: Returnstatus
is an enumeration of typefmi2Status
and indicates the success of the function call.
More detailed:
fmi2OK
: all wellfmi2Warning
: things are not quite right, but the computation can continuefmi2Discard
: if the slave computed successfully only a subinterval of the communication stepfmi2Error
: the communication step could not be carried out at allfmi2Fatal
: if an error occurred which corrupted the FMU irreparablyfmi2Pending
: 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!
.
FMICore.fmi2GetStringStatus!
— FunctionSource: 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.
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
: Arguments
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 thefmi2DoStep
function returnedfmi2Pending
. The function deliversfmi2Pending
if the computation is not finished. Otherwise the function returns the result of the asynchronously executedfmi2DoStep
call.fmi2PendingStatus::fmi2String
: Can be called when thefmi2DoStep
function returnedfmi2Pending
. The function delivers a string which informs about the status of the currently running asynchronousfmi2DoStep
computationfmi2LastSuccessfulTime:: fmi2Real
: Returns the end time of the last successfully completed communication step. Can be called after fmi2DoStep(..) returned fmi2Discard.fmi2Terminated::fmi2Boolean
: Returnsfmi2True
, if the slave wants to terminate the simulation. Can be called after fmi2DoStep(..) returnedfmi2Discard
. Use fmi2LastSuccessfulTime to determine the time instant at which the slave terminated.value:Ref{fmi2String}:
Argumentvalue
points to the return value (fmi2String) which was requested.fmi2String
is a alias type forString
data type.
Returns
status::fmi2Status
: Returnstatus
is an enumeration of typefmi2Status
and indicates the success of the function call.
More detailed:
fmi2OK
: all wellfmi2Warning
: things are not quite right, but the computation can continuefmi2Discard
: if the slave computed successfully only a subinterval of the communication stepfmi2Error
: the communication step could not be carried out at allfmi2Fatal
: if an error occurred which corrupted the FMU irreparablyfmi2Pending
: 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!
.