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.getGUIDFunction
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.
source
FMIBase.getGenerationDateAndTimeFunction
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.
source
FMIBase.getGenerationToolFunction
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.
source

technical information about the FMU

FMIBase.getNumberOfEventIndicatorsFunction
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.
source
FMIBase.getModelIdentifierFunction
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 tag modelIdentifier from ModelExchange section.
  • md.coSimulation.modelIdentifier::String: Returns the tag modelIdentifier from CoSimulation section.
source
FMIBase.getVariableNamingConventionFunction
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.
source

fmi2GetVersion fmi2GetTypesPlatform

default experiment settings

FMIBase.getDefaultStartTimeFunction
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 value startTime from the DefaultExperiment if defined else defaults to nothing.
source
FMIBase.getDefaultStepSizeFunction
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 value setpSize from the DefaultExperiment if defined else defaults to nothing.
source
FMIBase.getDefaultStopTimeFunction
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 value stopTime from the DefaultExperiment if defined else defaults to nothing.
source
FMIBase.getDefaultToleranceFunction
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 value tolerance from the DefaultExperiment if defined else defaults to nothing.
source

FMU capabilities

FMIBase.canSerializeFMUStateFunction
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
source
FMIBase.providesDirectionalDerivativesFunction
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
source

canGetSetFMUState fmi2DependenciesSupported fmi2DerivativeDependenciesSupported fmi2ProvidesDirectionalDerivative

value references

FMIBase.getValueReferencesAndNamesFunction
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 attribute valueReferences::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}.
source
FMIBase.getNamesFunction
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 attribute valueReferences::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 references vrs
source
FMIBase.dataTypeForValueReferenceFunction
dataTypeForValueReference(obj, vr::fmi2ValueReference)

where:

obj ∈ (fmi2ModelDescription, FMU2)

Returns the fmi2DataType (fmi2Real, fmi2Integer, fmi2Boolean, fmi2String) for a given value reference vr.

source
FMIBase.prepareValueReferenceFunction
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).

source
FMIBase.prepareValueFunction
prepareValue(value)

Prepares a value for a FMI ccall (they only accept arrays). Technically, the value is packed into an array - if not already.

source

In-/Outputs

FMIBase.getInputNamesFunction
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 attribute inputvalueReferences::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 references vrs
source
FMIBase.getInputValueReferencesAndNamesFunction
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)
source
FMIBase.getInputNamesAndStartsFunction
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.

source
FMIBase.getOutputNamesFunction
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 attribute outputvalueReferences::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 references vrs
source
FMIBase.getOutputValueReferencesAndNamesFunction
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 attribute outputvalueReferences::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)
source

Parameters

FMIBase.getParameterValueReferencesAndNamesFunction
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.

source
FMIBase.getParameterNamesFunction
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 attribute parameterValueReferences::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 references vrs
source

States

FMIBase.getStateNamesFunction
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 attribute parameterValueReferences::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 references vrs
source
FMIBase.getStateValueReferencesAndNamesFunction
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)
source

Derivatives

FMIBase.getDerivateValueReferencesAndNamesFunction
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

source
FMIBase.getDerivativeNamesFunction
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 attribute derivativeValueReferences::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 references vrs
source

Variables

FMIBase.getNamesAndInitialsFunction
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.

source
FMIBase.getNamesAndDescriptionsFunction
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))
source
FMIBase.getNamesAndUnitsFunction
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.

source