@@ -9,9 +9,16 @@ const FMU_DIR = joinpath(@__DIR__, "fmus")
9
9
truesol = FMI. simulate (
10
10
fmu, (0.0 , 8.0 ); saveat = 0.0 : 0.1 : 8.0 , recordValues = [" mass.s" , " mass.v" ])
11
11
12
+ function test_no_inputs_outputs (sys)
13
+ for var in unknowns (sys)
14
+ @test ! MTK. isinput (var)
15
+ @test ! MTK. isoutput (var)
16
+ end
17
+ end
12
18
@testset " v2, ME" begin
13
19
fmu = loadFMU (" SpringPendulum1D" , " Dymola" , " 2022x" ; type = :ME )
14
20
@mtkbuild sys = MTK. FMIComponent (Val (2 ); fmu, type = :ME )
21
+ test_no_inputs_outputs (sys)
15
22
prob = ODEProblem {true, SciMLBase.FullSpecialize} (
16
23
sys, [sys. mass__s => 0.5 , sys. mass__v => 0.0 ], (0.0 , 8.0 ))
17
24
sol = solve (prob, Tsit5 (); reltol = 1e-8 , abstol = 1e-8 )
@@ -28,6 +35,7 @@ const FMU_DIR = joinpath(@__DIR__, "fmus")
28
35
Val (2 ); fmu, communication_step_size = 0.001 , type = :CS )
29
36
@variables x (t) = 1.0
30
37
@mtkbuild sys = ODESystem ([D (x) ~ x], t; systems = [inner])
38
+ test_no_inputs_outputs (sys)
31
39
32
40
prob = ODEProblem {true, SciMLBase.FullSpecialize} (
33
41
sys, [sys. inner. mass__s => 0.5 , sys. inner. mass__v => 0.0 ], (0.0 , 8.0 ))
@@ -44,6 +52,7 @@ const FMU_DIR = joinpath(@__DIR__, "fmus")
44
52
@testset " v3, ME" begin
45
53
fmu = loadFMU (" SpringPendulum1D" , " Dymola" , " 2023x" , " 3.0" ; type = :ME )
46
54
@mtkbuild sys = MTK. FMIComponent (Val (3 ); fmu, type = :ME )
55
+ test_no_inputs_outputs (sys)
47
56
prob = ODEProblem {true, SciMLBase.FullSpecialize} (
48
57
sys, [sys. mass__s => 0.5 , sys. mass__v => 0.0 ], (0.0 , 8.0 ))
49
58
sol = solve (prob, Tsit5 (); reltol = 1e-8 , abstol = 1e-8 )
@@ -60,6 +69,7 @@ const FMU_DIR = joinpath(@__DIR__, "fmus")
60
69
Val (3 ); fmu, communication_step_size = 0.001 , type = :CS )
61
70
@variables x (t) = 1.0
62
71
@mtkbuild sys = ODESystem ([D (x) ~ x], t; systems = [inner])
72
+ test_no_inputs_outputs (sys)
63
73
64
74
prob = ODEProblem {true, SciMLBase.FullSpecialize} (
65
75
sys, [sys. inner. mass__s => 0.5 , sys. inner. mass__v => 0.0 ], (0.0 , 8.0 ))
75
85
@testset " v2, ME" begin
76
86
fmu = loadFMU (joinpath (FMU_DIR, " SimpleAdder.fmu" ); type = :ME )
77
87
@named adder = MTK. FMIComponent (Val (2 ); fmu, type = :ME )
88
+ @test MTK. isinput (adder. a)
89
+ @test MTK. isinput (adder. b)
90
+ @test MTK. isoutput (adder. out)
91
+ @test ! MTK. isinput (adder. c) && ! MTK. isoutput (adder. c)
92
+
78
93
@variables a (t) b (t) c (t) [guess = 1.0 ]
79
94
@mtkbuild sys = ODESystem (
80
95
[adder. a ~ a, adder. b ~ b, D (a) ~ t,
92
107
fmu = loadFMU (joinpath (FMU_DIR, " SimpleAdder.fmu" ); type = :CS )
93
108
@named adder = MTK. FMIComponent (
94
109
Val (2 ); fmu, type = :CS , communication_step_size = 0.001 )
110
+ @test MTK. isinput (adder. a)
111
+ @test MTK. isinput (adder. b)
112
+ @test MTK. isoutput (adder. out)
113
+ @test ! MTK. isinput (adder. c) && ! MTK. isoutput (adder. c)
95
114
@variables a (t) b (t) c (t) [guess = 1.0 ]
96
115
@mtkbuild sys = ODESystem (
97
116
[adder. a ~ a, adder. b ~ b, D (a) ~ t,
110
129
@testset " v3, ME" begin
111
130
fmu = loadFMU (joinpath (FMU_DIR, " StateSpace.fmu" ); type = :ME )
112
131
@named sspace = MTK. FMIComponent (Val (3 ); fmu, type = :ME )
132
+ @test MTK. isinput (sspace. u)
133
+ @test MTK. isoutput (sspace. y)
134
+ @test ! MTK. isinput (sspace. x) && ! MTK. isoutput (sspace. x)
113
135
@variables u (t)= 1.0 x (t)= 1.0 y (t) [guess = 1.0 ]
114
136
@mtkbuild sys = ODESystem (
115
137
[sspace. u ~ u, D (u) ~ t, D (x) ~ sspace. x + sspace. y, y^ 2 ~ sspace. y + x], t;
125
147
fmu = loadFMU (joinpath (FMU_DIR, " StateSpace.fmu" ); type = :CS )
126
148
@named sspace = MTK. FMIComponent (
127
149
Val (3 ); fmu, communication_step_size = 1e-3 , type = :CS )
150
+ @test MTK. isinput (sspace. u)
151
+ @test MTK. isoutput (sspace. y)
152
+ @test ! MTK. isinput (sspace. x) && ! MTK. isoutput (sspace. x)
128
153
@variables u (t)= 1.0 x (t)= 1.0 y (t) [guess = 1.0 ]
129
154
@mtkbuild sys = ODESystem (
130
155
[sspace. u ~ u, D (u) ~ t, D (x) ~ sspace. x + sspace. y, y^ 2 ~ sspace. y + x], t;
0 commit comments