Skip to content

Commit

Permalink
V1.0.6 (#29)
Browse files Browse the repository at this point in the history
* added snapshot tolerance

* typo

* typo
  • Loading branch information
ThummeTo authored Aug 30, 2024
1 parent 58c7f0d commit 5f16e85
Show file tree
Hide file tree
Showing 5 changed files with 13 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 = "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

0 comments on commit 5f16e85

Please sign in to comment.