|
50 | 50 | @mtkbuild sys = ODESystem(
|
51 | 51 | [D(x) ~ z[1] + z[2] + foo(z)[1], y[1] ~ 2t, y[2] ~ 3t, z ~ foo(y)], t)
|
52 | 52 | @test length(equations(sys)) == 1
|
53 |
| - @test length(observed(sys)) == 7 |
| 53 | + @test length(observed(sys)) == 6 |
54 | 54 | @test any(eq -> isequal(eq.lhs, y), observed(sys))
|
55 | 55 | @test any(eq -> isequal(eq.lhs, z), observed(sys))
|
56 | 56 | prob = ODEProblem(sys, [x => 1.0], (0.0, 1.0), [foo => _tmp_fn])
|
|
75 | 75 | end
|
76 | 76 | @mtkbuild sys = ODESystem([D(x) ~ y[1] + y[2], y ~ foo(x)], t)
|
77 | 77 | @test length(equations(sys)) == 1
|
78 |
| - @test length(observed(sys)) == 3 |
| 78 | + @test length(observed(sys)) == 2 |
79 | 79 | prob = ODEProblem(sys, [x => 1.0], (0.0, 1.0), [foo => _tmp_fn2])
|
80 | 80 | val[] = 0
|
81 | 81 | @test_nowarn prob.f(prob.u0, prob.p, 0.0)
|
|
88 | 88 | iscall(eq.rhs) && operation(eq.rhs) in [StructuralTransformations.getindex_wrapper,
|
89 | 89 | StructuralTransformations.change_origin]
|
90 | 90 | end
|
91 |
| - |
92 |
| - @testset "CSE hack in equations(sys)" begin |
93 |
| - val[] = 0 |
94 |
| - @variables z(t)[1:2] |
95 |
| - @mtkbuild sys = ODESystem( |
96 |
| - [D(y) ~ foo(x), D(x) ~ sum(y), zeros(2) ~ foo(prod(z))], t) |
97 |
| - @test length(equations(sys)) == 5 |
98 |
| - @test length(observed(sys)) == 2 |
99 |
| - prob = ODEProblem( |
100 |
| - sys, [y => ones(2), z => 2ones(2), x => 3.0], (0.0, 1.0), [foo => _tmp_fn2]) |
101 |
| - val[] = 0 |
102 |
| - @test_nowarn prob.f(prob.u0, prob.p, 0.0) |
103 |
| - @test val[] == 2 |
104 |
| - |
105 |
| - isys = ModelingToolkit.generate_initializesystem(sys) |
106 |
| - @test length(unknowns(isys)) == 5 |
107 |
| - @test length(equations(isys)) == 2 |
108 |
| - @test !any(equations(isys)) do eq |
109 |
| - iscall(eq.rhs) && |
110 |
| - operation(eq.rhs) in [StructuralTransformations.getindex_wrapper, |
111 |
| - StructuralTransformations.change_origin] |
112 |
| - end |
113 |
| - end |
114 | 91 | end
|
115 | 92 |
|
116 |
| -@testset "array and cse hacks can be disabled" begin |
| 93 | +@testset "array hacks can be disabled" begin |
117 | 94 | @testset "fully_determined = true" begin
|
118 | 95 | @variables x(t) y(t)[1:2] z(t)[1:2]
|
119 | 96 | @parameters foo(::AbstractVector)[1:2]
|
|
129 | 106 | end
|
130 | 107 |
|
131 | 108 | sys2 = structural_simplify(sys; array_hack = false)
|
132 |
| - @test length(observed(sys2)) == 5 |
| 109 | + @test length(observed(sys2)) == 4 |
133 | 110 | @test !any(observed(sys2)) do eq
|
134 | 111 | iscall(eq.rhs) && operation(eq.rhs) == StructuralTransformations.change_origin
|
135 | 112 | end
|
|
150 | 127 | end
|
151 | 128 |
|
152 | 129 | sys2 = structural_simplify(sys; array_hack = false, fully_determined = false)
|
153 |
| - @test length(observed(sys2)) == 5 |
| 130 | + @test length(observed(sys2)) == 4 |
154 | 131 | @test !any(observed(sys2)) do eq
|
155 | 132 | iscall(eq.rhs) && operation(eq.rhs) == StructuralTransformations.change_origin
|
156 | 133 | end
|
|
0 commit comments