diff --git a/Project.toml b/Project.toml index 64cb3f7..3748589 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "FMIBase" uuid = "900ee838-d029-460e-b485-d98a826ceef2" authors = ["TT ", "LM "] -version = "1.0.5" +version = "1.0.6" [deps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" diff --git a/src/callbacks.jl b/src/callbacks.jl index ad514c7..76a6d48 100644 --- a/src/callbacks.jl +++ b/src/callbacks.jl @@ -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 diff --git a/src/error_msg.jl b/src/error_msg.jl index 25ce312..204f151 100644 --- a/src/error_msg.jl +++ b/src/error_msg.jl @@ -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." diff --git a/src/snapshot.jl b/src/snapshot.jl index d309117..721a816 100644 --- a/src/snapshot.jl +++ b/src/snapshot.jl @@ -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 diff --git a/src/struct.jl b/src/struct.jl index a1bc6b2..5e4c03f 100644 --- a/src/struct.jl +++ b/src/struct.jl @@ -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) @@ -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