I would like to make an interactive plot of a SIV model using GLMakie. But how can I link GLMakie with DifferentialEquations? The latter requires parameters that are passed to the solver and these parameters are made of observable. I have troubles with the links.
I tried with the following:
julia> using GLMakie, DifferentialEquations, Parsers
julia> function odeSolver!(du, u, p, t)
μ = p.μ # bacterial 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] = S; du[2] = I; du[3] = V
ρ = 1 - (u[1] + u[2])/κ # rho: logistic factor
ϡ = (δ*u[1]*u[3]) # upsampi : infected bacteria
du[1] = (μ*u[1]*ρ) - ϡ - (ω*u[1])
du[2] = ϡ - (η*u[2]) - (ω*u[2])
du[3] = (β*η*u[2]) - ϡ - (λ*u[3]) - (ω*u[3])
end
odeSolver! (generic function with 1 method)
julia> begin
Mu = Observable(0.16) # μ: default growth rate
Kappa = Observable(2.2e7) # κ: default carrying capacity
Omega = Observable(0.05) # ω: default outflow
Eta = Observable(0.025) # η: default τ reciprocal
Delta = Observable(1e-9) # δ: default adsorption rate
Beta = Observable(50) # β: default burst size
Lambda = Observable(0) # λ: default decay rate
S0 = Observable(1e5) # default starting amount of naive bacteria
I0 = Observable(0) # default starting amount of infected bacteria
V0 = Observable(1e5) # default starting amount of phages
Tm = Observable(2000.0) # default time span
end
Observable(2000.0)
julia> begin
# initial amounts S, I, V
u0 = @lift(vcat($S0, $I0, $V0))
tspan = @lift(vcat(0.0, $Tm))
parms = @lift(μ=$Mu, κ=$Kappa, ω=$Omega, δ=$Delta, η=$Eta, β=$Beta, λ=$Lambda)
end
ERROR: LoadError: MethodError: no method matching var"@lift"(::LineNumberNode, ::Module, ::Expr, ::Expr, ::Expr, ::Expr, ::Expr, ::Expr, ::Expr)
Closest candidates are:
var"@lift"(::LineNumberNode, ::Module, ::Any)
@ Makie ~/.julia/packages/Makie/VRavR/src/interaction/liftmacro.jl:72
Stacktrace:
[1] eval
@ ./boot.jl:385 [inlined]
[2] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:2076
[3] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})
@ Base ./essentials.jl:892
[4] invokelatest(::Any, ::Any, ::Vararg{Any})
@ Base ./essentials.jl:889
[5] inlineeval(m::Module, code::String, code_line::Int64, code_column::Int64, file::String; softscope::Bool)
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/eval.jl:263
[6] (::VSCodeServer.var"#67#72"{…})()
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/eval.jl:181
[7] withpath(f::VSCodeServer.var"#67#72"{…}, path::String)
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/repl.jl:274
[8] (::VSCodeServer.var"#66#71"{…})()
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/eval.jl:179
[9] hideprompt(f::VSCodeServer.var"#66#71"{…})
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/repl.jl:38
[10] (::VSCodeServer.var"#65#70"{…})()
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/eval.jl:150
[11] with_logstate(f::Function, logstate::Any)
@ Base.CoreLogging ./logging.jl:515
[12] with_logger
@ ./logging.jl:627 [inlined]
[13] (::VSCodeServer.var"#64#69"{VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/eval.jl:255
[14] #invokelatest#2
@ ./essentials.jl:892 [inlined]
[15] invokelatest(::Any)
@ Base ./essentials.jl:889
[16] (::VSCodeServer.var"#62#63")()
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/eval.jl:34
in expression starting at /home/gigiux/Documents/Model/MkBact_1.jl:42
Some type information was truncated. Use `show(err)` to see complete types.
How do I pass observable to the ODE solver?
Thank you