Structural_simplify unexpected ERROR when applied twice in a row

I mentioned this on slack, but I took me a while to create an MWE, so I’m posting it here again.

Here is the MWE:

using ModelingToolkit
@variables t u(t)[1:2] 
eqs = [u[1] ~ 1
        D(u[2]) ~ u[1]-u[2]]

@named sys = ODESystem(eqs) #Model sys with 2 equations
sys = structural_simplify(sys) #Model sys with 1 equations
sys = structural_simplify(sys) #ERROR: ExtraVariablesSystemException...

The error is

ERROR: ExtraVariablesSystemException: The system is unbalanced. There are 2 highest order derivative variables and 1 equations.
More variables than equations, here are the potential extra variable(s):
 [5] structural_simplify(sys::ODESystem, io::Nothing; simplify::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ ModelingToolkit C:\Users\*\.julia\packages\ModelingToolkit\QxF9d\src\systems\systems.jl:39 [6] structural_simplify (repeats 2 times)
   @ C:\Users\*\.julia\packages\ModelingToolkit\QxF9d\src\systems\systems.jl:19 [inlined]
 [7] top-level scope

I was informed on slack that this error is not expected, but is it a problem? I guess there isnt really a reason to use structural_simplify in this way, should I open an Issue anyway?

Open an issue.

1 Like

Okay thanks.