I kind of forgot the values I used for the figure (the file got lost in the sync), but the point is exactly: how to find the parameters that make an oscillatory environment. I tried with:
function logistic!(du, u, p, t)
μ = p[:μ] # susceptible growth rate
ν = p[:ν] # resistant growth rate
κ = p[:κ] # bacterial carrying capacity
ω = p[:ω] # system wash-out rate
δ = p[:δ] # phagial infection rate
η = p[:η] # phagial lysis rate (inverse latency)
β = p[:β] # phagial burst size
λ = p[:λ] # phagial decay rate
#=
du[1] = species A sensible
du[2] = species A infected
du[3] = species B
du[4] = phages
=#
N = u[1] + u[2] + u[3] # total bacteria
ρ = 1 - N/κ # logistic term
ϡ = (δ*u[1]*u[4]) # upsampi : infected bacteria
du[1] = (μ*u[1]*ρ) - ϡ - (ω*u[1])
du[2] = ϡ - (η*u[2]) - (ω*u[2])
du[3] = (ν*u[3]*ρ) - (ω*u[3])
du[4] = (η*β*u[2]) - ϡ - (λ*u[4]) - (ω*u[4])
return(SVector(du[1], du[2], du[3], du[4]))
end
begin
kappa = 1e9
mu = 0.19
nu = 0.16
su0 = 1e6
re0 = 1e4
omega = 0.05
delta = 1e-9
eta = 0.25
lambda = 0.05
beta = 50.0
v0 = 1e5
t_mx = 1e3
end
u0 = [su0, 0, re0, v0] # S, I, R, V
tspan = (0.0, t_mx)
parms = (μ=mu, ν=nu, κ=kappa, δ=delta, ω=omega, η=eta, β=beta, λ=lambda)
prob = ODEProblem(logistic!, u0, tspan, parms)
soln = solve( prob, Rosenbrock23(), tstops=[t_in] )
When I try the implementation:
julia> Si = range(su0/100, su0*100; length = 100)
10000.0:1.01e6:1.0e8
julia> Ii = range(0, 0; length = 100)
StepRangeLen(0.0, 0.0, 100)
julia> Ri = range(re0/100, re0*100; length = 100)
100.0:10100.0:1.0e6
julia> Vi = range(v0/100, v0*100; length = 100)
1000.0:101000.0:1.0e7
julia> grid = (Si, Ii, Ri, Vi)
(10000.0:1.01e6:1.0e8, StepRangeLen(0.0, 0.0, 100), 100.0:10100.0:1.0e6, 1000.0:101000.0:1.0e7)
julia> u0 = [su0, 0, re0, v0]
4-element Vector{Float64}:
1.0e6
0.0
10000.0
100000.0
julia> parms = (μ=mu, ν=nu, κ=kappa, δ=delta, ω=omega, η=eta, β=beta, λ=lambda)
(μ = 0.19, ν = 0.16, κ = 1.0e9, δ = 1.0e-9, ω = 0.05, η = 0.25, β = 50.0, λ = 0.05)
julia> lo = ContinuousDynamicalSystem(logistic, u0, parms)
ERROR: UndefVarError: logistic not defined
Stacktrace:
[1] top-level scope
@ none:1
Yet logistic
is defined at the beginning. Why is it not recognized?