Skip to content

Commit fb9e3f2

Browse files
committed
test: use SciMLBase.successful_retcode(sol)
1 parent 9f7f000 commit fb9e3f2

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

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/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/Thermal/demo.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ using OrdinaryDiffEq: ReturnCode.Success
2222
sys = structural_simplify(model)
2323
prob = ODEProblem(sys, [mass1.der_T => 1.0, mass2.der_T => 1.0], (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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ using ModelingToolkitStandardLibrary.Blocks
4040

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

test/Thermal/thermal.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ using OrdinaryDiffEq: ReturnCode.Success
2929

3030
# Check if Relative temperature sensor reads the temperature of heat capacitor
3131
# when connected to a thermal conductor and a fixed temperature source
32-
@test sol.retcode == Success
32+
@test SciMLBase.successful_retcode(sol)
3333
@test sol[reltem_sensor.T] + sol[tem_src.port.T] == sol[mass1.T] + sol[th_conductor.dT]
3434

3535
@info "Building a two-body system..."
@@ -49,7 +49,7 @@ using OrdinaryDiffEq: ReturnCode.Success
4949
prob = ODEProblem(sys, u0, (0, 3.0))
5050
sol = solve(prob, Tsit5())
5151

52-
@test sol.retcode == Success
52+
@test SciMLBase.successful_retcode(sol)
5353
m1, m2 = sol.u[end]
5454
@test m1m2 atol=1e-1
5555
mass_T = reduce(hcat, sol.u)
@@ -85,7 +85,7 @@ end
8585
prob = ODEProblem(sys, u0, (0, 3.0))
8686
sol = solve(prob, Tsit5())
8787

88-
@test sol.retcode == Success
88+
@test SciMLBase.successful_retcode(sol)
8989
@test sol[th_conductor.dT] .* G == sol[th_conductor.Q_flow]
9090
@test sol[th_conductor.Q_flow] sol[hf_sensor1.Q_flow] + sol[flow_src.port.Q_flow]
9191

@@ -127,7 +127,7 @@ end
127127
prob = ODEProblem(sys, u0, (0, 3.0))
128128
sol = solve(prob, Rodas4())
129129

130-
@test sol.retcode == Success
130+
@test SciMLBase.successful_retcode(sol)
131131
@test sol[dissipator.dT] == sol[radiator.port_a.T] - sol[radiator.port_b.T]
132132
rad_Q_flow = G * σ * (T_gas^4 - T_coolant^4)
133133
@test sol[radiator.Q_flow] == fill(rad_Q_flow, length(sol[radiator.Q_flow]))
@@ -158,7 +158,7 @@ end
158158
prob = ODEProblem(sys, u0, (0, 3.0))
159159
sol = solve(prob, Rodas4())
160160

161-
@test sol.retcode == Success
161+
@test SciMLBase.successful_retcode(sol)
162162
@test sol[collector.port_b.Q_flow] + sol[collector.port_a1.Q_flow] +
163163
sol[collector.port_a2.Q_flow] ==
164164
zeros(length(sol[collector.port_b.Q_flow]))

0 commit comments

Comments
 (0)