Convert delayed differential equation in Julia notation for DifferentialEquations.jl

Hello
I am trying to convert the following delayed differential equations (DDE) into Julia notation:


Thus I wrote this code followingthis example:

using DifferentialEquations
function dynDelay!(du, u, h, p)
μ, κ, φ, ω, β, τ = p
#=
μ = r because this is used in other equations
du[1] = susceptible
du[2] = infected
du[3] = phages
=#
du[1] = (μ * u[1]) * (1 - (u[1]+u[2])/κ) - (φ * u[1] * u[3]) - (ω * u[1])
du[2] = (φ * u[1] * u[3]) - (phi * h(p, t-τ)[1] * h(p, t-τ)[3] * exp(-1 * ω * τ)) - (ω * u[2])
du[3] = (β * φ * h(p, t-τ)[1] * h(p, t-τ)[3] * exp(-1 * ω * τ)) - (phi * u[1] * u[3]) - (ω * u[3])
end

const mu = 0.16 # maximum growth rate
const kappa = 2.2*10^7 # maximum population density
const phi = 10.0^-9 # adsorption rate
const beta = 50.0 # burst size
const omega = 0.05 # outflow
const tau = 3.65 # latency time
const tmax = 4000.0 # time span 0-tmax
const s0 = 50000.0 # initial susceptible population
const i0 = 1.0e-9 # initial infected population
const v0 = 80.0 # initial phage population
h(t, p) = ones(3)
tspan = (0.0, tmax)
u0 = [1.0, 1.0, 1.0]
prob = DDEProblem(dynDelay!, u0, h, tspan, p=nothing; constant_lags = , dependent_lags = )
algt = MethodOfSteps(Tsit5())
soln = solve(prob, algt)

But when I run the last command:

julia> soln = solve(prob, algt)
ERROR: BoundsError: attempt to access 0.0
  at index [2]
