You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A [`ContinuousCallback`](@ref SciMLBase.ContinuousCallback) specified symbolically. Takes a vector of equations `eq`
83
+
as well as the positive-edge `affect` and negative-edge `affect_neg` that apply when *any* of `eq` are satisfied.
84
+
By default `affect_neg = affect`; to only get rising edges specify `affect_neg = nothing`.
85
+
86
+
Assume without loss of generality that the equation is of the form `c(u,p,t) ~ 0`; we denote the integrator state as `i.u`.
87
+
For compactness, we define `prev_sign = sign(c(u[t-1], p[t-1], t-1))` and `cur_sign = sign(c(u[t], p[t], t))`.
88
+
A condition edge will be detected and the callback will be invoked iff `prev_sign * cur_sign <= 0`.
89
+
Inter-sample condition activation is not guaranteed; for example if we use the dirac delta function as `c` to insert a
90
+
sharp discontinuity between integrator steps (which in this example would not normally be identified by adaptivity) then the condition is not
91
+
guaranteed to be triggered.
92
+
93
+
Once detected the integrator will "wind back" through a root-finding process to identify the point when the condition became active; the method used
94
+
is specified by `rootfind` from [`SciMLBase.RootfindOpt`](@ref). Multiple callbacks in the same system with different `rootfind` operations will be resolved
95
+
into separate VectorContinuousCallbacks in the enumeration order of `SciMLBase.RootfindOpt`, which may cause some callbacks to not fire if several become
96
+
active at the same instant. See the `SciMLBase` documentation for more information on the semantic rules.
97
+
98
+
The positive edge `affect` will be triggered iff an edge is detected and if `prev_sign < 0`; similarly, `affect_neg` will be
99
+
triggered iff an edge is detected `prev_sign > 0`.
100
+
101
+
Affects (i.e. `affect` and `affect_neg`) can be specified as either:
102
+
* A list of equations that should be applied when the callback is triggered (e.g. `x ~ 3, y ~ 7`) which must be of the form `unknown ~ observed value` where each `unknown` appears only once. Equations will be applied in the order that they appear in the vector; parameters and state updates will become immediately visible to following equations.
103
+
* A tuple `(f!, unknowns, read_parameters, modified_parameters, ctx)`, where:
104
+
+ `f!` is a function with signature `(integ, u, p, ctx)` that is called with the integrator, a state *index* vector `u` derived from `unknowns`, a parameter *index* vector `p` derived from `read_parameters`, and the `ctx` that was given at construction time. Note that `ctx` is aliased between instances.
105
+
+ `unknowns` is a vector of symbolic unknown variables and optionally their aliases (e.g. if the model was defined with `@variables x(t)` then a valid value for `unknowns` would be `[x]`). A variable can be aliased with a pair `x => :y`. The indices of these `unknowns` will be passed to `f!` in `u` in a named tuple; in the earlier example, if we pass `[x]` as `unknowns` then `f!` can access `x` as `integ.u[u.x]`. If no alias is specified the name of the index will be the symbol version of the variable name.
106
+
+ `read_parameters` is a vector of the parameters that are *used* by `f!`. Their indices are passed to `f` in `p` similarly to the indices of `unknowns` passed in `u`.
107
+
+ `modified_parameters` is a vector of the parameters that are *modified* by `f!`. Note that a parameter will not appear in `p` if it only appears in `modified_parameters`; it must appear in both `parameters` and `modified_parameters` if it is used in the affect definition.
108
+
+ `ctx` is a user-defined context object passed to `f!` when invoked. This value is aliased for each problem.
0 commit comments