I tried but did not work. I re-arranged as:
function kinInfect!(du, u, p, t)
μ, φ, η, β, ω, ε = p
H = h = 0
#=
du[1] = susceptible
du[2] = infected
du[3] = phages
μ = growth rate (replication coef), a
φ = adsorption rate (transmission coef), b
η = lysis rate, k
β = burst size, L
ω = outflow (decay rate phage), m
H = host response against bacterium
h = host response against phage
=#
X(x, y) = (x < y) ? 0.0 : 1.0
du[1] = (μ * u[1]) - (φ * u[1] * u[3]) - (H * u[1])
du[2] = (μ * u[2]) + (φ * u[1] * u[3]) - (η * u[2]) - (H * u[2])
du[3] = (X(t,ε) * η * β * u[2]) - (φ * u[1] * u[3]) - (ω * u[3]) - (h * u[3])
println("t= ", t, "> ", X(t,ε), ": ", du[3])
end
# parameters
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_in = 2.5 # time of inoculum, tφ
v_in = 100 # amount of inoculum, vφ
tmax = 20.0 # duration
# instantiate
tspan = (0.0, tmax)
parms = [mu, phi, eta, beta, omega, t_in]
u0 = [s0, i0, v0]
condition(u, t, integrator) = t==t_in # time of inoculum
affect!(integrator) = integrator.u[3] += v_in # amount of inoculum
cb = DiscreteCallback(condition,affect!)
prob = ODEProblem(kinInfect!, u0, tspan, parms)
soln = solve(prob, AutoVern7(Rodas5()), callback=cb, tstops=[1000])
and I got:
julia>
t= 0.02> 0.0: 0.0
t= 0.0> 0.0: 0.0
t= 0.0011528391772627539> 0.0: 0.0
t= 0.02510627541594441> 0.0: 0.0
t= 0.03765941312391662> 0.0: 0.0
t= 0.10502364904863687> 0.0: 0.0
t= 0.1405332743433084> 0.0: 0.0
t= 0.20382196654005486> 0.0: 0.0
t= 0.21327524779360946> 0.0: 0.0
t= 0.23056783545255075> 0.0: 0.0
t= 0.23056783545255075> 0.0: 0.0
t= 0.23056783545255075> 0.0: 0.0
t= 0.23500388065939562> 0.0: 0.0
t= 0.32717504217939464> 0.0: 0.0
t= 0.37547864554281657> 0.0: 0.0
t= 0.6346915537961186> 0.0: 0.0
t= 0.7713301294032545> 0.0: 0.0
t= 1.0148606280227241> 0.0: 0.0
t= 1.051236198718852> 0.0: 0.0
t= 1.117776876821525> 0.0: 0.0
t= 1.117776876821525> 0.0: 0.0
t= 1.117776876821525> 0.0: 0.0
t= 1.124538601794153> 0.0: 0.0
t= 1.2650322206698672> 0.0: 0.0
t= 1.3386598925940385> 0.0: 0.0
t= 1.7337700218279322> 0.0: 0.0
t= 1.942043929289803> 0.0: 0.0
t= 2.3132498519821483> 0.0: 0.0
t= 2.368695996757698> 0.0: 0.0
t= 2.470121871347117> 0.0: 0.0
t= 2.470121871347117> 0.0: 0.0
t= 2.470121871347117> 0.0: 0.0
t= 2.4779124745446595> 0.0: 0.0
t= 2.639783896538048> 1.0: 0.0
t= 2.7246149091335132> 1.0: 0.0
t= 3.1798458226432613> 1.0: 0.0
t= 3.419811123806132> 1.0: 0.0
t= 3.847500516672675> 1.0: 0.0
t= 3.9113834628925255> 1.0: 0.0
t= 4.028242510855667> 1.0: 0.0
t= 4.028242510855667> 1.0: 0.0
t= 4.028242510855667> 1.0: 0.0
t= 4.037152472484574> 1.0: 0.0
t= 4.2222816752185315> 1.0: 0.0
t= 4.319301257399964> 1.0: 0.0
t= 4.8399400152491> 1.0: 0.0
t= 5.114383671461072> 1.0: 0.0
t= 5.603523726846436> 1.0: 0.0
t= 5.676585412203474> 1.0: 0.0
t= 5.81023483663708> 1.0: 0.0
t= 5.81023483663708> 1.0: 0.0
t= 5.81023483663708> 1.0: 0.0
t= 5.820092888234482> 1.0: 0.0
t= 6.024921293647171> 1.0: 0.0
t= 6.132264522152217> 1.0: 0.0
t= 6.708303337160416> 1.0: 0.0
t= 7.011949956102049> 1.0: 0.0
t= 7.55313835905778> 1.0: 0.0
t= 7.633974382156477> 1.0: 0.0
t= 7.78184515611751> 1.0: 0.0
t= 7.78184515611751> 1.0: 0.0
t= 7.78184515611751> 1.0: 0.0
t= 7.792595310607519> 1.0: 0.0
t= 8.015959631677706> 1.0: 0.0
t= 8.133016869457805> 1.0: 0.0
t= 8.761184230157331> 1.0: 0.0
t= 9.092309304086916> 1.0: 0.0
t= 9.682472469951104> 1.0: 0.0
t= 9.77062373676918> 1.0: 0.0
t= 9.931876054119314> 1.0: 0.0
t= 9.931876054119314> 1.0: 0.0
t= 9.931876054119314> 1.0: 0.0
t= 9.94339866563282> 1.0: 0.0
t= 10.182812927080112> 1.0: 0.0
t= 10.30828136356051> 1.0: 0.0
t= 10.981585962999713> 1.0: 0.0
t= 11.336504173041954> 1.0: 0.0
t= 11.969073769707178> 1.0: 0.0
t= 12.063559184117928> 1.0: 0.0
t= 12.236398356820517> 1.0: 0.0
t= 12.236398356820517> 1.0: 0.0
t= 12.236398356820517> 1.0: 0.0
t= 12.248606138382897> 1.0: 0.0
t= 12.502256710845652> 1.0: 0.0
t= 12.63518588785822> 1.0: 0.0
t= 13.348527257153213> 1.0: 0.0
t= 13.724549999534794> 1.0: 0.0
t= 14.394734137049063> 1.0: 0.0
t= 14.494837945860569> 1.0: 0.0
t= 14.677954669296248> 1.0: 0.0
t= 14.677954669296248> 1.0: 0.0
t= 14.677954669296248> 1.0: 0.0
t= 14.690752829766621> 1.0: 0.0
t= 14.95667016398437> 1.0: 0.0
t= 15.096027911328429> 1.0: 0.0
t= 15.84386708814722> 1.0: 0.0
t= 16.23807461659283> 1.0: 0.0
t= 16.940669440458176> 1.0: 0.0
t= 17.045614356315234> 1.0: 0.0
t= 17.237586763370828> 1.0: 0.0
t= 17.237586763370828> 1.0: 0.0
t= 17.237586763370828> 1.0: 0.0
t= 17.250894453033002> 1.0: 0.0
t= 17.52739867156927> 1.0: 0.0
t= 17.672304625668488> 1.0: 0.0
t= 18.449917291594815> 1.0: 0.0
t= 18.859819282055923> 1.0: 0.0
t= 19.590386295643068> 1.0: 0.0
t= 19.69950935087289> 1.0: 0.0
t= 19.89912469580549> 1.0: 0.0
t= 19.89912469580549> 1.0: 0.0
t= 19.89912469580549> 1.0: 0.0
t= 19.899629072326462> 1.0: 0.0
t= 19.91010889559556> 1.0: 0.0
t= 19.915600995490593> 1.0: 0.0
t= 19.94507339686609> 1.0: 0.0
t= 19.960609146882575> 1.0: 0.0
t= 19.988298464713438> 1.0: 0.0
t= 19.992434352185413> 1.0: 0.0
t= 20.0> 1.0: 0.0
t= 20.0> 1.0: 0.0
julia>
Looks like the test worked but the condition did not…