@@ -41,14 +41,30 @@ using ModelingToolkit, OrdinaryDiffEq, Test
41
41
42
42
@named model = ODESystem (connections, t, systems= [ground, voltage_step, source, R1, L1, emf, fixed, load, load_step, inertia, friction])
43
43
sys = structural_simplify (model)
44
- prob = ODAEProblem (sys, Pair[], (0 , 6.0 ))
45
- sol = solve (prob, Rodas4 ())
46
44
45
+ @test_broken prob = ODAEProblem (sys, Pair[], (0 , 6.0 ))
46
+ @test_skip begin
47
+ sol = solve (prob, Rodas4 ())
48
+ @test sol. retcode == :Success
49
+ # EMF equations
50
+ @test - 0.5 .* sol[emf. i] == sol[emf. flange. tau]
51
+ @test sol[emf. v] == 0.5 .* sol[emf. w]
52
+ # test steady-state values
53
+ dc_gain = [f/ (k^ 2 + f* R) k/ (k^ 2 + f* R); k/ (k^ 2 + f* R) - R/ (k^ 2 + f* R)]
54
+ idx_t = findfirst (sol. t .> 2.5 )
55
+ @test sol[inertia. w][idx_t] ≈ (dc_gain* [V_step; 0 ])[2 ]
56
+ @test sol[emf. i][idx_t] ≈ (dc_gain* [V_step; 0 ])[1 ]
57
+ idx_t = findfirst (sol. t .> 5.5 )
58
+ @test sol[inertia. w][idx_t] ≈ (dc_gain* [V_step; - tau_L_step])[2 ]
59
+ @test sol[emf. i][idx_t] ≈ (dc_gain* [V_step; - tau_L_step])[1 ]
60
+ end
61
+
62
+ prob = DAEProblem (sys, D .(states (sys)) .=> 0.0 , Pair[], (0 , 6.0 ))
63
+ sol = solve (prob, DFBDF ())
47
64
@test sol. retcode == :Success
48
65
# EMF equations
49
66
@test - 0.5 .* sol[emf. i] == sol[emf. flange. tau]
50
67
@test sol[emf. v] == 0.5 .* sol[emf. w]
51
-
52
68
# test steady-state values
53
69
dc_gain = [f/ (k^ 2 + f* R) k/ (k^ 2 + f* R); k/ (k^ 2 + f* R) - R/ (k^ 2 + f* R)]
54
70
idx_t = findfirst (sol. t .> 2.5 )
@@ -57,7 +73,7 @@ using ModelingToolkit, OrdinaryDiffEq, Test
57
73
idx_t = findfirst (sol. t .> 5.5 )
58
74
@test sol[inertia. w][idx_t] ≈ (dc_gain* [V_step; - tau_L_step])[2 ]
59
75
@test sol[emf. i][idx_t] ≈ (dc_gain* [V_step; - tau_L_step])[1 ]
60
-
76
+
61
77
# p1 = Plots.plot(sol, vars=[inertia.w], ylabel="Angular Vel. in rad/s", label="")
62
78
# p2 = Plots.plot(sol, vars=[emf.i], ylabel="Current in A", label="")
63
79
# Plots.plot(p1, p2, layout=(2,1))
100
116
101
117
@named model = ODESystem (connections, t, systems= [ground, voltage_step, source, R1, L1, emf, fixed, load, load_step, inertia, friction, speed_sensor])
102
118
sys = structural_simplify (model)
103
- @test_broken prob = ODAEProblem (sys, Pair[], (0 , 6.0 )) # KeyError: key 17 not found
104
119
120
+ @test_broken prob = ODAEProblem (sys, Pair[], (0 , 6.0 )) # KeyError: key 17 not found
105
121
@test_skip begin
106
122
sol = solve (prob, Rodas4 ())
107
123
122
138
#
123
139
@test sol[inertia. w] == sol[speed_sensor. w]
124
140
end
141
+
142
+ prob = DAEProblem (sys, D .(states (sys)) .=> 0.0 , Pair[], (0 , 6.0 ))
143
+ sol = solve (prob, DFBDF ())
144
+
145
+ @test sol. retcode == :Success
146
+ # EMF equations
147
+ @test - 0.5 .* sol[emf. i] == sol[emf. flange. tau]
148
+ @test sol[emf. v] == 0.5 .* sol[emf. w]
149
+ # test steady-state values
150
+ dc_gain = [f/ (k^ 2 + f* R) k/ (k^ 2 + f* R); k/ (k^ 2 + f* R) - R/ (k^ 2 + f* R)]
151
+ idx_t = findfirst (sol. t .> 2.5 )
152
+ @test sol[inertia. w][idx_t] ≈ (dc_gain* [V_step; 0 ])[2 ]
153
+ @test sol[emf. i][idx_t] ≈ (dc_gain* [V_step; 0 ])[1 ]
154
+ idx_t = findfirst (sol. t .> 5.5 )
155
+ @test sol[inertia. w][idx_t] ≈ (dc_gain* [V_step; - tau_L_step])[2 ]
156
+ @test sol[emf. i][idx_t] ≈ (dc_gain* [V_step; - tau_L_step])[1 ]
157
+ #
158
+ @test sol[inertia. w] == sol[speed_sensor. w]
159
+
125
160
end
126
161
127
162
@testset " DC-motor with PI controller" begin
@@ -160,17 +195,23 @@ end
160
195
161
196
@named model = ODESystem (connections, t, systems= [ground, ref, pi_controller, feedback, source, R1, L1, emf, fixed, load, load_step, inertia, friction, speed_sensor, fixed2])
162
197
sys = structural_simplify (model)
163
- prob = ODAEProblem (sys, Pair[], ( 0 , 6.0 ))
164
-
198
+
199
+ @test_broken prob = ODAEProblem (sys, Pair[], ( 0 , 6.0 ))
165
200
@test_skip begin
166
201
sol = solve (prob, Rodas4 ())
167
-
168
202
@test sol. retcode == :Success
169
203
@test - 0.5 .* sol[emf. i] == sol[emf. flange. tau]
170
204
@test sol[emf. v] == 0.5 .* sol[emf. w]
171
205
@test sol[speed_sensor. w_rel. u][end ] == 1 # zero control error
172
206
end
173
207
208
+ prob = DAEProblem (sys, D .(states (sys)) .=> 0.0 , Pair[], (0 , 6.0 ))
209
+ sol = solve (prob, DFBDF ())
210
+ @test sol. retcode == :Success
211
+ @test - 0.5 .* sol[emf. i] == sol[emf. flange. tau]
212
+ @test sol[emf. v] == 0.5 .* sol[emf. w]
213
+ @test sol[speed_sensor. w_rel. u][end ] == 1 # zero control error
214
+
174
215
# p1 = Plots.plot(sol, vars=[inertia.w], ylabel="Angular Vel. in rad/s", label="")
175
216
# p2 = Plots.plot(sol, vars=[emf.i], ylabel="Current in A", label="")
176
217
# Plots.plot(p1, p2, layout=(2,1))
0 commit comments