@@ -17,6 +17,10 @@ sol = solve(initprob)
17
17
@test SciMLBase. successful_retcode (sol)
18
18
@test maximum (abs .(sol[conditions])) < 1e-14
19
19
20
+ @test_throws ModelingToolkit. ExtraVariablesSystemException ModelingToolkit. InitializationProblem (pend, 0.0 , [], [g => 1 ];
21
+ guesses = [ModelingToolkit. missing_variable_defaults (pend); x => 1 ; y => 0.2 ],
22
+ fully_determined = true )
23
+
20
24
initprob = ModelingToolkit. InitializationProblem (pend, 0.0 , [x => 1 , y => 0 ], [g => 1 ];
21
25
guesses = ModelingToolkit. missing_variable_defaults (pend))
22
26
@test initprob isa NonlinearProblem
@@ -31,6 +35,10 @@ initprob = ModelingToolkit.InitializationProblem(
31
35
sol = solve (initprob)
32
36
@test ! SciMLBase. successful_retcode (sol)
33
37
38
+ @test_throws ModelingToolkit. ExtraVariablesSystemException ModelingToolkit. InitializationProblem (
39
+ pend, 0.0 , [], [g => 1 ]; guesses = ModelingToolkit. missing_variable_defaults (pend),
40
+ fully_determined = true )
41
+
34
42
prob = ODEProblem (pend, [x => 1 , y => 0 ], (0.0 , 1.5 ), [g => 1 ],
35
43
guesses = ModelingToolkit. missing_variable_defaults (pend))
36
44
prob. f. initializeprob isa NonlinearProblem
@@ -47,6 +55,10 @@ sol = solve(prob.f.initializeprob)
47
55
sol = solve (prob, Rodas5P ())
48
56
@test maximum (abs .(sol[conditions][1 ])) < 1e-14
49
57
58
+ @test_throws ModelingToolkit. ExtraVariablesSystemException ODEProblem (pend, [x => 1 ], (0.0 , 1.5 ), [g => 1 ],
59
+ guesses = ModelingToolkit. missing_variable_defaults (pend),
60
+ fully_determined = true )
61
+
50
62
@connector Port begin
51
63
p (t)
52
64
dm (t) = 0 , [connect = Flow]
@@ -225,14 +237,20 @@ initsol = solve(initprob, reltol = 1e-12, abstol = 1e-12)
225
237
@test SciMLBase. successful_retcode (initsol)
226
238
@test maximum (abs .(initsol[conditions])) < 1e-14
227
239
240
+ @test_throws ModelingToolkit. ExtraEquationsSystemException ModelingToolkit. InitializationProblem (sys, 0.0 , fully_determined = true )
241
+
228
242
allinit = unknowns (sys) .=> initsol[unknowns (sys)]
229
243
prob = ODEProblem (sys, allinit, (0 , 0.1 ))
230
244
sol = solve (prob, Rodas5P (), initializealg = BrownFullBasicInit ())
231
245
# If initialized incorrectly, then it would be InitialFailure
232
246
@test sol. retcode == SciMLBase. ReturnCode. Unstable
233
247
@test maximum (abs .(initsol[conditions][1 ])) < 1e-14
234
248
249
+ prob = ODEProblem (sys, allinit, (0 , 0.1 ))
235
250
prob = ODEProblem (sys, [], (0 , 0.1 ), check = false )
251
+
252
+ @test_throws ModelingToolkit. ExtraEquationsSystemException ODEProblem (sys, [], (0 , 0.1 ), fully_determined = true )
253
+
236
254
sol = solve (prob, Rodas5P ())
237
255
# If initialized incorrectly, then it would be InitialFailure
238
256
@test sol. retcode == SciMLBase. ReturnCode. Unstable
0 commit comments