Skip to content

Commit da5262e

Browse files
Fix deprecation warnings in tests
- Remove duplicate initial condition for PT2 test (pt2.xd already in unknowns) - Remove bound parameter IC setting for PI/LimPI tests (gainPI.k is bound) - Replace deprecated @mtkbuild with @mtkcompile in analog electrical tests - Fix deprecated integer indexing on DiffEqArray in hydraulic actuator test - Remove unused deprecated imports (get_eqs, vars, @set!) in analysis points test - Fix linearize call to not wrap scalars in vectors Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
1 parent 6b6f9bb commit da5262e

4 files changed

Lines changed: 8 additions & 10 deletions

File tree

test/Blocks/continuous.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ end
9090
@named pt2 = SecondOrder(; k = k, w = w, d = d)
9191
@named iosys = System(connect(c.output, pt2.input), t, systems = [pt2, c])
9292
sys = mtkcompile(iosys)
93-
prob = ODEProblem(sys, [unknowns(sys) .=> 0.0...; pt2.xd => 0.0], (0.0, 100.0))
93+
prob = ODEProblem(sys, unknowns(sys) .=> 0.0, (0.0, 100.0))
9494
sol = solve(prob, Rodas4())
9595
@test sol.retcode == Success
9696
@test sol[pt2.output.u] pt2_func.(sol.t, k, w, d) atol = 1.0e-3
@@ -176,7 +176,6 @@ end
176176
systems = [pi_controller, plant, ref, fb]
177177
)
178178
sys = mtkcompile(model)
179-
initial_conditions(sys)[sys.pi_controller.gainPI.k] = 1.0
180179
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
181180
sol = solve(prob, Rodas4())
182181
@test sol.retcode == Success
@@ -277,7 +276,6 @@ end
277276
systems = [pi_controller, plant, ref, fb, sat]
278277
)
279278
sys = mtkcompile(model)
280-
initial_conditions(sys)[sys.pi_controller.gainPI.k] = 1.0
281279
prob = ODEProblem(sys, Pair[], (0.0, 20.0))
282280
sol = solve(prob, Rodas4())
283281
end

test/Blocks/test_analysis_points.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using SciCompDSL
33
using ModelingToolkit
44
using ModelingToolkitStandardLibrary.Blocks
55
using OrdinaryDiffEq
6-
using ModelingToolkit: get_eqs, vars, @set!, t_nounits as t
6+
using ModelingToolkit: t_nounits as t
77
using ControlSystemsBase
88

99
@named P = FirstOrder(k = 1, T = 1)
@@ -80,7 +80,7 @@ L = P*C
8080
open_sys, (u, y) = ModelingToolkit.open_loop(sys, :plant_input)
8181

8282
# Linearizing the open-loop system should yield the same system as get_looptransfer
83-
matrices, _ = linearize(open_sys, [u], [y])
83+
matrices, _ = linearize(open_sys, u, y)
8484
@test matrices.A[] == -1
8585
@test matrices.B[] * matrices.C[] == -1 # either one negative
8686
@test matrices.D[] == 0

test/Electrical/analog.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ end
633633
end
634634
end
635635

636-
@mtkbuild sys = SimpleNMOSCircuit(V_cc = 5.0, V_b = 3.5)
636+
@mtkcompile sys = SimpleNMOSCircuit(V_cc = 5.0, V_b = 3.5)
637637

638638
prob = ODEProblem(sys, Pair[], (0.0, 10.0))
639639
sol = solve(prob)
@@ -673,7 +673,7 @@ end
673673
end
674674
end
675675

676-
@mtkbuild flipped_sys = FlippedNMOSCircuit(V_cc = 5.0, V_b = 3.5)
676+
@mtkcompile flipped_sys = FlippedNMOSCircuit(V_cc = 5.0, V_b = 3.5)
677677

678678
flipped_prob = ODEProblem(flipped_sys, Pair[], (0.0, 10.0))
679679
flipped_sol = solve(flipped_prob)
@@ -717,7 +717,7 @@ end
717717
end
718718
end
719719

720-
@mtkbuild sys = SimplePMOSCircuit(V_s = 5.0, V_b = 2.5, V_d = 3)
720+
@mtkcompile sys = SimplePMOSCircuit(V_s = 5.0, V_b = 2.5, V_d = 3)
721721

722722
prob = ODEProblem(sys, Pair[], (0.0, 10.0))
723723
sol = solve(prob)
@@ -760,7 +760,7 @@ end
760760
end
761761
end
762762

763-
@mtkbuild flipped_sys = FlippedPMOSCircuit(V_s = 5.0, V_b = 2.5, V_d = 3)
763+
@mtkcompile flipped_sys = FlippedPMOSCircuit(V_s = 5.0, V_b = 2.5, V_d = 3)
764764

765765
flipped_prob = ODEProblem(flipped_sys, Pair[], (0.0, 10.0))
766766
flipped_sol = solve(flipped_prob)

test/Hydraulic/isothermal_compressible.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ end
320320
defs[sys.input.buffer] = Parameter(0.5 * x, dt)
321321

322322
# NOTE: bypassing initialization system: https://github.com/SciML/ModelingToolkit.jl/issues/3312
323-
prob = ODEProblem(sys, [unknowns(initsys)[1] => initsol[1]], (0, 0.1); build_initializeprob = false)
323+
prob = ODEProblem(sys, unknowns(initsys) .=> initsol.u[end], (0, 0.1); build_initializeprob = false)
324324

325325
#TODO: Implement proper initialization system after issue is resolved
326326
#TODO: How to bring the body back and not have an overdetermined system?

0 commit comments

Comments
 (0)