I have this model of bacteria and phage interactions:
using DifferentialEquations function payneJansenODE!(du, u, p, t) μ , φ, η, β, ω = p H = h = 0 du = (μ * u) - (φ * u * u) - (H * u) du = (μ * u) + (φ * u * u) - (η * u) - (H * u) du = (η * β * u) - (φ * u * u) - (ω * u) - (h * u) end mu = 0.5 # growth rate, a phi = 1e-7 # adsorption rate, b eta = 5 # lysis rate, k beta = 100 # burst size, L omega = 5 # outflow, m s0 = 1000 # initial susceptible population, x0 i0 = 0.0 # initial infected population, y0 v0 = 0.0 # initial phage population tϕ = 2.5 # time of inoculum, tφ vϕ = 1e9 # amount of inoculum, vφ tmax = 20.0 # duration u0 = [s0, i0, v0] parms = [mu, phi, eta, beta, omega] tspan = (0.0, tmax) condition(u, t, integrator) = t==tϕ # time of inoculum affect!(integrator) = integrator.u += vϕ # amount of inoculum cb = DiscreteCallback(condition, affect!) prob = ODEProblem(payneJansenODE!, u0, tspan, parms) soln = solve(prob, AutoVern7(Rodas5()), callback=cb, tstops=[tϕ])
The model works but from the plot (the horizontal line is y=1):
It is possible to force u to zero (which will bring also u = 0) when a condition is reached? (in this case, when u <1).