@@ -34,7 +34,7 @@ pendulum = ODESystem(eqs, t, [x, y, w, z, T], [L, g], name=:pendulum)
34
34
pendulum = initialize_system_structure (pendulum)
35
35
sss = structure (pendulum)
36
36
@unpack graph, fullvars, varassoc = sss
37
- @test StructuralTransformations. matching (sss, varassoc .== 0 ) == map (x -> x == 0 ? StructuralTransformations. UNASSIGNED : x, [1 , 0 , 2 , 0 , 3 , 4 , 0 , 0 , 0 ])
37
+ @test StructuralTransformations. matching (sss, varassoc .== 0 ) == map (x -> x == 0 ? StructuralTransformations. UNASSIGNED : x, [0 , 1 , 0 , 0 , 2 , 0 , 3 , 0 , 4 ])
38
38
39
39
sys, assign, eqassoc = StructuralTransformations. pantelides! (pendulum)
40
40
sss = structure (sys)
@@ -48,18 +48,8 @@ scc = StructuralTransformations.find_scc(graph, assign)
48
48
[6 ],
49
49
]
50
50
51
- @test graph. fadjlist == sort .([
52
- [1 , 2 ],
53
- [3 , 4 ],
54
- [5 , 6 , 7 ],
55
- [6 , 8 , 9 ],
56
- [7 , 9 ],
57
- [1 , 3 , 7 , 9 ],
58
- [1 , 2 , 5 , 10 ],
59
- [3 , 4 , 8 , 11 ],
60
- [1 , 3 , 7 , 9 , 10 , 11 ],
61
- ])
62
- @test varassoc == [10 , 5 , 11 , 8 , 0 , 0 , 1 , 0 , 3 , 0 , 0 ]
51
+ @test graph. fadjlist == sort .([[1 , 2 ], [4 , 5 ], [3 , 7 , 8 ], [6 , 7 , 9 ], [3 , 6 ], [2 , 3 , 5 , 6 ], [1 , 2 , 8 , 10 ], [4 , 5 , 9 , 11 ], [2 , 3 , 5 , 6 , 10 , 11 ]])
52
+ @test varassoc == [8 , 10 , 2 , 9 , 11 , 5 , 0 , 0 , 0 , 0 , 0 ]
63
53
# 1: D(x) ~ w
64
54
# 2: D(y) ~ z
65
55
# 3: D(w) ~ T*x
@@ -100,22 +90,24 @@ using LinearAlgebra
100
90
prob = ODEProblem (ODEFunction (first_order_idx1_pendulum),
101
91
# [x, y, w, z, xˍt, yˍt, T]
102
92
[1 , 0 , 0 , 0 , 0 , 0 , 0.0 ],# 0, 0, 0, 0],
103
- (0 , 100 .0 ),
93
+ (0 , 10 .0 ),
104
94
[1 , 9.8 ],
105
95
mass_matrix= calculate_massmatrix (first_order_idx1_pendulum))
106
96
sol = solve (prob, Rodas5 ());
107
97
# plot(sol, vars=(1, 2))
108
98
109
99
new_sys = dae_index_lowering (ModelingToolkit. ode_order_lowering (pendulum2))
110
100
111
- prob_auto = ODEProblem (ODEFunction (new_sys),
112
- # [xˍt, yˍt, x, y, T]
113
- [0 , 0 , 1 , 0 , 0.0 ],# 0, 0, 0, 0],
114
- (0 , 100.0 ),
115
- [1 , 9.8 ],
116
- mass_matrix= calculate_massmatrix (new_sys))
101
+ prob_auto = ODEProblem (new_sys,
102
+ [D (x)=> 0 ,
103
+ D (y)=> 0 ,
104
+ x=> 1 ,
105
+ y=> 0 ,
106
+ T=> 0.0 ],
107
+ (0 , 100.0 ),
108
+ [1 , 9.8 ])
117
109
sol = solve (prob_auto, Rodas5 ());
118
- # plot(sol, vars=(3, 4 ))
110
+ # plot(sol, vars=(x, y ))
119
111
120
112
# Define some variables
121
113
@parameters t L g
@@ -146,7 +138,7 @@ p = [
146
138
g => 9.8
147
139
]
148
140
149
- prob_auto = ODEProblem (new_sys,u0,(0.0 ,100 .0 ),p)
141
+ prob_auto = ODEProblem (new_sys,u0,(0.0 ,10 .0 ),p)
150
142
sol = solve (prob_auto, Rodas5 ());
151
143
# plot(sol, vars=(D(x), y))
152
144
0 commit comments