Skip to content

Cannot initialize system with default that depends on observed variable #2792

@hersle

Description

@hersle

I expect this to work:

using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D
@variables x(t) y(t) z(t)
@mtkbuild sys = ODESystem([
    D(x) ~ 0.0
    D(y) ~ 0.0
    z ~ 2.0
], t; defaults = [y => z])
prob = ODEProblem(sys, [x => 1.0], (0.0, 1.0), [])

I specified x => 1.0, and the default should make y => z ~ 2.0. But (on master) it fails with

ERROR: LoadError: ArgumentError: Any[z(t)] are either missing from the variable map or missing from the system's unknowns/parameters list.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions