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
We can also model discrete events. Similar to our example with continuous events, we start by creating reaction equations, parameters, variables, and unknowns.
253
+
We can again also model discrete events. Similar to our example with continuous
254
+
events, we start by creating reaction equations, parameters, variables, and
255
+
unknowns.
175
256
```@example ceq3
176
257
t = default_t()
177
258
@parameters k_on switch_time k_off
@@ -193,22 +274,7 @@ Simulating our model,
193
274
rs2 = complete(rs2)
194
275
195
276
oprob = ODEProblem(rs2, u0, tspan, p)
196
-
sol = solve(oprob, Tsit5(); tstops = 2.0)
197
-
plot(sol)
198
-
```
199
-
Note that for discrete events we need to set a stop time via `tstops` so that
200
-
the ODE solver can step exactly to the specific time of our event. In the
201
-
previous example we just manually set the numeric value of the parameter in the
202
-
`tstops` kwarg to `solve`, however, it can often be convenient to instead get
203
-
the value of the parameter from `oprob` and pass this numeric value. This helps
204
-
ensure consistency between the value passed via `p` and/or symbolic defaults and
205
-
what we pass as a `tstop` to `solve`. We can do this as
206
-
```julia
207
277
switch_time_val = oprob.ps[:switch_time]
208
278
sol = solve(oprob, Tsit5(); tstops = switch_time_val)
209
279
plot(sol)
210
280
```
211
-
For a detailed discussion on how to directly use the lower-level but more
212
-
flexible DifferentialEquations.jl event/callback interface, see the
0 commit comments