SciML / DifferentialEquations.jl

Multi-language suite for high-performance solvers of differential equations and scientific machine learning (SciML) components. Ordinary differential equations (ODEs), stochastic differential equations (SDEs), delay differential equations (DDEs), differential-algebraic equations (DAEs), and more in Julia.
https://docs.sciml.ai/DiffEqDocs/stable/
Other
2.8k stars 222 forks source link

oneunit(::Type{Any} #1003

Open Li-shiyue opened 7 months ago

Li-shiyue commented 7 months ago

Is it grammatical to construct a system of differential equations in this way? What does this error mean? function eee!(u, p, t) x, y = u a,b,c = p for i=2:1:99 dx[i] = ax[i-1]+(i+1)x[i+1]-by[i] dy[i] = (i+1)y[i+1]-iy[i]-cy[i]+bx[i] end end using DifferentialEquations u1 = [] u2 = [] for i =1:100 push!(u1,0) push!(u2,0) end tspan = (0.0, 20.0) p = [0.2, 0.04, 20] u0=[u1,u2] prob = ODEProblem(eee!, u0, tspan,p) solve(prob)

ERROR: MethodError: no method matching oneunit(::Type{Any})

Closest candidates are: oneunit(::Type{Union{Missing, T}}) where T @ Base missing.jl:105 oneunit(::Type{T}) where T @ Base number.jl:370 oneunit(::T) where T @ Base number.jl:369 ...

ChrisRackauckas commented 6 months ago

Your issue here is that you don't have a Number element type, you have an array of arrays, which is non-concrete. I recommend turning that array of arrays into a type that has a valid interpretation as a vector, such as as a VectorOfArray from RecursiveArrayTools, or a ComponentArray via ComponentArrays.jl.