Skip to content

Commit b12c23c

Browse files
committed
Test consistency check
1 parent f3e1283 commit b12c23c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/systems/systemstructure.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function initialize_system_structure(sys)
9090
eqs = copy(equations(sys))
9191
neqs = length(eqs)
9292
algeqs = trues(neqs)
93-
dervaridxs = Int[]
93+
dervaridxs = Set{Int}()
9494
var2idx = Dict{Any,Int}()
9595
symbolic_incidence = []
9696
fullvars = []
@@ -141,6 +141,7 @@ function initialize_system_structure(sys)
141141
end
142142

143143
# sort `fullvars` such that the mass matrix is as diagonal as possible.
144+
dervaridxs = collect(dervaridxs)
144145
sorted_fullvars = OrderedSet(fullvars[dervaridxs])
145146
for dervaridx in dervaridxs
146147
dervar = fullvars[dervaridx]

test/reduction.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,19 @@ A = reshape(1:N^2, N, N)
212212
eqs = xs .~ A * xs
213213
sys′ = NonlinearSystem(eqs, xs, [])
214214
sys = structural_simplify(sys′)
215+
216+
# issue 958
217+
@parameters t k₁ k₂ k₋₁ E₀
218+
@variables E(t) C(t) S(t) P(t)
219+
D = Differential(t)
220+
221+
equations = [
222+
D(E) ~ k₋₁ * C - k₁ * E * S
223+
D(C) ~ k₁ * E * S - k₋₁ * C - k₂ * C
224+
D(S) ~ k₋₁ * C - k₁ * E * S
225+
D(P) ~ k₂ * C
226+
E₀ ~ E + C
227+
]
228+
229+
@named sys = ODESystem(equations, t, [E, C, S, P], [k₁, k₂, k₋₁, E₀])
230+
@test_throws ModelingToolkit.InvalidSystemException structural_simplify(sys)

0 commit comments

Comments
 (0)