From 574b0fd1001eb1a44474d901b02f4833862a1ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Miclu=C8=9Ba-C=C3=A2mpeanu?= Date: Fri, 18 Oct 2024 03:36:25 +0300 Subject: [PATCH] test: remove unneeded initial conditions with newer versions of MTK we no longer need to provides these, as initialization can find the appropriate initial conditions. If the extra u0s are provided, they lead to initialization failures. --- test/Blocks/sources.jl | 2 +- test/Thermal/demo.jl | 2 +- test/Thermal/piston.jl | 4 +--- test/Thermal/thermal.jl | 17 ++++------------- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/test/Blocks/sources.jl b/test/Blocks/sources.jl index f03a6de4a..c073385b1 100644 --- a/test/Blocks/sources.jl +++ b/test/Blocks/sources.jl @@ -25,7 +25,7 @@ end @testset "TimeVaryingFunction" begin f(t) = t^2 + 1 - vars = @variables y(t)=1 dy(t)=0 ddy(t)=0 + vars = @variables y(t) dy(t) ddy(t) @named src = TimeVaryingFunction(f) @named int = Integrator() @named iosys = ODESystem( diff --git a/test/Thermal/demo.jl b/test/Thermal/demo.jl index 14b61b215..001a43840 100644 --- a/test/Thermal/demo.jl +++ b/test/Thermal/demo.jl @@ -20,7 +20,7 @@ using OrdinaryDiffEq: ReturnCode.Success @named model = ODESystem(connections, t, systems = [mass1, mass2, conduction, Tsensor1, Tsensor2]) sys = structural_simplify(model) - prob = ODEProblem(sys, [mass1.der_T => 1.0, mass2.der_T => 1.0], (0, 3.0)) + prob = ODEProblem(sys, [], (0, 3.0)) sol = solve(prob, Tsit5()) @test SciMLBase.successful_retcode(sol) end diff --git a/test/Thermal/piston.jl b/test/Thermal/piston.jl index f1c8e3cb3..1d3426902 100644 --- a/test/Thermal/piston.jl +++ b/test/Thermal/piston.jl @@ -33,9 +33,7 @@ using ModelingToolkitStandardLibrary.Blocks @mtkbuild piston = Piston() - u0 = [piston.coolant.dT => 5.0 - piston.wall.Q_flow => 10.0] - prob = ODEProblem(piston, u0, (0, 3.0)) + prob = ODEProblem(piston, [], (0, 3.0)) sol = solve(prob) # Heat-flow-rate is equal in magnitude diff --git a/test/Thermal/thermal.jl b/test/Thermal/thermal.jl index a62ca5e61..49c5d634c 100644 --- a/test/Thermal/thermal.jl +++ b/test/Thermal/thermal.jl @@ -22,8 +22,7 @@ using OrdinaryDiffEq: ReturnCode.Success @named h1 = ODESystem(eqs, t, systems = [mass1, reltem_sensor, tem_src, th_conductor]) sys = structural_simplify(h1) - u0 = [mass1.T => 2.0 - mass1.der_T => 1.0] + u0 = [mass1.T => 2] prob = ODEProblem(sys, u0, (0, 2.0)) sol = solve(prob, Tsit5()) @@ -42,10 +41,7 @@ using OrdinaryDiffEq: ReturnCode.Success sys = structural_simplify(h2) u0 = [mass1.T => 1.0 - mass2.T => 10.0 - final_T => 12 - mass1.der_T => 1.0 - mass2.der_T => 1.0] + mass2.T => 10.0] prob = ODEProblem(sys, u0, (0, 3.0)) sol = solve(prob, Tsit5()) @@ -79,9 +75,7 @@ end th_resistor, flow_src, th_ground, th_conductor]) sys = structural_simplify(h2) - u0 = [mass1.T => 10.0 - th_resistor.Q_flow => 1.0 - mass1.der_T => 1.0] + u0 = [mass1.T => 10.0] prob = ODEProblem(sys, u0, (0, 3.0)) sol = solve(prob, Tsit5()) @@ -121,9 +115,7 @@ end ]) sys = structural_simplify(rad) - u0 = [base.Q_flow => 10 - dissipator.Q_flow => 10 - mass.T => T_gas] + u0 = [mass.T => T_gas] prob = ODEProblem(sys, u0, (0, 3.0)) sol = solve(prob, Rodas4()) @@ -152,7 +144,6 @@ end sys = structural_simplify(coll) u0 = [ - th_resistor.Q_flow => 1.0, mass.T => 0.0 ] prob = ODEProblem(sys, u0, (0, 3.0))