-
Notifications
You must be signed in to change notification settings - Fork 298
/
testArrayAlg.mos
77 lines (72 loc) · 2.29 KB
/
testArrayAlg.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
// name: testArrayAlgDiff
// keywords: differentiation linearization array algorithm
// status: correct
// teardown_command: rm -rf ticket4545* output.log linearized_model*
//
//
loadString("
package ticket4545
model Test_vector
Real x[2](each start = 0, each fixed = true);
discrete Real u[2](each start = 0, each fixed = true);
Real y[2];
equation
for i in 1:2 loop
der(x[i]) = u[i]+y[i];
y[i] = 0.5*x[i];
end for;
algorithm
when sample(0,1) then
for i in 1:2 loop
u[i] := 1 - y[i];
end for;
end when;
annotation(experiment(StopTime = 10));
end Test_vector;
end ticket4545;
");
getErrorString();
setCommandLineOptions("--generateSymbolicLinearization");
getErrorString();
linearize(ticket4545.Test_vector, stopTime=0);
getErrorString();
loadFile("linearized_model.mo");
list(linearized_model);
getErrorString();
// Result:
// true
// ""
// true
// ""
// record SimulationResult
// resultFile = "ticket4545.Test_vector_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 0.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'ticket4545.Test_vector', 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;
// ""
// true
// "model linearized_model \"ticket4545_Test_vector\"
// 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] = {0, 0};
// parameter Real u0[m] = zeros(0);
// parameter Real A[n, n] = [0.5, 0; 0, 0.5];
// 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[1]' = x[1];
// Real 'x_x[2]' = x[2];
// equation
// der(x) = A * x + B * u;
// y = C * x + D * u;
// end linearized_model;"
// ""
// endResult