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}: Argumentvris an array ofnvrvalue handels called "ValueReference" that t define the variables whose derivatives shall be set.order::Array{fmi2Integer}: Argumentorderis an array of fmi2Integer values witch specifys the corresponding order of derivative of the real input variable.
Returns
value::AbstactArray{fmi2Integer}: Returnvalueis 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: ArgumentcurrentCommunicationPointcontains a value of typefmi2Realwhich is a identifier for a variable value .currentCommunicationPointdefines the current communication point of the master.communicationStepSize::fmi2Real: ArgumentcommunicationStepSizecontains a value of typefmi2Realwhich is a identifier for a variable value.communicationStepSizedefines 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: Returnstatusis an enumeration of typefmi2Statusand 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: ArgumentcommunicationStepSizecontains a value of typeRealorNothing, if no argument is passed the default valuenothingis used.communicationStepSizedefines the communiction step size.
Keywords
currentCommunicationPoint::Union{Real, Nothing} = nothing: ArgumentcurrentCommunicationPointcontains a value of typeRealor typeNothing. If no argument is passed the default valuenothingis used.currentCommunicationPointdefines the current communication point of the master.noSetFMUStatePriorToCurrentPoint::Bool = true: ArgumentnoSetFMUStatePriorToCurrentPointcontains a value of typeBoolean. If no argument is passed the default valuetrueis used.noSetFMUStatePriorToCurrentPointindicates whetherfmi2SetFMUStateis no longer called for times before thecurrentCommunicationPointin this simulation run Simulation run.
Returns
status::fmi2Status: Returnstatusis an enumeration of typefmi2Statusand 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: Returnstatusis an enumeration of typefmi2Statusand 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: Argumentsdefines which status information is to be returned.fmi2StatusKindis an enumeration that defines which status is inquired.
The following status information can be retrieved from a slave:
fmi2DoStepStatus::fmi2Status: Can be called when thefmi2DoStepfunction returnedfmi2Pending. The function deliversfmi2Pendingif the computation is not finished. Otherwise the function returns the result of the asynchronously executedfmi2DoStepcall.fmi2PendingStatus::fmi2String: Can be called when thefmi2DoStepfunction returnedfmi2Pending. The function delivers a string which informs about the status of the currently running asynchronousfmi2DoStepcomputationfmi2LastSuccessfulTime:: 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}: Thevalueargument points to a status flag that was requested.
Returns
status::fmi2Status: Returnstatusis an enumeration of typefmi2Statusand 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: Argumentsdefines which status information is to be returned.fmi2StatusKindis an enumeration that defines which status is inquired.
The following status information can be retrieved from a slave:
fmi2DoStepStatus::fmi2Status: Can be called when thefmi2DoStepfunction returnedfmi2Pending. The function deliversfmi2Pendingif the computation is not finished. Otherwise the function returns the result of the asynchronously executedfmi2DoStepcall.fmi2PendingStatus::fmi2String: Can be called when thefmi2DoStepfunction returnedfmi2Pending. The function delivers a string which informs about the status of the currently running asynchronousfmi2DoStepcomputationfmi2LastSuccessfulTime:: 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}: Argumentvaluepoints to the return value (fmi2Real) which was requested.fmi2Realis a alias type forRealdata type.
Returns
status::fmi2Status: Returnstatusis an enumeration of typefmi2Statusand 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: Argumentsdefines which status information is to be returned.fmi2StatusKindis an enumeration that defines which status is inquired.
The following status information can be retrieved from a slave:
fmi2DoStepStatus::fmi2Status: Can be called when thefmi2DoStepfunction returnedfmi2Pending. The function deliversfmi2Pendingif the computation is not finished. Otherwise the function returns the result of the asynchronously executedfmi2DoStepcall.fmi2PendingStatus::fmi2String: Can be called when thefmi2DoStepfunction returnedfmi2Pending. The function delivers a string which informs about the status of the currently running asynchronousfmi2DoStepcomputationfmi2LastSuccessfulTime:: 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}: Argumentvaluepoints to the return value (fmi2Integer) which was requested.fmi2Integeris a alias type forIntegerdata type.
Returns
status::fmi2Status: Returnstatusis an enumeration of typefmi2Statusand 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: Argumentsdefines which status information is to be returned.fmi2StatusKindis an enumeration that defines which status is inquired.
The following status information can be retrieved from a slave:
fmi2DoStepStatus::fmi2Status: Can be called when thefmi2DoStepfunction returnedfmi2Pending. The function deliversfmi2Pendingif the computation is not finished. Otherwise the function returns the result of the asynchronously executedfmi2DoStepcall.fmi2PendingStatus::fmi2String: Can be called when thefmi2DoStepfunction returnedfmi2Pending. The function delivers a string which informs about the status of the currently running asynchronousfmi2DoStepcomputationfmi2LastSuccessfulTime:: 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}: Argumentvaluepoints to the return value (fmi2Boolean) which was requested.fmi2Booleanis a alias type forBooleandata type.
Returns
status::fmi2Status: Returnstatusis an enumeration of typefmi2Statusand 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: Argumentsdefines which status information is to be returned.fmi2StatusKindis an enumeration that defines which status is inquired.
The following status information can be retrieved from a slave:
fmi2DoStepStatus::fmi2Status: Can be called when thefmi2DoStepfunction returnedfmi2Pending. The function deliversfmi2Pendingif the computation is not finished. Otherwise the function returns the result of the asynchronously executedfmi2DoStepcall.fmi2PendingStatus::fmi2String: Can be called when thefmi2DoStepfunction returnedfmi2Pending. The function delivers a string which informs about the status of the currently running asynchronousfmi2DoStepcomputationfmi2LastSuccessfulTime:: 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}:Argumentvaluepoints to the return value (fmi2String) which was requested.fmi2Stringis a alias type forStringdata type.
Returns
status::fmi2Status: Returnstatusis an enumeration of typefmi2Statusand 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!.