@@ -2,6 +2,8 @@ using ModelingToolkit, FMI, FMIZoo, OrdinaryDiffEq
2
2
using ModelingToolkit: t_nounits as t, D_nounits as D
3
3
import ModelingToolkit as MTK
4
4
5
+ const FMU_DIR = joinpath (@__DIR__ , " fmus" )
6
+
5
7
@testset " Standalone pendulum model" begin
6
8
fmu = loadFMU (" SpringPendulum1D" , " Dymola" , " 2022x" ; type = :ME )
7
9
truesol = FMI. simulate (
71
73
72
74
@testset " IO Model" begin
73
75
@testset " v2, ME" begin
74
- fmu = loadFMU (" ../../omc-fmus/ SimpleAdder.fmu" ; type = :ME )
76
+ fmu = loadFMU (joinpath (FMU_DIR, " SimpleAdder.fmu" ) ; type = :ME )
75
77
@named adder = MTK. FMIComponent (Val (2 ); fmu, type = :ME )
76
78
@variables a (t) b (t) c (t) [guess = 1.0 ]
77
79
@mtkbuild sys = ODESystem (
87
89
@test SciMLBase. successful_retcode (sol)
88
90
end
89
91
@testset " v2, CS" begin
90
- fmu = loadFMU (" ../../omc-fmus/ SimpleAdder.fmu" ; type = :CS )
92
+ fmu = loadFMU (joinpath (FMU_DIR, " SimpleAdder.fmu" ) ; type = :CS )
91
93
@named adder = MTK. FMIComponent (
92
94
Val (2 ); fmu, type = :CS , communication_step_size = 0.001 )
93
95
@variables a (t) b (t) c (t) [guess = 1.0 ]
104
106
sol = solve (prob, Rodas5P (autodiff = false ))
105
107
@test SciMLBase. successful_retcode (sol)
106
108
end
109
+
110
+ @testset " v3, ME" begin
111
+ fmu = loadFMU (joinpath (FMU_DIR, " StateSpace.fmu" ); type = :ME )
112
+ @named sspace = MTK. FMIComponent (Val (3 ); fmu, type = :ME )
113
+ @variables u (t)= 1.0 x (t)= 1.0 y (t) [guess = 1.0 ]
114
+ @mtkbuild sys = ODESystem (
115
+ [sspace. u ~ u, D (u) ~ t, D (x) ~ sspace. x + sspace. y, y^ 2 ~ sspace. y + x], t;
116
+ systems = [sspace]
117
+ )
118
+
119
+ prob = ODEProblem (sys, [sys. sspace. x => 1.0 ], (0.0 , 1.0 ); use_scc = false )
120
+ sol = solve (prob, Rodas5P (autodiff = false ))
121
+ @test SciMLBase. successful_retcode (sol)
122
+ end
123
+
124
+ @testset " v3, CS" begin
125
+ fmu = loadFMU (joinpath (FMU_DIR, " StateSpace.fmu" ); type = :CS )
126
+ @named sspace = MTK. FMIComponent (
127
+ Val (3 ); fmu, communication_step_size = 1e-3 , type = :CS )
128
+ @variables u (t)= 1.0 x (t)= 1.0 y (t) [guess = 1.0 ]
129
+ @mtkbuild sys = ODESystem (
130
+ [sspace. u ~ u, D (u) ~ t, D (x) ~ sspace. x + sspace. y, y^ 2 ~ sspace. y + x], t;
131
+ systems = [sspace]
132
+ )
133
+
134
+ prob = ODEProblem (sys, [sys. sspace. x => 1.0 ], (0.0 , 1.0 ); use_scc = false )
135
+ sol = solve (prob, Rodas5P (autodiff = false ))
136
+ @test SciMLBase. successful_retcode (sol)
137
+ end
107
138
end
0 commit comments