Skip to content

structural_simplify on DiscreteSystem says "this should never happen" #1166

Closed
@pepijndevos

Description

@pepijndevos

I can't really find much documentation on DiscreteSystem, except the example inside the docstring.

It seems that every LHS variable is treated as t+1, while I also want to have algebraic equations. I figured if I'd structural simplify the system it might simplify the algebraic equations leaving only the difference equations. But instead it just throws an exception.

using ModelingToolkit

@parameters t σ ρ β
@variables x(t) y(t) z(t) next_x(t) next_y(t) next_z(t)

eqs = [next_x ~ σ*(y-x),
       next_y ~ x*-z)-y,
       next_z ~ x*y - β*z]

de = DiscreteSystem(eqs,t,[x,y,z],[σ,ρ,β])
structural_simplify(de)
ERROR: LoadError: This should never happen. Trying to set DataType with NamedTuple{(:structure,), Tuple{SystemStructure}}.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33
  [2] #s58#28
    @ ~/.julia/packages/ModelingToolkit/yGWxM/src/systems/abstractsystem.jl:200 [inlined]
  [3] var"#s58#28"(::Any, obj::Any, patch::Any)
    @ ModelingToolkit ./none:0
  [4] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any, N} where N)
    @ Core ./boot.jl:571
  [5] set
    @ ~/.julia/packages/Setfield/NshXm/src/lens.jl:110 [inlined]
  [6] macro expansion
    @ ~/.julia/packages/Setfield/NshXm/src/sugar.jl:192 [inlined]
  [7] initialize_system_structure(sys::DiscreteSystem)
    @ ModelingToolkit.SystemStructures ~/.julia/packages/ModelingToolkit/yGWxM/src/systems/systemstructure.jl:198
  [8] alias_elimination(sys::DiscreteSystem)
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/yGWxM/src/systems/alias_elimination.jl:6
  [9] structural_simplify(sys::DiscreteSystem)
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/yGWxM/src/systems/abstractsystem.jl:767
 [10] top-level scope
    @ ~/code/juliacomp/symbolichdl.jl/src/discrete.jl:18
in expression starting at /home/pepijn/code/juliacomp/symbolichdl.jl/src/discrete.jl:18

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