Skip to content

Commit e05965e

Browse files
test: add test for component FMU hooked up to MTK model, initialization
1 parent fe195b8 commit e05965e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/extensions/fmi.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,20 @@ import ModelingToolkit as MTK
1717
@test_nowarn solve(prob, Tsit5())
1818
end
1919
end
20+
21+
@testset "IO Model" begin
22+
fmu = loadFMU("./fmus/SimpleAdder.fmu"; type = :ME)
23+
@named adder = MTK.FMIComponent(Val(2), Val(:ME); fmu)
24+
@variables a(t) b(t) c(t) [guess = 1.0]
25+
@mtkbuild sys = ODESystem(
26+
[adder.a ~ a, adder.b ~ b, D(a) ~ t,
27+
D(b) ~ adder.out + adder.c, c^2 ~ adder.out + adder.value],
28+
t;
29+
systems = [adder])
30+
31+
# c will be solved for by initialization
32+
# this tests that initialization also works with FMUs
33+
prob = ODEProblem(sys, [sys.adder.c => 1.0, sys.a => 1.0, sys.b => 1.0], (0.0, 1.0))
34+
sol = solve(prob, Rodas5P(autodiff = false))
35+
@test SciMLBase.successful_retcode(sol)
36+
end

0 commit comments

Comments
 (0)