-
Notifications
You must be signed in to change notification settings - Fork 298
/
forceComplexEq3.mos
187 lines (183 loc) · 7.28 KB
/
forceComplexEq3.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
//name: forceInlineComplexEq3
// status: correct
setCommandLineOptions("--postOptModules+=forceInlineFunctionInLoops --initOptModules+=forceInlineFunctionInLoops +d=backenddaeinfo,dumpLoops +inlineMethod=append");
loadString("
model foo
function f
input Real x1;
input Real x2;
output Real y1;
output Real y2;
protected
Real a = x1 - x2 + 10;
Real b = 23*a;
algorithm
y1 := b*x2 - a;
y2 := 3*x2-5;
end f;
Real x1, x2, x3, x4;
equation
(x1, x2) = f(3*x1 + cos(time), 3*x2 +1+x3-5*x4);
(x4, x3) = f(sin(time), x1 + x3 - x2);
end foo;
");
getErrorString();
simulate(foo);
getErrorString();
val(x1,{0,1});
val(x2,{0,1});
val(x3,{0,1});
// Result:
// true
// true
// ""
//
// ########################################
//
// Algbraic Loops (Simulation):
//
// ########################################
//
// system 1
// ========================================
//
// ################################################################################
// dumpLoops: SORTED COMPONENT
// ################################################################################
//
// torn nonlinear Equationsystem:
//
// internal vars (10)
// 1: y2$$Pfoo$Pf9:VARIABLE() type: Real
// 2: x4:VARIABLE() type: Real
// 3: y1$$Pfoo$Pf12:VARIABLE() type: Real
// 4: y2$$Pfoo$Pf13:VARIABLE() type: Real
// 5: x1:VARIABLE() type: Real
// 6: a$$Pfoo$Pf10:VARIABLE() type: Real
// 7: a$$Pfoo$Pf14:VARIABLE() type: Real
// 8: b$$Pfoo$Pf15:VARIABLE() type: Real
// 9: b$$Pfoo$Pf11:VARIABLE() type: Real
// 10: y1$$Pfoo$Pf8:VARIABLE() type: Real
//
// residual vars (2)
// 1: x3:VARIABLE() type: Real
// 2: x2:VARIABLE() type: Real
//
// internal equations (10)
// 1/1 (1): x2 = y2$$Pfoo$Pf9 [unknown |0|0|0|0|]
// 2/2 (1): y2$$Pfoo$Pf9 = -5.0 + 3.0 * (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) [unknown |0|0|0|0|]
// 3/3 (1): x4 = y1$$Pfoo$Pf12 [unknown |0|0|0|0|]
// 4/4 (1): x3 = y2$$Pfoo$Pf13 [unknown |0|0|0|0|]
// 5/5 (1): y2$$Pfoo$Pf13 = -5.0 + 3.0 * (x1 + x3 - x2) [unknown |0|0|0|0|]
// 6/6 (1): a$$Pfoo$Pf10 = 10.0 + 3.0 * x1 + $cse1 - (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) [unknown |0|0|0|0|]
// 7/7 (1): a$$Pfoo$Pf14 = 10.0 + $cse2 - (x1 + x3 - x2) [unknown |0|0|0|0|]
// 8/8 (1): b$$Pfoo$Pf15 = 23.0 * a$$Pfoo$Pf14 [unknown |0|0|0|0|]
// 9/9 (1): b$$Pfoo$Pf11 = 23.0 * a$$Pfoo$Pf10 [unknown |0|0|0|0|]
// 10/10 (1): y1$$Pfoo$Pf8 = b$$Pfoo$Pf11 * (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) - a$$Pfoo$Pf10 [unknown |0|0|0|0|]
//
// residual equations (2)
// 1/1 (1): y1$$Pfoo$Pf12 = b$$Pfoo$Pf15 * (x1 + x3 - x2) - a$$Pfoo$Pf14 [unknown |0|0|0|0|]
// 2/2 (1): x1 = y1$$Pfoo$Pf8 [unknown |0|0|0|0|]
//
//
// ########################################
//
// Algbraic Loops (Initialization):
//
// ########################################
//
// system 1
// ========================================
//
// ################################################################################
// dumpLoops: SORTED COMPONENT
// ################################################################################
//
// torn nonlinear Equationsystem:
//
// internal vars (10)
// 1: y2$$Pfoo$Pf5:VARIABLE() type: Real
// 2: x1:VARIABLE() type: Real
// 3: a$$Pfoo$Pf6:VARIABLE() type: Real
// 4: b$$Pfoo$Pf7:VARIABLE() type: Real
// 5: y1$$Pfoo$Pf4:VARIABLE() type: Real
// 6: x4:VARIABLE() type: Real
// 7: a$$Pfoo$Pf2:VARIABLE() type: Real
// 8: y2$$Pfoo$Pf1:VARIABLE() type: Real
// 9: b$$Pfoo$Pf3:VARIABLE() type: Real
// 10: y1$$Pfoo$Pf0:VARIABLE() type: Real
//
// residual vars (2)
// 1: x2:VARIABLE() type: Real
// 2: x3:VARIABLE() type: Real
//
// internal equations (10)
// 1/1 (1): x3 = y2$$Pfoo$Pf5 [dynamic |0|0|0|0|]
// 2/2 (1): y2$$Pfoo$Pf5 = -5.0 + 3.0 * (x1 + x3 - x2) [unknown |0|0|0|0|]
// 3/3 (1): a$$Pfoo$Pf6 = 10.0 + sin(time) - (x1 + x3 - x2) [unknown |0|0|0|0|]
// 4/4 (1): b$$Pfoo$Pf7 = 23.0 * a$$Pfoo$Pf6 [unknown |0|0|0|0|]
// 5/5 (1): y1$$Pfoo$Pf4 = b$$Pfoo$Pf7 * (x1 + x3 - x2) - a$$Pfoo$Pf6 [unknown |0|0|0|0|]
// 6/6 (1): x4 = y1$$Pfoo$Pf4 [dynamic |0|0|0|0|]
// 7/7 (1): a$$Pfoo$Pf2 = 10.0 + 3.0 * x1 + cos(time) - (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) [unknown |0|0|0|0|]
// 8/8 (1): y2$$Pfoo$Pf1 = -5.0 + 3.0 * (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) [unknown |0|0|0|0|]
// 9/9 (1): b$$Pfoo$Pf3 = 23.0 * a$$Pfoo$Pf2 [unknown |0|0|0|0|]
// 10/10 (1): y1$$Pfoo$Pf0 = b$$Pfoo$Pf3 * (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) - a$$Pfoo$Pf2 [unknown |0|0|0|0|]
//
// residual equations (2)
// 1/1 (1): x2 = y2$$Pfoo$Pf1 [dynamic |0|0|0|0|]
// 2/2 (1): x1 = y1$$Pfoo$Pf0 [dynamic |0|0|0|0|]
//
// record SimulationResult
// resultFile = "foo_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'foo', 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;
// "Notification: Model statistics after passing the front-end and creating the data structures used by the back-end:
// * Number of equations: 4
// * Number of variables: 4
// Warning: There are nonlinear iteration variables with default zero start attribute found in NLSJac0. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions(\"-d=initialization\").
// Notification: Model statistics after passing the back-end for initialization:
// * Number of independent subsystems: 1
// * Number of states: 0 ('-d=stateselection' for list of states)
// * Number of discrete variables: 0 ('-d=discreteinfo' for list of discrete vars)
// * Number of discrete states: 0 ('-d=discreteinfo' for list of discrete states)
// * Top-level inputs: 0
// Notification: Strong component statistics for initialization (1):
// * Single equations (assignments): 0
// * Array equations: 0
// * Algorithm blocks: 0
// * Record equations: 0
// * When equations: 0
// * If-equations: 0
// * Equation systems (linear and non-linear blocks): 0
// * Torn equation systems: 1
// * Mixed (continuous/discrete) equation systems: 0
// Notification: Torn system details for strict tearing set:
// * Linear torn systems: 0
// * Non-linear torn systems: 1 {2 10}
// Notification: Model statistics after passing the back-end for simulation:
// * Number of independent subsystems: 1
// * Number of states: 0 ('-d=stateselection' for list of states)
// * Number of discrete variables: 0 ('-d=discreteinfo' for list of discrete vars)
// * Number of discrete states: 0 ('-d=discreteinfo' for list of discrete states)
// * Top-level inputs: 0
// Notification: Strong component statistics for simulation (3):
// * Single equations (assignments): 2
// * Array equations: 0
// * Algorithm blocks: 0
// * Record equations: 0
// * When equations: 0
// * If-equations: 0
// * Equation systems (linear and non-linear blocks): 0
// * Torn equation systems: 1
// * Mixed (continuous/discrete) equation systems: 0
// Notification: Torn system details for strict tearing set:
// * Linear torn systems: 0
// * Non-linear torn systems: 1 {2 10}
// "
// {0.07675361072940334,0.07423981665119772}
// {-4.868670267709003,-4.868661846237771}
// {-4.91813581765761,-4.914352494333452}
// endResult