Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/src/features/callback_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ This allows you to build sophisticated models of populations with births and dea

### Example 1: Bouncing Ball with multiple walls

This is similar to the above Bouncing Ball example, but now we have two more vertical walls, at `x = 0` and `x = 10.0`. We have our ODEFunction as -
This is similar to the above Bouncing Ball example, but ball now can move in both `x` and `y`. We have also added two more vertical walls, at `x = 0` and `x = 10.0`. We have our ODEFunction as -

```@example callback6
function f(du, u, p, t)
Expand All @@ -780,10 +780,10 @@ function condition(out, u, t, integrator) # Event when condition(out,u,t,integra
return
end

function affect!(integrator, idx)
if idx == 1
function affect!(integrator, simultaneous_events)
if simultaneous_events[1] != 0
integrator.u[2] = -0.9integrator.u[2]
elseif idx == 2
elseif simultaneous_events[2] != 0
integrator.u[4] = -0.9integrator.u[4]
end
return
Expand All @@ -803,5 +803,5 @@ p = 9.8
prob = DE.ODEProblem(f, u0, tspan, p)
sol = DE.solve(prob, DE.Tsit5(), callback = cb, dt = 1.0e-3, adaptive = false)
import Plots: plot
plot(sol, idxs = (1, 3));
plot(sol, idxs = (3, 1));
```