Skip to content
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

Error when initializing iterator for SteadyStateProblem with DynamicSS and Dual numbers #918

Open
harisorgn opened this issue Dec 7, 2022 · 1 comment

Comments

@harisorgn
Copy link

harisorgn commented Dec 7, 2022

MWE :

using ModelingToolkit
using DifferentialEquations
using Turing
using ForwardDiff
using ForwardDiff: Dual

@variables begin
    t
    y1(t) = 1.0
    y2(t) = 0.0
    y3(t) = 0.0
    y4(t) = 0.0
    y5(t) = 0.0
    y6(t) = 0.0
    y7(t) = 0.0
    y8(t) = 0.0057
end

@parameters begin
    k1 = 1.71
    k2 = 280.0
    k3 = 8.32
    k4 = 0.69
    k5 = 0.43
    k6 = 1.81
end

D = Differential(t)
eqs = [
    D(y1) ~ (-k1*y1 + k5*y2 + k3*y3 + 0.0007),
    D(y2) ~ (k1*y1 - 8.75*y2),
    D(y3) ~ (-10.03*y3 + k5*y4 + 0.035*y5),
    D(y4) ~ (k3*y2 + k1*y3 - 1.12*y4),
    D(y5) ~ (-1.745*y5 + k5*y6 + k5*y7),
    D(y6) ~ (-k2*y6*y8 + k4*y4 + k1*y5 - k5*y6 + k4*y7),
    D(y7) ~ (k2*y6*y8 - k6*y7),
    D(y8) ~ (-k2*y6*y8 + k6*y7)
]

@named model = ODESystem(eqs)

u0 = [
    Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}}(1.8983788068509213,0.6970981087506788,0.0,0.0,0.0,0.0,0.0,0.0),
    Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}}(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0),
    Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}}(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0),
    Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}}(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0),
    Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}}(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0),
    Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}}(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0),
    Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}}(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0),
    Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}}(0.0057,0.0,0.0,0.0,0.0,0.0,0.0,0.0)
]

p = [
    Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}}(1.5174072564237708,0.0,0.38355212192378396,0.0,0.0,0.0,0.0,0.0),
    Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}}(0.43,0.0,0.0,0.0,0.0,0.0,0.0,0.0),
    Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}}(8.32,0.0,0.0,0.0,0.0,0.0,0.0,0.0),
    Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}}(268.1197063467946,0.0,0.0,44.91823438292696,0.0,0.0,0.0,0.0),
    Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}}(0.69,0.0,0.0,0.0,0.0,0.0,0.0,0.0),
    Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}}(20.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0)
]

prob = SteadyStateProblem(model, u0, p)
alg = DynamicSS(QNDF())
int = init(prob, alg)

gives

ERROR: The chosen algorithm, SSRootfind{SteadyStateDiffEq.var"#2#4"}(SteadyStateDiffEq.var"#2#4"()), does not exist. Please verify that the appropriate solver package has been installed.

Top of stack trace is a call to

function DiffEqBase.__init(prob::DiffEqBase.DEProblem,
alg::Union{Nothing, DiffEqBase.DEAlgorithm},
args...; default_set = false, kwargs...)

This dispatch on alg::DiffEqBase.DEAlgorithm seems too wide and DynamicSS is treated like the recently deprecated SSRootfind?

Same behavior no matter what ODESolver I use inside DynamicSS (tried Tsit5 and TRBDF2).

cc @SebastianM-C

@ChrisRackauckas
Copy link
Member

SSRootfind{SteadyStateDiffEq.var"#2#4"} Odd, SSRootfind shouldn't be involved at all. But I don't think init is defined on DynamicSS so that's probably the root cause here. It shouldn't be falling back to the default algorithm handling though, that's a bit odd so indeed it needs to be tightened.

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

No branches or pull requests

2 participants