From b9b150ceb9facdce9b73c8f0118cb31b850758fd Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Mon, 13 Jul 2026 06:07:42 -0400 Subject: [PATCH 1/3] Raise ModelingToolkitBase floor for array codegen ModelingToolkitBase 1.0 passes symbolic array indices directly to OffsetArrays and errors with the supported SymbolicUtils floor. Version 1.1 uses the stable-index API and is the first compatible release. Co-Authored-By: Chris Rackauckas --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 6d35e924..6b0d87ab 100644 --- a/Project.toml +++ b/Project.toml @@ -22,7 +22,7 @@ DiffEqBase = "6.190, 7" ForwardDiff = "0.10, 1" LinearAlgebra = "1.10" ModelingToolkit = "11" -ModelingToolkitBase = "1" +ModelingToolkitBase = "1.1" OrdinaryDiffEq = "6, 7" OrdinaryDiffEqBDF = "1, 2" OrdinaryDiffEqDefault = "1, 2" From f106c56af45a74782a2cff9890e517d0d66e5ee3 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Mon, 13 Jul 2026 06:20:25 -0400 Subject: [PATCH 2/3] Test symbolic array state codegen Add a focused regression that compiles a StateSpace block with array states and constructs its ODEProblem under downgraded dependencies. Co-Authored-By: Chris Rackauckas --- test/array_state_codegen.jl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/array_state_codegen.jl diff --git a/test/array_state_codegen.jl b/test/array_state_codegen.jl new file mode 100644 index 00000000..a141840b --- /dev/null +++ b/test/array_state_codegen.jl @@ -0,0 +1,22 @@ +using ModelingToolkitBase: System, connect, mtkcompile, @named, t_nounits +using ModelingToolkitStandardLibrary.Blocks: Constant, StateSpace +using SciMLBase: ODEProblem +using Test + +@testset "Array state codegen" begin + A = [0 1; -1 -0.5] + B = [0, 1] + C = [0.9 1;] + D = [0;;] + @named ss = StateSpace(; A, B, C, D, x = zeros(2)) + @named source = Constant(; k = 1) + @named model = System( + connect(source.output, ss.input), + t_nounits, + systems = [ss, source] + ) + + sys = mtkcompile(model) + prob = ODEProblem(sys, Pair[], (0.0, 1.0)) + @test prob.u0 == zeros(2) +end From 2b9b8f58b2d26013dc6edf55068a5b00e10bf919 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Mon, 13 Jul 2026 14:28:44 +0000 Subject: [PATCH 3/3] Delete test/array_state_codegen.jl --- test/array_state_codegen.jl | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 test/array_state_codegen.jl diff --git a/test/array_state_codegen.jl b/test/array_state_codegen.jl deleted file mode 100644 index a141840b..00000000 --- a/test/array_state_codegen.jl +++ /dev/null @@ -1,22 +0,0 @@ -using ModelingToolkitBase: System, connect, mtkcompile, @named, t_nounits -using ModelingToolkitStandardLibrary.Blocks: Constant, StateSpace -using SciMLBase: ODEProblem -using Test - -@testset "Array state codegen" begin - A = [0 1; -1 -0.5] - B = [0, 1] - C = [0.9 1;] - D = [0;;] - @named ss = StateSpace(; A, B, C, D, x = zeros(2)) - @named source = Constant(; k = 1) - @named model = System( - connect(source.output, ss.input), - t_nounits, - systems = [ss, source] - ) - - sys = mtkcompile(model) - prob = ODEProblem(sys, Pair[], (0.0, 1.0)) - @test prob.u0 == zeros(2) -end