diff --git a/test/Blocks/nonlinear.jl b/test/Blocks/nonlinear.jl index 3b5f58787..8fa2c2ade 100644 --- a/test/Blocks/nonlinear.jl +++ b/test/Blocks/nonlinear.jl @@ -20,7 +20,7 @@ using OrdinaryDiffEq: ReturnCode.Success prob = ODEProblem(sys, [int.x => 1.0], (0.0, 1.0)) sol = solve(prob, Rodas4()) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test sol[int.output.u][end] ≈ 2 @test sol[sat.output.u][end] ≈ 0.8 end @@ -42,7 +42,7 @@ using OrdinaryDiffEq: ReturnCode.Success prob = ODEProblem(sys, unknowns(sys) .=> 0.0, (0.0, 10.0)) sol = solve(prob, Rodas4()) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test all(abs.(sol[lim.output.u]) .<= 0.5) @test all(isapprox.(sol[lim.output.u], _clamp.(sol[source.output.u], y_min, y_max), atol = 1e-2)) @@ -69,7 +69,7 @@ end prob = ODEProblem(sys, [int.x => 1.0], (0.0, 1.0)) sol = solve(prob, Rodas4()) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test all(sol[int.output.u][end] .≈ 2) end @@ -89,7 +89,7 @@ end prob = ODEProblem(sys, [int.x => 1.0], (0.0, 10.0)) sol = solve(prob, Rodas4()) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test all(sol[dz.output.u] .<= 2) @test all(sol[dz.output.u] .>= -1) @test all(isapprox.(sol[dz.output.u], @@ -115,7 +115,7 @@ end tS = 0.01 sol = solve(prob, Rodas4(), saveat = tS, abstol = 1e-10, reltol = 1e-10) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test all(abs.(sol[rl.output.u]) .<= 0.51) @test all(-1 - 1e-5 .<= diff(sol[rl.output.u]) ./ tS .<= 1 + 1e-5) # just an approximation end diff --git a/test/Electrical/analog.jl b/test/Electrical/analog.jl index fbbeb24a9..1ac86ef73 100644 --- a/test/Electrical/analog.jl +++ b/test/Electrical/analog.jl @@ -48,7 +48,7 @@ using OrdinaryDiffEq: ReturnCode.Success # Plots.plot(sol; vars=[capacitor.v, voltage_sensor.v]) # Plots.plot(sol; vars=[power_sensor.power, capacitor.i * capacitor.v]) # Plots.plot(sol; vars=[resistor.i, current_sensor.i]) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test sol[capacitor.v]≈sol[voltage_sensor.v] atol=1e-3 @test sol[power_sensor.power]≈sol[capacitor.i * capacitor.v] atol=1e-3 @test sol[resistor.i]≈sol[current_sensor.i] atol=1e-3 @@ -75,7 +75,7 @@ end sys = structural_simplify(model) prob = ODEProblem(sys, Pair[R2.i => 0.0], (0, 2.0)) sol = solve(prob, Rodas4()) # has no state; does not work with Tsit5 - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test sol[short.v] == sol[R0.v] == zeros(length(sol.t)) @test sol[R0.i] == zeros(length(sol.t)) @test sol[R1.p.v][end]≈10 atol=1e-3 @@ -103,7 +103,7 @@ end sol = solve(prob, Tsit5()) # Plots.plot(sol; vars=[source.v, capacitor.v]) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test sol[capacitor.v][end]≈10 atol=1e-3 end @@ -127,7 +127,7 @@ end sol = solve(prob, Tsit5()) # Plots.plot(sol; vars=[inductor.i, inductor.i]) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test sol[inductor.i][end]≈10 atol=1e-3 end @@ -160,9 +160,9 @@ end sys = structural_simplify(model) prob = ODEProblem(sys, Pair[], (0.0, 10.0)) sol = solve(prob, Tsit5()) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) sol = solve(prob, Rodas4()) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) # Plots.plot(sol; vars=[voltage.v, capacitor.v]) end @@ -188,7 +188,7 @@ end prob = ODEProblem(sys, Pair[], (0.0, 10.0)) sol = solve(prob, Tsit5()) y(x, st) = (x .> st) .* abs.(collect(x) .- st) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test sum(reduce(vcat, sol[capacitor.v]) .- y(sol.t, start_time))≈0 atol=1e-2 end @@ -228,7 +228,7 @@ end R1.v => 0.0] prob = ODEProblem(sys, u0, (0, 100.0)) sol = solve(prob, Rodas4()) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test sol[opamp.v2] == sol[C1.v] # Not a great one however. Rely on the plot @test sol[opamp.p2.v] == sol[sensor.v] @@ -298,7 +298,7 @@ _damped_sine_wave(x, f, A, st, ϕ, d) = exp((st - x) * d) * A * sin(2 * π * f * prob = ODEProblem(vsys, u0, (0, 10.0)) sol = solve(prob, dt = 0.1, Tsit5()) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test sol[voltage.V.u]≈waveforms(i, sol.t) atol=1e-1 @test sol[voltage.p.v] ≈ sol[voltage.V.u] # For visual inspection @@ -364,7 +364,7 @@ end prob = ODEProblem(isys, u0, (0, 10.0)) sol = solve(prob, dt = 0.1, Tsit5()) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test sol[current.I.u]≈waveforms(i, sol.t) atol=1e-1 @test sol[current.I.u]≈sol[current.p.i] atol=1e-1 # For visual inspection diff --git a/test/Magnetic/magnetic.jl b/test/Magnetic/magnetic.jl index c81439fc1..0564aafa9 100644 --- a/test/Magnetic/magnetic.jl +++ b/test/Magnetic/magnetic.jl @@ -54,7 +54,7 @@ using OrdinaryDiffEq: ReturnCode.Success # Plots.plot(sol; vars=[r.i]) # Plots.plot(sol; vars=[r_mFe.V_m, r_mFe.Phi]) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test sol[r_mFe.Phi] == sol[r_mAirPar.Phi] @test all(sol[coil.port_p.Phi] + sol[r_mLeak.Phi] + sol[r_mAirPar.Phi] .== 0) end diff --git a/test/Thermal/demo.jl b/test/Thermal/demo.jl index 5403681fc..14b61b215 100644 --- a/test/Thermal/demo.jl +++ b/test/Thermal/demo.jl @@ -22,5 +22,5 @@ using OrdinaryDiffEq: ReturnCode.Success sys = structural_simplify(model) prob = ODEProblem(sys, [mass1.der_T => 1.0, mass2.der_T => 1.0], (0, 3.0)) sol = solve(prob, Tsit5()) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) end diff --git a/test/Thermal/motor.jl b/test/Thermal/motor.jl index c02d43538..a8f951256 100644 --- a/test/Thermal/motor.jl +++ b/test/Thermal/motor.jl @@ -46,7 +46,7 @@ using ModelingToolkitStandardLibrary.Blocks sol = solve(prob) # plot(sol; vars=[T_winding.T, T_core.T]) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test sol[motor.T_winding.T] == sol[motor.winding.T] @test sol[motor.T_core.T] == sol[motor.core.T] @test sol[-motor.core.port.Q_flow] ≈ diff --git a/test/Thermal/piston.jl b/test/Thermal/piston.jl index d514c5f4f..f1c8e3cb3 100644 --- a/test/Thermal/piston.jl +++ b/test/Thermal/piston.jl @@ -40,7 +40,7 @@ using ModelingToolkitStandardLibrary.Blocks # Heat-flow-rate is equal in magnitude # and opposite in direction - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) # The initial value doesn't add up to absolute zero, while the rest do. To avoid # tolerance on the latter, the test is split in two parts. @test sol[piston.gas.Q_flow][1] + sol[piston.coolant.Q_flow][1]≈0 atol=1e-6 diff --git a/test/Thermal/thermal.jl b/test/Thermal/thermal.jl index 85348faf5..a62ca5e61 100644 --- a/test/Thermal/thermal.jl +++ b/test/Thermal/thermal.jl @@ -29,7 +29,7 @@ using OrdinaryDiffEq: ReturnCode.Success # Check if Relative temperature sensor reads the temperature of heat capacitor # when connected to a thermal conductor and a fixed temperature source - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test sol[reltem_sensor.T] + sol[tem_src.port.T] == sol[mass1.T] + sol[th_conductor.dT] @info "Building a two-body system..." @@ -49,7 +49,7 @@ using OrdinaryDiffEq: ReturnCode.Success prob = ODEProblem(sys, u0, (0, 3.0)) sol = solve(prob, Tsit5()) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) m1, m2 = sol.u[end] @test m1≈m2 atol=1e-1 mass_T = reduce(hcat, sol.u) @@ -85,7 +85,7 @@ end prob = ODEProblem(sys, u0, (0, 3.0)) sol = solve(prob, Tsit5()) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test sol[th_conductor.dT] .* G == sol[th_conductor.Q_flow] @test sol[th_conductor.Q_flow] ≈ sol[hf_sensor1.Q_flow] + sol[flow_src.port.Q_flow] @@ -127,7 +127,7 @@ end prob = ODEProblem(sys, u0, (0, 3.0)) sol = solve(prob, Rodas4()) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test sol[dissipator.dT] == sol[radiator.port_a.T] - sol[radiator.port_b.T] rad_Q_flow = G * σ * (T_gas^4 - T_coolant^4) @test sol[radiator.Q_flow] == fill(rad_Q_flow, length(sol[radiator.Q_flow])) @@ -158,7 +158,7 @@ end prob = ODEProblem(sys, u0, (0, 3.0)) sol = solve(prob, Rodas4()) - @test sol.retcode == Success + @test SciMLBase.successful_retcode(sol) @test sol[collector.port_b.Q_flow] + sol[collector.port_a1.Q_flow] + sol[collector.port_a2.Q_flow] == zeros(length(sol[collector.port_b.Q_flow]))