From ef9a560502900ddc7bff433bf699597b8a6affa5 Mon Sep 17 00:00:00 2001 From: ThummeTo <83663542+ThummeTo@users.noreply.github.com> Date: Thu, 9 Nov 2023 13:09:17 +0100 Subject: [PATCH] fixed derivative getter (#106) --- Project.toml | 2 +- src/FMI2/convert.jl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index 843624d..fce8751 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "FMIImport" uuid = "9fcbc62e-52a0-44e9-a616-1359a0008194" authors = ["TT ", "LM ", "JK "] -version = "0.16.2" +version = "0.16.3" [deps] Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6" diff --git a/src/FMI2/convert.jl b/src/FMI2/convert.jl index 3e7688c..5a8a30a 100644 --- a/src/FMI2/convert.jl +++ b/src/FMI2/convert.jl @@ -308,7 +308,7 @@ More detailed: `fmi2ValueReferenceFormat = Union{Nothing, String, Array{String,1 - FMISpec2.0.2 Link: [https://fmi-standard.org/](https://fmi-standard.org/) - FMISpec2.0.2[p.22]: 2.1.2 Platform Dependent Definitions (fmi2TypesPlatform.h) """ -function fmi2GetSolutionDerivative(solution::FMU2Solution, vrs::fmi2ValueReferenceFormat; isIndex::Bool=false) +function fmi2GetSolutionDerivative(solution::FMU2Solution, vrs::fmi2ValueReferenceFormat; isIndex::Bool=false, order::Integer=1) indices = [] if isIndex @@ -342,10 +342,10 @@ function fmi2GetSolutionDerivative(solution::FMU2Solution, vrs::fmi2ValueReferen if length(indices) == length(vrs) if length(vrs) == 1 # single value - return collect(ForwardDiff.derivative(t -> solution.states(t)[indices[1]], myt) for myt in solution.states.t) + return collect(solution.states(t, Val{order})[indices[1]] for t in solution.states.t) else # multi value - return collect(collect(ForwardDiff.derivative(t -> solution.states(t)[indices[i]], myt) for myt in solution.states.t) for i in 1:length(indices)) + return collect(collect(solution.states(t, Val{order})[indices[i]] for t in solution.states.t) for i in 1:length(indices)) end end