Skip to content

Commit

Permalink
fixed derivative getter (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThummeTo committed Nov 9, 2023
1 parent 5d400ea commit ef9a560
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FMIImport"
uuid = "9fcbc62e-52a0-44e9-a616-1359a0008194"
authors = ["TT <[email protected]>", "LM <[email protected]>", "JK <[email protected]>"]
version = "0.16.2"
version = "0.16.3"

[deps]
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Expand Down
6 changes: 3 additions & 3 deletions src/FMI2/convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

2 comments on commit ef9a560

@ThummeTo
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/95047

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.16.3 -m "<description of version>" ef9a560502900ddc7bff433bf699597b8a6affa5
git push origin v0.16.3

Please sign in to comment.