Skip to content

Commit c372361

Browse files
Brad CarmanChrisRackauckas
authored andcommitted
Added a test for SISO initial value set
1 parent 6c32692 commit c372361

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/Blocks/utils.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using ModelingToolkitStandardLibrary.Blocks
22
using ModelingToolkit
3+
using OrdinaryDiffEq
34

45
@testset "Array Guesses" begin
56
for (block, guess) in [
@@ -23,6 +24,22 @@ end
2324
end
2425
end
2526

27+
@testset "SISO Check" begin
28+
k, w, d = 1.0, 1.0, 0.5
29+
@named c = Constant(; k = 1)
30+
@named so = SecondOrder(; k = k, w = w, d = d, xd = 1)
31+
@named iosys = ODESystem(connect(c.output, so.input), t, systems = [so, c])
32+
sys = structural_simplify(iosys)
33+
34+
initsys = ModelingToolkit.generate_initializesystem(sys)
35+
initsys = structural_simplify(initsys)
36+
initprob = NonlinearProblem(initsys, [t=>0])
37+
initsol = solve(initprob)
38+
39+
@test initsol[sys.so.xd] == 1.0
40+
@test initsol[sys.so.u] == 1.0
41+
end
42+
2643
@test_deprecated RealInput(; name = :a, u_start = 1.0)
2744
@test_deprecated RealInput(; name = :a, nin = 2, u_start = ones(2))
2845
@test_deprecated RealOutput(; name = :a, u_start = 1.0)

0 commit comments

Comments
 (0)