forked from OpenModelica/OMLibraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModelica 3.2.1.patch
311 lines (303 loc) · 12.5 KB
/
Modelica 3.2.1.patch
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
diff -u -x .svn -x Library -r svn/MSL 3.2.1/Modelica/Blocks/Sources.mo build/Modelica 3.2.1/Blocks/Sources.mo
--- svn/MSL 3.2.1/Modelica/Blocks/Sources.mo 2014-12-31 19:52:22.410931274 +0100
+++ build/Modelica 3.2.1/Blocks/Sources.mo 2014-12-31 20:02:33.012474808 +0100
@@ -2313,7 +2313,7 @@
discrete input Modelica.SIunits.Time nextTimeEvent;
discrete input Modelica.SIunits.Time pre_nextTimeEvent;
input Real tableAvailable
- "Dummy input to ensure correct sorting of function calls";
+ "Dummy input to ensure correct sorting of function calls" annotation(__OpenModelica_UnusedVariable=true);
output Real y;
external"C" y = ModelicaStandardTables_CombiTimeTable_getValue(tableID, icol, timeIn, nextTimeEvent, pre_nextTimeEvent)
annotation (Library={"ModelicaStandardTables"});
@@ -2332,7 +2332,7 @@
discrete input Modelica.SIunits.Time nextTimeEvent;
discrete input Modelica.SIunits.Time pre_nextTimeEvent;
input Real tableAvailable
- "Dummy input to ensure correct sorting of function calls";
+ "Dummy input to ensure correct sorting of function calls" annotation(__OpenModelica_UnusedVariable=true);
output Real y;
external"C" y = ModelicaStandardTables_CombiTimeTable_getValue(tableID, icol, timeIn, nextTimeEvent, pre_nextTimeEvent)
annotation (Library={"ModelicaStandardTables"});
@@ -2347,7 +2347,7 @@
discrete input Modelica.SIunits.Time nextTimeEvent;
discrete input Modelica.SIunits.Time pre_nextTimeEvent;
input Real tableAvailable
- "Dummy input to ensure correct sorting of function calls";
+ "Dummy input to ensure correct sorting of function calls" annotation(__OpenModelica_UnusedVariable=true);
input Real der_timeIn;
output Real der_y;
external"C" der_y = ModelicaStandardTables_CombiTimeTable_getDerValue(tableID, icol, timeIn, nextTimeEvent, pre_nextTimeEvent, der_timeIn)
@@ -2359,7 +2359,7 @@
extends Modelica.Icons.Function;
input Modelica.Blocks.Types.ExternalCombiTimeTable tableID;
input Real tableAvailable
- "Dummy input to ensure correct sorting of function calls";
+ "Dummy input to ensure correct sorting of function calls" annotation(__OpenModelica_UnusedVariable=true);
output Modelica.SIunits.Time timeMin "Minimum time value in table";
external"C" timeMin = ModelicaStandardTables_CombiTimeTable_minimumTime(tableID)
annotation (Library={"ModelicaStandardTables"});
@@ -2370,7 +2370,7 @@
extends Modelica.Icons.Function;
input Modelica.Blocks.Types.ExternalCombiTimeTable tableID;
input Real tableAvailable
- "Dummy input to ensure correct sorting of function calls";
+ "Dummy input to ensure correct sorting of function calls" annotation(__OpenModelica_UnusedVariable=true);
output Modelica.SIunits.Time timeMax "Maximum time value in table";
external"C" timeMax = ModelicaStandardTables_CombiTimeTable_maximumTime(tableID)
annotation (Library={"ModelicaStandardTables"});
@@ -2382,7 +2382,7 @@
input Modelica.Blocks.Types.ExternalCombiTimeTable tableID;
input Modelica.SIunits.Time timeIn;
input Real tableAvailable
- "Dummy input to ensure correct sorting of function calls";
+ "Dummy input to ensure correct sorting of function calls" annotation(__OpenModelica_UnusedVariable=true);
output Modelica.SIunits.Time nextTimeEvent "Next time event in table";
external"C" nextTimeEvent = ModelicaStandardTables_CombiTimeTable_nextTimeEvent(tableID, timeIn)
annotation (Library={"ModelicaStandardTables"});
diff -u -x .svn -x Library -r svn/MSL 3.2.1/Modelica/Blocks/Tables.mo build/Modelica 3.2.1/Blocks/Tables.mo
--- svn/MSL 3.2.1/Modelica/Blocks/Tables.mo 2014-05-05 20:17:45.090764986 +0200
+++ build/Modelica 3.2.1/Blocks/Tables.mo 2014-12-31 19:54:19.531073997 +0100
@@ -58,7 +58,7 @@
input Integer icol;
input Real u;
input Real tableAvailable
- "Dummy input to ensure correct sorting of function calls";
+ "Dummy input to ensure correct sorting of function calls" annotation(__OpenModelica_UnusedVariable=true);
output Real y;
external"C" y = ModelicaStandardTables_CombiTable1D_getValue(tableID, icol, u)
annotation (Library={"ModelicaStandardTables"});
@@ -72,7 +72,7 @@
input Integer icol;
input Real u;
input Real tableAvailable
- "Dummy input to ensure correct sorting of function calls";
+ "Dummy input to ensure correct sorting of function calls" annotation(__OpenModelica_UnusedVariable=true);
output Real y;
external"C" y = ModelicaStandardTables_CombiTable1D_getValue(tableID, icol, u)
annotation (Library={"ModelicaStandardTables"});
@@ -85,7 +85,7 @@
input Integer icol;
input Real u;
input Real tableAvailable
- "Dummy input to ensure correct sorting of function calls";
+ "Dummy input to ensure correct sorting of function calls" annotation(__OpenModelica_UnusedVariable=true);
input Real der_u;
output Real der_y;
external"C" der_y = ModelicaStandardTables_CombiTable1D_getDerValue(tableID, icol, u, der_u)
@@ -360,7 +360,7 @@
input Integer icol;
input Real u;
input Real tableAvailable
- "Dummy input to ensure correct sorting of function calls";
+ "Dummy input to ensure correct sorting of function calls" annotation(__OpenModelica_UnusedVariable=true);
output Real y;
external"C" y = ModelicaStandardTables_CombiTable1D_getValue(tableID, icol, u)
annotation (Library={"ModelicaStandardTables"});
@@ -374,7 +374,7 @@
input Integer icol;
input Real u;
input Real tableAvailable
- "Dummy input to ensure correct sorting of function calls";
+ "Dummy input to ensure correct sorting of function calls" annotation(__OpenModelica_UnusedVariable=true);
output Real y;
external"C" y = ModelicaStandardTables_CombiTable1D_getValue(tableID, icol, u)
annotation (Library={"ModelicaStandardTables"});
@@ -387,7 +387,7 @@
input Integer icol;
input Real u;
input Real tableAvailable
- "Dummy input to ensure correct sorting of function calls";
+ "Dummy input to ensure correct sorting of function calls" annotation(__OpenModelica_UnusedVariable=true);
input Real der_u;
output Real der_y;
external"C" der_y = ModelicaStandardTables_CombiTable1D_getDerValue(tableID, icol, u, der_u)
@@ -657,7 +657,7 @@
input Real u1;
input Real u2;
input Real tableAvailable
- "Dummy input to ensure correct sorting of function calls";
+ "Dummy input to ensure correct sorting of function calls" annotation(__OpenModelica_UnusedVariable=true);
output Real y;
external"C" y = ModelicaStandardTables_CombiTable2D_getValue(tableID, u1, u2)
annotation (Library={"ModelicaStandardTables"});
@@ -671,7 +671,7 @@
input Real u1;
input Real u2;
input Real tableAvailable
- "Dummy input to ensure correct sorting of function calls";
+ "Dummy input to ensure correct sorting of function calls" annotation(__OpenModelica_UnusedVariable=true);
output Real y;
external"C" y = ModelicaStandardTables_CombiTable2D_getValue(tableID, u1, u2)
annotation (Library={"ModelicaStandardTables"});
@@ -684,7 +684,7 @@
input Real u1;
input Real u2;
input Real tableAvailable
- "Dummy input to ensure correct sorting of function calls";
+ "Dummy input to ensure correct sorting of function calls" annotation(__OpenModelica_UnusedVariable=true);
input Real der_u1;
input Real der_u2;
output Real der_y;
diff -u -x .svn -x Library -r svn/MSL 3.2.1/Modelica/Math/package.mo build/Modelica 3.2.1/Math/package.mo
--- svn/MSL 3.2.1/Modelica/Math/package.mo 2014-12-31 19:52:22.314927878 +0100
+++ build/Modelica 3.2.1/Math/package.mo 2014-12-31 19:54:19.531073997 +0100
@@ -12722,9 +12722,67 @@
annotation (Documentation(info="<html>
-</html>"));
+</html>"),
+derivative(zeroDerivative=table,zeroDerivative=icol)=tempInterpol1_der);
end tempInterpol1;
+function tempInterpol1_der
+ "Temporary function for linear interpolation (will be removed)"
+ input Real u "input value (first column of table)";
+ input Real table[:, :] "table to be interpolated";
+ input Integer icol "column of table to be interpolated";
+ input Real du;
+ output Real dy "interpolated input value (icol column of table)";
+ protected
+ Integer i;
+ Integer n "number of rows of table";
+ Real u1;
+ Real u2;
+ Real y1;
+ Real y2;
+algorithm
+ n := size(table, 1);
+
+ if n <= 1 then
+ dy := 0;
+
+ else
+ // Search interval
+
+ if u <= table[1, 1] then
+ i := 1;
+
+ else
+ i := 2;
+ // Supports duplicate table[i, 1] values
+ // in the interior to allow discontinuities.
+ // Interior means that
+ // if table[i, 1] = table[i+1, 1] we require i>1 and i+1<n
+
+ while i < n and u >= table[i, 1] loop
+ i := i + 1;
+
+ end while;
+ i := i - 1;
+
+ end if;
+
+ // Get interpolation data
+ u1 := table[i, 1];
+ u2 := table[i + 1, 1];
+ y1 := table[i, icol];
+ y2 := table[i + 1, icol];
+
+ assert(u2 > u1, "Table index must be increasing");
+ // Interpolate
+ dy := (y2 - y1)/(u2 - u1);
+
+ end if;
+
+ annotation (Documentation(info="<html>
+
+</html>"));
+end tempInterpol1_der;
function tempInterpol2
"Temporary function for vectorized linear interpolation (will be removed)"
@@ -12784,9 +12842,74 @@
annotation (Documentation(info="<html>
-</html>"));
+</html>"),
+derivative(zeroDerivative=table,zeroDerivative=icol)=tempInterpol2_der);
end tempInterpol2;
+function tempInterpol2_der
+ "Temporary function for vectorized linear interpolation (will be removed)"
+ extends Modelica.Icons.Function;
+ extends Modelica.Icons.ObsoleteModel;
+
+ input Real u "input value (first column of table)";
+ input Real table[:, :] "table to be interpolated";
+ input Integer icol[:] "column(s) of table to be interpolated";
+ input Real du "input value (first column of table)";
+ output Real dy[1, size(icol, 1)]
+ "interpolated input value(s) (column(s) icol of table)";
+protected
+ Integer i;
+ Integer n "number of rows of table";
+ Real u1;
+ Real u2;
+ Real y1[1, size(icol, 1)];
+ Real y2[1, size(icol, 1)];
+algorithm
+ n := size(table, 1);
+
+ if n <= 1 then
+ dy := zeros(1, size(icol,1));
+
+ else
+ // Search interval
+
+ if u <= table[1, 1] then
+ i := 1;
+
+ else
+ i := 2;
+ // Supports duplicate table[i, 1] values
+ // in the interior to allow discontinuities.
+ // Interior means that
+ // if table[i, 1] = table[i+1, 1] we require i>1 and i+1<n
+
+ while i < n and u >= table[i, 1] loop
+ i := i + 1;
+
+ end while;
+ i := i - 1;
+
+ end if;
+
+ // Get interpolation data
+ u1 := table[i, 1];
+ u2 := table[i + 1, 1];
+ y1 := transpose([table[i, icol]]);
+ y2 := transpose([table[i + 1, icol]]);
+
+ assert(u2 > u1, "Table index must be increasing");
+ // Interpolate
+ dy := (y2 - y1)/(u2 - u1);
+
+ end if;
+
+ annotation (Documentation(info="<html>
+
+</html>")
+);
+end tempInterpol2_der;
+
+
annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},
{100,100}}), graphics={Line(points={{-80,0},{-68.7,34.2},{-61.5,53.1},
diff -u -x .svn -x Library -r svn/MSL 3.2.1/Modelica/Math/package.order build/Modelica 3.2.1/Math/package.order
--- svn/MSL 3.2.1/Modelica/Math/package.order 2014-04-07 09:23:24.742123932 +0200
+++ build/Modelica 3.2.1/Math/package.order 2014-12-31 19:54:19.531073997 +0100
@@ -24,4 +24,6 @@
baseIcon1
baseIcon2
tempInterpol1
+tempInterpol1_der
tempInterpol2
+tempInterpol2_der
diff -u -x .svn -x Library -r svn/MSL 3.2.1/Modelica/Media/Water/IF97_Utilities.mo build/Modelica 3.2.1/Media/Water/IF97_Utilities.mo
--- svn/MSL 3.2.1/Modelica/Media/Water/IF97_Utilities.mo 2014-12-04 09:16:53.807509442 +0100
+++ build/Modelica 3.2.1/Media/Water/IF97_Utilities.mo 2014-12-31 19:54:19.535074138 +0100
@@ -7159,7 +7159,7 @@
else region;
aux.R := BaseIF97.data.RH2O;
aux.p := p;
- aux.T := T;
+ aux.T := T; /* OpenModelica patch */ aux.dpT := 0.0; aux.pt := 0.0; aux.pd := 0.0; aux.x := 0.0; aux.rho := 0.0; aux.vt := 0.0; aux.vp := 0.0; aux.cp := 0.0; /* end OpenModelica patch */
if (aux.region == 1) then
g := BaseIF97.Basic.g1(p, T);
aux.h := aux.R*aux.T*g.tau*g.gtau;