Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.0.6 #29

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FMIBase"
uuid = "900ee838-d029-460e-b485-d98a826ceef2"
authors = ["TT <[email protected]>", "LM <[email protected]>"]
version = "1.0.5"
version = "1.0.6"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
2 changes: 1 addition & 1 deletion src/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function f(

f(c, dx, x, p, t)

# correct statisitics, because fx-call above -> this was in fact an out-of-place evaluation
# correct statistics, because fx-call above -> this was in fact an out-of-place evaluation
c.solution.evals_fx_inplace -= 1

return dx
Expand Down
2 changes: 1 addition & 1 deletion src/error_msg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# Licensed under the MIT license. See LICENSE file in the project root for details.
#

const ERR_MSG_CONT_TIME_MODE = "Function must be called in mode continuous time!\nThis is most probably because the FMU errored before. If no messages are printed, check that the FMU message prinintg is enabled (this is tool dependent and must be selected during export) and follow the message printing instructions under https://thummeto.github.io/FMI.jl/dev/features/#Debugging-/-Logging"
const ERR_MSG_CONT_TIME_MODE = "Function must be called in mode continuous time!\nThis is most probably because the FMU errored before. If no messages are printed, check that the FMU message printing is enabled (this is tool dependent and must be selected during export) and follow the message printing instructions under https://thummeto.github.io/FMI.jl/dev/features/#Debugging-/-Logging"
ERR_MSG_NO_FMISENSITIVITY(varname, vartype) =
"Wrong dispatched: `$(varname)` is `$(vartype)`.\nThis is most likely because you tried differentiating (AD) over a FMU.\nIf so, you need to `import FMISensitivity` first."
9 changes: 8 additions & 1 deletion src/snapshot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ function snapshot!(sol::FMUSolution)
end
export snapshot!

function snapshot_if_needed!(obj::Union{FMUInstance,FMUSolution}, t::Real; atol = 1e-8)
function snapshotDeltaTimeTolerance(inst::FMUInstance)
return inst.fmu.executionConfig.snapshotDeltaTimeTolerance
end
function snapshotDeltaTimeTolerance(sol::FMUSolution)
return snapshotDeltaTimeTolerance(sol.instance)
end

function snapshot_if_needed!(obj::Union{FMUInstance,FMUSolution}, t::Real; atol = snapshotDeltaTimeTolerance(obj))
if !hasSnapshot(obj, t; atol = atol)
snapshot!(obj)
end
Expand Down
2 changes: 2 additions & 0 deletions src/struct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ mutable struct FMUExecutionConfiguration

maxNewDiscreteStateCalls::UInt # max calls for fmi2NewDiscreteStates before throwing an exception
maxStateEventsPerSecond::UInt # max state events allowed to occur per second (more is interpreted as event chattering)
snapshotDeltaTimeTolerance::Float64 # distance to distinguish between snapshots

eval_t_gradients::Bool # if time gradients ∂ẋ_∂t and ∂y_∂t should be sampled (not part of the FMI standard)
JVPBuiltInDerivatives::Bool # use built-in directional derivatives for JVP-sensitivities over FMU without caching the jacobian (because this is done in the FMU, but not per default)
Expand Down Expand Up @@ -94,6 +95,7 @@ mutable struct FMUExecutionConfiguration

inst.maxNewDiscreteStateCalls = 100
inst.maxStateEventsPerSecond = 100
inst.snapshotDeltaTimeTolerance = 1e-8

inst.eval_t_gradients = false
inst.JVPBuiltInDerivatives = false
Expand Down
Loading