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
`MutatingFunctionalAffect` is a helper for writing affect functions that will compute observed values and
78
78
ensure that modified values are correctly written back into the system. The affect function `f` needs to have
79
-
one of three signatures:
80
-
* `f(observed::ComponentArray)` if the function only reads observed values back from the system,
81
-
* `f(observed::ComponentArray, modified::ComponentArray)` if the function also writes values (unknowns or parameters) into the system,
82
-
* `f(observed::ComponentArray, modified::ComponentArray, ctx)` if the function needs the user-defined context,
83
-
* `f(observed::ComponentArray, modified::ComponentArray, ctx, integrator)` if the function needs the low-level integrator.
79
+
one of four signatures:
80
+
* `f(modified::ComponentArray)` if the function only writes values (unknowns or parameters) to the system,
81
+
* `f(modified::ComponentArray, observed::ComponentArray)` if the function also reads observed values from the system,
82
+
* `f(modified::ComponentArray, observed::ComponentArray, ctx)` if the function needs the user-defined context,
83
+
* `f(modified::ComponentArray, observed::ComponentArray, ctx, integrator)` if the function needs the low-level integrator.
84
+
These will be checked in reverse order (that is, the four-argument version first, than the 3, etc).
84
85
85
86
The function `f` will be called with `observed` and `modified` `ComponentArray`s that are derived from their respective `NamedTuple` definitions.
86
87
Each `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`
@@ -90,7 +91,7 @@ so the value of `a + b` will be accessible as `observed.x` in `f`. `modified` cu
90
91
Both `observed` and `modified` will be automatically populated with the current values of their corresponding expressions on function entry.
91
92
The values in `modified` will be written back to the system after `f` returns. For example, if we want to update the value of `x` to be the result of `x + y` we could write
92
93
93
-
MutatingFunctionalAffect(observed=(; x_plus_y = x + y), modified=(; x)) do o, m
94
+
MutatingFunctionalAffect(observed=(; x_plus_y = x + y), modified=(; x)) do m, o
@error"User affect function $user_affect needs to implement one of the supported MutatingFunctionalAffect callback forms; see the MutatingFunctionalAffect docstring for more details"
939
+
user_affect(upd_component_array, obs_component_array, integ, ctx) # this WILL error but it'll give a more sensible message
0 commit comments