@@ -3,41 +3,44 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
3
3
4
4
@parameters g
5
5
@variables x (t) y (t) [state_priority = 10 ] λ (t)
6
- eqs = [
7
- D (D (x)) ~ λ * x
6
+ eqs = [D (D (x)) ~ λ * x
8
7
D (D (y)) ~ λ * y - g
9
- x^ 2 + y^ 2 ~ 1
10
- ]
11
- @mtkbuild pend = ODESystem (eqs,t)
8
+ x^ 2 + y^ 2 ~ 1 ]
9
+ @mtkbuild pend = ODESystem (eqs, t)
12
10
13
- initprob = ModelingToolkit. InitializationProblem (pend, [], [g => 1 ]; guesses = [ModelingToolkit. missing_variable_defaults (pend); x => 1 ; y => 0.2 ])
14
- conditions = getfield .(equations (initprob. f. sys),:rhs )
11
+ initprob = ModelingToolkit. InitializationProblem (pend, [], [g => 1 ];
12
+ guesses = [ModelingToolkit. missing_variable_defaults (pend); x => 1 ; y => 0.2 ])
13
+ conditions = getfield .(equations (initprob. f. sys), :rhs )
15
14
16
15
@test initprob isa NonlinearLeastSquaresProblem
17
16
sol = solve (initprob)
18
17
@test SciMLBase. successful_retcode (sol)
19
18
@test maximum (abs .(sol[conditions])) < 1e-14
20
19
21
- initprob = ModelingToolkit. InitializationProblem (pend, [x => 1 , y => 0 ], [g => 1 ]; guesses = ModelingToolkit. missing_variable_defaults (pend))
20
+ initprob = ModelingToolkit. InitializationProblem (pend, [x => 1 , y => 0 ], [g => 1 ];
21
+ guesses = ModelingToolkit. missing_variable_defaults (pend))
22
22
@test initprob isa NonlinearProblem
23
23
sol = solve (initprob)
24
24
@test SciMLBase. successful_retcode (sol)
25
- @test sol. u == [1.0 ,0.0 ,0.0 ,0.0 ]
25
+ @test sol. u == [1.0 , 0.0 , 0.0 , 0.0 ]
26
26
@test maximum (abs .(sol[conditions])) < 1e-14
27
27
28
- initprob = ModelingToolkit. InitializationProblem (pend, [], [g => 1 ]; guesses = ModelingToolkit. missing_variable_defaults (pend))
28
+ initprob = ModelingToolkit. InitializationProblem (
29
+ pend, [], [g => 1 ]; guesses = ModelingToolkit. missing_variable_defaults (pend))
29
30
@test initprob isa NonlinearLeastSquaresProblem
30
31
sol = solve (initprob)
31
32
@test ! SciMLBase. successful_retcode (sol)
32
33
33
- prob = ODEProblem (pend, [x => 1 , y => 0 ], (0.0 , 1.5 ), [g => 1 ], guesses = ModelingToolkit. missing_variable_defaults (pend))
34
+ prob = ODEProblem (pend, [x => 1 , y => 0 ], (0.0 , 1.5 ), [g => 1 ],
35
+ guesses = ModelingToolkit. missing_variable_defaults (pend))
34
36
prob. f. initializeprob isa NonlinearProblem
35
37
sol = solve (prob. f. initializeprob)
36
38
@test maximum (abs .(sol[conditions])) < 1e-14
37
39
sol = solve (prob, Rodas5P ())
38
40
@test maximum (abs .(sol[conditions][1 ])) < 1e-14
39
41
40
- prob = ODEProblem (pend, [x => 1 ], (0.0 , 1.5 ), [g => 1 ], guesses = ModelingToolkit. missing_variable_defaults (pend))
42
+ prob = ODEProblem (pend, [x => 1 ], (0.0 , 1.5 ), [g => 1 ],
43
+ guesses = ModelingToolkit. missing_variable_defaults (pend))
41
44
prob. f. initializeprob isa NonlinearLeastSquaresProblem
42
45
sol = solve (prob. f. initializeprob)
43
46
@test maximum (abs .(sol[conditions])) < 1e-14
214
217
215
218
@mtkbuild sys = System ()
216
219
initprob = ModelingToolkit. InitializationProblem (sys)
217
- conditions = getfield .(equations (initprob. f. sys),:rhs )
220
+ conditions = getfield .(equations (initprob. f. sys), :rhs )
218
221
219
222
@test initprob isa NonlinearLeastSquaresProblem
220
223
@test length (initprob. u0) == 2
@@ -229,7 +232,7 @@ sol = solve(prob, Rodas5P(), initializealg = BrownFullBasicInit())
229
232
@test sol. retcode == SciMLBase. ReturnCode. Unstable
230
233
@test maximum (abs .(initsol[conditions][1 ])) < 1e-14
231
234
232
- prob = ODEProblem (sys, [], (0 , 0.1 ), check= false )
235
+ prob = ODEProblem (sys, [], (0 , 0.1 ), check = false )
233
236
sol = solve (prob, Rodas5P ())
234
237
# If initialized incorrectly, then it would be InitialFailure
235
238
@test sol. retcode == SciMLBase. ReturnCode. Unstable
@@ -328,4 +331,4 @@ p = [σ => 28.0,
328
331
β => 8 / 3 ]
329
332
330
333
tspan = (0.0 , 100.0 )
331
- @test_throws ArgumentError prob = ODEProblem (sys, u0, tspan, p, jac = true )
334
+ @test_throws ArgumentError prob= ODEProblem (sys, u0, tspan, p, jac = true )
0 commit comments