Skip to content

Commit f106c56

Browse files
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 <accounts@chrisrackauckas.com>
1 parent b9b150c commit f106c56

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

test/array_state_codegen.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using ModelingToolkitBase: System, connect, mtkcompile, @named, t_nounits
2+
using ModelingToolkitStandardLibrary.Blocks: Constant, StateSpace
3+
using SciMLBase: ODEProblem
4+
using Test
5+
6+
@testset "Array state codegen" begin
7+
A = [0 1; -1 -0.5]
8+
B = [0, 1]
9+
C = [0.9 1;]
10+
D = [0;;]
11+
@named ss = StateSpace(; A, B, C, D, x = zeros(2))
12+
@named source = Constant(; k = 1)
13+
@named model = System(
14+
connect(source.output, ss.input),
15+
t_nounits,
16+
systems = [ss, source]
17+
)
18+
19+
sys = mtkcompile(model)
20+
prob = ODEProblem(sys, Pair[], (0.0, 1.0))
21+
@test prob.u0 == zeros(2)
22+
end

0 commit comments

Comments
 (0)