Skip to content

Commit d857ef7

Browse files
Update for ModelingToolkit v11, OrdinaryDiffEq v7, DifferentialEquations v8
Bump compat for the breaking CompatHelper PRs: - ModelingToolkit 10.10 -> 11 (main, test, docs) - OrdinaryDiffEq 6 -> 7 (test) - DifferentialEquations 7.6 -> 8 (docs) - Replace ModelingToolkit `defaults` with `initial_conditions` in `deim`, storing numeric initial values for the reduced unknowns derived from the snapshot's first column. `defaults` was removed in MTK v11 and replaced by `bindings` (for symbolic expressions) and `initial_conditions` (for numeric values). - Use `ModelingToolkit.bindings(sys)` semantics: keys must be whole array symbolics, not scalarized indices, hence the array-valued assignment. - Switch the tutorial from `structural_simplify` (deprecated in MTK v10) to `mtkcompile`. - Pass `missing_guess_value = ModelingToolkit.MissingGuessValue.Constant(0.0)` to `ODEProblem` for the MOL-discretized FitzHugh-Nagumo system in the test and docs to work around cyclic self-referencing guesses produced by `MethodOfLines` under MTK v11. Closes/supersedes the breaking-major CompatHelper PRs: #127, #128, #137 (ModelingToolkit -> 11), #146 (OrdinaryDiffEq -> 7), #147 (DifferentialEquations -> 8). Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
1 parent d1d261c commit d857ef7

6 files changed

Lines changed: 16 additions & 16 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ TSVD = "9449cd9e-2762-5aa3-a617-5413e99d722e"
1616
[compat]
1717
DocStringExtensions = "0.8, 0.9"
1818
LinearAlgebra = "1"
19-
ModelingToolkit = "10.10"
19+
ModelingToolkit = "11"
2020
PrecompileTools = "1"
2121
RandomizedLinAlg = "0.1"
2222
Setfield = "0.8, 1"

docs/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
99
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
1010

1111
[compat]
12-
DifferentialEquations = "7.6"
12+
DifferentialEquations = "8"
1313
Documenter = "1"
1414
LaTeXStrings = "1.3"
1515
MethodOfLines = "0.11"
1616
ModelOrderReduction = "0.1"
17-
ModelingToolkit = "10"
17+
ModelingToolkit = "11"
1818
Plots = "1.40"

docs/src/tutorials/deim_FitzHugh-Nagumo.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ dxs = [x => dx]
7878
order = 2
7979
discretization = MOLFiniteDifference(dxs, t; approx_order = order)
8080
ode_sys, tspan = symbolic_discretize(pde_sys, discretization)
81-
simp_sys = structural_simplify(ode_sys)
82-
ode_prob = ODEProblem(simp_sys, nothing, tspan)
81+
simp_sys = mtkcompile(ode_sys)
82+
ode_prob = ODEProblem(simp_sys, nothing, tspan;
83+
missing_guess_value = ModelingToolkit.MissingGuessValue.Constant(0.0))
8384
nothing # hide
8485
```
8586

src/deim.jl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,11 @@ function deim(
176176
)
177177
@set! sys.observed = new_sorted_observed
178178

179-
inv_dict = Dict(Symbolics.scalarize(ŷ .=> V' * dvs)) # reduced vars to original vars
180-
@set! sys.defaults = merge(ModelingToolkit.defaults(sys), inv_dict)
181-
182-
# CRITICAL: Call complete() on the system before returning to ensure all subsystems,
183-
# variables, and parameters are properly registered and namespaced. Without this,
184-
# attempting to create an ODEProblem from the DEIM system will fail with errors about
185-
# missing initial conditions for variables that should exist in the system.
186-
# This is required due to changes in ModelingToolkit.jl's internal structure handling.
179+
# Numeric initial conditions for the reduced unknowns from the snapshot's first column.
180+
# The snapshot is assumed to start at t = tspan[1], matching the FOM initial state.
181+
new_ics = copy(ModelingToolkit.get_initial_conditions(sys))
182+
new_ics[Symbolics.unwrap(ŷ)] = V' * snapshot[:, 1]
183+
@set! sys.initial_conditions = new_ics
184+
187185
return complete(sys)
188186
end

test/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1111
LinearAlgebra = "1"
1212
MethodOfLines = "0.11"
1313
Pkg = "1.10"
14-
ModelingToolkit = "10.10"
15-
OrdinaryDiffEq = "6"
14+
ModelingToolkit = "11"
15+
OrdinaryDiffEq = "7"
1616
SafeTestsets = "0.1"

test/deim.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ 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(simp_sys, nothing, tspan)
41+
ode_prob = ODEProblem(simp_sys, nothing, tspan;
42+
missing_guess_value = ModelingToolkit.MissingGuessValue.Constant(0.0))
4243
sol = solve(ode_prob, Tsit5(), saveat = 1.0)
4344

4445
snapshot_simpsys = Array(sol.original_sol)

0 commit comments

Comments
 (0)