-
Notifications
You must be signed in to change notification settings - Fork 298
/
FmuExportFlags.mos
168 lines (149 loc) · 6.5 KB
/
FmuExportFlags.mos
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// name: FmuExportFlags
// keywords: fmu export simulation flags
// status: correct
// teardown_command: rm -rf BouncingBallFMI20* exampleFlags.json BouncingBallFMI20-tmp/
// cflags: -d=-newInst
//
// Export of 2.0 CS FMU with simulation flags.
// Also tests example from users guide.
loadString("
model BouncingBallFMI20
parameter Real e=0.7 \"coefficient of restitution\";
parameter Real g=9.81 \"gravity acceleration\";
Real h(start=1) \"height of ball\";
Real v \"velocity of ball\";
Real v_new;
equation
der(v) = -g;
der(h) = v;
when h <= 0.0 then
v_new = -e*pre(v);
reinit(v, v_new);
end when;
end BouncingBallFMI20;
"); getErrorString();
// Don't generate simulation settings file
setCommandLineOptions("--fmiFlags=none"); getErrorString();
buildModelFMU(BouncingBallFMI20, version = "2.0", fmuType="cs"); getErrorString();
system("unzip -cqq BouncingBallFMI20.fmu resources/BouncingBallFMI20_flags.json > BouncingBallFMI20_flags.json"); getErrorString();
// Generate default simulation settings file
setCommandLineOptions("--fmiFlags=default"); getErrorString();
buildModelFMU(BouncingBallFMI20, version = "2.0", fmuType="cs"); getErrorString();
system("unzip -cqq BouncingBallFMI20.fmu resources/BouncingBallFMI20_flags.json > BouncingBallFMI20_flags.json"); getErrorString();
readFile("BouncingBallFMI20_flags.json"); getErrorString();
// Comandline options for simflags
setCommandLineOptions("--fmiFlags=s:cvode,nls:homotopy,yourFlagName:here"); getErrorString();
buildModelFMU(BouncingBallFMI20, version = "2.0", fmuType="cs"); getErrorString();
system("unzip -cqq BouncingBallFMI20.fmu resources/BouncingBallFMI20_flags.json > BouncingBallFMI20_flags.json"); getErrorString();
readFile("BouncingBallFMI20_flags.json"); getErrorString();
// Give file with simflags as relative path
writeFile("exampleFlags.json",
"{
\"s\" : \"cvode\",
\"SomeAwesomFlag\" : \"crazyStuff\"
}"); getErrorString();
setCommandLineOptions("--fmiFlags=exampleFlags.json"); getErrorString();
buildModelFMU(BouncingBallFMI20, version = "2.0", fmuType="cs"); getErrorString();
system("unzip -cqq BouncingBallFMI20.fmu resources/BouncingBallFMI20_flags.json > BouncingBallFMI20_flags.json"); getErrorString();
readFile("BouncingBallFMI20_flags.json"); getErrorString();
// Give file with simflags as absolute path
setCommandLineOptions("--fmiFlags=" + realpath(".") + "/exampleFlags.json"); getErrorString();
buildModelFMU(BouncingBallFMI20, version = "2.0", fmuType="cs"); getErrorString();
system("unzip -cqq BouncingBallFMI20.fmu resources/BouncingBallFMI20_flags.json > BouncingBallFMI20_flags.json"); getErrorString();
readFile("BouncingBallFMI20_flags.json"); getErrorString();
// Simulate FMU
system(getInstallationDirectoryPath() + "/bin/OMSimulator BouncingBallFMI20.fmu --mode=cs --tolerance=1e-6 --resultFile=\"BouncingBallFMI20_res.mat\" --stopTime=1.0 --suppressPath=true --tempDir=\"BouncingBallFMI20-tmp\" --timeout=180", "BouncingBallFMI20_cs_systemCall.log"); getErrorString();
readFile("BouncingBallFMI20_cs_systemCall.log");
// Read results
val(h, 0.0, "BouncingBallFMI20_res.mat"); getErrorString();
val(v, 0.0, "BouncingBallFMI20_res.mat"); getErrorString();
val(h, 1.0, "BouncingBallFMI20_res.mat"); getErrorString();
val(v, 1.0, "BouncingBallFMI20_res.mat"); getErrorString();
// Result:
// true
// ""
// true
// ""
// "BouncingBallFMI20.fmu"
// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->Show additional information from the initialization process, in OMNotebook call setCommandLineOptions(\"-d=initialization\").
// "
// caution: filename not matched: resources/BouncingBallFMI20_flags.json
// 11
// ""
// true
// ""
// "BouncingBallFMI20.fmu"
// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->Show additional information from the initialization process, in OMNotebook call setCommandLineOptions(\"-d=initialization\").
// "
// 0
// ""
// "{
// \"s\" : \"euler\"
// }"
// ""
// true
// ""
// "BouncingBallFMI20.fmu"
// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->Show additional information from the initialization process, in OMNotebook call setCommandLineOptions(\"-d=initialization\").
// Warning: Adding unknown FMU simulation flag \"nls\" .
// Warning: Adding unknown FMU simulation flag \"yourFlagName\" .
// "
// 0
// ""
// "{
// \"s\" : \"cvode\",
// \"nls\" : \"homotopy\",
// \"yourFlagName\" : \"here\"
// }"
// ""
// true
// ""
// true
// ""
// "BouncingBallFMI20.fmu"
// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->Show additional information from the initialization process, in OMNotebook call setCommandLineOptions(\"-d=initialization\").
// "
// 0
// ""
// "{
// \"s\" : \"cvode\",
// \"SomeAwesomFlag\" : \"crazyStuff\"
// }"
// ""
// true
// ""
// "BouncingBallFMI20.fmu"
// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->Show additional information from the initialization process, in OMNotebook call setCommandLineOptions(\"-d=initialization\").
// "
// 0
// ""
// "{
// \"s\" : \"cvode\",
// \"SomeAwesomFlag\" : \"crazyStuff\"
// }"
// ""
// 0
// ""
// "LOG_SOLVER | info | CVODE linear multistep method CV_BDF
// LOG_SOLVER | info | CVODE maximum integration order CV_ITER_NEWTON
// LOG_SOLVER | info | CVODE use equidistant time grid YES
// LOG_SOLVER | info | CVODE Using relative error tolerance 1.000000e-06
// LOG_SOLVER | info | CVODE Using dense internal linear solver SUNLinSol_Dense.
// LOG_SOLVER | info | CVODE Use internal dense numeric jacobian method.
// LOG_SOLVER | info | CVODE uses internal root finding method NO
// LOG_SOLVER | info | CVODE maximum absolut step size 0
// LOG_SOLVER | info | CVODE initial step size is set automatically
// LOG_SOLVER | info | CVODE maximum integration order 5
// LOG_SOLVER | info | CVODE maximum number of nonlinear convergence failures permitted during one step 10
// LOG_SOLVER | info | CVODE BDF stability limit detection algorithm OFF
// info: Result file: BouncingBallFMI20_res.mat (bufferSize=1)
// "
// 1.0
// ""
// 0.0
// ""
// 0.23877146800000526
// ""
// -2.238641999999977
// ""
// endResult