forked from OpenModelica/OMLibraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Modelica 3.2.2.manual.patch
158 lines (150 loc) · 4.06 KB
/
Modelica 3.2.2.manual.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
diff -u -x .svn -x .git -x Library -r git/MSL/Modelica/Math/package.mo "build/Modelica 3.2.2/Math/package.mo"
--- git/MSL/Modelica/Math/package.mo 2015-05-06 23:05:39.079856721 +0200
+++ build/Modelica 3.2.2/Math/package.mo 2015-05-06 23:05:39.655876463 +0200
@@ -13162,9 +13162,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)"
@@ -13224,9 +13282,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 .git -x Library -r git/MSL/Modelica/Math/package.order "build/Modelica 3.2.2/Math/package.order"
--- git/MSL/Modelica/Math/package.order 2015-05-06 23:05:25.499391283 +0200
+++ build/Modelica 3.2.2/Math/package.order 2015-05-06 23:05:39.655876463 +0200
@@ -24,4 +24,6 @@
baseIcon1
baseIcon2
tempInterpol1
+tempInterpol1_der
tempInterpol2
+tempInterpol2_der