Stacktrace:
 [1] indexed_iterate(::Float64, ::Int64, ::Nothing) at ./tuple.jl:72
 [2] dynDelay!(::Array{Float64,1}, ::Function, ::Nothing, ::Float64) at /home/gigiux/Downloads/DelayDynamo.jl:6
 [3] (::DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),DelayDiffEq.HistoryFunction{typeof(h),DelayDiffEq.HistoryODEIntegrator{Tsit5,false,Array{Float64,1},Float64,Float64,Array{Array{Float64,1},1},ODESolution{Float64,2,Array{Array{Float64,1},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,1},1},1},ODEProblem{Array{Float64,1},Tuple{Float64,Float64},false,Nothing,DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},DiffEqBase.DEStats},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing})(::Array{Float64,1}, ::Nothing, ::Float64) at /home/gigiux/.julia/packages/DelayDiffEq/uLfcX/src/functionwrapper.jl:58
 [4] initialize!(::DelayDiffEq.DDEIntegrator{Tsit5,false,Array{Float64,1},Float64,Nothing,Float64,Float64,Float64,Array{Array{Float64,1},1},ODESolution{Float64,2,Array{Array{Float64,1},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,1},1},1},DDEProblem{Array{Float64,1},Tuple{Float64,Float64},Array{Any,1},Array{Any,1},false,Nothing,DDEFunction{false,typeof(dynDelay!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(h),Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}},Tsit5,OrdinaryDiffEq.InterpolationData{DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),DelayDiffEq.HistoryFunction{typeof(h),DelayDiffEq.HistoryODEIntegrator{Tsit5,false,Array{Float64,1},Float64,Float64,Array{Array{Float64,1},1},ODESolution{Float64,2,Array{Array{Float64,1},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,1},1},1},ODEProblem{Array{Float64,1},Tuple{Float64,Float64},false,Nothing,DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},DiffEqBase.DEStats},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},DelayDiffEq.DDEStats},DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),DelayDiffEq.HistoryFunction{typeof(h),DelayDiffEq.HistoryODEIntegrator{Tsit5,false,Array{Float64,1},Float64,Float64,Array{Array{Float64,1},1},ODESolution{Float64,2,Array{Array{Float64,1},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,1},1},1},ODEProblem{Array{Float64,1},Tuple{Float64,Float64},false,Nothing,DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},DiffEqBase.DEStats},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64},DelayDiffEq.HistoryODEIntegrator{Tsit5,false,Array{Float64,1},Float64,Float64,Array{Array{Float64,1},1},ODESolution{Float64,2,Array{Array{Float64,1},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,1},1},1},ODEProblem{Array{Float64,1},Tuple{Float64,Float64},false,Nothing,DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},DiffEqBase.DEStats},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},DelayDiffEq.FPSolver{NLFunctional{Rational{Int64},Rational{Int64}},false,Float64,DelayDiffEq.FPFunctionalConstantCache},OrdinaryDiffEq.DEOptions{Float64,Float64,Float64,Float64,typeof(DiffEqBase.ODE_DEFAULT_NORM),typeof(LinearAlgebra.opnorm),CallbackSet{Tuple{},Tuple{}},typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN),typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE),typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK),DataStructures.BinaryHeap{Float64,DataStructures.LessThan},DataStructures.BinaryHeap{Discontinuity{Float64},DataStructures.LessThan},Nothing,Nothing,Int64,Array{Float64,1},Array{Float64,1},Array{Discontinuity{Float64},1}},Float64,Int64,DelayDiffEq.HistoryFunction{typeof(h),DelayDiffEq.HistoryODEIntegrator{Tsit5,false,Array{Float64,1},Float64,Float64,Array{Array{Float64,1},1},ODESolution{Float64,2,Array{Array{Float64,1},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,1},1},1},ODEProblem{Array{Float64,1},Tuple{Float64,Float64},false,Nothing,DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},DiffEqBase.DEStats},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},Array{Float64,1},Float64,Nothing}, ::OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}) at /home/gigiux/.julia/packages/OrdinaryDiffEq/ROQW3/src/perform_step/low_order_rk_perform_step.jl:565
 [5] initialize!(::DelayDiffEq.DDEIntegrator{Tsit5,false,Array{Float64,1},Float64,Nothing,Float64,Float64,Float64,Array{Array{Float64,1},1},ODESolution{Float64,2,Array{Array{Float64,1},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,1},1},1},DDEProblem{Array{Float64,1},Tuple{Float64,Float64},Array{Any,1},Array{Any,1},false,Nothing,DDEFunction{false,typeof(dynDelay!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(h),Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}},Tsit5,OrdinaryDiffEq.InterpolationData{DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),DelayDiffEq.HistoryFunction{typeof(h),DelayDiffEq.HistoryODEIntegrator{Tsit5,false,Array{Float64,1},Float64,Float64,Array{Array{Float64,1},1},ODESolution{Float64,2,Array{Array{Float64,1},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,1},1},1},ODEProblem{Array{Float64,1},Tuple{Float64,Float64},false,Nothing,DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},DiffEqBase.DEStats},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},DelayDiffEq.DDEStats},DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),DelayDiffEq.HistoryFunction{typeof(h),DelayDiffEq.HistoryODEIntegrator{Tsit5,false,Array{Float64,1},Float64,Float64,Array{Array{Float64,1},1},ODESolution{Float64,2,Array{Array{Float64,1},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,1},1},1},ODEProblem{Array{Float64,1},Tuple{Float64,Float64},false,Nothing,DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},DiffEqBase.DEStats},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64},DelayDiffEq.HistoryODEIntegrator{Tsit5,false,Array{Float64,1},Float64,Float64,Array{Array{Float64,1},1},ODESolution{Float64,2,Array{Array{Float64,1},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,1},1},1},ODEProblem{Array{Float64,1},Tuple{Float64,Float64},false,Nothing,DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},DiffEqBase.DEStats},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},DelayDiffEq.FPSolver{NLFunctional{Rational{Int64},Rational{Int64}},false,Float64,DelayDiffEq.FPFunctionalConstantCache},OrdinaryDiffEq.DEOptions{Float64,Float64,Float64,Float64,typeof(DiffEqBase.ODE_DEFAULT_NORM),typeof(LinearAlgebra.opnorm),CallbackSet{Tuple{},Tuple{}},typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN),typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE),typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK),DataStructures.BinaryHeap{Float64,DataStructures.LessThan},DataStructures.BinaryHeap{Discontinuity{Float64},DataStructures.LessThan},Nothing,Nothing,Int64,Array{Float64,1},Array{Float64,1},Array{Discontinuity{Float64},1}},Float64,Int64,DelayDiffEq.HistoryFunction{typeof(h),DelayDiffEq.HistoryODEIntegrator{Tsit5,false,Array{Float64,1},Float64,Float64,Array{Array{Float64,1},1},ODESolution{Float64,2,Array{Array{Float64,1},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,1},1},1},ODEProblem{Array{Float64,1},Tuple{Float64,Float64},false,Nothing,DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{DelayDiffEq.ODEFunctionWrapper{false,typeof(dynDelay!),typeof(h),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},DiffEqBase.DEStats},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},Array{Float64,1},Float64,Nothing}) at /home/gigiux/.julia/packages/DelayDiffEq/uLfcX/src/integrators/interface.jl:145
 [6] #__init#33(::Array{Float64,1}, ::Array{Float64,1}, ::Array{Discontinuity{Float64},1}, ::Nothing, ::Bool, ::Bool, ::Bool, ::Bool, ::Nothing, ::Bool, ::Bool, ::Float64, ::Float64, ::Float64, ::Bool, ::Bool, ::Rational{Int64}, ::Nothing, ::Nothing, ::Rational{Int64}, ::Int64, ::Int64, ::Int64, ::Rational{Int64}, ::Bool, ::Int64, ::Nothing, ::Nothing, ::Int64, ::typeof(DiffEqBase.ODE_DEFAULT_NORM), ::typeof(LinearAlgebra.opnorm), ::typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), ::typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Int64, ::String, ::typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), ::Nothing, ::Bool, ::Bool, ::Bool, ::Int64, ::Float64, ::Int64, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(DiffEqBase.__init), ::DDEProblem{Array{Float64,1},Tuple{Float64,Float64},Array{Any,1},Array{Any,1},false,Nothing,DDEFunction{false,typeof(dynDelay!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(h),Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}}, ::MethodOfSteps{Tsit5,NLFunctional{Rational{Int64},Rational{Int64}},false}, ::Array{Array{Float64,1},1}, ::Array{Float64,1}, ::Array{Any,1}) at /home/gigiux/.julia/packages/DelayDiffEq/uLfcX/src/solve.jl:298
 [7] __init(::DDEProblem{Array{Float64,1},Tuple{Float64,Float64},Array{Any,1},Array{Any,1},false,Nothing,DDEFunction{false,typeof(dynDelay!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(h),Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}}, ::MethodOfSteps{Tsit5,NLFunctional{Rational{Int64},Rational{Int64}},false}, ::Array{Array{Float64,1},1}, ::Array{Float64,1}, ::Array{Any,1}) at /home/gigiux/.julia/packages/DelayDiffEq/uLfcX/src/solve.jl:68 (repeats 2 times)
 [8] #__solve#32 at /home/gigiux/.julia/packages/DelayDiffEq/uLfcX/src/solve.jl:4 [inlined]
 [9] __solve at /home/gigiux/.julia/packages/DelayDiffEq/uLfcX/src/solve.jl:4 [inlined]
 [10] #solve_call#433(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::DDEProblem{Array{Float64,1},Tuple{Float64,Float64},Array{Any,1},Array{Any,1},false,Nothing,DDEFunction{false,typeof(dynDelay!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(h),Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}}, ::MethodOfSteps{Tsit5,NLFunctional{Rational{Int64},Rational{Int64}},false}) at /home/gigiux/.julia/packages/DiffEqBase/IDJcQ/src/solve.jl:40
 [11] solve_call at /home/gigiux/.julia/packages/DiffEqBase/IDJcQ/src/solve.jl:37 [inlined]
 [12] #solve#434(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::DDEProblem{Array{Float64,1},Tuple{Float64,Float64},Array{Any,1},Array{Any,1},false,DiffEqBase.NullParameters,DDEFunction{false,typeof(dynDelay!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(h),Base.Iterators.Pairs{Symbol,Nothing,Tuple{Symbol},NamedTuple{(:p,),Tuple{Nothing}}}}, ::MethodOfSteps{Tsit5,NLFunctional{Rational{Int64},Rational{Int64}},false}) at /home/gigiux/.julia/packages/DiffEqBase/IDJcQ/src/solve.jl:57
 [13] solve(::DDEProblem{Array{Float64,1},Tuple{Float64,Float64},Array{Any,1},Array{Any,1},false,DiffEqBase.NullParameters,DDEFunction{false,typeof(dynDelay!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(h),Base.Iterators.Pairs{Symbol,Nothing,Tuple{Symbol},NamedTuple{(:p,),Tuple{Nothing}}}}, ::MethodOfSteps{Tsit5,NLFunctional{Rational{Int64},Rational{Int64}},false}) at /home/gigiux/.julia/packages/DiffEqBase/IDJcQ/src/solve.jl:45
 [14] top-level scope at none:0

What am I getting wrong?
Also: shall I state the variables as constant?
And the term φ * h(p, t-τ)[1] * h(p, t-τ)[3] * exp(-1 * ω * τ)) is the same in two equations: it is possible to set it into a variable so not to calculate it twice?

Quite a few things. You should follow the syntax in the documentation. You didn’t pass any parameters, you passed p=nothing which isn’t anything in the documentation, and you didn’t put the t in the derivative function definition.

I believe what you meant to write was:

using DelayDiffEq
function dynDelay!(du, u, h, p, t)
    μ, κ, φ, ω, β, τ = p
    #=
    μ = r because this is used in other equations
    du[1] = susceptible
    du[2] = infected
    du[3] = phages
    =#
    hist = h(p, t-τ)
    val = φ * hist[1] * hist[3] * exp(-1 * ω * τ)

    du[1] = (μ * u[1]) * (1 - (u[1]+u[2])/κ) - (φ * u[1] * u[3]) - (ω * u[1])
    du[2] = (φ * u[1] * u[3]) - val - (ω * u[2])
    du[3] = (β * val) - (phi * u[1] * u[3]) - (ω * u[3])
end

mu = 0.16 # maximum growth rate
kappa = 2.2*10^7 # maximum population density
phi = 10.0^-9 # adsorption rate
beta = 50.0 # burst size
omega = 0.05 # outflow
tau = 3.65 # latency time
tmax = 4000.0 # time span 0-tmax
s0 = 50000.0 # initial susceptible population
i0 = 1.0e-9 # initial infected population
v0 = 80.0 # initial phage population
h(t, p) = ones(3)
tspan = (0.0, tmax)
u0 = [s0,i0,v0]
prob = DDEProblem(dynDelay!, u0, h, tspan,
                  [mu,kappa,phi,beta,omega,tau],constant_lags = [tau])
algt = MethodOfSteps(Tsit5())
soln = solve(prob, algt)

I’ll update the DDE tutorial example to make some of this more explicit.

4 Likes

Docs are updated:

https://docs.juliadiffeq.org/dev/tutorials/dde_example/

2 Likes

Thank you, much clearer now.

That syntax… N_\tau V_\tau \exp(-\omega \tau) was weird… I assume that the handwritten note should not be N_\tau V_\tau = N(t-\tau) V(t-\tau), but rather N_\tau V_\tau \exp(-\omega \tau) = N(t-\tau)V(t-\tau)

Probably, this is some sort of quasi notation where N_\tau V_\tau \exp(-\omega \tau) really should be N(s)V(s)\exp(-s\tau), and where the differential equation is some sort of weird mixture of time domain and s domain (Laplace domain)? And that one has set s=j\omega where j\triangleq \sqrt{-1}, and that the j mysteriously has disappeared?

Or is this common syntax?

Thanks for the note. The handwriting comes from other ways of writing these sort of formulas, such as:


where P and Ns are the V and N in the previous ones. There is a line in the book I pasted the image from that extend the term N(t - \tau)V(t-\tau), but I don’t have it now. In my naivety, I initially though that t - \tau was actually the difference between these two measures.

PS the line in the book was simply: Nτ ≡ N(t – τ). And yes, the handwriting was only converting the NτVτ term, not the exponential part…