SciFracX / FractionalDiffEq.jl

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

FDDESystem with multiple lags #77

Open finmod opened 1 year ago

finmod commented 1 year ago

The delayChen is running fine whereas the delaySolow gives the following error:

#using FractionalDiffEq, Plots
#α=[0.94, 0.94, 0.94]; ϕ=[0.2, 0, 0.5]; τ=0.009; T=1.4; h=0.001
#function delaychen!(dy, y, ϕ, t)
#   a=35; b=3; c=27
#   dy[1] = a*(y[2]-ϕ[1])
#   dy[2] = (c-a)*ϕ[1]-y[1]*y[3]+c*y[2]
#   dy[3] = y[1]*y[2]-b*ϕ[3]
#end
#prob = FDDESystem(delaychen!, ϕ, α, τ, T)
#sol=solve(prob, h, DelayABM())

# Solow model with time delay FDDESystem
using FractionalDiffEq, Plots
q = [0.7, 0.7, 0.7]           # order 
ϕ = [4.0152, 0.1383, 1.7788]  # initial value of delayed variable
τ = [0., 2.0, 0.]             # delays
tspan = (0., 150)              # final time
h = 0.01                      # step length

function delaysolow!(dy, y, ϕ, t)
    α = 0.6; p = 0.06; w = 0.
    dy[1] = 0.05*(1.0 - ϕ[1]/8.)*ϕ[1]
    dy[2] = 0.4*y[3]*y[2]^(α)*y[1]^(1-α) - 0.2*ϕ[2]
    dy[3] = p*ϕ[3] + w*ϕ[1] + h*ϕ[2]
end
prob = FDDESystem(delaysolow!, ϕ, q, τ, tspan)

image

finmod commented 1 year ago

This example is from: https://www.mdpi.com/2504-3110/5/3/74

ErikQQY commented 1 year ago

Hi there! Thanks for pointing this out!

I think this error is caused by the multiple delays. Currently, FractionalDiffEq.jl doesn't support solving FDDE system with multiple lags, it only supports FDDEProblem with multiple lags or FDDESystem with one lag.

Very sorry for the error, I will add this feature in the future.

finmod commented 1 year ago

Ok.

For this particular example, one delay would be good enough for the second variable y[2]. I was not quite sure how to frame this so I put three delays with two of them set to zero. Showing that FDDE works on this example with one delay would be perfect for now. In short, this example is multiple order system with one delay. Next will be multiple order with multiple delays.

ErikQQY commented 1 year ago

Yeah, multiple order with multiple delays FDDE solving would greatly enrich FractionalDiffEq.jl.