Hello, this is a question that looks related to the following:
I am hoping to perturb the system state at multiple times using Catalyst / DiscreteProblem / JumpProblem.
I have found the above answer as well as the remarks in the tutorial (https://diffeq.sciml.ai/stable/tutorials/discrete_stochastic_example/#Continuous-Time-Jump-Processes-and-Gillespie-Methods) and thought I understood them. But evidently I do not. Here is a minimal example.
this is a basic model and works fine
using Catalyst, DifferentialEquations
using Plots, StatsPlots
rs = @reaction_network begin
g, X → 2X
l, X → 0
end g l
dprob = DiscreteProblem(rs, [1000.0], (0.0, 100.0), ( 1.0, 1.0 ) )
jprob = JumpProblem(rs, dprob, Direct(), save_positions=(false, false))
jsol = solve(jprob, SSAStepper(), saveat=0.1)
plot(jsol,lw=2,title=“Jump solution”)
Trying to add a callback to affect u has no effect
condition20(u, t, integrator) = t==20.0
function affect20!(integrator)
integrator.u[1] = 100
reset_jumps!(integrator)
# reset_aggregated_jumps!(integrator)
end
jsol = solve(jprob, SSAStepper(), saveat=0.1, callback=DiscreteCallback( condition20, affect20! ) )
plot(jsol,lw=2,title=“Jump solution with perturbation at time=20”)
I have also tried PresetTimeCallback ( as I have multiple perturbations that I am trying to simulate). No joy there either.
Would anyone have a hint as to how I can implement such perturbations in a Jump model?
Thanks!
Jae