Skip to content

Commit eb976a8

Browse files
docs: fix FunctionAffect usage and documentation
1 parent 4b2ef38 commit eb976a8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/src/basics/Events.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ ModelingToolkit therefore supports regular Julia functions as affects: instead
144144
of one or more equations, an affect is defined as a `tuple`:
145145

146146
```julia
147-
[x ~ 0] => (affect!, [v, x], [p, q], ctx)
147+
[x ~ 0] => (affect!, [v, x], [p, q], [discretes...], ctx)
148148
```
149149

150150
where, `affect!` is a Julia function with the signature: `affect!(integ, u, p, ctx)`; `[u,v]` and `[p,q]` are the symbolic unknowns (variables) and parameters
151-
that are accessed by `affect!`, respectively; and `ctx` is any context that is
152-
passed to `affect!` as the `ctx` argument.
151+
that are accessed by `affect!`, respectively; `discretes` are the parameters modified by `affect!`, if any;
152+
and `ctx` is any context that is passed to `affect!` as the `ctx` argument.
153153

154154
`affect!` receives a [DifferentialEquations.jl
155155
integrator](https://docs.sciml.ai/DiffEqDocs/stable/basics/integrator/)
@@ -172,7 +172,7 @@ When accessing variables of a sub-system, it can be useful to rename them
172172
(alternatively, an affect function may be reused in different contexts):
173173

174174
```julia
175-
[x ~ 0] => (affect!, [resistor₊v => :v, x], [p, q => :p2], ctx)
175+
[x ~ 0] => (affect!, [resistor₊v => :v, x], [p, q => :p2], [], ctx)
176176
```
177177

178178
Here, the symbolic variable `resistor₊v` is passed as `v` while the symbolic
@@ -191,7 +191,7 @@ function bb_affect!(integ, u, p, ctx)
191191
integ.u[u.v] = -integ.u[u.v]
192192
end
193193
194-
reflect = [x ~ 0] => (bb_affect!, [v], [], nothing)
194+
reflect = [x ~ 0] => (bb_affect!, [v], [], [], nothing)
195195
196196
@mtkbuild bb_sys = ODESystem(bb_eqs, t, sts, par,
197197
continuous_events = reflect)

0 commit comments

Comments
 (0)