Skip to content

Modelingtoolkitize doesn't work if parameters are kept in a named tuple or struct #361

Open
@pcjentsch

Description

@pcjentsch

I know this isn't supposed to work right now, but it would be nice to have!

example:

using OrdinaryDiffEq
using ModelingToolkit
p = (a = 1.01,)
f(u,p,t) = p.a*u
u0 = 1/2
tspan = (0.0,1.0)
prob = ODEProblem(f,u0,tspan,p)
mtk_prob = modelingtoolkitize(prob)

gives

ERROR: LoadError: KeyError: key 'a' not found

and with structs

using OrdinaryDiffEq
using ModelingToolkit
using Parameters
@with_kw struct parameter_struct
    a = 1.01
end
p = parameter_struct()
f(u,p,t) = p.a*u
u0 = 1/2
tspan = (0.0,1.0)
prob = ODEProblem(f,u0,tspan,p)
mtk_prob = modelingtoolkitize(prob)
ERROR: LoadError: MethodError: no method matching keys(::parameter_struct)
Closest candidates are:
  keys(::Core.SimpleVector) at essentials.jl:605
  keys(::Cmd) at process.jl:639  
  keys(::LibGit2.GitTree) at C:\Users\peter\.julia\packages\Revise\AMRie\src\git.jl:52
  ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions