FMI Common Concepts for Model Exchange and Co-Simulation
In both cases, FMI defines an input/output block of a dynamic model where the distribution of the block, the platform dependent header file, several access functions, as well as the schema files are identical.
Opening and closing FMUs
fmi2Unzip fmi2Load fmi2Reload fmi2Unload
Creation, Destruction and Logging of FMU Instances
FMIImport.fmi2Instantiate!
— Functionfmi2Instantiate!(fmu::FMU2;
instanceName::String=fmu.modelName,
type::fmi2Type=fmu.type,
pushComponents::Bool = true,
visible::Bool = false,
loggingOn::Bool = fmu.executionConfig.loggingOn,
externalCallbacks::Bool = fmu.executionConfig.externalCallbacks,
logStatusOK::Bool=true,
logStatusWarning::Bool=true,
logStatusDiscard::Bool=true,
logStatusError::Bool=true,
logStatusFatal::Bool=true,
logStatusPending::Bool=true)
Create a new instance of the given fmu, adds a logger if logginOn == true.
Arguments
fmu::FMU2
: Mutable struct representing a FMU and all it instantiated instances in the FMI 2.0.2 Standard.
Keywords
instanceName::String=fmu.modelName
: Name of the instancetype::fmi2Type=fmu.type
: Defines whether a Co-Simulation or Model Exchange is presentpushComponents::Bool = true
: Defines if the fmu components should be pushed in the application.visible::Bool = false
if the FMU should be started with graphic interface, if supported (default=false
)loggingOn::Bool = fmu.executionConfig.loggingOn
if the FMU should log and display function calls (default=false
)externalCallbacks::Bool = fmu.executionConfig.externalCallbacks
if an external shared library should be used for the fmi2CallbackFunctions, this may improve readability of logging messages (default=false
)logStatusOK::Bool=true
whether to log status of kindfmi2OK
(default=true
)logStatusWarning::Bool=true
whether to log status of kindfmi2Warning
(default=true
)logStatusDiscard::Bool=true
whether to log status of kindfmi2Discard
(default=true
)logStatusError::Bool=true
whether to log status of kindfmi2Error
(default=true
)logStatusFatal::Bool=true
whether to log status of kindfmi2Fatal
(default=true
)logStatusPending::Bool=true
whether to log status of kindfmi2Pending
(default=true
)
Returns
- Returns the instance of a new FMU component.
Source
- FMISpec2.0.2 Link: https://fmi-standard.org/
- FMISpec2.0.2: 2.2.7 Definition of Model Variables (ModelVariables)
See also fmi2Instantiate
.
FMICore.fmi2Instantiate
— FunctionSource: FMISpec2.0.2[p.19]: 2.1.5 Creation, Destruction and Logging of FMU Instances
The function returns a new instance of an FMU.
FMICore.fmi2FreeInstance
— FunctionSource: FMISpec2.0.2[p.22]: 2.1.5 Creation, Destruction and Logging of FMU Instances
Disposes the given instance, unloads the loaded model, and frees all the allocated memory and other resources that have been allocated by the functions of the FMU interface. If a null pointer is provided for “c”, the function call is ignored (does not have an effect).
Removes the component from the FMUs component list.
FMICore.fmi2SetDebugLogging
— FunctionSource: FMISpec2.0.2[p.22]: 2.1.5 Creation, Destruction and Logging of FMU Instances
The function controls debug logging that is output via the logger function callback. If loggingOn = fmi2True, debug logging is enabled, otherwise it is switched off.
fmi2SetDebugLogging(c::FMU2Component, loggingOn::fmi2Boolean, nCategories::Unsigned, categories::Ptr{Nothing})
Control the use of the logging callback function, version independent.
Arguments
c::FMU2Component
: Argumentc
is a Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.loggingOn::fmi2Boolean
: IfloggingOn = fmi2True
, debug logging is enabled for the log categories specified in categories, otherwise it is disabled. Typefmi2Boolean
is defined as an alias Type for the C-Type Boolean and is to be used withfmi2True
andfmi2False
.nCategories::Unsigned
: ArgumentnCategories
defines the length of the argumentcategories
.categories::Ptr{Nothing}
:
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.22]: 2.1.2 Platform Dependent Definitions (fmi2TypesPlatform.h)
- FMISpec2.0.2[p.22]: 2.1.3 Status Returned by Functions
- FMISpec2.0.2[p.22]: 2.1.5 Creation, Destruction and Logging of FMU Instances
See also fmi2SetDebugLogging
.
fmi2SetDebugLogging(c::FMU2Component)
Control the use of the logging callback function, version independent.
Arguments
c::FMU2Component
: Argumentc
is a mutable struct representing 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.22]: 2.1.2 Platform Dependent Definitions (fmi2TypesPlatform.h)
- FMISpec2.0.2[p.22]: 2.1.3 Status Returned by Functions
- FMISpec2.0.2[p.22]: 2.1.5 Creation, Destruction and Logging of FMU Instances
See also fmi2SetDebugLogging
.
Initialization, Termination, and Resetting an FMU
FMICore.fmi2SetupExperiment
— FunctionSource: FMISpec2.0.2[p.23]: 2.1.6 Initialization, Termination, and Resetting an FMU
Informs the FMU to setup the experiment. This function must be called after fmi2Instantiate and before fmi2EnterInitializationMode is called.The function controls debug logging that is output via the logger function callback. If loggingOn = fmi2True, debug logging is enabled, otherwise it is switched off.
fmi2SetupExperiment(c::FMU2Component, toleranceDefined::fmi2Boolean, tolerance::fmi2Real, startTime::fmi2Real, stopTimeDefined::fmi2Boolean, stopTime::fmi2Real)
Informs the FMU to setup the experiment. This function must be called after fmi2Instantiate
and before fmi2EnterInitializationMode
is called.
Arguments
c::FMU2Component
: Argumentc
is a Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.toleranceDefined::fmi2Boolean
: ArgumentstoleranceDefined
depend on the FMU type:- fmuType = fmi2ModelExchange: If
toleranceDefined = fmi2True
, then the model is called with a numerical integration scheme where the step size is controlled by usingtolerance
for error estimation. In such a case, all numerical algorithms used inside the model (for example, to solve non-linear algebraic equations) should also operate with an error estimation of an appropriate smaller relative tolerance. - fmuType = fmi2CoSimulation: If
toleranceDefined = fmi2True
, then the communication interval of the slave is controlled by error estimation. In case the slave utilizes a numerical integrator with variable step size and error estimation, it is suggested to use “tolerance” for the error estimation of the internal integrator (usually as relative tolerance). An FMU for Co-Simulation might ignore this argument.
- fmuType = fmi2ModelExchange: If
startTime::fmi2Real
: ArgumentstartTime
can be used to check whether the model is valid within the given boundaries or to allocate memory which is necessary for storing results. It is the fixed initial value of the independent variable and if the independent variable istime
,startTime
is the starting time of initializaton.stopTimeDefined::fmi2Boolean
: IfstopTimeDefined = fmi2True
, then stopTime is the defined final value of the independent variable and ifstopTimeDefined = fmi2False
, then no final value
of the independent variable is defined and argument stopTime
is meaningless.
stopTime::fmi2Real
: ArgumentstopTime
can be used to check whether the model is valid within the given boundaries or to allocate memory which is necessary for storing results. It is the fixed final value of the independent variable and if the independent variable is “time”, stopTime is the stop time of the simulation.
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.22]: 2.1.2 Platform Dependent Definitions (fmi2TypesPlatform.h)
- FMISpec2.0.2[p.22]: 2.1.3 Status Returned by Functions
- FMISpec2.0.2[p.22]: 2.1.6 Initialization, Termination, and Resetting an FMU
See also fmi2SetupExperiment
.
fmi2SetupExperiment(c::FMU2Component,
startTime::Union{Real, Nothing} = nothing,
stopTime::Union{Real, Nothing} = nothing;
tolerance::Union{Real, Nothing} = nothing)
Setup the simulation but without defining all of the parameters.
Arguments
c::fmi2Struct
: Representative for an FMU in the FMI 2.0.2 Standard.
More detailed: fmi2Struct = Union{FMU2, FMU2Component}
c::FMU2
: Mutable struct representing a FMU and all it instantiated instances in the FMI 2.0.2 Standard.c::FMU2Component
: Mutable struct representing an instantiated instance of an FMU in the FMI 2.0.2 Standard.startTime::Union{Real, Nothing} = nothing
:startTime
is a real number which sets the value of starting time of the experiment. The default value is set automatically if doing nothing (default =nothing
).stopTime::Union{Real, Nothing} = nothing
:stopTime
is a real number which sets the value of ending time of the experiment. The default value is set automatically if doing nothing (default =nothing
).
Keywords
tolerance::Union{Real, Nothing} = nothing
:tolerance
is a real number which sets the value of tolerance range. The default value is set automatically if doing nothing (default =nothing
).
Returns
- Returns a warning if
str.state
is not called infmi2ComponentStateInstantiated
. 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.23]: 2.1.6 Initialization, Termination, and Resetting an FMU
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
See also fmi2SetupExperiment
.
FMICore.fmi2EnterInitializationMode
— FunctionSource: FMISpec2.0.2[p.23]: 2.1.6 Initialization, Termination, and Resetting an FMU
Informs the FMU to enter Initialization Mode. Before calling this function, all variables with attribute <ScalarVariable initial = "exact" or "approx"> can be set with the “fmi2SetXXX” functions (the ScalarVariable attributes are defined in the Model Description File, see section 2.2.7). Setting other variables is not allowed. Furthermore, fmi2SetupExperiment must be called at least once before calling fmi2EnterInitializationMode, in order that startTime is defined.
fmi2EnterInitializationMode(c::FMU2Component)
Informs the FMU to enter Initialization Mode. Before calling this function, all variables with attribute <ScalarVariable initial = "exact" or "approx"> can be set with the “fmi2SetXXX” functions (the ScalarVariable attributes are defined in the Model Description File, see section 2.2.7). Setting other variables is not allowed. Furthermore, fmi2SetupExperiment
must be called at least once before calling fmi2EnterInitializationMode
, in order that startTime
is defined.
Arguments
c::FMU2Component
: Argumentc
is a 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.22]: 2.1.2 Platform Dependent Definitions (fmi2TypesPlatform.h)
- FMISpec2.0.2[p.22]: 2.1.3 Status Returned by Functions
- FMISpec2.0.2[p.22]: 2.1.6 Initialization, Termination, and Resetting an FMU
See also fmi2EnterInitializationMode
.
FMICore.fmi2ExitInitializationMode
— FunctionSource: FMISpec2.0.2[p.23]: 2.1.6 Initialization, Termination, and Resetting an FMU
Informs the FMU to exit Initialization Mode.
fmi2ExitInitializationMode(c::FMU2Component)
Informs the FMU to exit Initialization Mode.
Arguments
c::FMU2Component
: Argumentc
is a 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.22]: 2.1.2 Platform Dependent Definitions (fmi2TypesPlatform.h)
- FMISpec2.0.2[p.22]: 2.1.3 Status Returned by Functions
- FMISpec2.0.2[p.22]: 2.1.6 Initialization, Termination, and Resetting an FMU
See also fmi2EnterInitializationMode
.
FMICore.fmi2Terminate
— FunctionSource: FMISpec2.0.2[p.24]: 2.1.6 Initialization, Termination, and Resetting an FMU
Informs the FMU that the simulation run is terminated.
fmi2Terminate(c::FMU2Component; soft::Bool=false)
Informs the FMU that the simulation run is terminated.
Arguments
c::FMU2Component
: Argumentc
is a Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.
Keywords
soft::Bool=false
: If the Keywordsoft = true
the command is only performed if the FMU is in an allowed state for this command.
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.22]: 2.1.2 Platform Dependent Definitions (fmi2TypesPlatform.h)
- FMISpec2.0.2[p.22]: 2.1.3 Status Returned by Functions
- FMISpec2.0.2[p.22]: 2.1.6 Initialization, Termination, and Resetting an FMU
See also fmi2Terminate
.
FMICore.fmi2Reset
— FunctionSource: FMISpec2.0.2[p.24]: 2.1.6 Initialization, Termination, and Resetting an FMU
Is called by the environment to reset the FMU after a simulation run. The FMU goes into the same state as if fmi2Instantiate would have been called.
fmi2Reset(c::FMU2Component; soft::Bool=false)
Is called by the environment to reset the FMU after a simulation run. The FMU goes into the same state as if fmi2Instantiate would have been called.All variables have their default values. Before starting a new run, fmi2SetupExperiment and fmi2EnterInitializationMode have to be called.
Arguments
c::FMU2Component
: Argumentc
is a Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.
Keywords
soft::Bool=false
: If the Keywordsoft = true
the command is only performed if the FMU is in an allowed state for this command.
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.3 Link: https://fmi-standard.org/
- FMISpec2.0.3[p.16]: 2.1.2 Platform Dependent Definitions (fmi2TypesPlatform.h)
- FMISpec2.0.3[p.18]: 2.1.3 Status Returned by Functions
- FMISpec2.0.3[p.22]: 2.1.6 Initialization, Termination, and Resetting an FMU
See also fmi2Terminate
.
Getting and Setting Variable Values
All variable values of an FMU are identified with a variable handle called “value reference”. The handle is defined in the modelDescription.xml file (as attribute “valueReference” in element “ScalarVariable”). Element “valueReference” might not be unique for all variables. If two or more variables of the same base data type (such as fmi2Real) have the same valueReference, then they have identical values but other parts of the variable definition might be different (for example, min/max attributes).
FMIImport.fmi2GetReal
— Functionfmi2GetReal(c::FMU2Component, vr::fmi2ValueReferenceFormat)
Get the values of an array of fmi2Real variables.
Arguments
c::fmi2Struct
: Representative for an FMU in the FMI 2.0.2 Standard.
More detailed: fmi2Struct = Union{FMU2, FMU2Component}
c::FMU2
: Mutable struct representing a FMU and all it instantiated instances in the FMI 2.0.2 Standard.c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::fmi2ValueReferenceFormat
: wildcards for how a user can pass a fmi[X]ValueReference
More detailed: fmi2ValueReferenceFormat = Union{Nothing, String, Array{String,1}, fmi2ValueReference, Array{fmi2ValueReference,1}, Int64, Array{Int64,1}, Symbol}
Returns
values::Array{fm2Real}
: Returns values of an array of fmi2Real variables with the dimension of fmi2ValueReferenceFormat length.
Source
- FMISpec2.0.2 Link: https://fmi-standard.org/
- FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
See also fmi2GetReal
.
FMICore.fmi2GetReal!
— FunctionSource: FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
Functions to get and set values of variables idetified by their valueReference
fmi2GetReal!(c::FMU2Component, vr::AbstractArray{fmi2ValueReference}, nvr::Csize_t, value::AbstractArray{fmi2Real})
Functions to get and set values of variables idetified by their valueReference
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::AbstractArray{fmi2ValueReference}
: Argumentvr
is an AbstractArray ofnvr
value handels called "ValueReference" that define the variable that shall be inquired.nvr::Csize_t
: Argumentnvr
defines the size ofvr
.values::AbstractArray{fm2Real}
: Argumentvalues
is an AbstractArray with the actual values of these variables.
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.18]: 2.1.3 Status Returned by Functions
- FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
See also fmi2GetReal!
.
fmi2GetReal!(c::FMU2Component, vr::fmi2ValueReferenceFormat, values::AbstractArray{fmi2Real})
Get the values of an array of fmi2Real variables.
rites the real values of an array of variables in the given field
Arguments
c::fmi2Struct
: Representative for an FMU in the FMI 2.0.2 Standard.
More detailed: fmi2Struct = Union{FMU2, FMU2Component}
c::FMU2
: Mutable struct representing a FMU and all it instantiated instances in the FMI 2.0.2 Standard.c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::fmi2ValueReferenceFormat
: Wildcards for how a user can pass a fmi[X]ValueReference
More detailed: fmi2ValueReferenceFormat = Union{Nothing, String, Array{String,1}, fmi2ValueReference, Array{fmi2ValueReference,1}, Int64, Array{Int64,1}, Symbol}
values::AbstractArray{fm2Real}
: Argumentvalues
is an AbstractArray with the actual values of these variables.
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.24]: 2.1.7 Getting and Setting Variable Values
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
See also fmi2GetReal!
.
FMIImport.fmi2GetInteger
— Functionfmi2GetInteger(c::FMU2Component, vr::fmi2ValueReferenceFormat)
Returns the integer values of an array of variables
Arguments
c::fmi2Struct
: Representative for an FMU in the FMI 2.0.2 Standard.
More detailed: fmi2Struct = Union{FMU2, FMU2Component}
c::FMU2
: Mutable struct representing a FMU and all it instantiated instances in the FMI 2.0.2 Standard.c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::fmi2ValueReferenceFormat
: Argumentvr
defines the value references of the variables
More detailed: fmi2ValueReferenceFormat = Union{Nothing, String, Array{String,1}, fmi2ValueReference, Array{fmi2ValueReference,1}, Int64, Array{Int64,1}, Symbol}
Returns
values::Array{fmi2Integer}
: Returnvalues
is an array with the actual values of these variables.
Source
- FMISpec2.0.2 Link: https://fmi-standard.org/
- FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
- FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
See also fmi2GetInteger!
FMICore.fmi2GetInteger!
— FunctionSource: FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
Functions to get and set values of variables idetified by their valueReference
fmi2GetInteger!(c::FMU2Component, vr::AbstractArray{fmi2ValueReference}, nvr::Csize_t, value::AbstractArray{fmi2Integer})
Writes the integer values of an array of variables in the given field
fmi2GetInteger! is only possible for arrays of values, please use an array instead of a scalar.
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::AbstractArray{fmi2ValueReference}
: Argumentvr
is an AbstractArray ofnvr
value handels, called "ValueReference" that define the variable that shall be inquired.nvr::Csize_t
: Argumentnvr
defines the size ofvr
.values::AbstractArray{fmi2Integer}
: Argumentvalues
is an AbstractArray with the actual values of these variables.
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.24]: 2.1.7 Getting and Setting Variable Values
- FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
See also fmi2GetInteger!
.
fmi2GetInteger!(c::FMU2Component, vr::fmi2ValueReferenceFormat, values::AbstractArray{fmi2Integer})
Writes the integer values of an array of variables in the given field
fmi2GetInteger! is only possible for arrays of values, please use an array instead of a scalar.
Arguments
c::fmi2Struct
: Representative for an FMU in the FMI 2.0.2 Standard.
More detailed: fmi2Struct = Union{FMU2, FMU2Component}
c::FMU2
: Mutable struct representing a FMU and all it instantiated instances in the FMI 2.0.2 Standard.c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::fmi2ValueReferenceFormat
: Argumentvr
defines the value references of the variables.
More detailed: fmi2ValueReferenceFormat = Union{Nothing, String, Array{String,1}, fmi2ValueReference, Array{fmi2ValueReference,1}, Int64, Array{Int64,1}, Symbol}
vr::Array{fmi2ValueReference}
: Argumentvr
is an array ofnvr
value handels called "ValueReference" that define the variable that shall be inquired.nvr::Csize_t
: Argumentnvr
defines the size ofvr
.values::Array{fmi2Integer}
: Argumentvalues
is an array with the actual values of these variables.
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.24]: 2.1.7 Getting and Setting Variable Values
- FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
See also fmi2GetInteger!
.
FMIImport.fmi2GetBoolean
— Functionfmi2GetBoolean(c::FMU2Component, vr::fmi2ValueReferenceFormat)
Get the values of an array of fmi2Boolean variables.
Arguments
c::fmi2Struct
: Representative for an FMU in the FMI 2.0.2 Standard.
More detailed: fmi2Struct = Union{FMU2, FMU2Component}
c::FMU2
: Mutable struct representing a FMU and all it instantiated instances in the FMI 2.0.2 Standard.c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::fmi2ValueReferenceFormat
: Argumentvr
defines the value references of the variables.
More detailed: fmi2ValueReferenceFormat = Union{Nothing, String, Array{String,1}, fmi2ValueReference, Array{fmi2ValueReference,1}, Int64, Array{Int64,1}, Symbol}
Returns
values::Array{fmi2Boolean}
: Returnvalues
is an array with the actual values of these variables.
See also fmi2GetBoolean!
.
FMICore.fmi2GetBoolean!
— FunctionSource: FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
Functions to get and set values of variables idetified by their valueReference
fmi2GetBoolean!(c::FMU2Component, vr::AbstractArray{fmi2ValueReference}, nvr::Csize_t, value::AbstractArray{fmi2Boolean})
Writes the boolean values of an array of variables in the given field
fmi2GetBoolean! is only possible for arrays of values, please use an array instead of a scalar.
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::AbstractArray{fmi2ValueReference}
: Argumentvr
is an AbstractArray ofnvr
value handels called "ValueReference" that define the variable that shall be inquired.nvr::Csize_t
: Argumentnvr
defines the size ofvr
.value::AbstractArray{fmi2Boolean}
: Argumentvalues
is an array with the actual values of these variables.
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.24]: 2.1.7 Getting and Setting Variable Values
- FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
See also fmi2GetBoolean!
.
fmi2GetBoolean!(c::FMU2Component, vr::fmi2ValueReferenceFormat, values::AbstractArray{fmi2Boolean})
Writes the boolean values of an array of variables in the given field
fmi2GetBoolean! is only possible for arrays of values, please use an array instead of a scalar.
Arguments
str::fmi2Struct
: Representative for an FMU in the FMI 2.0.2 Standard.
More detailed: fmi2Struct = Union{FMU2, FMU2Component}
str::FMU2
: Mutable struct representing a FMU and all it instantiated instances in the FMI 2.0.2 Standard.str::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::fmi2ValueReferenceFormat
: Argumentvr
defines the value references of the variables.
More detailed: fmi2ValueReferenceFormat = Union{Nothing, String, Array{String,1}, fmi2ValueReference, Array{fmi2ValueReference,1}, Int64, Array{Int64,1}, Symbol}
vr::AbstractArray{fmi2ValueReference}
: Argumentvr
is an array ofnvr
value handels called "ValueReference" that define the variable that shall be inquired.nvr::Csize_t
: Argumentnvr
defines the size ofvr
.values::AbstractArray{fmi2Boolean}
: Argumentvalue
is an array with the actual values of these variables
Returns
- Return singleton instance of type
Nothing
, if there is no value to return (as in a C void function) or when a variable or field holds no value.
Source
- FMISpec2.0.2 Link: https://fmi-standard.org/
- FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
- FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
See also fmi2GetBoolean!
.
FMIImport.fmi2GetString
— Functionfmi2GetString(c::FMU2Component, vr::fmi2ValueReferenceFormat)
Get the values of an array of fmi2String variables.
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::fmi2ValueReferenceFormat
: Argumentvr
defines the value references of the variables.
More detailed: fmi2ValueReferenceFormat = Union{Nothing, String, Array{String,1}, fmi2ValueReference, Array{fmi2ValueReference,1}, Int64, Array{Int64,1}, Symbol}
Returns
values::Array{fmi2String}
: Returnvalues
is an array with the actual values of these variables.
Source
- FMISpec2.0.2 Link: https://fmi-standard.org/
- FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
- FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
See also fmi2GetString!
.
FMICore.fmi2GetString!
— FunctionSource: FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
Functions to get and set values of variables idetified by their valueReference
fmi2GetString!(c::FMU2Component, vr::AbstractArray{fmi2ValueReference}, nvr::Csize_t, value::Union{AbstractArray{Ptr{Cchar}}, AbstractArray{Ptr{UInt8}}})
Functions to get and set values of variables idetified by their valueReference
These functions are especially used to get the actual values of output variables if a model is connected with other models.
Arguments
str::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::AbstractArray{fmi2ValueReference}
: Argumentvr
is an array ofnvr
value handels called "ValueReference" that define the variable that shall be inquired.nvr::Csize_t
: Argumentnvr
defines the size ofvr
.value::Union{AbstractArray{Ptr{Cchar}, AbstractArray{Ptr{UInt8}}}
: Thevalue
argument is an AbstractArray of values whose memory address refers to data of type Cchar or UInt8and describes a vector with the actual values of these. variables.
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
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
- FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
See also fmi2GetString!
.
fmi2GetString!(c::FMU2Component, vr::fmi2ValueReferenceFormat, values::AbstractArray{fmi2String})
Writes the string values of an array of variables in the given field
These functions are especially used to get the actual values of output variables if a model is connected with other models.
Arguments
str::fmi2Struct
: Representative for an FMU in the FMI 2.0.2 Standard.
More detailed: fmi2Struct = Union{FMU2, FMU2Component}
str::FMU2
: Mutable struct representing a FMU and all it instantiated instances in the FMI 2.0.2 Standard.str::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::fmi2ValueReferenceFormat
: Argumentvr
defines the value references of the variables.
More detailed: fmi2ValueReferenceFormat = Union{Nothing, String, Array{String,1}, fmi2ValueReference, Array{fmi2ValueReference,1}, Int64, Array{Int64,1}, Symbol}
values::AbstractArray{fmi2String}
: Argumentvalues
is an AbstractArray with the actual values of these variables
Returns
- Return singleton instance of type
Nothing
, if there is no value to return (as in a C void function) or when a variable or field holds no value.
Source
- FMISpec2.0.2 Link: https://fmi-standard.org/
- FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
- FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
See also fmi2GetString!
.
FMICore.fmi2SetReal
— FunctionSource: FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
Functions to get and set values of variables idetified by their valueReference
fmi2SetReal(c::FMU2Component, vr::AbstractArray{fmi2ValueReference}, nvr::Csize_t, value::AbstractArray{fmi2Real})
Functions to get and set values of variables idetified by their valueReference
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::AbstractArray{fmi2ValueReference}
: Argumentvr
is an AbstractArray ofnvr
value handels, called "ValueReference" that define the variable that shall be inquired.nvr::Csize_t
: Argumentnvr
defines the size ofvr
.values::AbstractArray{fm2Real}
: Argumentvalues
is an AbstractArray with the actual values of these variables.
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.18]: 2.1.3 Status Returned by Functions
- FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
See also fmi2GetReal
.
fmi2SetReal(c::FMU2Component, vr::fmi2ValueReferenceFormat, values::Union{AbstractArray{<:Real}, <:Real})
Set the values of an array of real variables
Arguments
c::fmi2Struct
: Representative for an FMU in the FMI 2.0.2 Standard.
More detailed: fmi2Struct = Union{FMU2, FMU2Component}
c::FMU2
: Mutable struct representing a FMU and all it instantiated instances in the FMI 2.0.2 Standard.c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::fmi2ValueReferenceFormat
: Wildcards for how a user can pass a fmi[X]ValueReference
More detailed: fmi2ValueReferenceFormat = Union{Nothing, String, Array{String,1}, fmi2ValueReference, Array{fmi2ValueReference,1}, Int64, Array{Int64,1}, Symbol}
values::Union{Array{<:Real}, <:Real}
: Argumentvalues
is an array with the actual values of these variables.
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.24]: 2.1.7 Getting and Setting Variable Values
- FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
See also fmi2SetReal
.
FMICore.fmi2SetInteger
— FunctionSource: FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
Functions to get and set values of variables idetified by their valueReference
fmi2SetInteger(c::FMU2Component, vr::AbstractArray{fmi2ValueReference}, nvr::Csize_t, value::AbstractArray{fmi2Integer})
Set the values of an array of integer variables
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::AbstractArray{fmi2ValueReference}
: Argumentvr
is an AbstractArray ofnvr
value handels, called "ValueReference" that define the variable that shall be inquired.nvr::Csize_t
: Argumentnvr
defines the size ofvr
.values::AbstractArray{fmi2Integer}
: Argumentvalues
is an AbstractArray with the actual values of these variables.
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.24]: 2.1.7 Getting and Setting Variable Values
- FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
See also fmi2GetInteger!
.
fmi2SetInteger(c::FMU2Component, vr::fmi2ValueReferenceFormat, values::Union{AbstractArray{<:Integer}, <:Integer})
Set the values of an array of integer variables
Arguments
c::fmi2Struct
: Representative for an FMU in the FMI 2.0.2 Standard.
More detailed: fmi2Struct = Union{FMU2, FMU2Component}
c::FMU2
: Mutable struct representing a FMU and all it instantiated instances in the FMI 2.0.2 Standard.c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::fmi2ValueReferenceFormat
: Argumentvr
defines the value references of the variables.
More detailed: fmi2ValueReferenceFormat = Union{Nothing, String, Array{String,1}, fmi2ValueReference, Array{fmi2ValueReference,1}, Int64, Array{Int64,1}, Symbol}
vr::Array{fmi2ValueReference}
: Argumentvr
is an array ofnvr
value handels called "ValueReference" that define the variable that shall be inquired.values::Union{Array{<:Integer}, <:Integer}
: Argumentvalues
is an array or a single value with type Integer or any subtyp
Returns
status::fmi2Status
: Returnstatus
indicates the success of the function call.
Source
- FMISpec2.0.2 Link: https://fmi-standard.org/
- FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
- FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
See also fmi2SetInteger
.
FMICore.fmi2SetBoolean
— FunctionSource: FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
Functions to get and set values of variables idetified by their valueReference
fmi2SetBoolean(c::FMU2Component, vr::AbstractArray{fmi2ValueReference}, nvr::Csize_t, value::AbstractArray{fmi2Boolean})
Functions to get and set values of variables idetified by their valueReference
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::AbstractArray{fmi2ValueReference}
: Argumentvr
is an array ofnvr
value handels called "ValueReference" that define the variable that shall be inquired.nvr::Csize_t
: Argumentnvr
defines the size ofvr
.value::AbstractArray{fmi2Boolean}
: Argumentvalues
is an array with the actual values of these variables.
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.24]: 2.1.7 Getting and Setting Variable Values
- FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
See also fmi2GetBoolean
.
fmi2SetBoolean(c::FMU2Component, vr::fmi2ValueReferenceFormat, values::Union{AbstractArray{Bool}, Bool})
Set the values of an array of boolean variables
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::fmi2ValueReferenceFormat
: Argumentvr
defines the value references of the variables.
More detailed: fmi2ValueReferenceFormat = Union{Nothing, String, Array{String,1}, fmi2ValueReference, Array{fmi2ValueReference,1}, Int64, Array{Int64,1}, Symbol}
values::Union{Array{Bool}, Bool}
: Argumentvalues
is an array or a single value with type Boolean or any subtyp
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.24]: 2.1.7 Getting and Setting Variable Values
- FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
See also fmi2GetBoolean!
.
FMICore.fmi2SetString
— FunctionSource: FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
Functions to get and set values of variables idetified by their valueReference
fmi2SetString(c::FMU2Component, vr::AbstractArray{fmi2ValueReference}, nvr::Csize_t, value::Union{AbstractArray{Ptr{Cchar}}, AbstractArray{Ptr{UInt8}}})
Set the values of an array of string variables
For the exact rules on which type of variables fmi2SetXXX can be called see FMISpec2.0.2 section 2.2.7 , as well as FMISpec2.0.2 section 3.2.3 in case of ModelExchange and FMISpec2.0.2 section 4.2.4 in case ofCoSimulation.
Arguments
str::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::AbstractArray{fmi2ValueReference}
: Argumentvr
is an array ofnvr
value handels called "ValueReference" that define the variable that shall be inquired.nvr::Csize_t
: Argumentnvr
defines the size ofvr
.value::Union{AbstractArray{Ptr{Cchar}, AbstractArray{Ptr{UInt8}}}
: Thevalue
argument is an AbstractArray of values whose memory address refers to data of type Cchar or UInt8and describes a vector with the actual values of these. variables.
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
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
- FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
See also fmi2GetString!
.
fmi2SetString(c::FMU2Component, vr::fmi2ValueReferenceFormat, values::Union{AbstractArray{String}, String})
Set the values of an array of string variables
For the exact rules on which type of variables fmi2SetXXX can be called see FMISpec2.0.2 section 2.2.7 , as well as FMISpec2.0.2 section 3.2.3 in case of ModelExchange and FMISpec2.0.2 section 4.2.4 in case of CoSimulation.
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vr::fmi2ValueReferenceFormat
: Argumentvr
defines the value references of the variables.
More detailed: fmi2ValueReferenceFormat = Union{Nothing, String, Array{String,1}, fmi2ValueReference, Array{fmi2ValueReference,1}, Int64, Array{Int64,1}, Symbol}
values::Union{Array{String}, String}
: Argumentvalues
is an array or a single value with type String.
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
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
- FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
- FMISpec2.0.2[p.46]: 2.2.7 Definition of Model Variables
- FMISpec2.0.2[p.46]: 3.2.3 State Machine of Calling Sequence
- FMISpec2.0.2[p.108]: 4.2.4 State Machine of Calling Sequence from Master to Slave
See also fmi2SetString
.
fmi2Get fmi2Get! fmi2Set
Getting and Setting the Complete FMU State
The FMU has an internal state consisting of all values that are needed to continue a simulation. This internal state consists especially of the values of the continuous-time states, iteration variables, parameter values, input values, delay buffers, file identifiers, and FMU internal status information. With the functions of this section, the internal FMU state can be copied and the pointer to this copy is returned to the environment. The FMU state copy can be set as actual FMU state, in order to continue the simulation from it.
FMIImport.fmi2GetFMUstate
— Functionfmi2GetFMUstate(c::FMU2Component)
Makes a copy of the internal FMU state and returns a pointer to this copy.
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.
Returns
- Return
state
is a pointer to a copy of the internal FMU state.
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.25]: 2.1.8 Getting and Setting the Complete FMU State
See also fmi2GetFMUstate
.
FMICore.fmi2GetFMUstate!
— FunctionSource: FMISpec2.0.2[p.26]: 2.1.8 Getting and Setting the Complete FMU State
fmi2GetFMUstate makes a copy of the internal FMU state and returns a pointer to this copy
fmi2GetFMUstate!(c::FMU2Component, FMUstate::Ref{fmi2FMUstate})
Makes a copy of the internal FMU state and returns a pointer to this copy.
Arguments
str::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.FMUstate::Ref{fmi2FMUstate}
:If on entryFMUstate == NULL
, a new allocation is required. IfFMUstate != NULL
, thenFMUstate
points to a previously returnedFMUstate
that has not been modified since.
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
- FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions
- FMISpec2.0.2[p.24]: 2.1.7 Getting and Setting Variable Values
See also fmi2GetFMUstate!
.
FMICore.fmi2SetFMUstate
— FunctionSource: FMISpec2.0.2[p.26]: 2.1.8 Getting and Setting the Complete FMU State
fmi2SetFMUstate copies the content of the previously copied FMUstate back and uses it as actual new FMU state.
fmi2SetFMUstate(c::FMU2Component, FMUstate::fmi2FMUstate)
Copies the content of the previously copied FMUstate back and uses it as actual new FMU state.
Arguments
str::fmi2Struct
: Representative for an FMU in the FMI 2.0.2 Standard.
More detailed: fmi2Struct = Union{FMU2, FMU2Component}
str::FMU2
: Mutable struct representing a FMU and all it instantiated instances in the FMI 2.0.2 Standard.str::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.FMUstate::fmi2FMUstate
: ArgumentFMUstate
is a pointer to a data structure in the FMU that saves the internal FMU state of the actual or a previous time instant.
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.25]: 2.1.8 Getting and Setting the Complete FMU State
See also fmi2GetFMUstate
.
FMICore.fmi2FreeFMUstate
— FunctionSource: FMISpec2.0.2[p.26]: 2.1.8 Getting and setting the complete FMU state
fmi2FreeFMUstate frees all memory and other resources allocated with the fmi2GetFMUstate call for this FMUstate.
fmi2FreeFMUstate(c::FMU2Component, FMUstate::Ref{fmi2FMUstate})
Frees all memory and other resources allocated with the fmi2GetFMUstate call for this FMUstate.
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.FMUstate::Ref{fmi2FMUstate}
: ArgumentFMUstate
is an object that safely references data of typefmi3FMUstate
which is a pointer to a data structure in the FMU that saves the internal FMU state of the actual or a previous time instant.
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.25]: 2.1.8 Getting and Setting the Complete FMU State
See also fmi2FreeFMUstate
.
fmi2FreeFMUstate!(c::FMU2Component, state::fmi2FMUstate)
Free the memory for the allocated FMU state
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.state::fmi2FMUstate
: Argumentstate
is a pointer to a data structure in the FMU that saves the internal FMU state of the actual or a previous time instant.
Returns
- Return singleton instance of type
Nothing
, if there is no value to return (as in a C void function) or when a variable or field holds no value.
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.25]: 2.1.8 Getting and Setting the Complete FMU State
See also fmi2FreeFMUstate
.
FMIImport.fmi2SerializedFMUstateSize
— Functionfmi2SerializedFMUstateSize(c::FMU2Component, state::fmi2FMUstate)
Returns the size of the byte vector in which the FMUstate can be stored.
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.state::fmi2FMUstate
: Argumentstate
is a pointer to a data structure in the FMU that saves the internal FMU state of the actual or a previous time instant.
Returns
- Return
size
is an object that safely references a value of typeCsize_t
.
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.25]: 2.1.8 Getting and Setting the Complete FMU State
See also fmi2SerializedFMUstateSize
.
FMICore.fmi2SerializedFMUstateSize!
— FunctionSource: FMISpec2.0.2[p.26]: 2.1.8 Getting and Setting the Complete FMU State
fmi2SerializedFMUstateSize returns the size of the byte vector, in order that FMUstate can be stored in it.
fmi2SerializedFMUstateSize!(c::FMU2Component, FMUstate::fmi2FMUstate, size::Ref{Csize_t})
Stores the size of the byte vector in the given referenced Address, in order that FMUstate can be stored in it.
Argument
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.FMUstate::fmi2FMUstate
: ArgumentFMUstate
is a pointer to a data structure in the FMU that saves the internal FMU state of the actual or a previous time instant.size::Ref{Csize_t}
: Argumentsize
is an object that safely references a value of typeCsize_t
and defines the size of the byte vector in which the FMUstate can be stored.
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.25]: 2.1.8 Getting and Setting the Complete FMU State
See also fmi2SerializedFMUstateSize!
.
FMIImport.fmi2SerializeFMUstate
— Functionfmi2SerializeFMUstate(c::FMU2Component, state::fmi2FMUstate)
Serializes the data referenced by the pointer FMUstate and copies this data into the byte vector serializedState of length size to be provided by the environment.
Arguments
str::fmi2Struct
: Representative for an FMU in the FMI 2.0.2 Standard.
More detailed: fmi2Struct = Union{FMU2, FMU2Component}
str::FMU2
: Mutable struct representing a FMU and all it instantiated instances in the FMI 2.0.2 Standard.str::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.state::fmi2FMUstate
: Argumentstate
is a pointer to a data structure in the FMU that saves the internal FMU state of the actual or a previous time instant.
Returns
serializedState:: Array{fmi2Byte}
: ReturnserializedState
contains the copy of the serialized data referenced by the pointer FMUstate
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.25]: 2.1.8 Getting and Setting the Complete FMU State
See also fmi2SerializeFMUstate
.
FMICore.fmi2SerializeFMUstate!
— FunctionSource: FMISpec2.0.2[p.26]: 2.1.8 Getting and Setting the Complete FMU State
fmi2SerializeFMUstate serializes the data which is referenced by pointer FMUstate and copies this data in to the byte vector serializedState of length size
fmi2SerializeFMUstate!(c::FMU2Component, FMUstate::fmi2FMUstate, serialzedState::AbstractArray{fmi2Byte}, size::Csize_t)
Serializes the data which is referenced by pointer FMUstate
and copies this data in to the byte vector serializedState
of length size
, that must be provided by the environment.
Arguments
str::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.state::fmi2FMUstate
: Argumentstate
is a pointer to a data structure in the FMU that saves the internal FMU state of the actual or a previous time instant.serialzedState::AbstractArray{fmi2Byte}
: ArgumentserializedState
contains the copy of the serialized data referenced by the pointer FMUstate.size::Csize_t
: Argumentsize
defines the length of the serialized vector.
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.25]: 2.1.8 Getting and Setting the Complete FMU State
See also fmi2SerializeFMUstate
.
FMIImport.fmi2DeSerializeFMUstate
— Functionfmi2DeSerializeFMUstate(c::FMU2Component, serializedState::AbstractArray{fmi2Byte})
Deserialize the data in the serializedState fmi2Byte field
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.serializedState::Array{fmi2Byte}
: ArgumentserializedState
contains the fmi2Byte field to be deserialized.
Returns
- Return
state
is a pointer to a copy of the internal FMU state.
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.25]: 2.1.8 Getting and Setting the Complete FMU State
See also fmi2DeSerializeFMUstate
.
FMICore.fmi2DeSerializeFMUstate!
— FunctionSource: FMISpec2.0.2[p.26]: 2.1.8 Getting and Setting the Complete FMU State
fmi2DeSerializeFMUstate deserializes the byte vector serializedState of length size, constructs a copy of the FMU state and returns FMUstate, the pointer to this copy.
fmi2DeSerializeFMUstate!(c::FMU2Component, serializedState::AbstractArray{fmi2Byte}, size::Csize_t, FMUstate::Ref{fmi2FMUstate})
Deserializes the byte vector serializedState of length size, constructs a copy of the FMU state and stores the FMU state in the given address of the reference FMUstate
, the pointer to this copy.
Arguments
str::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.state::fmi2FMUstate
: Argumentstate
is a pointer to a data structure in the FMU that saves the internal FMU state of the actual or a previous time instant.serialzedState::AbstractArray{fmi2Byte}
: ArgumentserializedState
contains the copy of the serialized data referenced by the pointer FMUstate.size::Csize_t
: Argumentsize
defines the length of the serialized vector.FMUstate::Ref{fmi2FMUstate}
: ArgumentFMUstate
is an object that safely references data of typefmi3FMUstate
which is a pointer to a data structure in the FMU that saves the internal FMU state of the actual or a previous time instant.
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.25]: 2.1.8 Getting and Setting the Complete FMU State
See also fmi2DeSerializeFMUstate!
.
Getting Partial Dervatives
It is optionally possible to provide evaluation of partial derivatives for an FMU. For Model Exchange, this means computing the partial derivatives at a particular time instant. For Co-Simulation, this means to compute the partial derivatives at a particular communication point. One function is provided to compute directional derivatives. This function can be used to construct the desired partial derivative matrices.
FMIImport.fmi2GetDirectionalDerivative
— Functionfmi2GetDirectionalDerivative(c::FMU2Component,
vUnknown_ref::AbstractArray{fmi2ValueReference},
vKnown_ref::AbstractArray{fmi2ValueReference},
dvKnown::Union{AbstractArray{fmi2Real}, Nothing} = nothing)
Wrapper Function call to compute the partial derivative with respect to the variables vKnown_ref
.
Computes the directional derivatives of an FMU. An FMU has different Modes and in every Mode an FMU might be described by different equations and different unknowns.The precise definitions are given in the mathematical descriptions of Model Exchange (section 3.1) and Co-Simulation (section 4.1). In every Mode, the general form of the FMU equations are: 𝐯unknown = 𝐡(𝐯known, 𝐯_rest)
v_unknown
: vector of unknown Real variables computed in the actual Mode:- Initialization Mode: unkowns kisted under
<ModelStructure><InitialUnknowns>
that have type Real. - Continuous-Time Mode (ModelExchange): The continuous-time outputs and state derivatives. (= the variables listed under
<ModelStructure><Outputs>
with type Real and variability =continuous
and the variables listed as state derivatives under<ModelStructure><Derivatives>)
. - Event Mode (ModelExchange): The same variables as in the Continuous-Time Mode and additionally variables under
<ModelStructure><Outputs>
with type Real and variability =discrete
. - Step Mode (CoSimulation): The variables listed under
<ModelStructure><Outputs>
with type Real and variability =continuous
ordiscrete
. If<ModelStructure><Derivatives>
is present, also the variables listed here as state derivatives.
- Initialization Mode: unkowns kisted under
v_known
: Real input variables of function h that changes its value in the actual Mode.v_rest
:Set of input variables of function h that either changes its value in the actual Mode but are non-Real variables, or do not change their values in this Mode, but change their values in other Modes
Computes a linear combination of the partial derivatives of h with respect to the selected input variables 𝐯_known:
Δv_unknown = (δh / δv_known) Δv_known
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vUnknown_ref::AbstractArray{fmi2ValueReference}
: ArgumentvUnknown_ref
contains values of typefmi2ValueReference
which are identifiers of a variable value of the model.vUnknown_ref
can be equated withv_unknown
(variable described above).vKnown_ref::AbstractArray{fmi2ValueReference}
: ArgumentvKnown_ref
contains values of typefmi2ValueReference
which are identifiers of a variable value of the model.vKnown_ref
can be equated withv_known
(variable described above).dvKnown::Union{AbstractArray{fmi2Real}, Nothing} = nothing
: If no seed vector is passed the valuenothing
is used. The vector values Compute the partial derivative with respect to the given entries in vectorvKnown_ref
with the matching evaluate ofdvKnown
. # gehört das zu den v_rest values
Returns
dvUnknown::Array{fmi2Real}
: ReturndvUnknown
contains the directional derivative vector values.
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.25]: 2.1.9 Getting Partial Derivatives
See also fmi2GetDirectionalDerivative!
.
FMICore.fmi2GetDirectionalDerivative!
— FunctionSource: FMISpec2.0.2[p.26]: 2.1.9 Getting Partial Derivatives
This function computes the directional derivatives of an FMU.
ΔvUnknown = ∂h / ∂vKnown ⋅ ΔvKnown
fmi2GetDirectionalDerivative!(c::FMU2Component,
vUnknown_ref::AbstractArray{fmi2ValueReference},
nUnknown::Csize_t,
vKnown_ref::AbstractArray{fmi2ValueReference},
nKnown::Csize_t,
dvKnown::AbstractArray{fmi2Real},
dvUnknown::AbstractArray{fmi2Real})
Wrapper Function call to compute the partial derivative with respect to the variables vKnown_ref
.
Computes the directional derivatives of an FMU. An FMU has different Modes and in every Mode an FMU might be described by different equations and different unknowns. The precise definitions are given in the mathematical descriptions of Model Exchange (section 3.1) and Co-Simulation (section 4.1). In every Mode, the general form of the FMU equations are: 𝐯unknown = 𝐡(𝐯known, 𝐯_rest)
v_unknown
: vector of unknown Real variables computed in the actual Mode:- Initialization Mode: unkowns kisted under
<ModelStructure><InitialUnknowns>
that have type Real. - Continuous-Time Mode (ModelExchange): The continuous-time outputs and state derivatives. (= the variables listed under
<ModelStructure><Outputs>
with type Real and variability =continuous
and the variables listed as state derivatives under<ModelStructure><Derivatives>)
. - Event Mode (ModelExchange): The same variables as in the Continuous-Time Mode and additionally variables under
<ModelStructure><Outputs>
with type Real and variability =discrete
. - Step Mode (CoSimulation): The variables listed under
<ModelStructure><Outputs>
with type Real and variability =continuous
ordiscrete
. If<ModelStructure><Derivatives>
is present, also the variables listed here as state derivatives.
- Initialization Mode: unkowns kisted under
v_known
: Real input variables of function h that changes its value in the actual Mode.v_rest
:Set of input variables of function h that either changes its value in the actual Mode but are non-Real variables, or do not change their values in this Mode, but change their values in other Modes
Computes a linear combination of the partial derivatives of h with respect to the selected input variables 𝐯_known:
Δvunknown = (δh / δvknown) Δv_known
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vUnknown_ref::AbstracArray{fmi2ValueReference}
: ArgumentvUnknown_ref
contains values of typefmi2ValueReference
which are identifiers of a variable value of the model.vUnknown_ref
can be equated withv_unknown
(variable described above).nUnknown::Csize_t
: Length of theUnknown
Array.vKnown_ref::AbstractArray{fmi2ValueReference}
: ArgumentvKnown_ref
contains values of typefmi2ValueReference
which are identifiers of a variable value of the model.vKnown_ref
can be equated withv_known
(variable described above).nKnown::Csize_t
: Length of theKnown
Array.dvKnown::AbstractArray{fmi2Real}
:The vector values Compute the partial derivative with respect to the given entries in vectorvKnown_ref
with the matching evaluate ofdvKnown
.dvUnknown::AbstractArray{fmi2Real}
: Stores the directional derivative vector values.
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.25]: 2.1.9 Getting Partial Derivatives
See also fmi2GetDirectionalDerivative!
.
fmiGetDirectionalDerivative!(c::FMU2Component,
vUnknown_ref::AbstractArray{fmi2ValueReference},
vKnown_ref::AbstractArray{fmi2ValueReference},
dvKnown::Array{fmi2Real},
dvUnknown::AbstractArray)
Wrapper Function call to compute the partial derivative with respect to the variables vKnown_ref
.
Computes the directional derivatives of an FMU. An FMU has different Modes and in every Mode an FMU might be described by different equations and different unknowns.The precise definitions are given in the mathematical descriptions of Model Exchange (section 3.1) and Co-Simulation (section 4.1). In every Mode, the general form of the FMU equations are: 𝐯unknown = 𝐡(𝐯known, 𝐯_rest)
v_unknown
: vector of unknown Real variables computed in the actual Mode:- Initialization Mode: unkowns kisted under
<ModelStructure><InitialUnknowns>
that have type Real. - Continuous-Time Mode (ModelExchange): The continuous-time outputs and state derivatives. (= the variables listed under
<ModelStructure><Outputs>
with type Real and variability =continuous
and the variables listed as state derivatives under<ModelStructure><Derivatives>)
. - Event Mode (ModelExchange): The same variables as in the Continuous-Time Mode and additionally variables under
<ModelStructure><Outputs>
with type Real and variability =discrete
. - Step Mode (CoSimulation): The variables listed under
<ModelStructure><Outputs>
with type Real and variability =continuous
ordiscrete
. If<ModelStructure><Derivatives>
is present, also the variables listed here as state derivatives.
- Initialization Mode: unkowns kisted under
v_known
: Real input variables of function h that changes its value in the actual Mode.v_rest
:Set of input variables of function h that either changes its value in the actual Mode but are non-Real variables, or do not change their values in this Mode, but change their values in other Modes
Computes a linear combination of the partial derivatives of h with respect to the selected input variables 𝐯_known:
Δv_unknown = (δh / δv_known) Δv_known
Arguments
c::FMU2Component
: Mutable struct represents an instantiated instance of an FMU in the FMI 2.0.2 Standard.vUnknown_ref::AbstracArray{fmi2ValueReference}
: ArgumentvUnknown_ref
contains values of typefmi2ValueReference
which are identifiers of a variable value of the model.vUnknown_ref
can be equated withv_unknown
(variable described above).vKnown_ref::AbstractArray{fmi2ValueReference}
: ArgumentvKnown_ref
contains values of typefmi2ValueReference
which are identifiers of a variable value of the model.vKnown_ref
can be equated withv_known
(variable described above).dvUnknown::AbstractArray{fmi2Real}
: Stores the directional derivative vector values.dvKnown::Union{AbstractArray{fmi2Real}, Nothing} = nothing
: If no seed vector is passed the valuenothing
is used. The vector values Compute the partial derivative with respect to the given entries in vectorvKnown_ref
with the matching evaluate ofdvKnown
.
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.25]: 2.1.9 Getting Partial Derivatives
See also fmi2GetDirectionalDerivative!
.
FMICore.fmi2SetRealInputDerivatives
— FunctionSource: FMISpec2.0.2[p.104]: 4.2.1 Transfer of Input / Output Values and Parameters
Sets the n-th time derivative of real input variables. vr defines the value references of the variables the array order specifies the corresponding order of derivation of the variables
fmi2SetRealInputDerivatives(c::FMU2Component,
vr::AbstractArray{fmi2ValueReference},
nvr::Csize_t,
order::AbstractArray{fmi2Integer},
value::AbstractArray{fmi2Real})
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.nvr::Csize_t
: Argumentnvr
defines the size ofvr
.order::AbstractArray{fmi2Integer}
: Argumentorder
is an AbstractArray of fmi2Integer values witch specifys the corresponding order of derivative of the real input variable.values::AbstractArray{fmi2Real}
: Argumentvalues
is an AbstractArray with the actual values of these variables.
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
- 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
See also fmi2SetRealInputDerivatives
.
fmi2SetRealInputDerivatives(c::FMU2Component,
vr::AbstractArray{fmi2ValueReference},
order::AbstractArray{fmi2Integer},
values::AbstractArray{fmi2Real})
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 define the variables whose derivatives shall be set.order::AbstractArray{fmi2Integer}
: Argumentorder
is an AbstractArray of fmi2Integer values witch specifys the corresponding order of derivative of the real input variable.values::AbstractArray{fmi2Real}
: Argumentvalues
is an AbstractArray with the actual values of these variables.
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
- 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
See also fmi2SetRealInputDerivatives
.
FMICore.fmi2GetRealOutputDerivatives!
— FunctionSource: FMISpec2.0.2[p.104]: 4.2.1 Transfer of Input / Output Values and Parameters
Retrieves the n-th derivative of output values. vr defines the value references of the variables the array order specifies the corresponding order of derivation of the variables
fmi2GetRealOutputDerivatives!(c::FMU2Component,
vr::AbstractArray{fmi2ValueReference},
nvr::Csize_t, order::AbstractArray{fmi2Integer},
value::AbstractArray{fmi2Real})
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.nvr::Csize_t
: Argumentnvr
defines the size ofvr
.order::Array{fmi2Integer}
: Argumentorder
is an array of fmi2Integer values witch specifys the corresponding order of derivative of the real input variable.values::Array{fmi2Real}
: Argumentvalues
is an array with the actual values of these variables.
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
- 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
fmi2SampleJacobian fmi2SampleJacobian!
External/Additional functions
FMIBase.setDiscreteStates
— FunctionToDo
setDiscreteStates(c::FMU2Component,
x::Union{AbstractArray{Float32},AbstractArray{Float64}})
Set a new (discrete) state vector and reinitialize chaching of variables that depend on states.
Arguments
[ToDo]
FMIBase.getDiscreteStates
— FunctiongetDiscreteStates(c)
Sets a new (discrete) state vector (out-of-place).
Arguments
c::FMU2Component
FMIBase.getDiscreteStates!
— FunctiongetDiscreteStates!(c, xd)
Sets a new (discrete) state vector (in-place).
Arguments
c::FMU2Component
xd::AbstractArray{Union{fmi2Real, fmi2Integer, fmi2Boolean}}
FMIBase.getSimpleTypeAttributeStruct
— FunctiongetSimpleTypeAttributeStruct(st::fmi2SimpleType)
Returns the attribute structure for the simple type st
. Depending on definition, this is either st.Real
, st.Integer
, st.String
, st.Boolean
or st.Enumeration
.
Arguments
st::fmi2SimpleType
: Struct which provides the information on custom SimpleTypes.
Source
- FMISpec2.0.3 Link: https://fmi-standard.org/
- FMISpec2.0.3[p.40]: 2.2.3 Definition of Types (TypeDefinitions)
FMIBase.getDeclaredType
— FunctiongetDeclaredType(md::fmi2ModelDescription, mv::fmi2ScalarVariable)
Returns the fmi2SimpleType
of the corresponding model variable mv
as defined in md.typeDefinitions
. If mv
does not have a declared type, return nothing
. If mv
has a declared type, but it is not found, issue a warning and return nothing
.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.mv::fmi2ScalarVariable
: The “ModelVariables” element consists of an ordered set of “ScalarVariable” elements. A “ScalarVariable” represents a variable of primitive type, like a real or integer variable.
Source
- FMISpec2.0.3 Link: https://fmi-standard.org/
- FMISpec2.0.3: 2.2.7 Definition of Model Variables (ModelVariables)
fmi2GetSolutionDerivative fmi2GetSolutionState fmi2GetSolutionValue fmi2GetSolutionTime fmi2GetJacobian fmi2GetJacobian! fmi2GetFullJacobian fmi2GetFullJacobian!