@@ -330,7 +330,8 @@ event time, the event condition now returns false. Here we used logical and,
330330cannot be used within symbolic expressions.
331331
332332Let's now also add a drug at time ` tkill ` that turns off production of new
333- cells, modeled by setting ` α = 0.0 `
333+ cells, modeled by setting ` α = 0.0 ` . Since this is a parameter we must explicitly
334+ set it as ` discrete_parameters ` .
334335
335336``` @example events
336337@parameters tkill
@@ -339,7 +340,8 @@ cells, modeled by setting `α = 0.0`
339340injection = (t == tinject) => [N ~ Pre(N) + M]
340341
341342# at time tkill we turn off production of cells
342- killing = (t == tkill) => [α ~ 0.0]
343+ killing = ModelingToolkit.SymbolicDiscreteCallback(
344+ (t == tkill) => [α ~ 0.0]; discrete_parameters = α, iv = t)
343345
344346tspan = (0.0, 30.0)
345347p = [α => 100.0, tinject => 10.0, M => 50, tkill => 20.0]
@@ -368,7 +370,8 @@ As such, our last example with treatment and killing could instead be modeled by
368370
369371``` @example events
370372injection = [10.0] => [N ~ Pre(N) + M]
371- killing = [20.0] => [α ~ 0.0]
373+ killing = ModelingToolkit.SymbolicDiscreteCallback(
374+ [20.0] => [α ~ 0.0], discrete_parameters = α, iv = t)
372375
373376p = [α => 100.0, M => 50]
374377@mtkbuild osys = ODESystem(eqs, t, [N], [α, M];
@@ -409,7 +412,8 @@ example:
409412@variables x(t)
410413@parameters c(t)
411414
412- ev = ModelingToolkit.SymbolicDiscreteCallback(1.0 => [c ~ Pre(c) + 1], discrete_parameters = c, iv = t)
415+ ev = ModelingToolkit.SymbolicDiscreteCallback(
416+ 1.0 => [c ~ Pre(c) + 1], discrete_parameters = c, iv = t)
413417@mtkbuild sys = ODESystem(
414418 D(x) ~ c * cos(x), t, [x], [c]; discrete_events = [ev])
415419
@@ -424,7 +428,7 @@ The solution object can also be interpolated with the discrete variables
424428sol([1.0, 2.0], idxs = [c, c * cos(x)])
425429```
426430
427- Note that only time-dependent parameters that are explicitly passed as ` discrete_parameters `
431+ Note that only time-dependent parameters that are explicitly passed as ` discrete_parameters `
428432will be saved. If we repeat the above example with ` c ` not a ` discrete_parameter ` :
429433
430434``` @example events
0 commit comments