I have this model with delayed differential equations:
using DifferentialEquations # function function baseInfect!(du, u, p, t) μ, κ, φ, ω, η, β = p du = ((μ * u) * (1 - ((u+u)/κ))) - (φ * u * u) - (ω * u) du = (φ * u * u) - (η * u) - (ω * u) du = (β * η * u) - (φ * u * u) - (ω * u) end # parameters mu = 0.47 # maximum growth rate susceptible (B. longum) kappa = 2.2*10^7 # maximum population density phi = 10.0^-9 # adsorption rate omega = 0.05 # outflow eta = 1.0 # lyse rate beta = 50.0 # burst size tmax = 4000.0 # time span 0-tmax s0 = 50000.0 # initial susceptible population i0 = 0.0 # initial infected population v0 = 0.0 # initial phage population v_in = 80.0 # amount of injection t_in = 1000 # injection time gran = 1000 # granularity of the ODE # instantiate solver u0 = [s0, i0, v0] parms = [mu, kappa, phi, omega, eta, beta] tspan = (0.0, tmax) # delay infection condition(u, t, integrator) = t==t_in # time of inoculum affect!(integrator) = integrator.u += v_in # amount of inoculum cb = DiscreteCallback(condition,affect!) # instantiate model prob = ODEProblem(baseInfect!, u0, tspan, parms) soln = solve(prob, AutoVern7(Rodas5()), callback=cb, tstops=[gran])
I have set
t_in to determine the time of modification of the equations and
gran to determine the “granularity” of the model via
tstops. In fact, the model works only if
gran are the same. I reckon the problem is that if the solver has a too large “granularity” (I don’t know the exact term), it might not kick on the modification. But the model does not work even if
gran goes to 1.
In other words, I am having this sort of model:
only when t==t_in is the same as tstops=[gran], otherwise I get this:
How can I module the solver?