Hello, I am a complete Julia beginner and am working through Example 2: Solving Systems of Equations and Defining Parameterized Functions, trying to adapt my food-chain formulas to Julia. I have also watched Intro to solving differential equations in Julia.
I am using Julia 1.0 on Windows 10, and have updated all packages and have DifferentialEquations (also updated) installed.
The start equations and parameters are:
du[1] = u1*(1-u1)-(1/e)*y2*x2*u1^(1-q)/(u012^(1+q)+u1^(q+1))*u2
du[2] = y2*x2*u1^(1+q)/(u012^(1+q)+u1^(1+q))*u2-(1/e)*y3*x3*u2^(1+q)/(u023^(1+q)+u2^(1+q))*u3-x2*u2
du[3] = y3*x3*u2^(1+q)/(u023^(1+q)+u2^(1+q))*u3-x3*u3
Initial values = u1= 0.01, u2 = 0.01, u3 = 0.01
e = 1
y2 = 2
x2 = 3
q = 4
u012 = 5
y3 = 6
x3 = 7
u023 = 8
t-max = 10000
t-interval = 0.05
Based on the tutorial my code currently looks like this:
using DifferentialEquations
function Bio(du,u,p,t)
du[1] = u[1](1-u[1])-(1/[1])[2]*[3]*u[1]^(1-[4])/([5]^(1+[4])u[1]^([4]+1))u[2]
du[2] = [2][3]u[1]^(1+[4])/([5]^(1+[4])+u[1]^(1+[4]))u[2]-(1/[1])[6][7]*u[2]^(1+[4])/([8]^(1+[4])+u[2]^(1+[4]))*u[3]-[3]u[2]
du[3] = [6][7]*u[2]^(1+[4])/([8]^(1+[4])+u[2]^(1+[4]))*u[3]-[7]*u[3]
end
u0 = [0.01,0.01,0.01]
p=(1,2.009,0.4,5,0.08,0,0.16129,0.5)
tspan = (0.01, 10000)
prob=ODEProblem(Bio,u0,tspan,p)
sol=solve(prob)
I generate an error once sol=solve(prob) runs.
ERROR: MethodError: no method matching -(::Int32, ::Array{Int32,1})
Closest candidates are:
-(::Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}) at int.jl:51
-(::T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}, ::T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8} at int.jl:52
-(::Union{Int16, Int32, Int8}, ::BigInt) at gmp.jl:458
…
Stacktrace:
[1] Bio(::Array{Float64,1}, ::Array{Float64,1}, ::Tuple{Int32,Float64,Float64,Int32,Float64,Int32,Float64,Float64}, ::Float64) at .\REPL[12]:2
[2] (::ODEFunction{true,typeof(Bio),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing})(::Array{Float64,1}, ::Array{Float64,1}, ::Vararg{Any,N} where N) at C:\Users\Helga.julia\packages\DiffEqBase\mcoTV\src\diffeqfunction.jl:106
[3] initialize!..
… followed by 5 pages of text.
What am I doing wrong? And how may I incorporate time intervals of 0.05? Any assistant/advice would be greatly appreciated.