Skip to content

Commit ffbea8f

Browse files
test: prevent CI 6-hour timeout and fix Thermal/Magnetic regressions
This addresses the real root cause of CI hitting the 6-hour job timeout: the `Thermal/thermal.jl` "FixedHeatFlow with alpha=0.0 test" testset calls `solve(prob)` (no algorithm) on a compiled system whose mtkcompile-reduced form has zero differential states. The default auto-switching algorithm cannot make forward progress on that and spins indefinitely instead of erroring or terminating. With an explicit `ImplicitEuler(; dt=1.0, adaptive=false)`, the test finishes in ~16s. (The retcode assertion still fails for this stateless system - same as on April 27 - but the rest of the suite can now run to completion.) Other test fixes in the same area, found while reproducing locally: * `Thermal/motor.jl`, `Thermal/piston.jl` - missing `using OrdinaryDiffEq` and `t_nounits as t` imports, causing `@mtkmodel`-expanded `iv` to be MTKBase's `PleaseImportDynamicQuantities()` sentinel and `solve(prob)` to error out at `Default algorithm choices require DifferentialEquations.jl`. * `Magnetic/magnetic.jl` Inductor: the flux-conservation assertion at the shared magnetic node used exact `.==` against an observable reconstructed via symbolic substitution; the structural equation is enforced but rounding in the substitution accumulates to ~2e-19. Loosened to `isapprox(...; atol=1e-12)` - still 7 orders of magnitude below any physical flux scale. Verified locally on MTK v11.26.0 / MTKBase v1.35.1 / Symbolics v7.23.0 / SymbolicUtils v4.29.1: - Thermal/thermal.jl: 18/19 pass (1 pre-existing fail in the alpha=0 testset, also failing on April 27 master) - Thermal/motor.jl: 6/6 - Thermal/piston.jl: 3/3 - Magnetic/magnetic.jl: 3/3 Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
1 parent 6c1a7b3 commit ffbea8f

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

test/Magnetic/magnetic.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,15 @@ using OrdinaryDiffEqRosenbrock: Rodas4
6363

6464
@test SciMLBase.successful_retcode(sol)
6565
@test sol[r_mFe.Phi] == sol[r_mAirPar.Phi]
66-
@test all(sol[coil.port_p.Phi] + sol[r_mLeak.Phi] + sol[r_mAirPar.Phi] .== 0)
66+
# Conservation of flux at the shared node is structural (a `connect` flow
67+
# equation), but observed via numerical reconstruction. Roundoff in the
68+
# observable substitution accumulates to ~1e-19; use isapprox with a
69+
# tolerance well above that (and far below any physical scale).
70+
@test all(
71+
isapprox.(
72+
sol[coil.port_p.Phi] + sol[r_mLeak.Phi] + sol[r_mAirPar.Phi],
73+
0;
74+
atol = 1.0e-12
75+
)
76+
)
6777
end

test/Thermal/motor.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using ModelingToolkit, Test
1+
using ModelingToolkit, OrdinaryDiffEq, Test
2+
using ModelingToolkit: t_nounits as t, D_nounits as D
23
using SciCompDSL
34
using SciMLBase
45
using ModelingToolkitStandardLibrary.Thermal

test/Thermal/piston.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using ModelingToolkit, Test
1+
using ModelingToolkit, OrdinaryDiffEq, Test
2+
using ModelingToolkit: t_nounits as t, D_nounits as D
23
using SciCompDSL
34
using SciMLBase
45
using ModelingToolkitStandardLibrary.Thermal

test/Thermal/thermal.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
55
using ModelingToolkitStandardLibrary.Blocks: Constant, Step
66
using OrdinaryDiffEq: ReturnCode.Success
77
using OrdinaryDiffEqRosenbrock: Rodas4
8+
using OrdinaryDiffEqSDIRK: ImplicitEuler
89

910
# Test HeatCapacitor, TemperatureSensor, RelativeTemperatureSensor, FixedTemperature
1011
@testset "Heat systems" begin
@@ -195,7 +196,11 @@ end
195196
@info "Building a FixedHeatFlow with alpha=0.0"
196197
@mtkcompile test_model = TestModel() allow_parameter = false
197198
prob = ODEProblem(test_model, [test_model.wall.Q_flow => nothing, test_model.wall.dT => nothing], (0, 10.0); guesses = [test_model.heatflow.port.T => 1.0])
198-
sol = solve(prob)
199+
# The compiled system has no differential states (purely algebraic). The
200+
# auto-switching default algorithm cannot make forward progress on this
201+
# and hangs the test runner indefinitely; ImplicitEuler with a fixed dt
202+
# handles the trivially-constant trajectory.
203+
sol = solve(prob, ImplicitEuler(); dt = 1.0, adaptive = false)
199204

200205
heat_flow = sol[test_model.heatflow.port.Q_flow]
201206

0 commit comments

Comments
 (0)