Skip to content

Commit aff82c5

Browse files
Use stiff solver in DEIM test (#164)
* Use stiff solver in DEIM test Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> * Fix DEIM test init: supply consistent u0 instead of missing-guess hack The full-order solve returned InitialFailure on the current MTK v11 / MethodOfLines stack, so the snapshot had a single time column and `POD(snapshot, 3)` errored with "Number of modes should be in {1,...,1}". Root cause is initialization, not the solver. Passing `missing_guess_value = Constant(0.0)` left every discretized state as a missing guess, so MethodOfLines' initialization system was structurally singular and underdetermined (1 equation for 11 unknowns). MTK fell back to a least-squares initialization that diverged from the all-zero guess (residual norm ~4.9e4, MaxIters), producing a garbage u0 (values ~1e19) and an InitialFailure return code. Switching the solver to Rodas5P did not help because the failure happens during initialization, before any step is taken. The boundary conditions fix every state to 0 at t=0 (v(x,0)=w(x,0)=0 and i₀(0)=0), so the correct initial condition is simply all zeros. Providing it explicitly makes the initialization well-posed and the solve succeeds, yielding a 15-column snapshot that exercises POD/DEIM as intended. Verified on the CI-failing stack (MethodOfLines 0.11.14, MTK 11.31.1, ModelingToolkitBase 1.51.0, PDEBase 0.1.27): GROUP=Core Pkg.test() passes (Core/deim.jl 4/4) and Runic --check is clean. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> --------- Co-authored-by: ChrisRackauckas-Claude <accounts@chrisrackauckas.com>
1 parent 35d5474 commit aff82c5

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

test/deim.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ order = 2
3838
discretization = MOLFiniteDifference(dxs, t; approx_order = order)
3939
ode_sys, tspan = symbolic_discretize(pde_sys, discretization)
4040
simp_sys = mtkcompile(ode_sys) # field substitutions is non-empty
41-
ode_prob = ODEProblem(
42-
simp_sys, nothing, tspan;
43-
missing_guess_value = ModelingToolkit.MissingGuessValue.Constant(0.0)
44-
)
45-
sol = solve(ode_prob, Tsit5(), saveat = 1.0)
41+
# The BCs fix every state to 0 at t=0, so provide those initial values directly.
42+
# Leaving them as missing guesses makes MethodOfLines' initialization system
43+
# structurally singular under MTK v11, and the least-squares solve diverges.
44+
u0 = [u => 0.0 for u in ModelingToolkit.get_unknowns(simp_sys)]
45+
ode_prob = ODEProblem(simp_sys, u0, tspan)
46+
sol = solve(ode_prob, Rodas5P(), saveat = 1.0)
4647

4748
snapshot_simpsys = Array(sol.original_sol)
4849
pod_dim = 3
@@ -53,7 +54,7 @@ deim_sys = @test_nowarn deim(simp_sys, snapshot_simpsys, pod_dim)
5354

5455
deim_prob = ODEProblem(complete(deim_sys), nothing, tspan)
5556

56-
deim_sol = solve(deim_prob, Tsit5(), saveat = 1.0)
57+
deim_sol = solve(deim_prob, Rodas5P(), saveat = 1.0)
5758

5859
nₓ = length(sol[x])
5960
nₜ = length(sol[t])

0 commit comments

Comments
 (0)