I’m new to using Julia and I’m attempting to simulate a reaction network while introducing a disturbance that changes the concentration of one species over time. I’ve learned that I can use a callback to alter the value of a specific species at a given time to simulate the disturbance. Although I’ve read the documentation, all the descriptions and examples are for cases using differential equations, not reaction networks. Here’s the code I’ve used to create the reaction network and necessary parameters:
using Catalyst
using DifferentialEquations
rn = @reaction_network begin
α, A + B --> 2B
β, B --> A
end α,β
p = [:α => 1, :β => 2]
tspan = (0.0,20.0)
u0 = [:A => 5.0, :B=> 5.0]
op = ODEProblem(rn, u0, tspan, p)
Next, for the callback that triggers at t=10
condition(u, t, integrator) = t == 10
to increase the value of species A by two
affect!(integrator) = integrator.??? += 2
But this is where I’m unsure about which parameters to use to change the value of A.
And the rest of my code:
cb = DiscreteCallback(condition, affect!)
sol = solve(prob, Tsit5(), callback = cb, tstops = [10.0])
using Plots
plot(sol)
I’d appreciate any help to improve my understanding in this area.