-
Notifications
You must be signed in to change notification settings - Fork 298
/
simVanDerPol.mos
126 lines (124 loc) · 6.13 KB
/
simVanDerPol.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
// name: VanDerPol linearization
// keywords: VanDerPol, linearization
// status: correct
// teardown_command: rm -rf VanDerPol.* VanDerPol_* output.log linearized_model.* linearized_model_* linearized_model VanDerPol
//
// Case for numeric linearization of VanDerPol model
//
//linearize with numeric linearization and data recovery
loadFile("modelVanDerPol.mo");
simulate(VanDerPol, 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
//
// Case for linearization of VanDerPol model
//
setCommandLineOptions("+generateSymbolicLinearization");
//linearize
linearize(VanDerPol,stopTime=0);
getErrorString();
loadFile("linearized_model.mo");
list(linearized_model);
simulate(linearized_model);
getErrorString();
readFile("linearized_model.log"); // Check that output log is empty
// Result:
// true
// record SimulationResult
// resultFile = "VanDerPol_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'VanDerPol', 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 \"VanDerPol\"
// parameter Integer n = 2 \"number of states\";
// parameter Integer m = 0 \"number of inputs\";
// parameter Integer p = 0 \"number of outputs\";
// parameter Integer nz = 0 \"data recovery variables\";
// parameter Real x0[2] = {1, 2};
// parameter Real u0[0] = zeros(0);
// parameter Real z0[0] = zeros(0);
// parameter Real A[n, n] = [0, 1.000000001354202; -2.200000078615666, 0];
// 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] = zeros(nz, n);
// 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];
// 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 = "VanDerPol_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 0.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'VanDerPol', 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 \"VanDerPol\"
// 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, 2};
// parameter Real u0[m] = zeros(0);
// parameter Real A[n, n] = [0, 1; -2.2, 0];
// 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