I am trying to solve a jump problem. As a part of it, mid simulation, I change a parameter. This is basically an input being triggered into the system. This does not seem to have much effect though, and I am unsure why:
using DifferentialEquations, Catalyst
my_network = @reaction_network begin
v0 + hill(σ,v,K,n), ∅ → σ
deg, (σ,iσ) → ∅
(kB,kD), σ ↔ iσ
input, iσ → σ
end v0 v K n kB kD deg input;
v0 = 0.01; v = 0.25; K = 5.; n = 2.;
kB = 1.; kD = 1.;
deg = 0.01;
input = 0.;
p = [v0, v, K, n, kB, kD, deg, input]
cb_condition(u,t,integrator) = (t==1000.)
function cb_affect!(integrator)
integrator.p[8] = 10.
#println(integrator.p) # This shows that p indeed gets modified correctly.
end
cb = DiscreteCallback(cb_condition,cb_affect!,save_positions = (false,false))
prob_disc = DiscreteProblem(my_network,[5,5],(0.,2000.),p)
prob_jump = JumpProblem(my_network,prob_disc,Direct())
sol = solve(prob_jump, SSAStepper(),callback=cb,tstops=[1000.])
using Plots
plot(sol)
Here the input should break the symmetry, but in the plot, I can see that both variables are very similar. The callback seems to work though, removing the comment gives me a print confirming that the parameter value is changed. Also, making the callback work on the 2nd parameter (v
), I can see a drastic change at time 1000
. Finally, by setting the initial value of the input to 10
, I can confirm that the system solution looks very different.
I have never really run much SSA stuff, is there possibly something I am missing where the callback is not registered properly, or is there something else going on?