-
Notifications
You must be signed in to change notification settings - Fork 298
/
simextfunction.mos
255 lines (250 loc) · 12.7 KB
/
simextfunction.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
// name: extfunctions linearization
// keywords: extfunctions, linearization
// status: correct
// teardown_command: rm -rf extfunction.* extfunction_* output.log linearized_model.* linearized_model_* linearized_model extfunction
//
// Case for numeric linearization of extfunctions model
//
//linearize with numeric linearization and data recovery at time 0
loadFile("modelextfunction.mo");
setCommandLineOptions("--generateSymbolicLinearization");
getErrorString();
simulate(extfunction, simflags="-l=0 -l_datarec");
getErrorString();
loadFile("linearized_model.mo");
list(linearized_model);
simulate(linearized_model);
getErrorString();
readFile("linearized_model.log"); // Check that output log is empty
setCommandLineOptions("--generateSymbolicLinearization=false");
getErrorString();
//linearize with numeric linearization and data recovery at time 0
simulate(extfunction, simflags="-l=1 -l_datarec");
getErrorString();
loadFile("linearized_model.mo");
list(linearized_model);
simulate(linearized_model);
getErrorString();
readFile("linearized_model.log"); // Check that output log is empty
//
// Case for linearization of extfunctions model
//
setCommandLineOptions("--generateSymbolicLinearization");
getErrorString();
//linearize at point in time 0
linearize(extfunction, stopTime=0);
getErrorString();
loadFile("linearized_model.mo");
list(linearized_model);
simulate(linearized_model);
getErrorString();
readFile("linearized_model.log"); // Check that output log is empty
setCommandLineOptions("--generateSymbolicLinearization=false");
getErrorString();
//linearize at point in time 1
linearize(extfunction, stopTime=1);
getErrorString();
loadFile("linearized_model.mo");
list(linearized_model);
simulate(linearized_model);
getErrorString();
readFile("linearized_model.log"); // Check that output log is empty
// Result:
// true
// true
// ""
// record SimulationResult
// resultFile = "extfunction_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'extfunction', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-l=0 -l_datarec'",
// messages = "stdout | info | Linearization will be performed at point of time: 0.000000
// LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// stdout | info | Linear model is created.
// "
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions(\"-d=initialization\").
// "
// true
// "model linearized_model \"extfunction\"
// parameter Integer n = 2 \"number of states\";
// parameter Integer m = 0 \"number of inputs\";
// parameter Integer p = 0 \"number of outputs\";
// parameter Integer nz = 2 \"data recovery variables\";
// parameter Real x0[2] = {1, -1};
// parameter Real u0[0] = zeros(0);
// parameter Real z0[2] = {0.5403023058681398, 0.5403023058681398};
// parameter Real A[n, n] = [0.5403023058681398, 0.8414709848078965; 0.8414709848078965, 0.5403023058681398];
// parameter Real B[n, m] = zeros(n, m);
// parameter Real C[p, n] = zeros(p, n);
// parameter Real D[p, m] = zeros(p, m);
// parameter Real Cz[nz, n] = [0, 0.8414709479039962; -0.8414710212080169, 0];
// parameter Real Dz[nz, m] = zeros(nz, m);
// Real x[n](start = x0);
// input Real u[m];
// output Real y[p];
// output Real z[nz];
// Real 'x_x' = x[1];
// Real 'x_y' = x[2];
// Real 'z_$cse1' = z[1];
// Real 'z_$cse2' = z[2];
// equation
// der(x) = A * x + B * u;
// y = C * x + D * u;
// z = Cz * x + Dz * u;
// end linearized_model;"
// record SimulationResult
// resultFile = "linearized_model_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'linearized_model', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// "
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions(\"-d=initialization\").
// "
// "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// "
// true
// ""
// record SimulationResult
// resultFile = "extfunction_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'extfunction', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-l=1 -l_datarec'",
// messages = "stdout | info | Linearization will be performed at point of time: 1.000000
// LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// stdout | info | Linear model is created.
// "
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions(\"-d=initialization\").
// "
// true
// "model linearized_model \"extfunction\"
// parameter Integer n = 2 \"number of states\";
// parameter Integer m = 0 \"number of inputs\";
// parameter Integer p = 0 \"number of outputs\";
// parameter Integer nz = 2 \"data recovery variables\";
// parameter Real x0[2] = {1.398992320427181, -1.398992320427181};
// parameter Real u0[0] = zeros(0);
// parameter Real z0[2] = {0.1709600740012847, 0.1709600740012847};
// parameter Real A[n, n] = [0.1709600742174606, 1.378396283075882; 1.378396310036173, 0.170960073974575];
// parameter Real B[n, m] = zeros(n, m);
// parameter Real C[p, n] = zeros(p, n);
// parameter Real D[p, m] = zeros(p, m);
// parameter Real Cz[nz, n] = [0, 0.9852779481952085; -0.9852779676260491, 0];
// parameter Real Dz[nz, m] = zeros(nz, m);
// Real x[n](start = x0);
// input Real u[m];
// output Real y[p];
// output Real z[nz];
// Real 'x_x' = x[1];
// Real 'x_y' = x[2];
// Real 'z_$cse1' = z[1];
// Real 'z_$cse2' = z[2];
// equation
// der(x) = A * x + B * u;
// y = C * x + D * u;
// z = Cz * x + Dz * u;
// end linearized_model;"
// record SimulationResult
// resultFile = "linearized_model_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'linearized_model', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// "
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions(\"-d=initialization\").
// "
// "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// "
// true
// ""
// record SimulationResult
// resultFile = "extfunction_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 0.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'extfunction', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "stdout | info | Linearization will be performed at point of time: 0.000000
// LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// stdout | info | Linear model is created.
// "
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions(\"-d=initialization\").
// "
// true
// "model linearized_model \"extfunction\"
// parameter Integer n = 2 \"number of states\";
// parameter Integer m = 0 \"number of inputs\";
// parameter Integer p = 0 \"number of outputs\";
// parameter Real x0[n] = {1, -1};
// parameter Real u0[m] = zeros(0);
// parameter Real A[n, n] = [0.5403023058681398, 0.8414709848078965; 0.8414709848078965, 0.5403023058681398];
// parameter Real B[n, m] = zeros(n, m);
// parameter Real C[p, n] = zeros(p, n);
// parameter Real D[p, m] = zeros(p, m);
// Real x[n](start = x0);
// input Real u[m];
// output Real y[p];
// Real 'x_x' = x[1];
// Real 'x_y' = x[2];
// equation
// der(x) = A * x + B * u;
// y = C * x + D * u;
// end linearized_model;"
// record SimulationResult
// resultFile = "linearized_model_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'linearized_model', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// "
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions(\"-d=initialization\").
// "
// "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// "
// true
// ""
// record SimulationResult
// resultFile = "extfunction_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'extfunction', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "stdout | info | Linearization will be performed at point of time: 1.000000
// LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// stdout | info | Linear model is created.
// "
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions(\"-d=initialization\").
// "
// true
// "model linearized_model \"extfunction\"
// parameter Integer n = 2 \"number of states\";
// parameter Integer m = 0 \"number of inputs\";
// parameter Integer p = 0 \"number of outputs\";
// parameter Real x0[n] = {1.398992320427181, -1.398992320427181};
// parameter Real u0[m] = zeros(0);
// parameter Real A[n, n] = [0.1709600742174606, 1.378396283075882; 1.378396310036173, 0.170960073974575];
// parameter Real B[n, m] = zeros(n, m);
// parameter Real C[p, n] = zeros(p, n);
// parameter Real D[p, m] = zeros(p, m);
// Real x[n](start = x0);
// input Real u[m];
// output Real y[p];
// Real 'x_x' = x[1];
// Real 'x_y' = x[2];
// equation
// der(x) = A * x + B * u;
// y = C * x + D * u;
// end linearized_model;"
// record SimulationResult
// resultFile = "linearized_model_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'linearized_model', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// "
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions(\"-d=initialization\").
// "
// "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// "
// endResult