You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attached example shows structural_simplify giving ExtraVariablesSystemException.
Describe the bug 🐞
The system has a @mtkmodel Passthrough that simply connects input to output. If this block is removed, the structural_simplify works ok. See the conditional in the connections-definition.
MWE
using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D
using ModelingToolkitStandardLibrary.Blocks: RealInput, RealOutput
@mtkmodel Dec begin@variablesbeginq(t)
end@componentsbegin
input =RealInput()
output =RealOutput()
end@equationsbeginD(q) ~-q +0.1*input.u
output.u ~ q
endend@mtkmodel Passthrough begin@componentsbegin
input =RealInput()
output =RealOutput()
end@equationsbegin
output.u ~ input.u
endend
systems =@namedbegin
dec =Dec()
pt =Passthrough()
end
connections = [
iftrue# failconnect(dec.output, pt.input)
connect(pt.output, dec.input)
else# okconnect(dec.output, dec.input)
end
]
@named sys_full =ODESystem(connections, t; systems)
sys =structural_simplify(sys_full, check_consistency =true)
Error & Stacktrace ⚠️
ERROR: ExtraVariablesSystemException: The system is unbalanced. There are 5 highest order derivative variables and 4 equations.
More variables than equations, here are the potential extra variable(s):dec₊q(t)
pt₊input₊u(t)
Note that the process of determining extra variables is a best-effort heuristic. The true extra variables are dependent on the model and may not be in this list.
Stacktrace:
[1] error_reporting(state::TearingState{…}, bad_idxs::Vector{…}, n_highest_vars::Int64, iseqs::Bool, orig_inputs::Set{…})
@ ModelingToolkit.StructuralTransformations C:\Users\jaakkor2\MyTemp\mtkdebug\packages\ModelingToolkit\yfT8s\src\structural_transformation\utils.jl:50
[2] check_consistency(state::TearingState{ODESystem}, orig_inputs::Set{Any})
@ ModelingToolkit.StructuralTransformations C:\Users\jaakkor2\MyTemp\mtkdebug\packages\ModelingToolkit\yfT8s\src\structural_transformation\utils.jl:85
[3] _structural_simplify!(state::TearingState{…}, io::Nothing; simplify::Bool, check_consistency::Bool, fully_determined::Bool, warn_initialize_determined::Bool, dummy_derivative::Bool, kwargs::@Kwargs{…})
@ ModelingToolkit C:\Users\jaakkor2\MyTemp\mtkdebug\packages\ModelingToolkit\yfT8s\src\systems\systemstructure.jl:692
[4] _structural_simplify!
@ C:\Users\jaakkor2\MyTemp\mtkdebug\packages\ModelingToolkit\yfT8s\src\systems\systemstructure.jl:675 [inlined]
[5] structural_simplify!(state::TearingState{…}, io::Nothing; simplify::Bool, check_consistency::Bool, fully_determined::Bool, warn_initialize_determined::Bool, kwargs::@Kwargs{…})
@ ModelingToolkit C:\Users\jaakkor2\MyTemp\mtkdebug\packages\ModelingToolkit\yfT8s\src\systems\systemstructure.jl:635
[6] __structural_simplify(sys::ODESystem, io::Nothing; simplify::Bool, kwargs::@Kwargs{…})
@ ModelingToolkit C:\Users\jaakkor2\MyTemp\mtkdebug\packages\ModelingToolkit\yfT8s\src\systems\systems.jl:85
[7] __structural_simplify
@ C:\Users\jaakkor2\MyTemp\mtkdebug\packages\ModelingToolkit\yfT8s\src\systems\systems.jl:66 [inlined]
[8] structural_simplify(sys::ODESystem, io::Nothing; simplify::Bool, split::Bool, allow_symbolic::Bool, allow_parameter::Bool, conservative::Bool, fully_determined::Bool, kwargs::@Kwargs{…})
@ ModelingToolkit C:\Users\jaakkor2\MyTemp\mtkdebug\packages\ModelingToolkit\yfT8s\src\systems\systems.jl:24
[9] structural_simplify
@ C:\Users\jaakkor2\MyTemp\mtkdebug\packages\ModelingToolkit\yfT8s\src\systems\systems.jl:20 [inlined]
[10] top-level scope
@ REPL[11]:1
Some type information was truncated. Use `show(err)` to see complete types.
but dec₊q(t) and pt₊input₊u(t) should be the same since in Decoutput.u ~ q and connect(dec.output, pt.input).
Environment (please complete the following information):
Latest ModelingToolkit and ModelingToolkitStandardLibrary
Output of using Pkg; Pkg.status()
Status `C:\Users\jaakkor2\MyTemp\mtkdebug\environments\v1.10\Project.toml`
[961ee093] ModelingToolkit v9.36.0
[16a59e39] ModelingToolkitStandardLibrary v2.11.0
Output of using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
Attached example shows
structural_simplify
givingExtraVariablesSystemException
.Describe the bug 🐞
The system has a
@mtkmodel Passthrough
that simply connects input to output. If this block is removed, thestructural_simplify
works ok. See the conditional in theconnections
-definition.MWE
Error & Stacktrace⚠️
but
dec₊q(t)
andpt₊input₊u(t)
should be the same since inDec
output.u ~ q
andconnect(dec.output, pt.input)
.Environment (please complete the following information):
Latest ModelingToolkit and ModelingToolkitStandardLibrary
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
The text was updated successfully, but these errors were encountered: