Skip to content

Commit 95fbfb1

Browse files
committed
Add comments on tests
1 parent 0e80ccb commit 95fbfb1

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/systems/diffeqs/index_reduction.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,5 @@ function pantelides!(edges, vars, vars_asso)
158158
end # if !pathfound
159159
end # while !pathfound
160160
end # for k in 1:neqs′
161-
return assign, vars_asso, eqs_asso
161+
return edges, assign, vars_asso, eqs_asso
162162
end

test/index_reduction.jl

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,31 @@ pendulum = ODESystem(eqs, t, [x, y, w, z, T], [L, g], name=:pendulum)
3333
edges, vars, vars_asso = sys2bigraph(pendulum)
3434
@test ModelingToolkit.matching(edges, length(vars), vars_asso .== 0) == [0, 0, 0, 0, 1, 2, 3, 4, 0]
3535

36-
@test ModelingToolkit.pantelides(pendulum) == ([0, 0, 0, 0, 1, 2, 3, 8, 4, 7, 9], [5, 6, 7, 8, 10, 11, 0, 0, 0, 0, 0], [7, 8, 0, 0, 6, 9, 0, 0, 0])
36+
edges, assign, vars_asso, eqs_asso = ModelingToolkit.pantelides(pendulum)
37+
38+
@test edges == [
39+
[5, 3], # 1
40+
[6, 4], # 2
41+
[7, 9, 1], # 3
42+
[8, 9, 2], # 4
43+
[2, 1], # 5
44+
[2, 1, 6, 5], # 6
45+
[5, 3, 10, 7], # 7
46+
[6, 4, 11, 8], # 8
47+
[2, 1, 6, 5, 11, 10], # 9
48+
]
49+
# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
50+
# [x, y, w, z, x', y', w', z', T, x'', y'']
51+
@test vars_asso == [5, 6, 7, 8, 10, 11, 0, 0, 0, 0, 0]
52+
#1: D(x) ~ w
53+
#2: D(y) ~ z
54+
#3: D(w) ~ T*x
55+
#4: D(z) ~ T*y - g
56+
#5: 0 ~ x^2 + y^2 - L^2
57+
# ----
58+
#6: D(5) -> 0 ~ 2xx'+ 2yy'
59+
#7: D(1) -> D(D(x)) ~ D(w)
60+
#8: D(2) -> D(D(y)) ~ D(z)
61+
#9: D(6) -> 0 ~ 2xx'' + 2x'x' + 2yy'' + 2y'y'
62+
# [1, 2, 3, 4, 5, 6, 7, 8, 9]
63+
@test eqs_asso == [7, 8, 0, 0, 6, 9, 0, 0, 0]

0 commit comments

Comments
 (0)