From dba0a367c8e0e614bf19bbeaadac18901c1cd447 Mon Sep 17 00:00:00 2001 From: Simon Exner Date: Fri, 29 Sep 2023 10:27:40 +0200 Subject: [PATCH 1/5] doc fixes + function exports --- src/FMIImport.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/FMIImport.jl b/src/FMIImport.jl index d274598..a9a5ef8 100644 --- a/src/FMIImport.jl +++ b/src/FMIImport.jl @@ -69,6 +69,7 @@ export fmi2GetJacobian, fmi2GetJacobian!, fmi2GetFullJacobian, fmi2GetFullJacobi export fmi2Get, fmi2Get!, fmi2Set export fmi2GetUnit, fmi2GetInitial, fmi2GetStartValue, fmi2SampleJacobian export fmi2GetContinuousStates +export fmi2GetDeclaredType, fmi2GetSimpleTypeAttributeStruct # FMI2_md.jl export fmi2LoadModelDescription @@ -142,7 +143,14 @@ export fmi3GetModelIdentifier, fmi3CanGetSetState, fmi3CanSerializeFMUState, fmi ### +""" +Union containing a [`FMU2`](@ref) or a [`FMU2Component`](@ref) +""" fmi2Struct = Union{FMU2, FMU2Component} + +""" +Union containing a [`FMU3`](@ref) or a [`FMU3Component`](@ref) +""" fmi3Struct = Union{FMU3, FMU3Instance} export fmi2Struct, fmi3Struct From 1a4533b1f59f092bd801f7cea0ca3ef8bc130390 Mon Sep 17 00:00:00 2001 From: Simon Exner Date: Fri, 6 Oct 2023 15:06:10 +0200 Subject: [PATCH 2/5] fixes for fmi.jl doc; moved doc to fmi.jl --- docs/.gitignore | 2 - docs/Project.toml | 5 - docs/make.jl | 26 ---- docs/src/contents.md | 4 - docs/src/fmi2_library.md | 250 --------------------------------------- docs/src/fmi3_library.md | 3 - docs/src/overview.md | 3 - docs/src/related.md | 5 - src/FMI2/md.jl | 4 +- src/FMIImport.jl | 4 +- 10 files changed, 4 insertions(+), 302 deletions(-) delete mode 100644 docs/.gitignore delete mode 100644 docs/Project.toml delete mode 100644 docs/make.jl delete mode 100644 docs/src/contents.md delete mode 100644 docs/src/fmi2_library.md delete mode 100644 docs/src/fmi3_library.md delete mode 100644 docs/src/overview.md delete mode 100644 docs/src/related.md diff --git a/docs/.gitignore b/docs/.gitignore deleted file mode 100644 index 8a5f33c..0000000 --- a/docs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -build/ -Manifest.toml diff --git a/docs/Project.toml b/docs/Project.toml deleted file mode 100644 index 67a236d..0000000 --- a/docs/Project.toml +++ /dev/null @@ -1,5 +0,0 @@ -[deps] -Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" - -[compat] -julia = "1.6" diff --git a/docs/make.jl b/docs/make.jl deleted file mode 100644 index 5e634e7..0000000 --- a/docs/make.jl +++ /dev/null @@ -1,26 +0,0 @@ -# -# Copyright (c) 2021 Tobias Thummerer, Johannes Stoljar, Lars Mikelsons -# Licensed under the MIT license. See LICENSE file in the project root for details. -# - -using Documenter, FMIImport - -makedocs(sitename="FMIImport.jl", - format = Documenter.HTML( - collapselevel = 1, - sidebar_sitename = false, - edit_link = nothing - ), - modules = [FMIImport], - checkdocs = :exports, - pages= Any[ - "Introduction" => "index.md" - "Examples" => "overview.md" - "FMI2 Library Functions" => "fmi2_library.md" - "FMI3 Library Functions" => "fmi3_library.md" - "Related Publication" => "related.md" - "Contents" => "contents.md" - ] - ) - -deploydocs(repo = "github.com/ThummeTo/FMIImport.jl.git", devbranch = "main") diff --git a/docs/src/contents.md b/docs/src/contents.md deleted file mode 100644 index 5aae11c..0000000 --- a/docs/src/contents.md +++ /dev/null @@ -1,4 +0,0 @@ - -```@contents -Depth = 2 -``` diff --git a/docs/src/fmi2_library.md b/docs/src/fmi2_library.md deleted file mode 100644 index 0cf5bc6..0000000 --- a/docs/src/fmi2_library.md +++ /dev/null @@ -1,250 +0,0 @@ - -# [FMI2 Library Functions](@id library) - -## FMI2 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. - -### Reading the model description -This section documents functions to inquire information about the model description of an FMU. - -#### Load/Parse the FMI model description -```@docs -fmi2LoadModelDescription -``` -#### Get value functions -```@docs -fmi2GetDefaultStartTime -fmi2GetDefaultStopTime -fmi2GetDefaultTolerance -fmi2GetDefaultStepSize -fmi2GetModelName -fmi2GetGUID -fmi2GetGenerationTool -fmi2GetGenerationDateAndTime -fmi2GetVariableNamingConvention -fmi2GetNumberOfEventIndicators -fmi2GetNumberOfStates -fmi2IsCoSimulation -fmi2IsModelExchange -``` - -#### Information functions - - -```@docs -fmi2DependenciesSupported -fmi2DerivativeDependenciesSupported -fmi2GetModelIdentifier -fmi2CanGetSetState -fmi2CanSerializeFMUstate -fmi2ProvidesDirectionalDerivative -fmi2GetValueReferencesAndNames -fmi2GetNames -fmi2GetModelVariableIndices -fmi2GetInputValueReferencesAndNames -fmi2GetInputNames -fmi2GetOutputValueReferencesAndNames -fmi2GetOutputNames -fmi2GetParameterValueReferencesAndNames -fmi2GetParameterNames -fmi2GetStateValueReferencesAndNames -fmi2GetStateNames -fmi2GetDerivateValueReferencesAndNames -fmi2GetDerivativeNames -fmi2GetNamesAndDescriptions -fmi2GetNamesAndUnits -fmi2GetNamesAndInitials -fmi2GetInputNamesAndStarts -fmi2GetVersion -fmi2GetTypesPlatform -fmi2GetSolutionDerivative -``` - -### Creation, Destruction and Logging of FMU Instances -This section documents functions that deal with instantiation, destruction and logging of FMUs. - -```@docs -fmi2Instantiate! -fmi2FreeInstance! -fmi2SetDebugLogging - -``` - -### Initialization, Termination, and Resetting an FMU -This section documents functions that deal with initialization, termination, resetting of an FMU. - -```@docs -fmi2SetupExperiment -fmi2EnterInitializationMode -fmi2ExitInitializationMode -fmi2Terminate -fmi2Reset -``` -### 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)]. - -```@docs -fmi2Get -fmi2Get! -fmi2Set -fmi2GetReal -fmi2GetReal! -fmi2GetInteger -fmi2GetInteger! -fmi2GetBoolean -fmi2GetBoolean! -fmi2GetString -fmi2GetString! -fmi2SetReal -fmi2SetInteger -fmi2SetBoolean -fmi2SetString -``` - - -### 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. - -```@docs -fmi2GetFMUstate -fmi2GetFMUstate! -fmi2SetFMUstate -fmi2FreeFMUstate! -fmi2SerializedFMUstateSize -fmi2SerializedFMUstateSize! -fmi2SerializeFMUstate -fmi2SerializeFMUstate! -fmi2DeSerializeFMUstate -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. - - -```@docs -fmi2GetDirectionalDerivative! -fmi2SetRealInputDerivatives -fmi2GetRealOutputDerivatives! -fmi2SampleJacobian -fmi2SampleJacobian! -``` - -## FMI for Model Exchange - -This chapter contains the interface description to access the equations of a dynamic system from a C -program. - -### Providing Independent Variables and Re-initialization of Caching -Depending on the situation, different variables need to be computed. In order to be efficient, it is important that the interface requires only the computation of variables that are needed in the present context. The state derivatives shall be reused from the previous call. This feature is called “caching of variables” in the sequel. Caching requires that the model evaluation can detect when the input arguments, like time or states, have changed. - -```@docs -fmi2SetTime -fmi2SetContinuousStates -``` - -### Evaluation of Model Equations -This section contains the core functions to evaluate the model equations. - - -```@docs -fmi2EnterEventMode -fmi2NewDiscreteStates -fmi2NewDiscreteStates! -fmi2EnterContinuousTimeMode -fmi2CompletedIntegratorStep -fmi2CompletedIntegratorStep! -fmi2GetDerivatives -fmi2GetDerivatives! -fmi2GetEventIndicators -fmi2GetEventIndicators! -fmi2GetContinuousStates -fmi2GetContinuousStates! -fmi2GetNominalsOfContinuousStates -fmi2GetNominalsOfContinuousStates! -``` - -## FMI for Co-Simulation -This chapter defines the Functional Mock-up Interface (FMI) for the coupling of two or more simulation -models in a Co-Simulation environment (FMI for Co-Simulation). Co-Simulation is a rather general -approach to the simulation of coupled technical systems and coupled physical phenomena in -engineering with focus on instationary (time-dependent) problems. - - -### Transfer of Input / Output Values and Parameters -In order to enable the slave to interpolate the continuous real inputs between communication steps, the -derivatives of the inputs with respect to time can be provided. Also, higher derivatives can be set to allow -higher order interpolation. - -```@docs -fmi2GetRealOutputDerivatives -``` - -### Computation -The computation of time steps is controlled by the following function. - -```@docs -fmi2DoStep -fmi2CancelStep -``` - -### Retrieving Status Information from the Slave -Status information is retrieved from the slave by the following functions: - -```@docs -fmi2GetStatus! -fmi2GetRealStatus! -fmi2GetIntegerStatus! -fmi2GetBooleanStatus! -fmi2GetStringStatus! -``` - -## add functions -These new functions, that are useful, but not part of the FMI-spec. (example: `fmi2Load`, `fmi2SampleJacobian`) - -### Opening and closing FMUs -```@docs -fmi2Unzip -fmi2Unload -fmi2Load -fmi2Reload -``` -### Conversion functions - -```@docs -fmi2StringToValueReference -fmi2ModelVariablesForValueReference -fmi2ValueReferenceToString -fmi2GetSolutionState -fmi2GetSolutionValue -fmi2GetSolutionTime -``` - -### External/Additional functions - -```@docs -fmi2GetJacobian -fmi2GetJacobian! -fmi2GetFullJacobian -fmi2GetFullJacobian! -fmi2GetStartValue -fmi2GetUnit -fmi2GetDeclaredType -fmi2GetInitial -fmi2GetSimpleTypeAttributeStruct -``` - - -## All functions - -```@index -``` diff --git a/docs/src/fmi3_library.md b/docs/src/fmi3_library.md deleted file mode 100644 index 9d2d27e..0000000 --- a/docs/src/fmi3_library.md +++ /dev/null @@ -1,3 +0,0 @@ -# [FMI3 Library Functions](@id library) - -## FMI2 Common Concepts for Model Exchange and Co-Simulation diff --git a/docs/src/overview.md b/docs/src/overview.md deleted file mode 100644 index 7eeaf4d..0000000 --- a/docs/src/overview.md +++ /dev/null @@ -1,3 +0,0 @@ -# Examples - Overview - -To see the handling with FMUs in Julia, you can have a look at the [examples](https://thummeto.github.io/FMI.jl/dev/examples/overview/) from the FMI.jl package. diff --git a/docs/src/related.md b/docs/src/related.md deleted file mode 100644 index e7b086c..0000000 --- a/docs/src/related.md +++ /dev/null @@ -1,5 +0,0 @@ -# Related Publications - -Thummerer T, Kircher J and Mikelsons L: __Neural FMU: Towards structual integration of FMUs into neural networks__ (Preprint, accepted 14th International Modelica Conference) [pdf](https://arxiv.org/abs/2109.04351)|DOI - -Thummerer T, Tintenherr J, Mikelsons L: __Hybrid modeling of the human cardiovascular system using NeuralFMUs__ (Preprint, accepted 10th International Conference on Mathematical Modeling in Physical Sciences) [pdf](https://arxiv.org/abs/2109.04880)|DOI diff --git a/src/FMI2/md.jl b/src/FMI2/md.jl index c1f27d6..8b067ac 100644 --- a/src/FMI2/md.jl +++ b/src/FMI2/md.jl @@ -1471,7 +1471,7 @@ Returns a dictionary `Dict(fmi2ValueReference, Array{String})` of derivative val # 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 [fmi2GetValueReferencesAndNames`](@ref) +See also [`fmi2GetValueReferencesAndNames`](@ref) """ function fmi2GetDerivateValueReferencesAndNames(md::fmi2ModelDescription) fmi2GetValueReferencesAndNames(md::fmi2ModelDescription; vrs=md.derivativeValueReferences) @@ -1487,7 +1487,7 @@ Returns a dictionary `Dict(fmi2ValueReference, Array{String})` of derivative val # 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 [fmi2GetValueReferencesAndNames`](@ref) +See also [`fmi2GetValueReferencesAndNames`](@ref) """ function fmi2GetDerivateValueReferencesAndNames(fmu::FMU2) fmi2GetDerivateValueReferencesAndNames(fmu.modelDescription) diff --git a/src/FMIImport.jl b/src/FMIImport.jl index a9a5ef8..f0d6393 100644 --- a/src/FMIImport.jl +++ b/src/FMIImport.jl @@ -126,7 +126,7 @@ export fmi3GetStartValue, fmi3SampleDirectionalDerivative, fmi3CompletedIntegrat # FMI3_ext.jl -export fmi3Unzip, fmi3Load, fmi3Unload, fmi3InstantiateModelExchange!, fmi3InstantiateCoSimulation!, fmi3InstantiateScheduledExecution! +export fmi3Unzip, fmi3Load, fmi3Reload, fmi3Unload, fmi3InstantiateModelExchange!, fmi3InstantiateCoSimulation!, fmi3InstantiateScheduledExecution! export fmi3Get, fmi3Get!, fmi3Set export fmi3SampleDirectionalDerivative! export fmi3GetJacobian, fmi3GetJacobian!, fmi3GetFullJacobian, fmi3GetFullJacobian! @@ -149,7 +149,7 @@ Union containing a [`FMU2`](@ref) or a [`FMU2Component`](@ref) fmi2Struct = Union{FMU2, FMU2Component} """ -Union containing a [`FMU3`](@ref) or a [`FMU3Component`](@ref) +Union containing a [`FMU3`](@ref) or a [`FMU3Instance`](@ref) """ fmi3Struct = Union{FMU3, FMU3Instance} export fmi2Struct, fmi3Struct From 8154c62bb02ab89004bdb3a6c49c0df2b06c1aca Mon Sep 17 00:00:00 2001 From: Simon Exner Date: Tue, 10 Oct 2023 08:20:19 +0200 Subject: [PATCH 3/5] doc fixes --- src/FMI3/c.jl | 11 +++-------- src/FMI3/int.jl | 4 +--- src/FMIImport.jl | 10 ++++++++++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/FMI3/c.jl b/src/FMI3/c.jl index 65c7a40..3987d24 100644 --- a/src/FMI3/c.jl +++ b/src/FMI3/c.jl @@ -658,7 +658,7 @@ end """ - fmi3SetInt8!(c::FMU3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Int8}, nvalue::Csize_t) + fmi3SetInt8(c::FMU3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Int8}, nvalue::Csize_t) Functions to get and set values of variables idetified by their valueReference. @@ -683,7 +683,6 @@ More detailed: - FMISpec3.0: 2.2.3 Platform Dependent Definitions - FMISpec3.0: 2.2.4 Status Returned by Functions - FMISpec3.0: 2.2.6.2. Getting and Setting Variable Values -See also [`fmi3SetInt8!`](@ref). """ function fmi3SetInt8(c::FMU3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3Int8}, nvalue::Csize_t) status = fmi3SetInt8(c.fmu.cSetInt8, @@ -902,7 +901,6 @@ More detailed: - FMISpec3.0: 2.2.3 Platform Dependent Definitions - FMISpec3.0: 2.2.4 Status Returned by Functions - FMISpec3.0: 2.2.6.2. Getting and Setting Variable Values -See also [`fmi3SetUInt16!`](@ref). """ function fmi3SetUInt16(c::FMU3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, value::AbstractArray{fmi3UInt16}, nvalue::Csize_t) status = fmi3SetUInt16(c.fmu.cSetUInt16, @@ -1584,7 +1582,6 @@ More detailed: - FMISpec3.0: 2.2.3 Platform Dependent Definitions - FMISpec3.0: 2.2.4 Status Returned by Functions - FMISpec3.0: 2.2.6.4. Getting and Setting the Complete FMU State -See also [`fmi3FreeFMUState!`](@ref). """ function fmi3FreeFMUState!(c::FMU3Instance, FMUstate::Ref{fmi3FMUState}) status = fmi3FreeFMUState!(c.fmu.cFreeFMUState, @@ -1697,8 +1694,8 @@ function fmi3DeSerializeFMUState!(c::FMU3Instance, serialzedState::AbstractArray return status end +# TODO Clocks and dependencies functions """ - fmi3SetIntervalDecimal(c::FMU3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, intervals::AbstractArray{fmi3Float64}) Sets the interval until the next clock tick @@ -1724,7 +1721,6 @@ More detailed: - FMISpec3.0: 2.2.9. Clocks See also [`fmi3SetIntervalDecimal`](@ref). """ -# TODO Clocks and dependencies functions function fmi3SetIntervalDecimal(c::FMU3Instance, vr::AbstractArray{fmi3ValueReference}, nvr::Csize_t, intervals::AbstractArray{fmi3Float64}) status = fmi3SetIntervalDecimal(c.fmu.cSetIntervalDecimal, c.compAddr, vr, nvr, intervals) @@ -1954,8 +1950,8 @@ function fmi3ActivateModelPartition(c::FMU3Instance, vr::fmi3ValueReference, act return status end +# TODO not tested """ - fmi3GetNumberOfVariableDependencies!(c::FMU3Instance, vr::fmi3ValueReference, nvr::Ref{Csize_t}) The number of dependencies of a given variable, which may change if structural parameters are changed, can be retrieved by calling fmi3GetNumberOfVariableDependencies. @@ -1983,7 +1979,6 @@ More detailed: - FMISpec3.0: 2.2.10. Dependencies of Variables See also [`fmi3GetNumberOfVariableDependencies!`](@ref). """ -# TODO not tested function fmi3GetNumberOfVariableDependencies!(c::FMU3Instance, vr::fmi3ValueReference, nvr::Ref{Csize_t}) status = fmi3GetNumberOfVariableDependencies!(c.fmu.cGetNumberOfVariableDependencies, c.compAddr, vr, nvr) diff --git a/src/FMI3/int.jl b/src/FMI3/int.jl index 1648fa2..ddac83b 100644 --- a/src/FMI3/int.jl +++ b/src/FMI3/int.jl @@ -1777,7 +1777,7 @@ end """ - fmi3FreeFMUState(c::FMU3Instance, state::fmi3FMUState) + fmi3FreeFMUState!(c::FMU3Instance, state::fmi3FMUState) Free the allocated memory for the FMU state. @@ -1792,8 +1792,6 @@ Free the allocated memory for the FMU state. - FMISpec3.0 Link: [https://fmi-standard.org/](https://fmi-standard.org/) - FMISpec3.0: 2.2.3 Platform Dependent Definitions - FMISpec3.0: 2.2.6.4. Getting and Setting the Complete FMU State - -See also [`fmi3FreeFMUState`](@ref). """ function fmi3FreeFMUState!(c::FMU3Instance, state::fmi3FMUState) stateRef = Ref(state) diff --git a/src/FMIImport.jl b/src/FMIImport.jl index f0d6393..bd5ca81 100644 --- a/src/FMIImport.jl +++ b/src/FMIImport.jl @@ -18,6 +18,9 @@ prepareValue(value::AbstractVector) = value export prepareValue, prepareValueReference # wildcards for how a user can pass a fmi[X]ValueReference +""" +TODO +""" fmi2ValueReferenceFormat = Union{Nothing, String, AbstractArray{String,1}, fmi2ValueReference, AbstractArray{fmi2ValueReference,1}, Int64, AbstractArray{Int64,1}, Symbol} fmi3ValueReferenceFormat = Union{Nothing, String, AbstractArray{String,1}, fmi3ValueReference, AbstractArray{fmi3ValueReference,1}, Int64, AbstractArray{Int64,1}} export fmi2ValueReferenceFormat, fmi3ValueReferenceFormat @@ -154,7 +157,14 @@ Union containing a [`FMU3`](@ref) or a [`FMU3Instance`](@ref) fmi3Struct = Union{FMU3, FMU3Instance} export fmi2Struct, fmi3Struct +""" +Union containing a [`FMU2`](@ref), a [`FMU2Component`](@ref) or a [`fmi2ModelDescription`](@ref) +""" fmi2StructMD = Union{FMU2, FMU2Component, fmi2ModelDescription} + +""" +Union containing a [`FMU3`](@ref), a [`FMU3Instance`](@ref) or a [`fmi3ModelDescription`](@ref) +""" fmi3StructMD = Union{FMU3, FMU3Instance , fmi3ModelDescription} export fmi2StructMD, fmi3StructMD From 666ed9ad8c9624144c5eea4d10a330efc0ca259c Mon Sep 17 00:00:00 2001 From: Simon Exner Date: Mon, 16 Oct 2023 09:28:36 +0200 Subject: [PATCH 4/5] doc fixes --- src/FMI2/convert.jl | 3 ++- src/FMI2/ext.jl | 4 ++++ src/FMI3/c.jl | 44 ++++++++++++++++++++++++++++++++++++-------- src/FMI3/ext.jl | 21 ++++++++++++--------- src/FMI3/int.jl | 23 +++++++++++++++++++---- src/FMIImport.jl | 5 ++++- 6 files changed, 77 insertions(+), 23 deletions(-) diff --git a/src/FMI2/convert.jl b/src/FMI2/convert.jl index 87db3a8..4c629e7 100644 --- a/src/FMI2/convert.jl +++ b/src/FMI2/convert.jl @@ -109,7 +109,8 @@ function fmi2ModelVariablesForValueReference(md::fmi2ModelDescription, vr::fmi2V end """ -ToDo. + fmi2DataTypeForValueReference(md::fmi2ModelDescription, vr::fmi2ValueReference) +Returns the fmi2DataType (`fmi2Real`, `fmi2Integer`, `fmi2Boolean`, `fmi2String`) for a given Valuereference `vr` of a given FMU-ModelDescription `md` """ function fmi2DataTypeForValueReference(md::fmi2ModelDescription, vr::fmi2ValueReference) mv = fmi2ModelVariablesForValueReference(md, vr)[1] diff --git a/src/FMI2/ext.jl b/src/FMI2/ext.jl index 0d64955..fc829bc 100644 --- a/src/FMI2/ext.jl +++ b/src/FMI2/ext.jl @@ -255,6 +255,10 @@ function fmi2Load(pathToFMU::String; unpackPath::Union{String, Nothing}=nothing, return fmu end +""" + loadBinary(fmu::FMU2) +load pointers to `fmu`\`s c functions from shared library handle (provided by `fmu.libHandle`) +""" function loadBinary(fmu::FMU2) lastDirectory = pwd() cd(dirname(fmu.binaryPath)) diff --git a/src/FMI3/c.jl b/src/FMI3/c.jl index 3987d24..a865a65 100644 --- a/src/FMI3/c.jl +++ b/src/FMI3/c.jl @@ -1704,6 +1704,7 @@ Sets the interval until the next clock tick - `c::FMU3Instance`: Argument `c` is a Mutable struct represents an instantiated instance of an FMU in the FMI 3.0 Standard. - `vr::AbstractArray{fmi3ValueReference}`: Argument `vr` is an AbstractArray of `nvr` value handels called "ValueReference" that define the variable that shall be inquired. - `nvr::Csize_t`: Argument `nvr` defines the size of `vr`. +- `intervals::AbstractArray{fmi3Float64}`: # Returns - `status::fmi3Status`: Return `status` is an enumeration of type `fmi3Status` and indicates the success of the function call. @@ -1738,6 +1739,8 @@ Sets the interval until the next clock tick. Only allowed if the attribute 'supp - `c::FMU3Instance`: Argument `c` is a Mutable struct represents an instantiated instance of an FMU in the FMI 3.0 Standard. - `vr::AbstractArray{fmi3ValueReference}`: Argument `vr` is an AbstractArray of `nvr` value handels called "ValueReference" that define the variable that shall be inquired. - `nvr::Csize_t`: Argument `nvr` defines the size of `vr`. +- `intervalCounters::AbstractArray{fmi3UInt64}`: +- `resolutions::AbstractArray{fmi3UInt64}`: # Returns - `status::fmi3Status`: Return `status` is an enumeration of type `fmi3Status` and indicates the success of the function call. @@ -1779,6 +1782,8 @@ For information about fmi3IntervalQualifiers, call ?fmi3IntervalQualifier - `c::FMU3Instance`: Argument `c` is a Mutable struct represents an instantiated instance of an FMU in the FMI 3.0 Standard. - `vr::AbstractArray{fmi3ValueReference}`: Argument `vr` is an AbstractArray of `nvr` value handels called "ValueReference" that define the variable that shall be inquired. - `nvr::Csize_t`: Argument `nvr` defines the size of `vr`. +- `intervals::AbstractArray{fmi3Float64}`: +- `qualifiers::fmi3IntervalQualifier`: # Returns - `status::fmi3Status`: Return `status` is an enumeration of type `fmi3Status` and indicates the success of the function call. @@ -1820,6 +1825,9 @@ For information about fmi3IntervalQualifiers, call ?fmi3IntervalQualifier - `c::FMU3Instance`: Argument `c` is a Mutable struct represents an instantiated instance of an FMU in the FMI 3.0 Standard. - `vr::AbstractArray{fmi3ValueReference}`: Argument `vr` is an AbstractArray of `nvr` value handels called "ValueReference" that define the variable that shall be inquired. - `nvr::Csize_t`: Argument `nvr` defines the size of `vr`. +- `intervalCounters::AbstractArray{fmi3UInt64}`: +- `resolutions::AbstractArray{fmi3UInt64}`: +- `qualifiers::fmi3IntervalQualifier`: # Returns - `status::fmi3Status`: Return `status` is an enumeration of type `fmi3Status` and indicates the success of the function call. @@ -1855,6 +1863,7 @@ fmi3GetShiftDecimal retrieves the delay to the first Clock tick from the FMU. - `c::FMU3Instance`: Argument `c` is a Mutable struct represents an instantiated instance of an FMU in the FMI 3.0 Standard. - `vr::AbstractArray{fmi3ValueReference}`: Argument `vr` is an AbstractArray of `nvr` value handels called "ValueReference" that define the variable that shall be inquired. - `nvr::Csize_t`: Argument `nvr` defines the size of `vr`. +- `shifts::AbstractArray{fmi3Float64}`: # Returns - `status::fmi3Status`: Return `status` is an enumeration of type `fmi3Status` and indicates the success of the function call. @@ -1890,6 +1899,8 @@ fmi3GetShiftFraction retrieves the delay to the first Clock tick from the FMU. - `c::FMU3Instance`: Argument `c` is a Mutable struct represents an instantiated instance of an FMU in the FMI 3.0 Standard. - `vr::AbstractArray{fmi3ValueReference}`: Argument `vr` is an AbstractArray of `nvr` value handels called "ValueReference" that define the variable that shall be inquired. - `nvr::Csize_t`: Argument `nvr` defines the size of `vr`. +- `shiftCounters::AbstractArray{fmi3UInt64}`: +- `resolutions::AbstractArray{fmi3UInt64}`: # Returns - `status::fmi3Status`: Return `status` is an enumeration of type `fmi3Status` and indicates the success of the function call. @@ -1926,6 +1937,7 @@ Each `fmi3ActivateModelPartition` call is associated with the computation of an # Arguments - `c::FMU3Instance`: Argument `c` is a Mutable struct represents an instantiated instance of an FMU in the FMI 3.0 Standard. - `vr::fmi3ValueReference`: Argument `vr` is the value handel called "ValueReference" that define the variable that shall be inquired. +- `activationTime::AbstractArray{fmi3Float64}`: # Returns - `status::fmi3Status`: Return `status` is an enumeration of type `fmi3Status` and indicates the success of the function call. @@ -1992,21 +2004,20 @@ end elementIndiceOfInpendents::AbstractArray{Csize_t}, dependencyKind::AbstractArray{fmi3DependencyKind}, ndependencies::Csize_t) The actual dependencies (of type dependenciesKind) can be retrieved by calling the function fmi3GetVariableDependencies: - -# TODO argmuents + # Arguments - `c::FMU3Instance`: Argument `c` is a Mutable struct represents an instantiated instance of an FMU in the FMI 3.0 Standard. - `vr::fmi3ValueReference`: Argument `vr` is the value handel called "ValueReference" that define the variable that shall be inquired. - `nvr::Csize_t`: Argument `nvr` defines the size of `vr`. -- `elementIndicesOfDependent::AbstractArray{Csize_t}`: must point to a buffer of size_t values of size `nDependencies` allocated by the calling environment. +- `elementIndiceOfDependents::AbstractArray{Csize_t}`: must point to a buffer of size_t values of size `nDependencies` allocated by the calling environment. It is filled in by this function with the element index of the dependent variable that dependency information is provided for. The element indices start with 1. Using the element index 0 means all elements of the variable. (Note: If an array has more than one dimension the indices are serialized in the same order as defined for values in Section 2.2.6.1.) - `independents::AbstractArray{fmi3ValueReference}`: must point to a buffer of `fmi3ValueReference` values of size `nDependencies` allocated by the calling environment. It is filled in by this function with the value reference of the independent variable that this dependency entry is dependent upon. -- `elementIndicesIndependents::AbstractArray{Csize_t}`: must point to a buffer of size_t `values` of size `nDependencies` allocated by the calling environment. +- `elementIndiceOfInpendents::AbstractArray{Csize_t}`: must point to a buffer of size_t `values` of size `nDependencies` allocated by the calling environment. It is filled in by this function with the element index of the independent variable that this dependency entry is dependent upon. The element indices start with 1. Using the element index 0 means all elements of the variable. (Note: If an array has more than one dimension the indices are serialized in the same order as defined for values in Section 2.2.6.1.) -- `dependencyKinds::AbstractArray{fmi3DependencyKind}`: must point to a buffer of dependenciesKind values of size `nDependencies` allocated by the calling environment. +- `dependencyKind::AbstractArray{fmi3DependencyKind}`: must point to a buffer of dependenciesKind values of size `nDependencies` allocated by the calling environment. It is filled in by this function with the enumeration value describing the dependency of this dependency entry. -- `nDependencies::Csize_t`: specifies the number of dependencies that the calling environment allocated space for in the result buffers, and should correspond to value obtained by calling `fmi3GetNumberOfVariableDependencies`. +- `ndependencies::Csize_t`: specifies the number of dependencies that the calling environment allocated space for in the result buffers, and should correspond to value obtained by calling `fmi3GetNumberOfVariableDependencies`. # Returns - `status::fmi3Status`: Return `status` is an enumeration of type `fmi3Status` and indicates the success of the function call. @@ -2509,7 +2520,6 @@ function fmi3EvaluateDiscreteStates(c::FMU3Instance) end """ - fmi3UpdateDiscreteStates(c::FMU3Instance, discreteStatesNeedUpdate::Ref{fmi3Boolean}, terminateSimulation::Ref{fmi3Boolean}, nominalsOfContinuousStatesChanged::Ref{fmi3Boolean}, valuesOfContinuousStatesChanged::Ref{fmi3Boolean}, nextEventTimeDefined::Ref{fmi3Boolean}, nextEventTime::Ref{fmi3Float64}) @@ -2519,6 +2529,12 @@ This function is called to signal a converged solution at the current super-dens # TODO Arguments # Arguments - `c::FMU3Instance`: Mutable struct represents an instantiated instance of an FMU in the FMI 3.0 Standard. +- `discreteStatesNeedUpdate::Ref{fmi3Boolean}`: +- `terminateSimulation::Ref{fmi3Boolean}`: +- `nominalsOfContinuousStatesChanged::Ref{fmi3Boolean}`: +- `valuesOfContinuousStatesChanged::Ref{fmi3Boolean}`: +- `nextEventTimeDefined::Ref{fmi3Boolean}`: +- `nextEventTime::Ref{fmi3Float64}`: # Returns - `status::fmi3Status`: Return `status` is an enumeration of type `fmi3Status` and indicates the success of the function call. @@ -2535,7 +2551,6 @@ More detailed: - FMISpec3.0: 2.2.4 Status Returned by Functions - FMISpec3.0: 2.3.5. State: Event Mode -See also [`fmi3UpdateDiscreteStates`](@ref). """ function fmi3UpdateDiscreteStates(c::FMU3Instance, discreteStatesNeedUpdate::Ref{fmi3Boolean}, terminateSimulation::Ref{fmi3Boolean}, nominalsOfContinuousStatesChanged::Ref{fmi3Boolean}, valuesOfContinuousStatesChanged::Ref{fmi3Boolean}, @@ -2847,6 +2862,12 @@ The model enters Event Mode from the Continuous-Time Mode in ModelExchange oder # TODO argmuents # Arguments - `c::FMU3Instance`: Mutable struct represents an instantiated instance of an FMU in the FMI 3.0 Standard. +- `stepEvent::fmi3Boolean`: +- `stateEvent::fmi3Boolean`: +- `rootsFound::AbstractArray{fmi3Int32}`: +- `nEventIndicators::Csize_t`: +- `timeEvent::fmi3Boolean`: +- `soft::Bool=false`: # Keywords - `soft::Bool=false`: If the Keyword `soft = true` the `fmi3Teminate` needs to be called in state `fmi3InstanceStateContinuousTimeMode` or `fmi3InstanceStateEventMode`. @@ -2897,6 +2918,13 @@ The computation of a time step is started. # TODO argmuents # Arguments - `c::FMU3Instance`: Mutable struct represents an instantiated instance of an FMU in the FMI 3.0 Standard. +- `currentCommunicationPoint::fmi3Float64`: +- `communicationStepSize::fmi3Float64`: +- `noSetFMUStatePriorToCurrentPoint::fmi3Boolean`: +- `eventEncountered::Ref{fmi3Boolean}`: +- `terminateSimulation::Ref{fmi3Boolean}`: +- `earlyReturn::Ref{fmi3Boolean}`: +- `lastSuccessfulTime::Ref{fmi3Float64}`: # Returns - `status::fmi3Status`: Return `status` is an enumeration of type `fmi3Status` and indicates the success of the function call. diff --git a/src/FMI3/ext.jl b/src/FMI3/ext.jl index 0b92cf9..eee523f 100644 --- a/src/FMI3/ext.jl +++ b/src/FMI3/ext.jl @@ -227,7 +227,8 @@ function fmi3Load(pathToFMU::String; unpackPath=nothing, type=nothing, cleanup=t end """ -TODO + loadBinary(fmu::FMU3) +load pointers to `fmu`\`s c functions from shared library handle (provided by `fmu.libHandle`) """ function loadBinary(fmu::FMU3) lastDirectory = pwd() @@ -736,8 +737,7 @@ function fmi3Unload(fmu::FMU3, cleanUp::Bool = true) end """ - -fmi3SampleDirectionalDerivative(c::FMU3Instance, + fmi3SampleDirectionalDerivative(c::FMU3Instance, vUnknown_ref::AbstractArray{fmi3ValueReference}, vKnown_ref::AbstractArray{fmi3ValueReference}, steps::Union{AbstractArray{fmi3Float64}, Nothing} = nothing) @@ -788,8 +788,7 @@ end """ - -fmi3SampleDirectionalDerivative!(c::FMU3Instance, + fmi3SampleDirectionalDerivative!(c::FMU3Instance, vUnknown_ref::AbstractArray{fmi3ValueReference}, vKnown_ref::AbstractArray{fmi3ValueReference}, steps::Union{AbstractArray{fmi3Float64}, Nothing} = nothing) @@ -1278,9 +1277,6 @@ function fmi3Set(inst::FMU3Instance, vrs::fmi3ValueReferenceFormat, srcArray::Ar return retcodes end -""" -ToDo: DocString -""" function fmi3Set(inst::FMU3Instance, vr::Union{fmi3ValueReference, String}, value) vrs = prepareValueReference(inst, vr) @@ -1430,7 +1426,14 @@ function fmi3GetStartValue(mv::fmi3Variable) end """ -TODO + function fmi3SampleDirectionalDerivative(c::FMU3Instance, + vUnknown_ref::Array{fmi3ValueReference}, + vKnown_ref::Array{fmi3ValueReference}, + steps::Array{fmi3Float64} = ones(fmi3Float64, length(vKnown_ref)).*1e-5) + +Wrapper for [`fmi3SampleDirectionalDerivative!`](@ref) with `dvUnknown` initialized with zeros + +Returning dvUnknown, modified by `fmi3SampleDirectionalDerivative!` call. """ function fmi3SampleDirectionalDerivative(c::FMU3Instance, vUnknown_ref::Array{fmi3ValueReference}, diff --git a/src/FMI3/int.jl b/src/FMI3/int.jl index ddac83b..ed33faa 100644 --- a/src/FMI3/int.jl +++ b/src/FMI3/int.jl @@ -2581,8 +2581,7 @@ function fmi3GetContinuousStateDerivatives!(c::FMU3Instance, derivatives::Abstr end """ - -fmi3UpdateDiscreteStates(c::FMU3Instance) + fmi3UpdateDiscreteStates(c::FMU3Instance) This function is called to signal a converged solution at the current super-dense time instant. fmi3UpdateDiscreteStates must be called at least once per super-dense time instant. @@ -2591,14 +2590,18 @@ This function is called to signal a converged solution at the current super-dens # TODO returns # Returns -- +- `discreteStatesNeedUpdate` +- `terminateSimulation` +- `nominalsOfContinuousStatesChanged` +- `valuesOfContinuousStatesChanged` +- `nextEventTimeDefined` +- `nextEventTime` # Source - FMISpec3.0 Link: [https://fmi-standard.org/](https://fmi-standard.org/) - FMISpec3.0: 2.2.3 Platform Dependent Definitions - FMISpec3.0: 2.3.5. State: Event Mode -See also [`fmi3UpdateDiscreteStates`](@ref). """ function fmi3UpdateDiscreteStates(c::FMU3Instance) discreteStatesNeedUpdate = fmi3True @@ -2706,6 +2709,11 @@ The model enters Event Mode from the Continuous-Time Mode in ModelExchange oder # TODO argmuents # Arguments - `c::FMU3Instance`: Mutable struct represents an instantiated instance of an FMU in the FMI 3.0 Standard. +- `stepEvent::Bool`: +- `stateEvent::Bool`: +- `rootsFound::AbstractArray{fmi3Int32}`: +- `nEventIndicators::Csize_t`: +- `timeEvent::Bool`: # Returns - `status::fmi3Status`: Return `status` is an enumeration of type `fmi3Status` and indicates the success of the function call. @@ -2737,6 +2745,13 @@ The computation of a time step is started. # TODO argmuents # Arguments - `c::FMU3Instance`: Mutable struct represents an instantiated instance of an FMU in the FMI 3.0 Standard. +- `currentCommunicationPoint::Union{Real, Nothing} = nothing` +- `communicationStepSize::Union{Real, Nothing} = nothing` +- `noSetFMUStatePriorToCurrentPoint::Bool = true` +- `eventEncountered::fmi3Boolean = fmi3False` +- `terminateSimulation::fmi3Boolean = fmi3False` +- `earlyReturn::fmi3Boolean = fmi3False` +- `lastSuccessfulTime::fmi3Float64 = 0.0` # Returns - `status::fmi3Status`: Return `status` is an enumeration of type `fmi3Status` and indicates the success of the function call. diff --git a/src/FMIImport.jl b/src/FMIImport.jl index bd5ca81..53cac0f 100644 --- a/src/FMIImport.jl +++ b/src/FMIImport.jl @@ -19,9 +19,12 @@ export prepareValue, prepareValueReference # wildcards for how a user can pass a fmi[X]ValueReference """ -TODO +Union of (wildcard for) all ways to describe and pass a fmi2ValueReference (e.g. String, Int64, Array, fmi2ValueReference, ...) """ fmi2ValueReferenceFormat = Union{Nothing, String, AbstractArray{String,1}, fmi2ValueReference, AbstractArray{fmi2ValueReference,1}, Int64, AbstractArray{Int64,1}, Symbol} +""" +Union of (wildcard for) all ways to describe and pass a fmi3ValueReference (e.g. String, Int64, Array, fmi3ValueReference, ...) +""" fmi3ValueReferenceFormat = Union{Nothing, String, AbstractArray{String,1}, fmi3ValueReference, AbstractArray{fmi3ValueReference,1}, Int64, AbstractArray{Int64,1}} export fmi2ValueReferenceFormat, fmi3ValueReferenceFormat From c20ad4940c7cd613e3e3c12afe4d0381d01f493f Mon Sep 17 00:00:00 2001 From: Simon Exner Date: Tue, 17 Oct 2023 13:51:04 +0200 Subject: [PATCH 5/5] changed logWarn to logWarning --- src/FMI2/ext.jl | 4 ++-- src/FMI2/sens.jl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/FMI2/ext.jl b/src/FMI2/ext.jl index fc829bc..a7b4fb0 100644 --- a/src/FMI2/ext.jl +++ b/src/FMI2/ext.jl @@ -97,7 +97,7 @@ end function dlsym_opt(libHandle, symbol) addr = dlsym(libHandle, symbol; throw_error=false) if addr == nothing - logWarn(fmu, "This FMU does not support function '$symbol'.") + logWarning(fmu, "This FMU does not support function '$symbol'.") addr = Ptr{Cvoid}(C_NULL) end addr @@ -454,7 +454,7 @@ function fmi2Instantiate!(fmu::FMU2; end if !isnothing(component) - logWarn(fmu, "fmi2Instantiate!(...): This component was already registered. This may be because you created the FMU by yourself with FMIExport.jl.") + logWarning(fmu, "fmi2Instantiate!(...): This component was already registered. This may be because you created the FMU by yourself with FMIExport.jl.") else component = FMU2Component(compAddr, fmu) diff --git a/src/FMI2/sens.jl b/src/FMI2/sens.jl index be38e7a..319a704 100644 --- a/src/FMI2/sens.jl +++ b/src/FMI2/sens.jl @@ -84,7 +84,7 @@ function (fmu::FMU2)(;dx::AbstractVector{<:Real}=Vector{fmi2Real}(), if hasCurrentComponent(fmu) c = getCurrentComponent(fmu) else - logWarn(fmu, "No FMU2Component found. Allocating one.") + logWarning(fmu, "No FMU2Component found. Allocating one.") c = fmi2Instantiate!(fmu) fmi2EnterInitializationMode(c) fmi2ExitInitializationMode(c)