Skip to content

Commit 4a4ab24

Browse files
authored
Merge pull request #122 from SciML/b/fix-deim-complete-system
Fix DEIM system construction by completing system before return
2 parents 97aa0bc + 67603fd commit 4a4ab24

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

docs/src/tutorials/deim_FitzHugh-Nagumo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ plt_2 = plot(xlabel = L"v(x,t)", ylabel = L"x", zlabel = L"w(x,t)", xlims = (-0.
181181
ylims = (0.0, L), zlims = (0.0, 0.25), xflip = true, camera = (50, 30),
182182
titlefont = 10, title = "Comparison of full and reduced systems")
183183
plot!(plt_2, unconnected(snapshot_v), unconnected(sol_x, nₜ), unconnected(snapshot_w),
184-
label = "Full$(length(ode_sys.eqs))")
184+
label = "Full$(length(ModelingToolkit.get_eqs(ode_sys)))")
185185
plot!(plt_2, unconnected(sol_deim_v), unconnected(sol_deim_x, nₜ_deim),
186186
unconnected(sol_deim_w), label = "POD$(pod_dim)/DEIM$(deim_dim)")
187187
```

src/deim.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,11 @@ function deim(sys::ODESystem, snapshot::AbstractMatrix, pod_dim::Integer;
172172

173173
inv_dict = Dict(Symbolics.scalarize(ŷ .=> V' * dvs)) # reduced vars to original vars
174174
@set! sys.defaults = merge(ModelingToolkit.defaults(sys), inv_dict)
175+
176+
# CRITICAL: Call complete() on the system before returning to ensure all subsystems,
177+
# variables, and parameters are properly registered and namespaced. Without this,
178+
# attempting to create an ODEProblem from the DEIM system will fail with errors about
179+
# missing initial conditions for variables that should exist in the system.
180+
# This is required due to changes in ModelingToolkit.jl's internal structure handling.
181+
return complete(sys)
175182
end

0 commit comments

Comments
 (0)