Skip to content

Commit f5f5885

Browse files
Merge pull request #338 from SebastianM-C/smc/update
Update MTK
2 parents a3de043 + 555145e commit f5f5885

File tree

11 files changed

+37
-48
lines changed

11 files changed

+37
-48
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
1515
Aqua = "0.8"
1616
ChainRulesCore = "1.24"
1717
ControlSystemsBase = "1.4"
18-
DataInterpolations = "4.6"
18+
DataInterpolations = "6"
1919
DiffEqBase = "6.152"
2020
IfElse = "0.1"
2121
LinearAlgebra = "1.10"
22-
ModelingToolkit = "9.32"
22+
ModelingToolkit = "9.46.1"
2323
OrdinaryDiffEq = "6.87"
2424
OrdinaryDiffEqDefault = "1.1"
2525
SafeTestsets = "0.1"
26-
Symbolics = "5.36, 6"
26+
Symbolics = "6.14"
2727
Test = "1"
2828
julia = "1.10"
2929

docs/src/tutorials/dc_motor_pi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ plot(p1, p2, layout = (2, 1))
9292
When implementing and tuning a control system in simulation, it is a good practice to analyze the closed-loop properties and verify robustness of the closed-loop with respect to, e.g., modeling errors. To facilitate this, we added two analysis points to the set of connections above, more specifically, we added the analysis points named `:y` and `:u` to the connections (for more details on analysis points, see [Linear Analysis](@ref))
9393

9494
```julia
95-
connect(sys.speed_sensor.w, :y, feedback.input2)
96-
connect(sys.pi_controller.ctr_output, :u, source.V)
95+
connect(sys.speed_sensor.w, :y, sys.feedback.input2)
96+
connect(sys.pi_controller.ctr_output, :u, sys.source.V)
9797
```
9898

9999
one at the plant output (`:y`) and one at the plant input (`:u`). We may use these analysis points to calculate, e.g., sensitivity functions, illustrated below. Here, we calculate the sensitivity function $S(s)$ and the complimentary sensitivity function $T(s) = I - S(s)$, defined as

test/Blocks/nonlinear.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ using OrdinaryDiffEq: ReturnCode.Success
2020
prob = ODEProblem(sys, [int.x => 1.0], (0.0, 1.0))
2121

2222
sol = solve(prob, Rodas4())
23-
@test sol.retcode == Success
23+
@test SciMLBase.successful_retcode(sol)
2424
@test sol[int.output.u][end] 2
2525
@test sol[sat.output.u][end] 0.8
2626
end
@@ -42,7 +42,7 @@ using OrdinaryDiffEq: ReturnCode.Success
4242
prob = ODEProblem(sys, unknowns(sys) .=> 0.0, (0.0, 10.0))
4343

4444
sol = solve(prob, Rodas4())
45-
@test sol.retcode == Success
45+
@test SciMLBase.successful_retcode(sol)
4646
@test all(abs.(sol[lim.output.u]) .<= 0.5)
4747
@test all(isapprox.(sol[lim.output.u], _clamp.(sol[source.output.u], y_min, y_max),
4848
atol = 1e-2))
@@ -69,7 +69,7 @@ end
6969
prob = ODEProblem(sys, [int.x => 1.0], (0.0, 1.0))
7070
sol = solve(prob, Rodas4())
7171

72-
@test sol.retcode == Success
72+
@test SciMLBase.successful_retcode(sol)
7373
@test all(sol[int.output.u][end] .≈ 2)
7474
end
7575

@@ -89,7 +89,7 @@ end
8989
prob = ODEProblem(sys, [int.x => 1.0], (0.0, 10.0))
9090
sol = solve(prob, Rodas4())
9191

