@@ -35,6 +35,9 @@ edges, vars, vars_asso = sys2bigraph(pendulum)
35
35
36
36
edges, assign, vars_asso, eqs_asso = ModelingToolkit. pantelides (pendulum)
37
37
38
+ function new_system (sys, assign, vars_asso, eqs_asso)
39
+ end
40
+
38
41
@test sort .(edges) == sort .([
39
42
[5 , 3 ], # 1
40
43
[6 , 4 ], # 2
@@ -47,7 +50,7 @@ edges, assign, vars_asso, eqs_asso = ModelingToolkit.pantelides(pendulum)
47
50
[2 , 1 , 6 , 5 , 11 , 10 ], # 9
48
51
])
49
52
# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
50
- # [x, y, w, z, x', y', w', z', T, x'', y'']
53
+ # [x, y, w, z, x', y', w', z', T, x'', y''] -- how can I get this vector of symbols?
51
54
@test vars_asso == [5 , 6 , 7 , 8 , 10 , 11 , 0 , 0 , 0 , 0 , 0 ]
52
55
# 1: D(x) ~ w
53
56
# 2: D(y) ~ z
@@ -61,3 +64,38 @@ edges, assign, vars_asso, eqs_asso = ModelingToolkit.pantelides(pendulum)
61
64
# 9: D(6) -> 0 ~ 2xx'' + 2x'x' + 2yy'' + 2y'y'
62
65
# [1, 2, 3, 4, 5, 6, 7, 8, 9]
63
66
@test eqs_asso == [7 , 8 , 0 , 0 , 6 , 9 , 0 , 0 , 0 ]
67
+
68
+ using ModelingToolkit
69
+ @parameters t L g
70
+ @variables x (t) y (t) w (t) z (t) T (t) xˍt (t) yˍt (t)
71
+ @derivatives D' ~ t
72
+ idx1_pendulum = [D (x) ~ w,
73
+ D (y) ~ z,
74
+ D (w) ~ T* x,
75
+ D (z) ~ T* y - g,
76
+ # 0 ~ x^2 + y^2 - L^2,
77
+ # 0 ~ 2x*w + 2y*z,
78
+ # D(xˍt) ~ D(w),
79
+ D (xˍt) ~ T* x,
80
+ # D(D(x)) ~ D(w) and substitute the rhs
81
+ # D(D(x)) ~ T*x,
82
+ # D(D(y)) ~ D(z) and substitute the rhs
83
+ # D(D(y)) ~ T*y - g,
84
+ D (yˍt) ~ T* y - g,
85
+ # 2x*D(D(x)) + 2*D(x)*D(x) + 2y*D(D(y)) + 2*D(y)*D(y) and
86
+ # substitute the rhs
87
+ 0 ~ 2 x* (T* x) + 2 * xˍt* xˍt + 2 y* (T* y - g) + 2 * yˍt* yˍt]
88
+ idx1_pendulum = ODESystem (idx1_pendulum, t, [x, y, w, z, xˍt, yˍt, T], [L, g])
89
+ first_order_idx1_pendulum = ode_order_lowering (idx1_pendulum)
90
+
91
+ using OrdinaryDiffEq
92
+ using LinearAlgebra
93
+ # [x, y, w, z, xˍt, yˍt, T]
94
+ # M = Diagonal([1, 1, 1, 1, 1, 1, 0])
95
+ prob = ODEProblem (ODEFunction (first_order_idx1_pendulum),
96
+ # [x, y, w, z, xˍt, yˍt, T]
97
+ [1 , 0 , 0 , 0 , 0 , 0 , 0.0 ],# 0, 0, 0, 0],
98
+ (0 , 100.0 ),
99
+ [1 , 9.8 ],
100
+ mass_matrix= calculate_massmatrix (first_order_idx1_pendulum))
101
+ sol = solve (prob, Rodas5 ())
0 commit comments