FractionalDiffEq.jl icon indicating copy to clipboard operation
FractionalDiffEq.jl copied to clipboard

BoundsError

Open moeinkh88 opened this issue 2 years ago • 3 comments

Hi

When I want to solve a problem in example chua or Brusselator:

result = solve(prob, h, NonLinearAlg())
result = solve(prob, h, GL())

there is a BoundsError. It happens because

tspan in lines 15-16 in Nonlinear.jl and lines 19-20 in GL.jl is only a number (100) rather than a time span.

    @unpack f, α, u0, tspan = prob
    t0 = tspan[1]; T = tspan[2]

I couldn't track the bug why it is not a time span!

moeinkh88 avatar Jun 08 '22 11:06 moeinkh88

That is very weird, can you provide the program and the version of FractionalDiffEq.jl you are using?

ErikQQY avatar Jun 08 '22 14:06 ErikQQY

If I want to install the package because of some compatibility issues the usable version is v0.2.0. So I have cloned the package to have the last version, v0.2.6.

Then, for example, I have tested the Brusselator.jl from the examples folder:

using FractionalDiffEq, Plots

α = [0.8, 0.8]
u0 = [0.2, 0.03]
h = 0.001

function Brusselator!(du, u, p, t)
    a, μ = 1, 4
    du[1] = a-(μ+1)*u[1]+(u[1])^2*u[2]
    du[2] = μ*u[1]-(u[1])^2*u[1]
end

prob = FODESystem(Brusselator!, α, u0, 100)
result = solve(prob, h, GL())

# Phase plane
plot(result[:, 1], result[:, 2])

# Time plane
plot(collect(0:h:100), result[:, 1])
plot!(collect(0:h:100), result[:, 2])

I got this error:

BoundsError
in eval at [base/boot.jl:360](https://github.com/SciFracX/FractionalDiffEq.jl/issues/39#) 
in top-level scope at [Brusselator.jl:14](https://github.com/SciFracX/FractionalDiffEq.jl/issues/39#)
in solve at [2.6/FractionalDiffEq.jl/src/fodesystem/GLWithMemory.jl:27](https://github.com/SciFracX/FractionalDiffEq.jl/issues/39#)
in getindex at [base/number.jl:96](https://github.com/SciFracX/FractionalDiffEq.jl/issues/39#)

BTW, when I run prob = FODESystem(Brusselator!, α, u0, 100) I get the following weird outcomes in REPL:

[0.8, 0.8]
timespan: 100
u0: [0.2, 0.03]
FODESystem with order [0.8, 0.8]
timespan: 100
u0: [0.2, 0.03]
FODESystem with order [0.8, 0.8]
timespan: 100
u0: [0.2, 0.03]

moeinkh88 avatar Jun 09 '22 09:06 moeinkh88

Sorry for the problems, there are a lot of refactoring recently, we should pass the time span as a Tuple to the problem definition: https://github.com/SciFracX/FractionalDiffEq.jl#system-of-fractional-differential-equations

prob = FODESystem(Brusselator!, α, u0, (0, 100))

the Brusselator example file has not been updated

ErikQQY avatar Jun 09 '22 14:06 ErikQQY

All the FODE solvers have been refactored, everything is fine now, so I am closing this issue, if there are still some problems, please let me know

ErikQQY avatar Jun 01 '24 12:06 ErikQQY