-
Notifications
You must be signed in to change notification settings - Fork 49
/
checkUnits.lua
64 lines (51 loc) · 2.03 KB
/
checkUnits.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
-- status: correct
-- teardown_command: rm -rf checkunits_lua/
-- linux: no
-- ucrt64: yes
-- win: yes
-- mac: no
oms_setCommandLineOption("--suppressPath=true")
oms_setTempDirectory("./checkunits_lua/")
oms_newModel("model")
oms_addSystem("model.root", oms_system_wc)
oms_addSubModel("model.root.A", "../resources/A.fmu")
oms_addSubModel("model.root.B", "../resources/B.fmu")
-- invalid connection with different unit
oms_addConnection("model.root.A.y", "model.root.B.u")
-- valid connection mm to m
oms_addConnection("model.root.A.y1", "model.root.B.u1")
oms_addConnection("model.root.A.y2", "model.root.B.u2")
oms_setResultFile("model", "units.mat")
src, status = oms_exportSnapshot("model")
-- print(src)
oms_instantiate("model")
oms_initialize("model")
print("info: Initialization")
print("info: model.root.A.y1 : " .. oms_getReal("model.root.A.y1"))
print("info: model.root.B.u1 : " .. oms_getReal("model.root.B.u1"))
print("info: model.root.A.y2 : " .. oms_getReal("model.root.A.y2"))
print("info: model.root.B.u2 : " .. oms_getReal("model.root.B.u2"))
oms_simulate("model")
print("info: Simulation")
print("info: model.root.A.y1 : " .. oms_getReal("model.root.A.y1"))
print("info: model.root.B.u1 : " .. oms_getReal("model.root.B.u1"))
print("info: model.root.A.y2 : " .. oms_getReal("model.root.A.y2"))
print("info: model.root.B.u2 : " .. oms_getReal("model.root.B.u2"))
oms_terminate("model")
oms_delete("model")
-- Result:
-- error: [addConnection] Unit mismatch in connection: A.y -> B.u
-- info: Result file: units.mat (bufferSize=1)
-- info: Initialization
-- info: model.root.A.y1 : 5.0
-- info: model.root.B.u1 : 0.005
-- info: model.root.A.y2 : 5.0
-- info: model.root.B.u2 : 5e-06
-- info: Simulation
-- info: model.root.A.y1 : 5.0
-- info: model.root.B.u1 : 0.005
-- info: model.root.A.y2 : 5.0
-- info: model.root.B.u2 : 5e-06
-- info: 0 warnings
-- info: 1 errors
-- endResult