SciFracX / FractionalDiffEq.jl

Solve Fractional Differential Equations using high performance numerical methods
https://scifracx.github.io/FractionalDiffEq.jl/dev/
MIT License
81 stars 11 forks source link

Example on System of Fractional Differential Equations returned ‘ERROR: LoadError: UndefVarError: `FODEProblem` not defined’ #113

Open sky-y11 opened 4 months ago

sky-y11 commented 4 months ago

My Julia version is 1.9.4 FractionalDiffeq version is 0.3.5

ErikQQY commented 1 month ago

Can you share an MWE? There should not be such errors since all the APIs are all standards now

sky-y11 commented 1 day ago

julia> using FractionalDiffEq

julia> function chua!(du, x, p, t) a, b, c, m0, m1 = p du[1] = a(x[2]-x[1]-(m1x[1]+0.5(m0-m1)(abs(x[1]+1)-abs(x[1]-1)))) du[2] = x[1]-x[2]+x[3] du[3] = -bx[2]-cx[3] end chua! (generic function with 1 method)

julia> α = [0.93, 0.99, 0.92];

julia> x0 = [0.2; -0.1; 0.1];

julia> tspan = (0, 100);

julia> p = [10.725, 10.593, 0.268, -1.1726, -0.7872] 5-element Vector{Float64}: 10.725 10.593 0.268 -1.1726 -0.7872

julia> prob = FODEProblem(chua!, α, x0, tspan, p) ERROR: UndefVarError: FODEProblem not defined Stacktrace: [1] top-level scope @ REPL[11]:1

julia> sol = solve(prob, BDF(), dt=0.01) ERROR: UndefVarError: BDF not defined Stacktrace: [1] top-level scope @ REPL[12]:1

(v1.9) pkg> pin FractionalDiffEq Resolving package versions... Updating F:\Program Files (x86)\julia-pkg\environments\v1.9\Project.toml ⌅ [c7492dd8] ~ FractionalDiffEq v0.3.1 ⇒ v0.3.1 ⚲ Updating F:\Program Files (x86)\julia-pkg\environments\v1.9\Manifest.toml ⌅ [c7492dd8] ~ FractionalDiffEq v0.3.1 ⇒ v0.3.1 ⚲ Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use status --outdated -m

sky-y11 commented 1 day ago

`julia> using FractionalDiffEq, Plots

[ Info: Precompiling Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80] ERROR: LoadError: InitError: could not load library "C:\Users\ASUS.julia\artifacts\09e3c39a42811f9e36aa9071725a5e176004c32d\bin\libfreetype-6.dll"`

ErikQQY commented 22 hours ago

The version of FractionalDiffEq.jl is way too old, could you upgrade the this package to the latest version and then try again?

sky-y11 commented 21 hours ago

`julia> using FractionalDiffEq

julia> function chua!(du, x, p, t) a, b, c, m0, m1 = p du[1] = a(x[2]-x[1]-(m1x[1]+0.5(m0-m1)(abs(x[1]+1)-abs(x[1]-1)))) du[2] = x[1]-x[2]+x[3] du[3] = -bx[2]-cx[3] end chua! (generic function with 1 method)

julia> α = [0.93, 0.99, 0.92];

julia> x0 = [0.2; -0.1; 0.1];

julia> tspan = (0, 100);

julia> p = [10.725, 10.593, 0.268, -1.1726, -0.7872] 5-element Vector{Float64}: 10.725 10.593 0.268 -1.1726 -0.7872

julia> prob = FODEProblem(chua!, α, x0, tspan, p) FODEProblem with uType Vector{Float64} and tType Int64. In-place: true timespan: (0, 100) u0: 3-element Vector{Float64}: 0.2 -0.1 0.1

julia> sol = solve(prob, BDF(), dt=0.01) ERROR: ArgumentError: BDF method is only for commensurate order FODE Stacktrace: [1] init(prob::FODEProblem{…}, alg::BDF; dt::Float64, reltol::Float64, abstol::Float64, maxiters::Int64, kwargs::@Kwargs{}) @ FractionalDiffEq C:\Users\ASUS.julia\packages\FractionalDiffEq\M3BiW\src\fode\bdf.jl:50 [2] init @ C:\Users\ASUS.julia\packages\FractionalDiffEq\M3BiW\src\fode\bdf.jl:40 [inlined] [3] #init_call#40 @ C:\Users\ASUS.julia\packages\DiffEqBase\frOsk\src\solve.jl:530 [inlined] [4] init_call @ C:\Users\ASUS.julia\packages\DiffEqBase\frOsk\src\solve.jl:503 [inlined] [5] #init_up#43 @ C:\Users\ASUS.julia\packages\DiffEqBase\frOsk\src\solve.jl:564 [inlined] [6] init_up @ C:\Users\ASUS.julia\packages\DiffEqBase\frOsk\src\solve.jl:551 [inlined] [7] #init#41 @ C:\Users\ASUS.julia\packages\DiffEqBase\frOsk\src\solve.jl:544 [inlined] [8] init @ C:\Users\ASUS.julia\packages\DiffEqBase\frOsk\src\solve.jl:534 [inlined] [9] solve(::FODEProblem{…}, ::BDF; kwargs::@Kwargs{…}) @ FractionalDiffEq C:\Users\ASUS.julia\packages\FractionalDiffEq\M3BiW\src\FractionalDiffEq.jl:67 [10] solve @ C:\Users\ASUS.julia\packages\FractionalDiffEq\M3BiW\src\FractionalDiffEq.jl:66 [inlined] [11] #solve_call#44 @ C:\Users\ASUS.julia\packages\DiffEqBase\frOsk\src\solve.jl:612 [inlined] [12] solve_call @ C:\Users\ASUS.julia\packages\DiffEqBase\frOsk\src\solve.jl:569 [inlined] [13] #solve_up#53 @ C:\Users\ASUS.julia\packages\DiffEqBase\frOsk\src\solve.jl:1092 [inlined] [14] solve_up @ C:\Users\ASUS.julia\packages\DiffEqBase\frOsk\src\solve.jl:1078 [inlined] [15] #solve#51 @ C:\Users\ASUS.julia\packages\DiffEqBase\frOsk\src\solve.jl:1015 [inlined] [16] top-level scope @ REPL[11]:1 Some type information was truncated. Use show(err) to see complete types.`

在我安装了0.5.0版本后无定义的问题得到了解决,但是BDF()好像是只能求解阶数一样的微分方程

ErikQQY commented 21 hours ago

ERROR: ArgumentError: BDF method is only for commensurate order FODE

是的,BDF算法是只支持同阶次FODE的求解的,你可以尝试一下PECE或者PITrap等算法