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
ModelingToolkit.ImperativeAffect(modified = (; furnace_on)) do x, o, i, c
424
+
ModelingToolkit.ImperativeAffect(modified = (; furnace_on)) do x, o, c, i
425
425
@set! x.furnace_on = true
426
426
end)
427
427
```
@@ -454,18 +454,16 @@ In our example, each event merely changes whether the furnace is on or off. Acco
454
454
evaluate this before calling our function to fill out all of the numerical values, then apply them back to the system
455
455
once our affect function returns. Furthermore, it will check that it is possible to do this assignment.
456
456
457
-
The function given to `ImperativeAffect` needs to have one of four signatures, checked in this order:
458
-
459
-
-`f(modified::NamedTuple, observed::NamedTuple, ctx, integrator)::NamedTuple` if the function needs the low-level integrator,
460
-
-`f(modified::NamedTuple, observed::NamedTuple, ctx)::NamedTuple` if the function needs the user-defined context,
461
-
-`f(modified::NamedTuple, observed::NamedTuple)::NamedTuple` if the function also reads observed values from the system,
462
-
-`f(modified::NamedTuple)::NamedTuple` if the function only writes values (unknowns or parameters) to the system.
463
-
The `do` block in the example implicitly constructs said function inline. For exposition, we use the full version (e.g. `x, o, i, c`) but this could be simplified to merely `x`.
457
+
The function given to `ImperativeAffect` needs to have the signature:
The function `f` will be called with `observed` and `modified` `NamedTuple`s that are derived from their respective `NamedTuple` definitions.
87
86
Each declaration`NamedTuple` should map an expression to a symbol; for example if we pass `observed=(; x = a + b)` this will alias the result of executing `a+b` in the system as `x`
@error"User affect function $user_affect needs to implement one of the supported ImperativeAffect callback forms; see the ImperativeAffect docstring for more details"
1149
-
user_affect(upd_component_array, obs_component_array, integ, ctx) # this WILL error but it'll give a more sensible message
0 commit comments