Skip to content

Commit 7f29017

Browse files
fix: error when simplified discrete system contains algebraic equations
1 parent 3f67126 commit 7f29017

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Diff for: src/systems/systems.jl

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ function structural_simplify(
2626
else
2727
newsys = newsys′
2828
end
29+
if newsys isa DiscreteSystem &&
30+
any(eq -> symbolic_type(eq.lhs) == NotSymbolic(), equations(newsys))
31+
error("""
32+
Encountered algebraic equations when simplifying discrete system. This is \
33+
not yet supported.
34+
""")
35+
end
2936
if newsys isa ODESystem || has_parent(newsys)
3037
@set! newsys.parent = complete(sys; split)
3138
end

Diff for: test/discrete_system.jl

+6
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,9 @@ function System(; name, buffer)
265265
end
266266

267267
@test_nowarn @mtkbuild sys = System(; buffer = ones(10))
268+
269+
# Ensure discrete systems with algebraic equations throw
270+
@variables x(t) y(t)
271+
k = ShiftIndex(t)
272+
@named sys = DiscreteSystem([x ~ x^2 + y^2, y ~ x(k - 1) + y(k - 1)], t)
273+
@test_throws ["algebraic equations", "not yet supported"] structural_simplify(sys)

0 commit comments

Comments
 (0)