92-
@test sol.retcode == Success
92+
@test SciMLBase.successful_retcode(sol)
9393
@test all(sol[dz.output.u] .<= 2)
9494
@test all(sol[dz.output.u] .>= -1)
9595
@test all(isapprox.(sol[dz.output.u],
@@ -115,7 +115,7 @@ end
115115

116116
tS = 0.01
117117
sol = solve(prob, Rodas4(), saveat = tS, abstol = 1e-10, reltol = 1e-10)
118-
@test sol.retcode == Success
118+
@test SciMLBase.successful_retcode(sol)
119119
@test all(abs.(sol[rl.output.u]) .<= 0.51)
120120
@test all(-1 - 1e-5 .<= diff(sol[rl.output.u]) ./ tS .<= 1 + 1e-5) # just an approximation
121121
end

test/Blocks/sources.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ end
2525

2626
@testset "TimeVaryingFunction" begin
2727
f(t) = t^2 + 1
28-
vars = @variables y(t)=1 dy(t)=0 ddy(t)=0
28+
vars = @variables y(t) dy(t) ddy(t)
2929
@named src = TimeVaryingFunction(f)
3030
@named int = Integrator()
3131
@named iosys = ODESystem(

test/Electrical/analog.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ using OrdinaryDiffEq: ReturnCode.Success
4848
# Plots.plot(sol; vars=[capacitor.v, voltage_sensor.v])
4949
# Plots.plot(sol; vars=[power_sensor.power, capacitor.i * capacitor.v])
5050
# Plots.plot(sol; vars=[resistor.i, current_sensor.i])
51-
@test sol.retcode == Success
51+
@test SciMLBase.successful_retcode(sol)
5252
@test sol[capacitor.v]sol[voltage_sensor.v] atol=1e-3
5353
@test sol[power_sensor.power]sol[capacitor.i * capacitor.v] atol=1e-3
5454
@test sol[resistor.i]sol[current_sensor.i] atol=1e-3
@@ -75,7 +75,7 @@ end
7575
sys = structural_simplify(model)
7676
prob = ODEProblem(sys, Pair[R2.i => 0.0], (0, 2.0))
7777
sol = solve(prob, Rodas4()) # has no state; does not work with Tsit5
78-
@test sol.retcode == Success
78+
@test SciMLBase.successful_retcode(sol)
7979
@test sol[short.v] == sol[R0.v] == zeros(length(sol.t))
8080
@test sol[R0.i] == zeros(length(sol.t))
8181
@test sol[R1.p.v][end]10 atol=1e-3
@@ -103,7 +103,7 @@ end
103103
sol = solve(prob, Tsit5())
104104

105105
# Plots.plot(sol; vars=[source.v, capacitor.v])
106-
@test sol.retcode == Success
106+
@test SciMLBase.successful_retcode(sol)
107107
@test sol[capacitor.v][end]10 atol=1e-3
108108
end
109109

@@ -127,7 +127,7 @@ end
127127
sol = solve(prob, Tsit5())
128128

129129
# Plots.plot(sol; vars=[inductor.i, inductor.i])
130-
@test sol.retcode == Success
130+
@test SciMLBase.successful_retcode(sol)
131131
@test sol[inductor.i][end]10 atol=1e-3
132132
end
133133

@@ -160,9 +160,9 @@ end
160160
sys = structural_simplify(model)
161161
prob = ODEProblem(sys, Pair[], (0.0, 10.0))
162162
sol = solve(prob, Tsit5())
163-
@test sol.retcode == Success
163+
@test SciMLBase.successful_retcode(sol)
164164
sol = solve(prob, Rodas4())
165-
@test sol.retcode == Success
165+
@test SciMLBase.successful_retcode(sol)
166166

167167
# Plots.plot(sol; vars=[voltage.v, capacitor.v])
168168
end
@@ -188,7 +188,7 @@ end
188188
prob = ODEProblem(sys, Pair[], (0.0, 10.0))
189189
sol = solve(prob, Tsit5())
190190
y(x, st) = (x .> st) .* abs.(collect(x) .- st)
191-
@test sol.retcode == Success
191+
@test SciMLBase.successful_retcode(sol)
192192
@test sum(reduce(vcat, sol[capacitor.v]) .- y(sol.t, start_time))0 atol=1e-2
193193
end
194194

@@ -228,7 +228,7 @@ end
228228
R1.v => 0.0]
229229
prob = ODEProblem(sys, u0, (0, 100.0))
230230
sol = solve(prob, Rodas4())
231-
@test sol.retcode == Success
231+
@test SciMLBase.successful_retcode(sol)
232232
@test sol[opamp.v2] == sol[C1.v] # Not a great one however. Rely on the plot
233233
@test sol[opamp.p2.v] == sol[sensor.v]
234234

@@ -298,7 +298,7 @@ _damped_sine_wave(x, f, A, st, ϕ, d) = exp((st - x) * d) * A * sin(2 * π * f *
298298
prob = ODEProblem(vsys, u0, (0, 10.0))
299299
sol = solve(prob, dt = 0.1, Tsit5())
300300

301-
@test sol.retcode == Success
301+
@test SciMLBase.successful_retcode(sol)
302302
@test sol[voltage.V.u]waveforms(i, sol.t) atol=1e-1
303303
@test sol[voltage.p.v] sol[voltage.V.u]
304304
# For visual inspection
@@ -364,7 +364,7 @@ end
364364
prob = ODEProblem(isys, u0, (0, 10.0))
365365
sol = solve(prob, dt = 0.1, Tsit5())
366366

367-
@test sol.retcode == Success
367+
@test SciMLBase.successful_retcode(sol)
368368
@test sol[current.I.u]waveforms(i, sol.t) atol=1e-1
369369
@test sol[current.I.u]sol[current.p.i] atol=1e-1
370370
# For visual inspection

test/Magnetic/magnetic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ using OrdinaryDiffEq: ReturnCode.Success
5454
# Plots.plot(sol; vars=[r.i])
5555
# Plots.plot(sol; vars=[r_mFe.V_m, r_mFe.Phi])
5656

57-
@test sol.retcode == Success
57+
@test SciMLBase.successful_retcode(sol)
5858
@test sol[r_mFe.Phi] == sol[r_mAirPar.Phi]
5959
@test all(sol[coil.port_p.Phi] + sol[r_mLeak.Phi] + sol[r_mAirPar.Phi] .== 0)
6060
end

test/Mechanical/translational.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ end
155155
delta_s = 1 / 1000
156156
s_b = 2 - delta_s + 1
157157

158-
@test sol[s.pos_value.u][end]s_b atol=1e-3
158+
@test sol[s.pos_value.u][end]1.0 atol=1e-3
159159
@test all(sol[s.spring.flange_a.f] .== sol[s.force_output.u])
160160
end
161161

test/Thermal/demo.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ using OrdinaryDiffEq: ReturnCode.Success
2020
@named model = ODESystem(connections, t,
2121
systems = [mass1, mass2, conduction, Tsensor1, Tsensor2])
2222
sys = structural_simplify(model)
23-
prob = ODEProblem(sys, [mass1.der_T => 1.0, mass2.der_T => 1.0], (0, 3.0))
23+
prob = ODEProblem(sys, [], (0, 3.0))
2424
sol = solve(prob, Tsit5())
25-
@test sol.retcode == Success
25+
@test SciMLBase.successful_retcode(sol)
2626
end

test/Thermal/motor.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ using ModelingToolkitStandardLibrary.Blocks
4646
sol = solve(prob)
4747

4848
# plot(sol; vars=[T_winding.T, T_core.T])
49-
@test sol.retcode == Success
49+
@test SciMLBase.successful_retcode(sol)
5050
@test sol[motor.T_winding.T] == sol[motor.winding.T]
5151
@test sol[motor.T_core.T] == sol[motor.core.T]
5252
@test sol[-motor.core.port.Q_flow]

test/Thermal/piston.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@ using ModelingToolkitStandardLibrary.Blocks
3333

3434
@mtkbuild piston = Piston()
3535

36-
u0 = [piston.coolant.dT => 5.0
37-
piston.wall.Q_flow => 10.0]
38-
prob = ODEProblem(piston, u0, (0, 3.0))
36+
prob = ODEProblem(piston, [], (0, 3.0))
3937
sol = solve(prob)
4038

4139
# Heat-flow-rate is equal in magnitude
4240
# and opposite in direction
43-
@test sol.retcode == Success
41+
@test SciMLBase.successful_retcode(sol)
4442
# The initial value doesn't add up to absolute zero, while the rest do. To avoid
4543
# tolerance on the latter, the test is split in two parts.
4644
@test sol[piston.gas.Q_flow][1] + sol[piston.coolant.Q_flow][1]0 atol=1e-6

0 commit comments

Comments
 (0)