Skip to content

Commit 74b2cae

Browse files
committed
Add Reference FMUs (#1365)
1 parent ece2b64 commit 74b2cae

103 files changed

Lines changed: 14779 additions & 16 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

testsuite/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
all: difftool resources test
44

5-
test: api.log AircraftVehicleDemonstrator.log import.log export.log simulation.log assc.log
5+
test: api.log AircraftVehicleDemonstrator.log import.log export.log simulation.log assc.log reference-fmus.log
66

77
partest: difftool resources
88
cd partest && time ./runtests.pl -nocolour -with-xml
@@ -36,3 +36,7 @@ simulation.log: difftool
3636
assc.log: difftool
3737
@$(MAKE) -C assc -f Makefile test > $@
3838
@grep == assc.log
39+
40+
reference-fmus.log: difftool
41+
@$(MAKE) -C reference-fmus -f Makefile test > $@
42+
@grep == reference-fmus.log
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
-- status: correct
2+
-- teardown_command: rm -rf BouncingBall-lua/
3+
-- linux: yes
4+
-- ucrt64: yes
5+
-- win: yes
6+
-- mac: yes
7+
-- asan: yes
8+
9+
oms_setCommandLineOption("--suppressPath=true")
10+
oms_setTempDirectory("./BouncingBall-lua/")
11+
oms_setWorkingDirectory("./BouncingBall-lua/")
12+
13+
oms_newModel("model")
14+
oms_addSystem("model.root", oms_system_wc)
15+
16+
oms_addSubModel("model.root.BouncingBall", "../../resources/BouncingBall.fmu")
17+
18+
oms_setResultFile("model", "BouncingBall-cs.mat")
19+
oms_setStopTime("model", 3.0)
20+
oms_setTolerance("model.root", 1e-5, 1e-5)
21+
22+
oms_instantiate("model")
23+
oms_initialize("model")
24+
oms_simulate("model")
25+
oms_terminate("model")
26+
oms_delete("model")
27+
28+
if 1 == oms_compareSimulationResults("../../references/BouncingBall-cs.mat", "BouncingBall-cs.mat", "model.root.BouncingBall.h", 1e-4, 1e-4) then
29+
print("signal h is equal")
30+
else
31+
print("signal h is not equal")
32+
end
33+
34+
if 1 == oms_compareSimulationResults("../../references/BouncingBall-cs.mat", "BouncingBall-cs.mat", "model.root.BouncingBall.v", 1e-4, 1e-4) then
35+
print("signal v is equal")
36+
else
37+
print("signal v is not equal")
38+
end
39+
40+
oms_newModel("model")
41+
oms_addSystem("model.root", oms_system_sc)
42+
43+
oms_addSubModel("model.root.BouncingBall", "../../resources/BouncingBall.fmu")
44+
45+
oms_setResultFile("model", "BouncingBall-me.mat")
46+
oms_setStopTime("model", 3.0)
47+
oms_setTolerance("model.root", 1e-5, 1e-5)
48+
49+
oms_instantiate("model")
50+
oms_initialize("model")
51+
oms_simulate("model")
52+
oms_terminate("model")
53+
oms_delete("model")
54+
55+
if 1 == oms_compareSimulationResults("../../references/BouncingBall-me.mat", "BouncingBall-me.mat", "model.root.BouncingBall.h", 1e-4, 1e-4) then
56+
print("signal h is equal")
57+
else
58+
print("signal h is not equal")
59+
end
60+
61+
if 1 == oms_compareSimulationResults("../../references/BouncingBall-me.mat", "BouncingBall-me.mat", "model.root.BouncingBall.v", 1e-4, 1e-4) then
62+
print("signal v is equal")
63+
else
64+
print("signal v is not equal")
65+
end
66+
67+
-- Result:
68+
-- info: Result file: BouncingBall-cs.mat (bufferSize=1)
69+
-- signal h is equal
70+
-- signal v is equal
71+
-- info: maximum step size for 'model.root': 0.001000
72+
-- info: Result file: BouncingBall-me.mat (bufferSize=1)
73+
-- info: Final Statistics for 'model.root':
74+
-- NumSteps = 502 NumRhsEvals = 503 NumLinSolvSetups = 27
75+
-- NumNonlinSolvIters = 502 NumNonlinSolvConvFails = 0 NumErrTestFails = 0
76+
-- signal h is equal
77+
-- signal v is equal
78+
-- endResult
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
-- status: correct
2+
-- teardown_command: rm -rf Dahlquist-lua/
3+
-- linux: yes
4+
-- ucrt64: yes
5+
-- win: yes
6+
-- mac: yes
7+
-- asan: yes
8+
9+
oms_setCommandLineOption("--suppressPath=true")
10+
oms_setTempDirectory("./Dahlquist-lua/")
11+
oms_setWorkingDirectory("./Dahlquist-lua/")
12+
13+
oms_newModel("model")
14+
oms_addSystem("model.root", oms_system_wc)
15+
16+
oms_addSubModel("model.root.Dahlquist", "../../resources/Dahlquist.fmu")
17+
18+
oms_setResultFile("model", "Dahlquist-cs.mat")
19+
oms_setStopTime("model", 10.0)
20+
oms_setTolerance("model.root", 1e-5, 1e-5)
21+
22+
oms_instantiate("model")
23+
oms_initialize("model")
24+
oms_simulate("model")
25+
oms_terminate("model")
26+
oms_delete("model")
27+
28+
if 1 == oms_compareSimulationResults("../../references/Dahlquist-cs.mat", "Dahlquist-cs.mat", "model.root.Dahlquist.x", 1e-4, 1e-4) then
29+
print("signal x is equal")
30+
else
31+
print("signal x is not equal")
32+
end
33+
34+
oms_newModel("model")
35+
oms_addSystem("model.root", oms_system_sc)
36+
37+
oms_addSubModel("model.root.Dahlquist", "../../resources/Dahlquist.fmu")
38+
39+
oms_setResultFile("model", "Dahlquist-me.mat")
40+
oms_setStopTime("model", 10.0)
41+
oms_setTolerance("model.root", 1e-5, 1e-5)
42+
43+
oms_instantiate("model")
44+
oms_initialize("model")
45+
oms_simulate("model")
46+
oms_terminate("model")
47+
oms_delete("model")
48+
49+
if 1 == oms_compareSimulationResults("../../references/Dahlquist-me.mat", "Dahlquist-me.mat", "model.root.Dahlquist.x", 1e-4, 1e-4) then
50+
print("signal x is equal")
51+
else
52+
print("signal x is not equal")
53+
end
54+
55+
-- Result:
56+
-- info: Result file: Dahlquist-cs.mat (bufferSize=1)
57+
-- signal x is equal
58+
-- info: maximum step size for 'model.root': 0.001000
59+
-- info: Result file: Dahlquist-me.mat (bufferSize=1)
60+
-- info: Final Statistics for 'model.root':
61+
-- NumSteps = 10001 NumRhsEvals = 10002 NumLinSolvSetups = 501
62+
-- NumNonlinSolvIters = 10001 NumNonlinSolvConvFails = 0 NumErrTestFails = 0
63+
-- signal x is equal
64+
-- endResult
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
-- status: correct
2+
-- teardown_command: rm -rf Feedthrough-lua/
3+
-- linux: yes
4+
-- ucrt64: yes
5+
-- win: yes
6+
-- mac: yes
7+
-- asan: yes
8+
9+
oms_setCommandLineOption("--suppressPath=true")
10+
oms_setTempDirectory("./Feedthrough-lua/")
11+
oms_setWorkingDirectory("./Feedthrough-lua/")
12+
13+
oms_newModel("model")
14+
oms_addSystem("model.root", oms_system_wc)
15+
16+
oms_addSubModel("model.root.Feedthrough", "../../resources/Feedthrough.fmu")
17+
18+
oms_setResultFile("model", "Feedthrough-cs.mat")
19+
oms_setStopTime("model", 10.0)
20+
oms_setTolerance("model.root", 1e-5, 1e-5)
21+
22+
oms_instantiate("model")
23+
oms_setBoolean("model.root.Feedthrough.Boolean_input", true)
24+
oms_setInteger("model.root.Feedthrough.Enumeration_input", 2)
25+
oms_setReal("model.root.Feedthrough.Float64_continuous_input", 3.1)
26+
oms_setReal("model.root.Feedthrough.Float64_discrete_input", 4.2)
27+
oms_setInteger("model.root.Feedthrough.Int32_input", 5)
28+
29+
oms_initialize("model")
30+
oms_simulate("model")
31+
print("info: Feedthrough.Boolean_output: " .. oms_getBoolean("model.root.Feedthrough.Boolean_output"))
32+
print("info: Feedthrough.Enumeration_output: " .. oms_getInteger("model.root.Feedthrough.Enumeration_output"))
33+
print("info: Feedthrough.Float64_continuous_output: " .. oms_getReal("model.root.Feedthrough.Float64_continuous_output"))
34+
print("info: Feedthrough.Float64_discrete_output: " .. oms_getReal("model.root.Feedthrough.Float64_discrete_output"))
35+
print("info: Feedthrough.Int32_output: " .. oms_getInteger("model.root.Feedthrough.Int32_output"))
36+
37+
oms_terminate("model")
38+
oms_delete("model")
39+
40+
oms_newModel("model")
41+
oms_addSystem("model.root", oms_system_sc)
42+
43+
oms_addSubModel("model.root.Feedthrough", "../../resources/Feedthrough.fmu")
44+
45+
oms_setResultFile("model", "Feedthrough-me.mat")
46+
oms_setStopTime("model", 10.0)
47+
oms_setTolerance("model.root", 1e-5, 1e-5)
48+
49+
oms_instantiate("model")
50+
oms_setBoolean("model.root.Feedthrough.Boolean_input", true)
51+
oms_setInteger("model.root.Feedthrough.Enumeration_input", 2)
52+
oms_setReal("model.root.Feedthrough.Float64_continuous_input", 3.1)
53+
oms_setReal("model.root.Feedthrough.Float64_discrete_input", 4.2)
54+
oms_setInteger("model.root.Feedthrough.Int32_input", 5)
55+
56+
oms_initialize("model")
57+
oms_simulate("model")
58+
print("info: Feedthrough.Boolean_output: " .. oms_getBoolean("model.root.Feedthrough.Boolean_output"))
59+
print("info: Feedthrough.Enumeration_output: " .. oms_getInteger("model.root.Feedthrough.Enumeration_output"))
60+
print("info: Feedthrough.Float64_continuous_output: " .. oms_getReal("model.root.Feedthrough.Float64_continuous_output"))
61+
print("info: Feedthrough.Float64_discrete_output: " .. oms_getReal("model.root.Feedthrough.Float64_discrete_output"))
62+
print("info: Feedthrough.Int32_output: " .. oms_getInteger("model.root.Feedthrough.Int32_output"))
63+
64+
oms_terminate("model")
65+
oms_delete("model")
66+
67+
-- Result:
68+
-- info: Result file: Feedthrough-cs.mat (bufferSize=1)
69+
-- info: Parameter model.root.Feedthrough.String_parameter will not be stored in the result file, because the signal type is not supported
70+
-- info: Feedthrough.Boolean_output: 1
71+
-- info: Feedthrough.Enumeration_output: 2
72+
-- info: Feedthrough.Float64_continuous_output: 3.1
73+
-- info: Feedthrough.Float64_discrete_output: 4.2
74+
-- info: Feedthrough.Int32_output: 5
75+
-- info: model doesn't contain any continuous state
76+
-- info: Result file: Feedthrough-me.mat (bufferSize=1)
77+
-- info: Parameter model.root.Feedthrough.String_parameter will not be stored in the result file, because the signal type is not supported
78+
-- info: Feedthrough.Boolean_output: 1
79+
-- info: Feedthrough.Enumeration_output: 2
80+
-- info: Feedthrough.Float64_continuous_output: 3.1
81+
-- info: Feedthrough.Float64_discrete_output: 4.2
82+
-- info: Feedthrough.Int32_output: 5
83+
-- endResult

testsuite/reference-fmus/Makefile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
TEST = ../rtest -v
2+
3+
TESTFILES = \
4+
BouncingBall.lua \
5+
Dahlquist.lua \
6+
Feedthrough.lua \
7+
Resource.lua \
8+
Stair.lua \
9+
VanDerPol.lua \
10+
11+
# Run make failingtest
12+
FAILINGTESTFILES = \
13+
14+
# Dependency files that are not .lua or Makefile
15+
# Add them here or they will be cleaned.
16+
DEPENDENCIES = \
17+
*.lua \
18+
*.py \
19+
Makefile \
20+
21+
CLEAN = `ls | grep -w -v -f deps.tmp`
22+
23+
.PHONY : test clean getdeps failingtest
24+
25+
test:
26+
@echo
27+
@echo Running tests...
28+
@$(TEST) $(TESTFILES)
29+
30+
baseline:
31+
@echo
32+
@echo Updating badelines...
33+
@$(TEST) -b $(TESTFILES)
34+
35+
# Cleans all files that are not listed as dependencies
36+
clean:
37+
@echo $(DEPENDENCIES) | sed 's/ /\\\|/g' > deps.tmp
38+
@rm -rf $(CLEAN)
39+
40+
# Run this if you want to list out the files (dependencies).
41+
# do it after cleaning and updating the folder
42+
# then you can get a list of file names (which must be dependencies
43+
# since you got them from repository + your own new files)
44+
# then add them to the DEPENDENCIES. You can find the
45+
# list in deps.txt
46+
getdeps:
47+
@echo $(DEPENDENCIES) | sed 's/ /\\\|/g' > deps.tmp
48+
@echo $(CLEAN) | sed -r 's/deps.txt|deps.tmp//g' | sed 's/ / \\\n/g' > deps.txt
49+
@echo Dependency list saved in deps.txt.
50+
@echo Copy the list from deps.txt and add it to the Makefile @DEPENDENCIES
51+
52+
failingtest:
53+
@echo
54+
@echo Running failing tests...
55+
@echo
56+
@$(TEST) $(FAILINGTESTFILES)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
-- status: correct
2+
-- teardown_command: rm -rf Resource-lua/
3+
-- linux: yes
4+
-- ucrt64: yes
5+
-- win: yes
6+
-- mac: yes
7+
-- asan: yes
8+
9+
oms_setCommandLineOption("--suppressPath=true")
10+
oms_setTempDirectory("./Resource-lua/")
11+
oms_setWorkingDirectory("./Resource-lua/")
12+
13+
oms_newModel("model")
14+
oms_addSystem("model.root", oms_system_wc)
15+
oms_addSubModel("model.root.Resource", "../../resources/Resource.fmu")
16+
oms_setResultFile("model", "Resource-cs.mat")
17+
oms_setStopTime("model", 10.0)
18+
oms_setTolerance("model.root", 1e-5, 1e-5)
19+
oms_instantiate("model")
20+
oms_initialize("model")
21+
oms_simulate("model")
22+
print("info: Resource.y: " .. oms_getInteger("model.root.Resource.y"))
23+
oms_terminate("model")
24+
oms_delete("model")
25+
26+
oms_newModel("model")
27+
oms_addSystem("model.root", oms_system_sc)
28+
oms_addSubModel("model.root.Resource", "../../resources/Resource.fmu")
29+
oms_setResultFile("model", "Resource-me.mat")
30+
oms_setStopTime("model", 10.0)
31+
oms_setTolerance("model.root", 1e-5, 1e-5)
32+
oms_instantiate("model")
33+
oms_initialize("model")
34+
oms_simulate("model")
35+
print("info: Resource.y: " .. oms_getInteger("model.root.Resource.y"))
36+
oms_terminate("model")
37+
oms_delete("model")
38+
39+
-- Result:
40+
-- info: Result file: Resource-cs.mat (bufferSize=1)
41+
-- info: Resource.y: 97
42+
-- info: model doesn't contain any continuous state
43+
-- info: Result file: Resource-me.mat (bufferSize=1)
44+
-- info: Resource.y: 97
45+
-- endResult

0 commit comments

Comments
 (0)