Skip to content

Add DDE support in System #2207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 12, 2023
Merged

Add DDE support in System #2207

merged 7 commits into from
Jul 12, 2023

Conversation

YingboMa
Copy link
Member

@YingboMa YingboMa commented Jul 10, 2023

@parameters p0=0.2 p1=0.2 q0=0.3 q1=0.3 v0=1 v1=1 d0=5 d1=1 d2=1 beta0=1 beta1=1
@variables t x₀(t) x₁(t) x₂(..)
tau = 1
D = Differential(t)
eqs = [D(x₀) ~ (v0 / (1 + beta0 * (x₂(t - tau)^2))) * (p0 - q0) * x₀ - d0 * x₀
    D(x₁) ~ (v0 / (1 + beta0 * (x₂(t - tau)^2))) * (1 - p0 + q0) * x₀ +
            (v1 / (1 + beta1 * (x₂(t - tau)^2))) * (p1 - q1) * x₁ - d1 * x₁
    D(x₂(t)) ~ (v1 / (1 + beta1 * (x₂(t - tau)^2))) * (1 - p1 + q1) * x₁ - d2 * x₂(t)]
@named sys = System(eqs)
prob = DDEProblem(sys,
    [x₀ => 1.0, x₁ => 1.0, x₂(t) => 1.0],
    tspan,
    constant_lags = [tau])
sol_mtk = solve(prob, alg, reltol = 1e-7, abstol = 1e-10)
@test sol_mtk.u[end]  sol.u[end]
prob2 = DDEProblem(sys,
    [x₀ => 1.0 - t * q1, x₁ => 1.0 - t * q1, x₂(t) => 1.0 - t * q1],
    tspan,
    constant_lags = [tau])
sol2_mtk = solve(prob2, alg, reltol = 1e-7, abstol = 1e-10)

now works. See test/dde.jl for more details.

DDEProblem{true}(sys, args...; kwargs...)
end
function DiffEqBase.DDEProblem{iip}(sys::AbstractODESystem, u0map = [],
h = (u, p) -> zeros(length(states(sts))),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bold assumption. yeah we'll need to have some way to give a history function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's a positional argument before something with a default, it must also have a default.

@ChrisRackauckas
Copy link
Member

What is your planned representation for passing symbolic history functions? Just if the default value is a symbolic expression?

@YingboMa
Copy link
Member Author

Yeah, since h(p, 0) is just u0, right?

@ChrisRackauckas
Copy link
Member

Yes, so okay just wanted to double check.

@YingboMa YingboMa changed the title Add basic DDE support in System Add DDE support in System Jul 11, 2023
@ChrisRackauckas ChrisRackauckas merged commit e63aad0 into master Jul 12, 2023
@ChrisRackauckas ChrisRackauckas deleted the myb/dde branch July 12, 2023 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants