Skip to content

Commit ede9bcc

Browse files
committed
Fix mishandling of constants within structural_simplify.
1 parent cc5724b commit ede9bcc

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/systems/systemstructure.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using SymbolicUtils: quick_cancel, similarterm
77
using ..ModelingToolkit
88
import ..ModelingToolkit: isdiffeq, var_from_nested_derivative, vars!, flatten,
99
value, InvalidSystemException, isdifferential, _iszero,
10-
isparameter,
10+
isparameter, isconstant
1111
independent_variables, SparseMatrixCLIL, AbstractSystem,
1212
equations, isirreducible
1313
using ..BipartiteGraphs
@@ -266,7 +266,7 @@ function TearingState(sys; quick_cancel = false, check = true)
266266
for var in vars
267267
_var, _ = var_from_nested_derivative(var)
268268
any(isequal(_var), ivs) && continue
269-
if isparameter(_var) || (istree(_var) && isparameter(operation(_var)))
269+
if isparameter(_var) || (istree(_var) && isparameter(operation(_var)) || isconstant(_var))
270270
continue
271271
end
272272
varidx = addvar!(var)

test/constants.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@ eqs = [D(x) ~ a]
1212
prob = ODEProblem(sys, [0, ], [0.0, 1.0],[])
1313
sol = solve(prob,Tsit5())
1414

15+
# Test structural_simplify handling
16+
eqs = [D(x) ~ t,
17+
w ~ a]
18+
@named sys = ODESystem(eqs)
19+
simp = structural_simplify(sys);
20+
@test isequal(simp.substitutions.subs[1], w~a)
21+

0 commit comments

Comments
 (0)