Skip to content

ModelingToolkit broken for SteadyStateProblems #322

@jd-lara

Description

@jd-lara

There is no way of solving SteadyState problems with ModelingToolKit. Here are two ways I tried and they return different errors

MWE

using ModelingToolkit
using DiffEqBase
using SteadyStateDiffEq
using LinearAlgebra

@parameters t σ ρ β
@variables x(t) y(t) z(t)
@derivatives D'~t

eqs = [D(D(x)) ~ σ*(y-x),
       D(y) ~ x*-z)-y,
       D(z) ~ x*y - β*z]

sys = ODESystem(eqs)
sys = ode_order_lowering(sys)

u0 = [D(x) => 2.0,
      x => 1.0,
      y => 0.0,
      z => 0.0]

p  ==> 28.0,
      ρ => 10.0,
      β => 8/3]

First try

prob =  SteadyStateProblem(sys, u0, p, mass_matrix=LinearAlgebra.I)
solve(prob, SSRootfind())

julia> solve(prob, SSRootfind())
ERROR: MethodError: no method matching Pair{Operation,Float64}(::Float64)
Closest candidates are:
  Pair{Operation,Float64}(::Any, ::Any) where {A, B} at pair.jl:7
Stacktrace:
 [1] alloc_DF(::Array{Pair{Operation,Float64},1}, ::Array{Pair{Operation,Float64},1}) at /Users/jdlara/.julia/packages/NLSolversBase/mGaJg/src/objective_types/abstract.jl:19
 [2] nlsolve(::Function, ::Array{Pair{Operation,Float64},1}; method::Symbol, autodiff::Symbol, inplace::Bool, kwargs::Base.Iterators.Pairs{Symbol,Float64,Tuple{Symbol},NamedTuple{(:ftol,),Tuple{Float64}}}) at /Users/jdlara/.julia/packages/NLsolve/ZBTu4/src/nlsolve/nlsolve.jl:49
 [3] (::SteadyStateDiffEq.var"#2#4")(::Function, ::Array{Pair{Operation,Float64},1}, ::Float64) at /Users/jdlara/.julia/packages/SteadyStateDiffEq/q0UMK/src/algorithms.jl:6
 [4] __solve(::SteadyStateProblem{Array{Pair{Operation,Float64},1},true,Array{Pair{Operation,Float64},1},ODEFunction{true,ModelingToolkit.var"#f#84"{GeneralizedGenerated.NGG.RuntimeFn{TypeEncoding(list(##MTKArg#255, ##MTKArg#256, ##MTKArg#257)),TypeEncoding(nil(GeneralizedGenerated.NGG.Argument)),TypeEncoding(begin

Second try

prob = ODEProblem(sys,u0,(0.0,10.0),p)
ss_prob = SteadyStateProblem(prob)
solve(prob, SSRootfind())

ERROR: Default algorithm choices require DifferentialEquations.jl. Please specify an algorithm or import DifferentialEquations directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions