Skip to content

Commit

Permalink
test: remove unneeded initial conditions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SebastianM-C committed Oct 18, 2024
1 parent fb9e3f2 commit 574b0fd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
2 changes: 1 addition & 1 deletion test/Blocks/sources.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion test/Thermal/demo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions test/Thermal/piston.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 4 additions & 13 deletions test/Thermal/thermal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -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())

Expand Down Expand Up @@ -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())

Expand Down Expand Up @@ -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())

Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 574b0fd

Please sign in to comment.