Working with the FMI model description
The FMI model description provides all human readable information on the model. The following functions can be used to obtain all information provided by the model description, which in turn can be extracted from the fmu.
Loading/Parsing
fmi2LoadModelDescription
general information about the FMU
FMIImport.getGUID
— FunctiongetGUID(md::fmi2ModelDescription)
Returns the tag 'guid' from the model description.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
guid::String
: Returns the tag 'guid' from the model description.
FMIBase.getInstantiationToken
— FunctionReturns the tag 'instantionToken' from the model description.
FMIBase.getGenerationDateAndTime
— FunctiongetGenerationDateAndTime(md::fmi2ModelDescription)
Returns the tag 'generationdateandtime' from the model description.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
md.generationDateAndTime::DateTime
: Returns the tag 'generationdateandtime' from the model description.
FMIBase.getGenerationTool
— FunctiongetGenerationTool(md::fmi2ModelDescription)
Returns the tag 'generationtool' from the model description.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
md.generationTool::Union{String, Nothing}
: Returns the tag 'generationtool' from the model description.
technical information about the FMU
FMIBase.getNumberOfEventIndicators
— FunctiongetNumberOfEventIndicators(md::fmi2ModelDescription)
Returns the tag 'numberOfEventIndicators' from the model description.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
md.numberOfEventIndicators::Union{UInt, Nothing}
: Returns the tag 'numberOfEventIndicators' from the model description.
FMIBase.getModelIdentifier
— FunctiongetModelIdentifier(md::fmiModelDescription; type=nothing)
Returns the tag 'modelIdentifier' from CS or ME section.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Keywords
type=nothing
: Defines whether a Co-Simulation or Model Exchange is present. (default = nothing)
Returns
md.modelExchange.modelIdentifier::String
: Returns the tagmodelIdentifier
from ModelExchange section.md.coSimulation.modelIdentifier::String
: Returns the tagmodelIdentifier
from CoSimulation section.
FMIBase.getVariableNamingConvention
— FunctiongetVariableNamingConvention(md::fmi2ModelDescription)
Returns the tag 'varaiblenamingconvention' from the model description.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
md.variableNamingConvention::Union{fmi2VariableNamingConvention, Nothing}
: Returns the tag 'variableNamingConvention' from the model description.
fmi2GetVersion fmi2GetTypesPlatform
default experiment settings
FMIBase.getDefaultStartTime
— FunctiongetDefaultStartTime(md::fmi2ModelDescription)
Returns startTime from DefaultExperiment if defined else defaults to nothing.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
md.defaultExperiment.startTime::Union{Real,Nothing}
: Returns a real valuestartTime
from the DefaultExperiment if defined else defaults tonothing
.
FMIBase.getDefaultStepSize
— FunctiongetDefaultStepSize(md::fmi2ModelDescription)
Returns stepSize from DefaultExperiment if defined else defaults to nothing.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
md.defaultExperiment.stepSize::Union{Real,Nothing}
: Returns a real valuesetpSize
from the DefaultExperiment if defined else defaults tonothing
.
FMIBase.getDefaultStopTime
— FunctiongetDefaultStopTime(md::fmi2ModelDescription)
Returns stopTime from DefaultExperiment if defined else defaults to nothing.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
md.defaultExperiment.stopTime::Union{Real,Nothing}
: Returns a real valuestopTime
from the DefaultExperiment if defined else defaults tonothing
.
FMIBase.getDefaultTolerance
— FunctiongetDefaultTolerance(md::fmi2ModelDescription)
Returns tolerance from DefaultExperiment if defined else defaults to nothing.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
md.defaultExperiment.tolerance::Union{Real,Nothing}
: Returns a real valuetolerance
from the DefaultExperiment if defined else defaults tonothing
.
FMU capabilities
FMIBase.canSerializeFMUState
— FunctioncanSerializeFMUState(md::fmi2ModelDescription)
Returns true, if the FMU state can be serialized
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
::Bool
: Returns true, if the FMU state can be serialized
FMIBase.providesDirectionalDerivatives
— FunctionprovidesDirectionalDerivative(md::fmi2ModelDescription)
Returns true, if the FMU provides directional derivatives
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
::Bool
: Returns true, if the FMU provides directional derivatives
FMIBase.providesAdjointDerivatives
— FunctionReturns true, if the FMU provides adjoint derivatives
canGetSetFMUState fmi2DependenciesSupported fmi2DerivativeDependenciesSupported fmi2ProvidesDirectionalDerivative
value references
FMIBase.getValueReferencesAndNames
— FunctiongetValueReferencesAndNames(obj; vrs=md.valueReferences)
with:
obj ∈ (fmi2ModelDescription, FMU2)
Returns a dictionary Dict(fmi2ValueReference, Array{String})
of value references and their corresponding names.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Keywords
vrs=md.valueReferences
: Additional attributevalueReferences::Array{fmi2ValueReference}
of the Model Description that is a handle to a (base type) variable value. Handle and base type uniquely identify the value of a variable. (default =md.valueReferences::Array{fmi2ValueReference}
)
Returns
dict::Dict{fmi2ValueReference, Array{String}}
: Returns a dictionary that constructs a hash table with keys of type fmi2ValueReference and values of type Array{String}.
FMIBase.getNames
— FunctiongetNames(md::fmi2ModelDescription; vrs=md.valueReferences, mode=:first)
Returns a array of names corresponding to value references vrs
.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Keywords
vrs=md.valueReferences
: Additional attributevalueReferences::Array{fmi2ValueReference}
of the Model Description that is a handle to a (base type) variable value. Handle and base type uniquely identify the value of a variable. (default =md.valueReferences::Array{fmi2ValueReference}
)mode=:first
: If there are multiple names per value reference, availabel modes are:first
(default, pick only the first one),:group
(pick all and group them into an array) and:flat
(pick all, but flat them out into a 1D-array together with all other names)
Returns
names::Array{String}
: Returns a array of names corresponding to value referencesvrs
FMIBase.dataTypeForValueReference
— FunctiondataTypeForValueReference(obj, vr::fmi2ValueReference)
where:
obj ∈ (fmi2ModelDescription, FMU2)
Returns the fmi2DataType (fmi2Real
, fmi2Integer
, fmi2Boolean
, fmi2String
) for a given value reference vr
.
FMIBase.prepareValueReference
— FunctionprepareValueReference(obj, vrs)
where:
obj ∈ (fmi2ModelDescription, fmi3ModelDescription, FMU2, FMU3, FMU2Component, FMU3Instance) vrs ∈ (fmi2ValueReference, AbstractVector{fmi2ValueReference}, fmi3ValueReference, AbstractVector{fmi3ValueReference}, String, AbstractVector{String}, Integer, AbstractVector{Integer}, :states, :derivatives, :inputs, :outputs, :all, :none, Nothing)
Receives one or an array of value references in an arbitrary format (see fmi2ValueReferenceFormat) and converts it into an Array{fmi2ValueReference} (if not already).
FMIBase.prepareValue
— FunctionprepareValue(value)
Prepares a value for a FMI ccall (they only accept arrays). Technically, the value is packed into an array - if not already.
In-/Outputs
FMIBase.getInputNames
— FunctiongetInputNames(md::fmi2ModelDescription; vrs=md.inputvalueReferences, mode=:first)
Returns names of inputs.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Keywords
vrs=md.inputvalueReferences
: Additional attributeinputvalueReferences::Array{fmi2ValueReference}
of the Model Description that is a handle to a (base type) variable value. Handle and base type uniquely identify the value of a variable. (default =md.valueReferences::Array{fmi2ValueReference}
)mode=:first
: If there are multiple names per value reference, availabel modes are:first
(default, pick only the first one),:group
(pick all and group them into an array) and:flat
(pick all, but flat them out into a 1D-array together with all other names)
Returns
names::Array{String}
: Returns a array of names corresponding to value referencesvrs
FMIBase.getInputValueReferencesAndNames
— FunctiongetInputValueReferencesAndNames(md::fmi2ModelDescription)
Returns a dict with (vrs, names of inputs).
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.fmu::FMU2
: Mutable struct representing a FMU and all it instantiated instances in the FMI 2.0.2 Standard.
Returns
dict::Dict{fmi2ValueReference, Array{String}}
: Returns a dictionary that constructs a hash table with keys of type fmi2ValueReference and values of type Array{String}. So returns a dict with (vrs, names of inputs)
FMIBase.getInputNamesAndStarts
— FunctiongetInputNamesAndStarts(md::fmi2ModelDescription)
Returns a dictionary of input variables with their starting values.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
dict::Dict{String, Array{fmi2ValueReferenceFormat}}
: Returns a dictionary that constructs a hash table with keys of type String and values of type fmi2ValueReferenceFormat. So returns a dict with (md.modelVariables[i].name::String
,starts:: Array{fmi2ValueReferenceFormat}
). (Creates a tuple (name, starts) for each i in inputIndices)
See also getStartValue
.
FMIBase.getOutputNames
— Functionfmi2GetOutputNames(md::fmi2ModelDescription; vrs=md.outputvalueReferences, mode=:first)
Returns names of outputs.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Keywords
vrs=md.outputvalueReferences
: Additional attributeoutputvalueReferences::Array{fmi2ValueReference}
of the Model Description that is a handle to a (base type) variable value. Handle and base type uniquely identify the value of a variable. (default =md.outputvalueReferences::Array{fmi2ValueReference}
)mode=:first
: If there are multiple names per value reference, availabel modes are:first
(default, pick only the first one),:group
(pick all and group them into an array) and:flat
(pick all, but flat them out into a 1D-array together with all other names)
Returns
names::Array{String}
: Returns a array of names corresponding to value referencesvrs
FMIBase.getOutputValueReferencesAndNames
— FunctiongetOutputValueReferencesAndNames(md::fmi2ModelDescription)
Returns a dictionary Dict(fmi2ValueReference, Array{String})
of value references and their corresponding names.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Keywords
vrs=md.outputvalueReferences
: Additional attributeoutputvalueReferences::Array{fmi2ValueReference}
of the Model Description that is a handle to a (base type) variable value. Handle and base type uniquely identify the value of a variable. (default =md.outputvalueReferences::Array{fmi2ValueReference}
)
Returns
dict::Dict{fmi2ValueReference, Array{String}}
: Returns a dictionary that constructs a hash table with keys of type fmi2ValueReference and values of type Array{String}.So returns a dict with (vrs, names of outputs)
Parameters
FMIBase.getParameterValueReferencesAndNames
— FunctiongetParameterValueReferencesAndNames(md::fmi2ModelDescription)
Returns a dictionary Dict(fmi2ValueReference, Array{String})
of parameterValueReferences and their corresponding names.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
dict::Dict{fmi2ValueReference, Array{String}}
: Returns a dictionary that constructs a hash table with keys of type fmi2ValueReference and values of type Array{String}. So returns a dict with (vrs, names of parameters).
See also getValueReferencesAndNames
.
FMIBase.getParameterNames
— Functionfmi2GetParameterNames(md::fmi2ModelDescription; vrs=md.parameterValueReferences, mode=:first)
Returns names of parameters.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Keywords
vrs=md.parameterValueReferences
: Additional attributeparameterValueReferences::Array{fmi2ValueReference}
of the Model Description that is a handle to a (base type) variable value. Handle and base type uniquely identify the value of a variable. (default =md.parameterValueReferences::Array{fmi2ValueReference}
)mode=:first
: If there are multiple names per value reference, availabel modes are:first
(default, pick only the first one),:group
(pick all and group them into an array) and:flat
(pick all, but flat them out into a 1D-array together with all other names)
Returns
names::Array{String}
: Returns a array of names corresponding to parameter value referencesvrs
States
FMIBase.getStateNames
— Functionfmi2GetStateNames(fmu::FMU2; vrs=md.stateValueReferences, mode=:first)
Returns names of states.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Keywords
vrs=md.stateValueReferences
: Additional attributeparameterValueReferences::Array{fmi2ValueReference}
of the Model Description that is a handle to a (base type) variable value. Handle and base type uniquely identify the value of a variable. (default =md.stateValueReferences::Array{fmi2ValueReference}
)mode=:first
: If there are multiple names per value reference, availabel modes are:first
(default, pick only the first one),:group
(pick all and group them into an array) and:flat
(pick all, but flat them out into a 1D-array together with all other names)
Returns
names::Array{String}
: Returns a array of names corresponding to parameter value referencesvrs
FMIBase.getStateValueReferencesAndNames
— Functionfmi2GetStateValueReferencesAndNames(md::fmi2ModelDescription)
Returns a dictionary Dict(fmi2ValueReference, Array{String})
of state value references and their corresponding names.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
dict::Dict{fmi2ValueReference, Array{String}}
: Returns a dictionary that constructs a hash table with keys of type fmi2ValueReference and values of type Array{String}. So returns a dict with (vrs, names of states)
Derivatives
FMIBase.getDerivateValueReferencesAndNames
— Functionfmi2GetDerivateValueReferencesAndNames(md::fmi2ModelDescription)
Returns a dictionary Dict(fmi2ValueReference, Array{String})
of derivative value references and their corresponding names.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
dict::Dict{fmi2ValueReference, Array{String}}
: Returns a dictionary that constructs a hash table with keys of type fmi2ValueReference and values of type Array{String}. So returns a dict with (vrs, names of derivatives)
See also getValueReferencesAndNames
FMIBase.getDerivativeNames
— Functionfmi2GetDerivativeNames(md::fmi2ModelDescription; vrs=md.derivativeValueReferences, mode=:first)
Returns names of derivatives.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Keywords
vrs=md.derivativeValueReferences
: Additional attributederivativeValueReferences::Array{fmi2ValueReference}
of the Model Description that is a handle to a (base type) variable value. Handle and base type uniquely identify the value of a variable. (default =md.derivativeValueReferences::Array{fmi2ValueReference}
)mode=:first
: If there are multiple names per value reference, availabel modes are:first
(default, pick only the first one),:group
(pick all and group them into an array) and:flat
(pick all, but flat them out into a 1D-array together with all other names)
Returns
names::Array{String}
: Returns a array of names corresponding to parameter value referencesvrs
Variables
FMIBase.getNamesAndInitials
— FunctiongetNamesAndInitials(md::fmi2ModelDescription)
Returns a dictionary of variables with their initials.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
dict::Dict{String, Cuint}
: Returns a dictionary that constructs a hash table with keys of type String and values of type Cuint. So returns a dict with (md.modelVariables[i].name::String
,md.modelVariables[i].inital::Union{fmi2Initial, Nothing}
). (Creates a tuple (name,initial) for each i in 1:length(md.modelVariables))
See also getInitial
.
FMIBase.getNamesAndDescriptions
— FunctiongetNamesAndDescriptions(md::fmi2ModelDescription)
Returns a dictionary of variables with their descriptions.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
dict::Dict{String, String}
: Returns a dictionary that constructs a hash table with keys of type String and values of type String. So returns a dict with (md.modelVariables[i].name::String
,md.modelVariables[i].description::Union{String, Nothing}
). (Creates a tuple (name, description) for each i in 1:length(md.modelVariables))
FMIBase.getNamesAndUnits
— FunctiongetNamesAndUnits(md::fmi2ModelDescription)
Returns a dictionary of variables with their units.
Arguments
md::fmi2ModelDescription
: Struct which provides the static information of ModelVariables.
Returns
dict::Dict{String, String}
: Returns a dictionary that constructs a hash table with keys of type String and values of type String. So returns a dict with (md.modelVariables[i].name::String
,md.modelVariables[i]._Real.unit::Union{String, Nothing}
). (Creates a tuple (name, unit) for each i in 1:length(md.modelVariables))
See also getUnit
.