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
FMIBase.FMIModelDescriptionLSSA — Type
Layered StandardFMIImport.getGUID — Function
getGUID(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 — Function
Returns the tag 'instantionToken' from the model description.
FMIBase.getGenerationDateAndTime — Function
getGenerationDateAndTime(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 — Function
getGenerationTool(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 — Function
getNumberOfEventIndicators(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 — Function
getModelIdentifier(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 tagmodelIdentifierfrom ModelExchange section.md.coSimulation.modelIdentifier::String: Returns the tagmodelIdentifierfrom CoSimulation section.
FMIBase.getVariableNamingConvention — Function
getVariableNamingConvention(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 — Function
getDefaultStartTime(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 valuestartTimefrom the DefaultExperiment if defined else defaults tonothing.
FMIBase.getDefaultStepSize — Function
getDefaultStepSize(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 valuesetpSizefrom the DefaultExperiment if defined else defaults tonothing.
FMIBase.getDefaultStopTime — Function
getDefaultStopTime(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 valuestopTimefrom the DefaultExperiment if defined else defaults tonothing.
FMIBase.getDefaultTolerance — Function
getDefaultTolerance(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 valuetolerancefrom the DefaultExperiment if defined else defaults tonothing.
FMU capabilities
FMIBase.canSerializeFMUState — Function
canSerializeFMUState(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 — Function
providesDirectionalDerivative(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 — Function
Returns true, if the FMU provides adjoint derivatives
canGetSetFMUState fmi2DependenciesSupported fmi2DerivativeDependenciesSupported fmi2ProvidesDirectionalDerivative
value references
FMIBase.getValueReferencesAndNames — Function
getValueReferencesAndNames(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 — Function
getNames(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 — Function
dataTypeForValueReference(obj, vr::fmi2ValueReference)where:
obj ∈ (fmi2ModelDescription, FMU2)
Returns the fmi2DataType (fmi2Real, fmi2Integer, fmi2Boolean, fmi2String) for a given value reference vr.
FMIBase.prepareValueReference — Function
prepareValueReference(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 — Function
prepareValue(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 — Function
getInputNames(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 — Function
getInputValueReferencesAndNames(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 — Function
getInputNamesAndStarts(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 — Function
fmi2GetOutputNames(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 — Function
getOutputValueReferencesAndNames(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 — Function
getParameterValueReferencesAndNames(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 — Function
fmi2GetParameterNames(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 — Function
fmi2GetStateNames(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 — Function
fmi2GetStateValueReferencesAndNames(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 — Function
fmi2GetDerivateValueReferencesAndNames(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 — Function
fmi2GetDerivativeNames(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 — Function
getNamesAndInitials(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 — Function
getNamesAndDescriptions(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 — Function
getNamesAndUnits(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.