-
Notifications
You must be signed in to change notification settings - Fork 298
/
test_dump_languages.mos
197 lines (191 loc) · 7.21 KB
/
test_dump_languages.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
// name: test_dump_languages.mos
// keywords: <...>
// status: correct
// teardown_command: rm -rf *simple_test* output.log
//
// <insert description here>
//
loadFile("test_dump_languages.mo"); getErrorString();
setCommandLineOptions("--linearizationDumpLanguage=modelica");
linearize(simple_test, stopTime=0.5); getErrorString();
readFile("linear_simple_test.mo"); getErrorString();
setCommandLineOptions("--linearizationDumpLanguage=matlab");
linearize(simple_test, stopTime=0.5); getErrorString();
readFile("linear_simple_test.m"); getErrorString();
setCommandLineOptions("--linearizationDumpLanguage=julia");
linearize(simple_test, stopTime=0.5); getErrorString();
readFile("linear_simple_test.jl"); getErrorString();
setCommandLineOptions("--linearizationDumpLanguage=python");
linearize(simple_test, stopTime=0.5); getErrorString();
readFile("linear_simple_test.py"); getErrorString();
// Result:
// true
// ""
// true
// record SimulationResult
// resultFile = "simple_test_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 0.5, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'simple_test', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "stdout | info | Linearization will be performed at point of time: 0.500000
// 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\").
// "
// "model linear_simple__test
// parameter Integer n = 2 \"number of states\";
// parameter Integer m = 1 \"number of inputs\";
// parameter Integer p = 1 \"number of outputs\";
//
// parameter Real x0[n] = {1.626558527192664, 2.380918053900121};
// parameter Real u0[m] = {0};
//
// parameter Real A[n, n] =
// [-2.887152375617477, -1.62655852935388;
// -2.380918056675567, -2.388394731625707];
//
// parameter Real B[n, m] =
// [0;
// 0];
//
// parameter Real C[p, n] =
// [0, 0];
//
// parameter Real D[p, m] =
// [4.007476581092785];
//
//
// Real x[n](start=x0);
// input Real u[m](start=u0);
// output Real y[p];
//
// Real 'x_num.x[1]' = x[1];
// Real 'x_num.x[2]' = x[2];
// Real 'u_u' = u[1];
// Real 'y_y' = y[1];
// equation
// der(x) = A * x + B * u;
// y = C * x + D * u;
// end linear_simple__test;
// "
// ""
// true
// record SimulationResult
// resultFile = "simple_test_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 0.5, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'simple_test', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "stdout | info | Linearization will be performed at point of time: 0.500000
// 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\").
// "
// "function [sys, x0, u0, n, m, p] = simple_test_GetLinearModel()
// % der(x) = A * x + B * u
// % y = C * x + D * u
// n = 2; % number of states
// m = 1; % number of inputs
// p = 1; % number of outputs
//
// x0 = {1.626558527192664, 2.380918053900121};
// u0 = {0};
//
// A = [-2.887152375617477, -1.62655852935388;
// -2.380918056675567, -2.388394731625707];
//
// B = [0;
// 0];
//
// C = [0, 0];
//
// D = [4.007476581092785];
//
// Ts = 0.5; % stop time
//
// % The Control System Toolbox is required for this. Alternatively just return the matrices A,B,C,D instead.
// sys = ss(A,B,C,D,Ts,'StateName',{'x_num_x(1)','x_num_x(2)'}, 'InputName',{'u_u'}, 'OutputName', {'y_y'});
// end"
// ""
// true
// record SimulationResult
// resultFile = "simple_test_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 0.5, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'simple_test', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "stdout | info | Linearization will be performed at point of time: 0.500000
// 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\").
// "
// "function simple_test_GetLinearModel()
// #= der(x) = A * x + B * u =#
// #= y = C * x + D * u =#
// local n = 2 #= number of states =#
// local m = 1 #= number of inputs =#
// local p = 1 #= number of outputs =#
//
// local x0 = {1.626558527192664, 2.380918053900121}
// local u0 = {0}
//
// local A = [-2.887152375617477, -1.62655852935388;
// -2.380918056675567, -2.388394731625707]
//
// local B = [0;
// 0]
//
// local C = [0, 0]
//
// local D = [4.007476581092785]
//
// # x_num_x(1) = x(1);
// # x_num_x(2) = x(2);
// # u_u = u(1);
// # y_y = y(1);
//
// (n, m, p, x0, u0, A, B, C, D)
// end"
// ""
// true
// record SimulationResult
// resultFile = "simple_test_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 0.5, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'simple_test', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "stdout | info | Linearization will be performed at point of time: 0.500000
// 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\").
// "
// "def simple_test_GetLinearModel()
// # der(x) = A * x + B * u
// # y = C * x + D * u
// n = 2 # number of states
// m = 1 # number of inputs
// p = 1 # number of outputs
//
// x0 = {1.626558527192664, 2.380918053900121}
// u0 = {0}
//
// A = [-2.887152375617477, -1.62655852935388;
// -2.380918056675567, -2.388394731625707];
//
// B = [0;
// 0];
//
// C = [0, 0];
//
// D = [4.007476581092785];
//
// # x_num_x(1) = x(1);
// # x_num_x(2) = x(2);
// # u_u = u(1);
// # y_y = y(1);
//
// return (n, m, p, x0, u0, A, B, C, D)
// end"
// ""
// endResult