1 | package Modelica "Modelica Standard Library (Version 3.2)"
|
---|
2 | extends Modelica.Icons.Package;
|
---|
3 |
|
---|
4 | package Blocks
|
---|
5 | "Library of basic input/output control blocks (continuous, discrete, logical, table blocks)"
|
---|
6 | import SI = Modelica.SIunits;
|
---|
7 | extends Modelica.Icons.Package;
|
---|
8 |
|
---|
9 | package Interfaces
|
---|
10 | "Library of connectors and partial models for input/output blocks"
|
---|
11 | import Modelica.SIunits;
|
---|
12 | extends Modelica.Icons.InterfacesPackage;
|
---|
13 |
|
---|
14 | connector RealInput = input Real "'input Real' as connector"
|
---|
15 | annotation (defaultComponentName="u",
|
---|
16 | Icon(graphics={Polygon(
|
---|
17 | points={{-100,100},{100,0},{-100,-100},{-100,100}},
|
---|
18 | lineColor={0,0,127},
|
---|
19 | fillColor={0,0,127},
|
---|
20 | fillPattern=FillPattern.Solid)},
|
---|
21 | coordinateSystem(extent={{-100,-100},{100,100}}, preserveAspectRatio=true, initialScale=0.2)),
|
---|
22 | Diagram(coordinateSystem(
|
---|
23 | preserveAspectRatio=true, initialScale=0.2,
|
---|
24 | extent={{-100,-100},{100,100}},
|
---|
25 | grid={1,1}), graphics={Polygon(
|
---|
26 | points={{0,50},{100,0},{0,-50},{0,50}},
|
---|
27 | lineColor={0,0,127},
|
---|
28 | fillColor={0,0,127},
|
---|
29 | fillPattern=FillPattern.Solid), Text(
|
---|
30 | extent={{-10,85},{-10,60}},
|
---|
31 | lineColor={0,0,127},
|
---|
32 | textString="%name")}),
|
---|
33 | Documentation(info="<html>
|
---|
34 | <p>
|
---|
35 | Connector with one input signal of type Real.
|
---|
36 | </p>
|
---|
37 | </html>"));
|
---|
38 |
|
---|
39 | connector RealOutput = output Real "'output Real' as connector"
|
---|
40 | annotation (defaultComponentName="y",
|
---|
41 | Icon(coordinateSystem(
|
---|
42 | preserveAspectRatio=true,
|
---|
43 | extent={{-100,-100},{100,100}},
|
---|
44 | grid={1,1}), graphics={Polygon(
|
---|
45 | points={{-100,100},{100,0},{-100,-100},{-100,100}},
|
---|
46 | lineColor={0,0,127},
|
---|
47 | fillColor={255,255,255},
|
---|
48 | fillPattern=FillPattern.Solid)}),
|
---|
49 | Diagram(coordinateSystem(
|
---|
50 | preserveAspectRatio=true,
|
---|
51 | extent={{-100,-100},{100,100}},
|
---|
52 | grid={1,1}), graphics={Polygon(
|
---|
53 | points={{-100,50},{0,0},{-100,-50},{-100,50}},
|
---|
54 | lineColor={0,0,127},
|
---|
55 | fillColor={255,255,255},
|
---|
56 | fillPattern=FillPattern.Solid), Text(
|
---|
57 | extent={{30,110},{30,60}},
|
---|
58 | lineColor={0,0,127},
|
---|
59 | textString="%name")}),
|
---|
60 | Documentation(info="<html>
|
---|
61 | <p>
|
---|
62 | Connector with one output signal of type Real.
|
---|
63 | </p>
|
---|
64 | </html>"));
|
---|
65 |
|
---|
66 | connector BooleanOutput = output Boolean "'output Boolean' as connector"
|
---|
67 | annotation (defaultComponentName="y",
|
---|
68 | Icon(coordinateSystem(
|
---|
69 | preserveAspectRatio=true,
|
---|
70 | extent={{-100,-100},{100,100}},
|
---|
71 | grid={1,1}), graphics={Polygon(
|
---|
72 | points={{-100,100},{100,0},{-100,-100},{-100,100}},
|
---|
73 | lineColor={255,0,255},
|
---|
74 | fillColor={255,255,255},
|
---|
75 | fillPattern=FillPattern.Solid)}),
|
---|
76 | Diagram(coordinateSystem(
|
---|
77 | preserveAspectRatio=true,
|
---|
78 | extent={{-100,-100},{100,100}},
|
---|
79 | grid={1,1}), graphics={Polygon(
|
---|
80 | points={{-100,50},{0,0},{-100,-50},{-100,50}},
|
---|
81 | lineColor={255,0,255},
|
---|
82 | fillColor={255,255,255},
|
---|
83 | fillPattern=FillPattern.Solid), Text(
|
---|
84 | extent={{30,110},{30,60}},
|
---|
85 | lineColor={255,0,255},
|
---|
86 | textString="%name")}),
|
---|
87 | Documentation(info="<html>
|
---|
88 | <p>
|
---|
89 | Connector with one output signal of type Boolean.
|
---|
90 | </p>
|
---|
91 | </html>"));
|
---|
92 |
|
---|
93 | partial block BlockIcon "Basic graphical layout of input/output block"
|
---|
94 |
|
---|
95 | annotation (
|
---|
96 | Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
|
---|
97 | 100,100}}), graphics={Rectangle(
|
---|
98 | extent={{-100,-100},{100,100}},
|
---|
99 | lineColor={0,0,127},
|
---|
100 | fillColor={255,255,255},
|
---|
101 | fillPattern=FillPattern.Solid), Text(
|
---|
102 | extent={{-150,150},{150,110}},
|
---|
103 | textString="%name",
|
---|
104 | lineColor={0,0,255})}),
|
---|
105 | Documentation(info="<html>
|
---|
106 | <p>
|
---|
107 | Block that has only the basic icon for an input/output
|
---|
108 | block (no declarations, no equations). Most blocks
|
---|
109 | of package Modelica.Blocks inherit directly or indirectly
|
---|
110 | from this block.
|
---|
111 | </p>
|
---|
112 | </html>"));
|
---|
113 |
|
---|
114 | end BlockIcon;
|
---|
115 |
|
---|
116 | partial block MO "Multiple Output continuous control block"
|
---|
117 | extends BlockIcon;
|
---|
118 |
|
---|
119 | parameter Integer nout(min=1) = 1 "Number of outputs";
|
---|
120 | RealOutput y[nout] "Connector of Real output signals"
|
---|
121 | annotation (Placement(transformation(extent={{100,-10},{120,10}},
|
---|
122 | rotation=0)));
|
---|
123 | annotation (
|
---|
124 | Documentation(info="<html>
|
---|
125 | <p>
|
---|
126 | Block has one continuous Real output signal vector.
|
---|
127 | </p>
|
---|
128 | </html>"));
|
---|
129 |
|
---|
130 | end MO;
|
---|
131 |
|
---|
132 | partial block SIMO "Single Input Multiple Output continuous control block"
|
---|
133 | extends BlockIcon;
|
---|
134 | parameter Integer nout=1 "Number of outputs";
|
---|
135 | RealInput u "Connector of Real input signal"
|
---|
136 | annotation (Placement(transformation(extent={{-140,-20},{-100,20}},
|
---|
137 | rotation=0)));
|
---|
138 | RealOutput y[nout] "Connector of Real output signals"
|
---|
139 | annotation (Placement(transformation(extent={{100,-10},{120,10}},
|
---|
140 | rotation=0)));
|
---|
141 |
|
---|
142 | annotation (Documentation(info="<HTML>
|
---|
143 | <p> Block has one continuous Real input signal and a
|
---|
144 | vector of continuous Real output signals.</p>
|
---|
145 |
|
---|
146 | </HTML>
|
---|
147 | "));
|
---|
148 | end SIMO;
|
---|
149 | annotation (
|
---|
150 | Documentation(info="<HTML>
|
---|
151 | <p>
|
---|
152 | This package contains interface definitions for
|
---|
153 | <b>continuous</b> input/output blocks with Real,
|
---|
154 | Integer and Boolean signals. Furthermore, it contains
|
---|
155 | partial models for continuous and discrete blocks.
|
---|
156 | </p>
|
---|
157 |
|
---|
158 | </HTML>
|
---|
159 | ", revisions="<html>
|
---|
160 | <ul>
|
---|
161 | <li><i>Oct. 21, 2002</i>
|
---|
162 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>
|
---|
163 | and <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br>
|
---|
164 | Added several new interfaces. <a href=\"modelica://Modelica/Documentation/ChangeNotes1.5.html\">Detailed description</a> available.
|
---|
165 | <li><i>Oct. 24, 1999</i>
|
---|
166 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
|
---|
167 | RealInputSignal renamed to RealInput. RealOutputSignal renamed to
|
---|
168 | output RealOutput. GraphBlock renamed to BlockIcon. SISOreal renamed to
|
---|
169 | SISO. SOreal renamed to SO. I2SOreal renamed to M2SO.
|
---|
170 | SignalGenerator renamed to SignalSource. Introduced the following
|
---|
171 | new models: MIMO, MIMOs, SVcontrol, MVcontrol, DiscreteBlockIcon,
|
---|
172 | DiscreteBlock, DiscreteSISO, DiscreteMIMO, DiscreteMIMOs,
|
---|
173 | BooleanBlockIcon, BooleanSISO, BooleanSignalSource, MI2BooleanMOs.</li>
|
---|
174 | <li><i>June 30, 1999</i>
|
---|
175 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
|
---|
176 | Realized a first version, based on an existing Dymola library
|
---|
177 | of Dieter Moormann and Hilding Elmqvist.</li>
|
---|
178 | </ul>
|
---|
179 | </html>
|
---|
180 | "));
|
---|
181 | end Interfaces;
|
---|
182 |
|
---|
183 | package Sources
|
---|
184 | "Library of signal source blocks generating Real and Boolean signals"
|
---|
185 | import Modelica.Blocks.Interfaces;
|
---|
186 | import Modelica.SIunits;
|
---|
187 | extends Modelica.Icons.SourcesPackage;
|
---|
188 |
|
---|
189 | model CombiTimeTable
|
---|
190 | "Table look-up with respect to time and linear/perodic extrapolation methods (data from matrix/file)"
|
---|
191 |
|
---|
192 | parameter Boolean tableOnFile=false
|
---|
193 | "= true, if table is defined on file or in function usertab"
|
---|
194 | annotation(Dialog(group="table data definition"));
|
---|
195 | parameter Real table[:, :] = fill(0.0,0,2)
|
---|
196 | "Table matrix (time = first column; e.g., table=[0,2])"
|
---|
197 | annotation(Dialog(group="table data definition", enable = not tableOnFile));
|
---|
198 | parameter String tableName="NoName"
|
---|
199 | "Table name on file or in function usertab (see docu)"
|
---|
200 | annotation(Dialog(group="table data definition", enable = tableOnFile));
|
---|
201 | parameter String fileName="NoName" "File where matrix is stored"
|
---|
202 | annotation(Dialog(group="table data definition", enable = tableOnFile,
|
---|
203 | __Dymola_loadSelector(filter="Text files (*.txt);;Matlab files (*.mat)",
|
---|
204 | caption="Open file in which table is present")));
|
---|
205 | parameter Integer columns[:]=2:size(table, 2)
|
---|
206 | "Columns of table to be interpolated"
|
---|
207 | annotation(Dialog(group="table data interpretation"));
|
---|
208 | parameter Modelica.Blocks.Types.Smoothness smoothness=Modelica.Blocks.Types.Smoothness.LinearSegments
|
---|
209 | "Smoothness of table interpolation"
|
---|
210 | annotation(Dialog(group="table data interpretation"));
|
---|
211 | parameter Modelica.Blocks.Types.Extrapolation extrapolation=Modelica.Blocks.Types.Extrapolation.LastTwoPoints
|
---|
212 | "Extrapolation of data outside the definition range"
|
---|
213 | annotation(Dialog(group="table data interpretation"));
|
---|
214 | parameter Real offset[:]={0} "Offsets of output signals"
|
---|
215 | annotation(Dialog(group="table data interpretation"));
|
---|
216 | parameter Modelica.SIunits.Time startTime=0
|
---|
217 | "Output = offset for time < startTime"
|
---|
218 | annotation(Dialog(group="table data interpretation"));
|
---|
219 | extends Modelica.Blocks.Interfaces.MO(final nout=max([size(columns, 1); size(offset, 1)]));
|
---|
220 | final parameter Real t_min(fixed=false)
|
---|
221 | "Minimum abscissa value defined in table";
|
---|
222 | final parameter Real t_max(fixed=false)
|
---|
223 | "Maximum abscissa value defined in table";
|
---|
224 |
|
---|
225 | protected
|
---|
226 | final parameter Real p_offset[nout]=(if size(offset, 1) == 1 then ones(nout)
|
---|
227 | *offset[1] else offset);
|
---|
228 |
|
---|
229 | Integer tableID;
|
---|
230 |
|
---|
231 | function tableTimeInit
|
---|
232 | "Initialize 1-dim. table where first column is time (for details see: Modelica/Resources/C-Sources/ModelicaTables.h)"
|
---|
233 | input String tableName;
|
---|
234 | input String fileName;
|
---|
235 | input Real table[ :, :];
|
---|
236 | input Real startTime;
|
---|
237 | input Modelica.Blocks.Types.Smoothness smoothness;
|
---|
238 | input Modelica.Blocks.Types.Extrapolation extrapolation;
|
---|
239 | output Integer tableID;
|
---|
240 | external "C" tableID = ModelicaTables_CombiTimeTable_init(
|
---|
241 | tableName, fileName, table, size(table, 1), size(table, 2),
|
---|
242 | startTime, smoothness, extrapolation);
|
---|
243 | annotation(Library="ModelicaExternalC");
|
---|
244 | end tableTimeInit;
|
---|
245 |
|
---|
246 | function tableTimeIpo
|
---|
247 | "Interpolate 1-dim. table where first column is time (for details see: Modelica/Resources/C-Sources/ModelicaTables.h)"
|
---|
248 | input Integer tableID;
|
---|
249 | input Integer icol;
|
---|
250 | input Real timeIn;
|
---|
251 | output Real value;
|
---|
252 | external "C" value =
|
---|
253 | ModelicaTables_CombiTimeTable_interpolate(tableID, icol, timeIn);
|
---|
254 | annotation(Library="ModelicaExternalC");
|
---|
255 | end tableTimeIpo;
|
---|
256 |
|
---|
257 | function tableTimeTmin
|
---|
258 | "Return minimum time value of 1-dim. table where first column is time (for details see: Modelica/Resources/C-Sources/ModelicaTables.h)"
|
---|
259 | input Integer tableID;
|
---|
260 | output Real Tmin "minimum time value in table";
|
---|
261 | external "C" Tmin =
|
---|
262 | ModelicaTables_CombiTimeTable_minimumTime(tableID);
|
---|
263 | annotation(Library="ModelicaExternalC");
|
---|
264 | end tableTimeTmin;
|
---|
265 |
|
---|
266 | function tableTimeTmax
|
---|
267 | "Return maximum time value of 1-dim. table where first column is time (for details see: Modelica/Resources/C-Sources/ModelicaTables.h)"
|
---|
268 | input Integer tableID;
|
---|
269 | output Real Tmax "maximum time value in table";
|
---|
270 | external "C" Tmax =
|
---|
271 | ModelicaTables_CombiTimeTable_maximumTime(tableID);
|
---|
272 | annotation(Library="ModelicaExternalC");
|
---|
273 | end tableTimeTmax;
|
---|
274 |
|
---|
275 | equation
|
---|
276 | if tableOnFile then
|
---|
277 | assert(tableName<>"NoName", "tableOnFile = true and no table name given");
|
---|
278 | end if;
|
---|
279 | if not tableOnFile then
|
---|
280 | assert(size(table,1) > 0 and size(table,2) > 0, "tableOnFile = false and parameter table is an empty matrix");
|
---|
281 | end if;
|
---|
282 | for i in 1:nout loop
|
---|
283 | y[i] = p_offset[i] + tableTimeIpo(tableID, columns[i], time);
|
---|
284 | end for;
|
---|
285 | when initial() then
|
---|
286 | tableID=tableTimeInit((if not tableOnFile then "NoName" else tableName),
|
---|
287 | (if not tableOnFile then "NoName" else fileName), table,
|
---|
288 | startTime, smoothness, extrapolation);
|
---|
289 | end when;
|
---|
290 | initial equation
|
---|
291 | t_min=tableTimeTmin(tableID);
|
---|
292 | t_max=tableTimeTmax(tableID);
|
---|
293 | annotation (
|
---|
294 | Documentation(info="<HTML>
|
---|
295 | <p>
|
---|
296 | This block generates an output signal y[:] by <b>linear interpolation</b> in
|
---|
297 | a table. The time points and function values are stored in a matrix
|
---|
298 | <b>table[i,j]</b>, where the first column table[:,1] contains the
|
---|
299 | time points and the other columns contain the data to be interpolated.
|
---|
300 | </p>
|
---|
301 |
|
---|
302 | <p>
|
---|
303 | <img src=\"modelica://Modelica/Resources/Images/Blocks/Sources/CombiTimeTable.png\">
|
---|
304 | </p>
|
---|
305 |
|
---|
306 | <p>
|
---|
307 | Via parameter <b>columns</b> it can be defined which columns of the
|
---|
308 | table are interpolated. If, e.g., columns={2,4}, it is assumed that
|
---|
309 | 2 output signals are present and that the first output is computed
|
---|
310 | by interpolation of column 2 and the second output is computed
|
---|
311 | by interpolation of column 4 of the table matrix.
|
---|
312 | The table interpolation has the following properties:
|
---|
313 | </p>
|
---|
314 | <ul>
|
---|
315 | <li>The time points need to be <b>monotonically increasing</b>. </li>
|
---|
316 | <li><b>Discontinuities</b> are allowed, by providing the same
|
---|
317 | time point twice in the table. </li>
|
---|
318 | <li>Values <b>outside</b> of the table range, are computed by
|
---|
319 | extrapolation according to the setting of parameter
|
---|
320 | <b>extrapolation</b>:
|
---|
321 | <pre>
|
---|
322 | extrapolation = 0: hold the first or last value of the table,
|
---|
323 | if outside of the range.
|
---|
324 | = 1: extrapolate through the last or first two
|
---|
325 | points of the table.
|
---|
326 | = 2: periodically repeat the table data
|
---|
327 | (periodical function).
|
---|
328 | </pre></li>
|
---|
329 | <li>Via parameter <b>smoothness</b> it is defined how the data is interpolated:
|
---|
330 | <pre>
|
---|
331 | smoothness = 0: linear interpolation
|
---|
332 | = 1: smooth interpolation with Akima Splines such
|
---|
333 | that der(y) is continuous.
|
---|
334 | </pre></li>
|
---|
335 | <li>If the table has only <b>one row</b>, no interpolation is performed and
|
---|
336 | the table values of this row are just returned.</li>
|
---|
337 | <li>Via parameters <b>startTime</b> and <b>offset</b> the curve defined
|
---|
338 | by the table can be shifted both in time and in the ordinate value.
|
---|
339 | The time instants stored in the table are therefore <b>relative</b>
|
---|
340 | to <b>startTime</b>.
|
---|
341 | If time < startTime, no interpolation is performed and the offset
|
---|
342 | is used as ordinate value for all outputs.
|
---|
343 | <li>The table is implemented in a numerically sound way by
|
---|
344 | generating <b>time events</b> at interval boundaries,
|
---|
345 | in order to not integrate over a discontinuous or not differentiable
|
---|
346 | points.
|
---|
347 | <li>For special applications it is sometimes needed to know the minimum
|
---|
348 | and maximum time instant defined in the table as a parameter. For this
|
---|
349 | reason parameters <b>t_min</b> and <b>t_max</b> are provided and can be access from
|
---|
350 | the outside of the table object.
|
---|
351 | </li>
|
---|
352 | </ul>
|
---|
353 | <p>
|
---|
354 | Example:
|
---|
355 | </p>
|
---|
356 | <pre>
|
---|
357 | table = [0 0
|
---|
358 | 1 0
|
---|
359 | 1 1
|
---|
360 | 2 4
|
---|
361 | 3 9
|
---|
362 | 4 16]; extrapolation = 1 (default)
|
---|
363 | If, e.g., time = 1.0, the output y = 0.0 (before event), 1.0 (after event)
|
---|
364 | e.g., time = 1.5, the output y = 2.5,
|
---|
365 | e.g., time = 2.0, the output y = 4.0,
|
---|
366 | e.g., time = 5.0, the output y = 23.0 (i.e., extrapolation via last 2 points).
|
---|
367 | </pre>
|
---|
368 | <p>
|
---|
369 | The table matrix can be defined in the following ways:
|
---|
370 | </p>
|
---|
371 | <ol>
|
---|
372 | <li> Explicitly supplied as <b>parameter matrix</b> \"table\",
|
---|
373 | and the other parameters have the following values:
|
---|
374 | <pre>
|
---|
375 | tableName is \"NoName\" or has only blanks,
|
---|
376 | fileName is \"NoName\" or has only blanks.
|
---|
377 | </pre></li>
|
---|
378 | <li> <b>Read</b> from a <b>file</b> \"fileName\" where the matrix is stored as
|
---|
379 | \"tableName\". Both ASCII and binary file format is possible.
|
---|
380 | (the ASCII format is described below).
|
---|
381 | It is most convenient to generate the binary file from Matlab
|
---|
382 | (Matlab 4 storage format), e.g., by command
|
---|
383 | <pre>
|
---|
384 | save tables.mat tab1 tab2 tab3 -V4
|
---|
385 | </pre>
|
---|
386 | when the three tables tab1, tab2, tab3 should be
|
---|
387 | used from the model.</li>
|
---|
388 | <li> Statically stored in function \"usertab\" in file \"usertab.c\".
|
---|
389 | The matrix is identified by \"tableName\". Parameter
|
---|
390 | fileName = \"NoName\" or has only blanks.</li>
|
---|
391 | </ol>
|
---|
392 | <p>
|
---|
393 | Table definition methods (1) and (3) do <b>not</b> allocate dynamic memory,
|
---|
394 | and do not access files, whereas method (2) does. Therefore (1) and (3)
|
---|
395 | are suited for hardware-in-the-loop simulation (e.g., with dSpace hardware).
|
---|
396 | When the constant \"NO_FILE\" is defined in \"usertab.c\", all parts of the
|
---|
397 | source code of method (2) are removed by the C-preprocessor, such that
|
---|
398 | no dynamic memory allocation and no access to files takes place.
|
---|
399 | </p>
|
---|
400 | <p>
|
---|
401 | If tables are read from an ASCII-file, the file need to have the
|
---|
402 | following structure (\"-----\" is not part of the file content):
|
---|
403 | </p>
|
---|
404 | <pre>
|
---|
405 | -----------------------------------------------------
|
---|
406 | #1
|
---|
407 | double tab1(6,2) # comment line
|
---|
408 | 0 0
|
---|
409 | 1 0
|
---|
410 | 1 1
|
---|
411 | 2 4
|
---|
412 | 3 9
|
---|
413 | 4 16
|
---|
414 | double tab2(6,2) # another comment line
|
---|
415 | 0 0
|
---|
416 | 2 0
|
---|
417 | 2 2
|
---|
418 | 4 8
|
---|
419 | 6 18
|
---|
420 | 8 32
|
---|
421 | -----------------------------------------------------
|
---|
422 | </pre>
|
---|
423 | <p>
|
---|
424 | Note, that the first two characters in the file need to be
|
---|
425 | \"#1\". Afterwards, the corresponding matrix has to be declared
|
---|
426 | with type, name and actual dimensions. Finally, in successive
|
---|
427 | rows of the file, the elements of the matrix have to be given.
|
---|
428 | Several matrices may be defined one after another.
|
---|
429 | </p>
|
---|
430 |
|
---|
431 | </HTML>
|
---|
432 | ", revisions="<html>
|
---|
433 | <p><b>Release Notes:</b></p>
|
---|
434 | <ul>
|
---|
435 | <li><i>March 31, 2001</i>
|
---|
436 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
|
---|
437 | Used CombiTableTime as a basis and added the
|
---|
438 | arguments <b>extrapolation, columns, startTime</b>.
|
---|
439 | This allows periodic function definitions. </li>
|
---|
440 | </ul>
|
---|
441 | </html>"),Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
|
---|
442 | 100}}), graphics={
|
---|
443 | Polygon(
|
---|
444 | points={{-80,90},{-88,68},{-72,68},{-80,90}},
|
---|
445 | lineColor={192,192,192},
|
---|
446 | fillColor={192,192,192},
|
---|
447 | fillPattern=FillPattern.Solid),
|
---|
448 | Line(points={{-80,68},{-80,-80}}, color={192,192,192}),
|
---|
449 | Line(points={{-90,-70},{82,-70}}, color={192,192,192}),
|
---|
450 | Polygon(
|
---|
451 | points={{90,-70},{68,-62},{68,-78},{90,-70}},
|
---|
452 | lineColor={192,192,192},
|
---|
453 | fillColor={192,192,192},
|
---|
454 | fillPattern=FillPattern.Solid),
|
---|
455 | Rectangle(
|
---|
456 | extent={{-48,70},{2,-50}},
|
---|
457 | lineColor={255,255,255},
|
---|
458 | fillColor={255,255,0},
|
---|
459 | fillPattern=FillPattern.Solid),
|
---|
460 | Line(points={{-48,-50},{-48,70},{52,70},{52,-50},{-48,-50},{-48,-20},
|
---|
461 | {52,-20},{52,10},{-48,10},{-48,40},{52,40},{52,70},{2,70},{2,-51}},
|
---|
462 | color={0,0,0})}),
|
---|
463 | Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
|
---|
464 | 100,100}}), graphics={
|
---|
465 | Polygon(
|
---|
466 | points={{-80,90},{-88,68},{-72,68},{-80,90}},
|
---|
467 | lineColor={95,95,95},
|
---|
468 | fillColor={95,95,95},
|
---|
469 | fillPattern=FillPattern.Solid),
|
---|
470 | Line(points={{-80,68},{-80,-80}}, color={95,95,95}),
|
---|
471 | Line(points={{-90,-70},{82,-70}}, color={95,95,95}),
|
---|
472 | Polygon(
|
---|
473 | points={{90,-70},{68,-62},{68,-78},{90,-70}},
|
---|
474 | lineColor={95,95,95},
|
---|
475 | fillColor={95,95,95},
|
---|
476 | fillPattern=FillPattern.Solid),
|
---|
477 | Rectangle(
|
---|
478 | extent={{-20,90},{20,-30}},
|
---|
479 | lineColor={255,255,255},
|
---|
480 | fillColor={192,192,192},
|
---|
481 | fillPattern=FillPattern.Solid),
|
---|
482 | Line(points={{-20,-30},{-20,90},{80,90},{80,-30},{-20,-30},{-20,0},{
|
---|
483 | 80,0},{80,30},{-20,30},{-20,60},{80,60},{80,90},{20,90},{20,-30}},
|
---|
484 | color={0,0,0}),
|
---|
485 | Text(
|
---|
486 | extent={{-71,-42},{-32,-54}},
|
---|
487 | lineColor={0,0,0},
|
---|
488 | textString="offset"),
|
---|
489 | Polygon(
|
---|
490 | points={{-31,-30},{-33,-40},{-28,-40},{-31,-30}},
|
---|
491 | lineColor={95,95,95},
|
---|
492 | fillColor={95,95,95},
|
---|
493 | fillPattern=FillPattern.Solid),
|
---|
494 | Polygon(
|
---|
495 | points={{-31,-70},{-34,-60},{-29,-60},{-31,-70},{-31,-70}},
|
---|
496 | lineColor={95,95,95},
|
---|
497 | fillColor={95,95,95},
|
---|
498 | fillPattern=FillPattern.Solid),
|
---|
499 | Line(points={{-31,-31},{-31,-70}}, color={95,95,95}),
|
---|
500 | Line(points={{-20,-30},{-20,-70}}, color={95,95,95}),
|
---|
501 | Text(
|
---|
502 | extent={{-42,-74},{6,-84}},
|
---|
503 | lineColor={0,0,0},
|
---|
504 | textString="startTime"),
|
---|
505 | Line(points={{-20,-30},{-80,-30}}, color={95,95,95}),
|
---|
506 | Text(
|
---|
507 | extent={{-73,93},{-44,74}},
|
---|
508 | lineColor={0,0,0},
|
---|
509 | textString="y"),
|
---|
510 | Text(
|
---|
511 | extent={{66,-81},{92,-92}},
|
---|
512 | lineColor={0,0,0},
|
---|
513 | textString="time"),
|
---|
514 | Text(
|
---|
515 | extent={{-19,83},{20,68}},
|
---|
516 | lineColor={0,0,0},
|
---|
517 | textString="time"),
|
---|
518 | Text(
|
---|
519 | extent={{21,82},{50,68}},
|
---|
520 | lineColor={0,0,0},
|
---|
521 | textString="y[1]"),
|
---|
522 | Line(points={{50,90},{50,-30}}, color={0,0,0}),
|
---|
523 | Line(points={{80,0},{100,0}}, color={0,0,255}),
|
---|
524 | Text(
|
---|
525 | extent={{34,-30},{71,-42}},
|
---|
526 | textString="columns",
|
---|
527 | lineColor={0,0,255}),
|
---|
528 | Text(
|
---|
529 | extent={{51,82},{80,68}},
|
---|
530 | lineColor={0,0,0},
|
---|
531 | textString="y[2]")}));
|
---|
532 | end CombiTimeTable;
|
---|
533 | annotation (
|
---|
534 | Documentation(info="<HTML>
|
---|
535 | <p>
|
---|
536 | This package contains <b>source</b> components, i.e., blocks which
|
---|
537 | have only output signals. These blocks are used as signal generators
|
---|
538 | for Real, Integer and Boolean signals.
|
---|
539 | </p>
|
---|
540 |
|
---|
541 | <p>
|
---|
542 | All Real source signals (with the exception of the Constant source)
|
---|
543 | have at least the following two parameters:
|
---|
544 | </p>
|
---|
545 |
|
---|
546 | <table border=1 cellspacing=0 cellpadding=2>
|
---|
547 | <tr><td valign=\"top\"><b>offset</b></td>
|
---|
548 | <td valign=\"top\">Value which is added to the signal</td>
|
---|
549 | </tr>
|
---|
550 | <tr><td valign=\"top\"><b>startTime</b></td>
|
---|
551 | <td valign=\"top\">Start time of signal. For time < startTime,
|
---|
552 | the output y is set to offset.</td>
|
---|
553 | </tr>
|
---|
554 | </table>
|
---|
555 |
|
---|
556 | <p>
|
---|
557 | The <b>offset</b> parameter is especially useful in order to shift
|
---|
558 | the corresponding source, such that at initial time the system
|
---|
559 | is stationary. To determine the corresponding value of offset,
|
---|
560 | usually requires a trimming calculation.
|
---|
561 | </p>
|
---|
562 | </HTML>
|
---|
563 | ", revisions="<html>
|
---|
564 | <ul>
|
---|
565 | <li><i>October 21, 2002</i>
|
---|
566 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>
|
---|
567 | and <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br>
|
---|
568 | Integer sources added. Step, TimeTable and BooleanStep slightly changed.</li>
|
---|
569 | <li><i>Nov. 8, 1999</i>
|
---|
570 | by <a href=\"mailto:clauss@eas.iis.fhg.de\">Christoph Clauß</a>,
|
---|
571 | <a href=\"mailto:Andre.Schneider@eas.iis.fraunhofer.de\">Andre.Schneider@eas.iis.fraunhofer.de</a>,
|
---|
572 | <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
|
---|
573 | New sources: Exponentials, TimeTable. Trapezoid slightly enhanced
|
---|
574 | (nperiod=-1 is an infinite number of periods).</li>
|
---|
575 | <li><i>Oct. 31, 1999</i>
|
---|
576 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
|
---|
577 | <a href=\"mailto:clauss@eas.iis.fhg.de\">Christoph Clauß</a>,
|
---|
578 | <a href=\"mailto:Andre.Schneider@eas.iis.fraunhofer.de\">Andre.Schneider@eas.iis.fraunhofer.de</a>,
|
---|
579 | All sources vectorized. New sources: ExpSine, Trapezoid,
|
---|
580 | BooleanConstant, BooleanStep, BooleanPulse, SampleTrigger.
|
---|
581 | Improved documentation, especially detailed description of
|
---|
582 | signals in diagram layer.</li>
|
---|
583 | <li><i>June 29, 1999</i>
|
---|
584 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
|
---|
585 | Realized a first version, based on an existing Dymola library
|
---|
586 | of Dieter Moormann and Hilding Elmqvist.</li>
|
---|
587 | </ul>
|
---|
588 | </html>"));
|
---|
589 | end Sources;
|
---|
590 |
|
---|
591 | package Tables
|
---|
592 | "Library of blocks to interpolate in one and two-dimensional tables"
|
---|
593 | extends Modelica.Icons.Package;
|
---|
594 |
|
---|
595 | model CombiTable1Ds
|
---|
596 | "Table look-up in one dimension (matrix/file) with one input and n outputs"
|
---|
597 |
|
---|
598 | import Modelica.Blocks.Types;
|
---|
599 | parameter Boolean tableOnFile=false
|
---|
600 | "true, if table is defined on file or in function usertab"
|
---|
601 | annotation(Dialog(group="table data definition"));
|
---|
602 | parameter Real table[:, :]=fill(0.0,0,2)
|
---|
603 | "table matrix (grid = first column; e.g., table=[0,2])"
|
---|
604 | annotation(Dialog(group="table data definition", enable = not tableOnFile));
|
---|
605 | parameter String tableName="NoName"
|
---|
606 | "table name on file or in function usertab (see docu)"
|
---|
607 | annotation(Dialog(group="table data definition", enable = tableOnFile));
|
---|
608 | parameter String fileName="NoName" "file where matrix is stored"
|
---|
609 | annotation(Dialog(group="table data definition", enable = tableOnFile,
|
---|
610 | __Dymola_loadSelector(filter="Text files (*.txt);;Matlab files (*.mat)",
|
---|
611 | caption="Open file in which table is present")));
|
---|
612 | parameter Integer columns[:]=2:size(table, 2)
|
---|
613 | "columns of table to be interpolated"
|
---|
614 | annotation(Dialog(group="table data interpretation"));
|
---|
615 | parameter Modelica.Blocks.Types.Smoothness smoothness=Types.Smoothness.LinearSegments
|
---|
616 | "smoothness of table interpolation"
|
---|
617 | annotation(Dialog(group="table data interpretation"));
|
---|
618 | extends Modelica.Blocks.Interfaces.SIMO(final nout=size(columns, 1));
|
---|
619 |
|
---|
620 | protected
|
---|
621 | Integer tableID;
|
---|
622 |
|
---|
623 | function tableInit
|
---|
624 | "Initialize 1-dim. table defined by matrix (for details see: Modelica/Resources/C-Sources/ModelicaTables.h)"
|
---|
625 | input String tableName;
|
---|
626 | input String fileName;
|
---|
627 | input Real table[ :, :];
|
---|
628 | input Modelica.Blocks.Types.Smoothness smoothness;
|
---|
629 | output Integer tableID;
|
---|
630 | external "C" tableID = ModelicaTables_CombiTable1D_init(
|
---|
631 | tableName, fileName, table, size(table, 1), size(table, 2),
|
---|
632 | smoothness);
|
---|
633 | annotation(Library="ModelicaExternalC");
|
---|
634 | end tableInit;
|
---|
635 |
|
---|
636 | function tableIpo
|
---|
637 | "Interpolate 1-dim. table defined by matrix (for details see: Modelica/Resources/C-Sources/ModelicaTables.h)"
|
---|
638 | input Integer tableID;
|
---|
639 | input Integer icol;
|
---|
640 | input Real u;
|
---|
641 | output Real value;
|
---|
642 | external "C" value =
|
---|
643 | ModelicaTables_CombiTable1D_interpolate(tableID, icol, u);
|
---|
644 | annotation(Library="ModelicaExternalC");
|
---|
645 | end tableIpo;
|
---|
646 |
|
---|
647 | equation
|
---|
648 | if tableOnFile then
|
---|
649 | assert(tableName<>"NoName", "tableOnFile = true and no table name given");
|
---|
650 | end if;
|
---|
651 | if not tableOnFile then
|
---|
652 | assert(size(table,1) > 0 and size(table,2) > 0, "tableOnFile = false and parameter table is an empty matrix");
|
---|
653 | end if;
|
---|
654 |
|
---|
655 | for i in 1:nout loop
|
---|
656 | y[i] = if not tableOnFile and size(table,1)==1 then
|
---|
657 | table[1, columns[i]] else tableIpo(tableID, columns[i], u);
|
---|
658 | end for;
|
---|
659 | when initial() then
|
---|
660 | tableID=tableInit(if tableOnFile then tableName else "NoName",
|
---|
661 | if tableOnFile then fileName else "NoName", table, smoothness);
|
---|
662 | end when;
|
---|
663 | annotation (
|
---|
664 | Documentation(info="<html>
|
---|
665 | <p>
|
---|
666 | <b>Linear interpolation</b> in <b>one</b> dimension of a <b>table</b>.
|
---|
667 | Via parameter <b>columns</b> it can be defined how many columns of the
|
---|
668 | table are interpolated. If, e.g., icol={2,4}, it is assumed that one input
|
---|
669 | and 2 output signals are present and that the first output interpolates
|
---|
670 | via column 2 and the second output interpolates via column 4 of the
|
---|
671 | table matrix.
|
---|
672 | </p>
|
---|
673 | <p>
|
---|
674 | The grid points and function values are stored in a matrix \"table[i,j]\",
|
---|
675 | where the first column \"table[:,1]\" contains the grid points and the
|
---|
676 | other columns contain the data to be interpolated. Example:
|
---|
677 | </p>
|
---|
678 | <pre>
|
---|
679 | table = [0, 0;
|
---|
680 | 1, 1;
|
---|
681 | 2, 4;
|
---|
682 | 4, 16]
|
---|
683 | If, e.g., the input u = 1.0, the output y = 1.0,
|
---|
684 | e.g., the input u = 1.5, the output y = 2.5,
|
---|
685 | e.g., the input u = 2.0, the output y = 4.0,
|
---|
686 | e.g., the input u =-1.0, the output y = -1.0 (i.e., extrapolation).
|
---|
687 | </pre>
|
---|
688 | <ul>
|
---|
689 | <li> The interpolation is <b>efficient</b>, because a search for a new interpolation
|
---|
690 | starts at the interval used in the last call.</li>
|
---|
691 | <li> If the table has only <b>one row</b>, the table value is returned,
|
---|
692 | independent of the value of the input signal.</li>
|
---|
693 | <li> If the input signal <b>u</b> is <b>outside</b> of the defined <b>interval</b>, i.e.,
|
---|
694 | u > table[size(table,1),1] or u < table[1,1], the corresponding
|
---|
695 | value is also determined by linear
|
---|
696 | interpolation through the last or first two points of the table.</li>
|
---|
697 | <li> The grid values (first column) have to be <b>strict</b>
|
---|
698 | monotonically increasing.</li>
|
---|
699 | </ul>
|
---|
700 | <p>
|
---|
701 | The table matrix can be defined in the following ways:
|
---|
702 | </p>
|
---|
703 | <ol>
|
---|
704 | <li> Explicitly supplied as <b>parameter matrix</b> \"table\",
|
---|
705 | and the other parameters have the following values:
|
---|
706 | <pre>
|
---|
707 | tableName is \"NoName\" or has only blanks,
|
---|
708 | fileName is \"NoName\" or has only blanks.
|
---|
709 | </pre></li>
|
---|
710 | <li> <b>Read</b> from a <b>file</b> \"fileName\" where the matrix is stored as
|
---|
711 | \"tableName\". Both ASCII and binary file format is possible.
|
---|
712 | (the ASCII format is described below).
|
---|
713 | It is most convenient to generate the binary file from Matlab
|
---|
714 | (Matlab 4 storage format), e.g., by command
|
---|
715 | <pre>
|
---|
716 | save tables.mat tab1 tab2 tab3 -V4
|
---|
717 | </pre>
|
---|
718 | when the three tables tab1, tab2, tab3 should be
|
---|
719 | used from the model.</li>
|
---|
720 | <li> Statically stored in function \"usertab\" in file \"usertab.c\".
|
---|
721 | The matrix is identified by \"tableName\". Parameter
|
---|
722 | fileName = \"NoName\" or has only blanks.</li>
|
---|
723 | </ol>
|
---|
724 | <p>
|
---|
725 | Table definition methods (1) and (3) do <b>not</b> allocate dynamic memory,
|
---|
726 | and do not access files, whereas method (2) does. Therefore (1) and (3)
|
---|
727 | are suited for hardware-in-the-loop simulation (e.g., with dSpace hardware).
|
---|
728 | When the constant \"NO_FILE\" is defined, all parts of the
|
---|
729 | source code of method (2) are removed by the C-preprocessor, such that
|
---|
730 | no dynamic memory allocation and no access to files takes place.
|
---|
731 | </p>
|
---|
732 | <p>
|
---|
733 | If tables are read from an ASCII-file, the file need to have the
|
---|
734 | following structure (\"-----\" is not part of the file content):
|
---|
735 | </p>
|
---|
736 | <pre>
|
---|
737 | -----------------------------------------------------
|
---|
738 | #1
|
---|
739 | double tab1(5,2) # comment line
|
---|
740 | 0 0
|
---|
741 | 1 1
|
---|
742 | 2 4
|
---|
743 | 3 9
|
---|
744 | 4 16
|
---|
745 | double tab2(5,2) # another comment line
|
---|
746 | 0 0
|
---|
747 | 2 2
|
---|
748 | 4 8
|
---|
749 | 6 18
|
---|
750 | 8 32
|
---|
751 | -----------------------------------------------------
|
---|
752 | </pre>
|
---|
753 | <p>
|
---|
754 | Note, that the first two characters in the file need to be
|
---|
755 | \"#1\". Afterwards, the corresponding matrix has to be declared
|
---|
756 | with type, name and actual dimensions. Finally, in successive
|
---|
757 | rows of the file, the elements of the matrix have to be given.
|
---|
758 | Several matrices may be defined one after another.
|
---|
759 | </p>
|
---|
760 | </HTML>
|
---|
761 | "), Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
|
---|
762 | 100}}), graphics={
|
---|
763 | Line(points={{-60,40},{-60,-40},{60,-40},{60,40},{30,40},{30,-40},{-30,
|
---|
764 | -40},{-30,40},{-60,40},{-60,20},{60,20},{60,0},{-60,0},{-60,-20},
|
---|
765 | {60,-20},{60,-40},{-60,-40},{-60,40},{60,40},{60,-40}}, color={
|
---|
766 | 0,0,0}),
|
---|
767 | Line(points={{0,40},{0,-40}}, color={0,0,0}),
|
---|
768 | Rectangle(
|
---|
769 | extent={{-60,40},{-30,20}},
|
---|
770 | lineColor={0,0,0},
|
---|
771 | fillColor={255,255,0},
|
---|
772 | fillPattern=FillPattern.Solid),
|
---|
773 | Rectangle(
|
---|
774 | extent={{-60,20},{-30,0}},
|
---|
775 | lineColor={0,0,0},
|
---|
776 | fillColor={255,255,0},
|
---|
777 | fillPattern=FillPattern.Solid),
|
---|
778 | Rectangle(
|
---|
779 | extent={{-60,0},{-30,-20}},
|
---|
780 | lineColor={0,0,0},
|
---|
781 | fillColor={255,255,0},
|
---|
782 | fillPattern=FillPattern.Solid),
|
---|
783 | Rectangle(
|
---|
784 | extent={{-60,-20},{-30,-40}},
|
---|
785 | lineColor={0,0,0},
|
---|
786 | fillColor={255,255,0},
|
---|
787 | fillPattern=FillPattern.Solid)}),
|
---|
788 | Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
|
---|
789 | 100,100}}), graphics={
|
---|
790 | Rectangle(
|
---|
791 | extent={{-60,60},{60,-60}},
|
---|
792 | fillColor={235,235,235},
|
---|
793 | fillPattern=FillPattern.Solid,
|
---|
794 | lineColor={0,0,255}),
|
---|
795 | Line(points={{-100,0},{-58,0}}, color={0,0,255}),
|
---|
796 | Line(points={{60,0},{100,0}}, color={0,0,255}),
|
---|
797 | Text(
|
---|
798 | extent={{-100,100},{100,64}},
|
---|
799 | textString="1 dimensional linear table interpolation",
|
---|
800 | lineColor={0,0,255}),
|
---|
801 | Line(points={{-54,40},{-54,-40},{54,-40},{54,40},{28,40},{28,-40},{-28,
|
---|
802 | -40},{-28,40},{-54,40},{-54,20},{54,20},{54,0},{-54,0},{-54,-20},
|
---|
803 | {54,-20},{54,-40},{-54,-40},{-54,40},{54,40},{54,-40}}, color={
|
---|
804 | 0,0,0}),
|
---|
805 | Line(points={{0,40},{0,-40}}, color={0,0,0}),
|
---|
806 | Rectangle(
|
---|
807 | extent={{-54,40},{-28,20}},
|
---|
808 | lineColor={0,0,0},
|
---|
809 | fillColor={255,255,0},
|
---|
810 | fillPattern=FillPattern.Solid),
|
---|
811 | Rectangle(
|
---|
812 | extent={{-54,20},{-28,0}},
|
---|
813 | lineColor={0,0,0},
|
---|
814 | fillColor={255,255,0},
|
---|
815 | fillPattern=FillPattern.Solid),
|
---|
816 | Rectangle(
|
---|
817 | extent={{-54,0},{-28,-20}},
|
---|
818 | lineColor={0,0,0},
|
---|
819 | fillColor={255,255,0},
|
---|
820 | fillPattern=FillPattern.Solid),
|
---|
821 | Rectangle(
|
---|
822 | extent={{-54,-20},{-28,-40}},
|
---|
823 | lineColor={0,0,0},
|
---|
824 | fillColor={255,255,0},
|
---|
825 | fillPattern=FillPattern.Solid),
|
---|
826 | Text(
|
---|
827 | extent={{-52,56},{-34,44}},
|
---|
828 | textString="u",
|
---|
829 | lineColor={0,0,255}),
|
---|
830 | Text(
|
---|
831 | extent={{-22,54},{2,42}},
|
---|
832 | textString="y[1]",
|
---|
833 | lineColor={0,0,255}),
|
---|
834 | Text(
|
---|
835 | extent={{4,54},{28,42}},
|
---|
836 | textString="y[2]",
|
---|
837 | lineColor={0,0,255}),
|
---|
838 | Text(
|
---|
839 | extent={{0,-40},{32,-54}},
|
---|
840 | textString="columns",
|
---|
841 | lineColor={0,0,255})}));
|
---|
842 | end CombiTable1Ds;
|
---|
843 | annotation (Documentation(info="<html>
|
---|
844 | <p>
|
---|
845 | This package contains blocks for one- and two-dimensional
|
---|
846 | interpolation in tables.
|
---|
847 | </p>
|
---|
848 | </html>"));
|
---|
849 | end Tables;
|
---|
850 |
|
---|
851 | package Types
|
---|
852 | "Library of constants and types with choices, especially to build menus"
|
---|
853 | extends Modelica.Icons.Package;
|
---|
854 |
|
---|
855 | type Smoothness = enumeration(
|
---|
856 | LinearSegments "Table points are linearly interpolated",
|
---|
857 | ContinuousDerivative
|
---|
858 | "Table points are interpolated such that the first derivative is continuous")
|
---|
859 | "Enumeration defining the smoothness of table interpolation";
|
---|
860 |
|
---|
861 | type Extrapolation = enumeration(
|
---|
862 | HoldLastPoint "Hold the last table point outside of the table scope",
|
---|
863 | LastTwoPoints
|
---|
864 | "Extrapolate linearly through the last two table points outside of the table scope",
|
---|
865 |
|
---|
866 | Periodic "Repeat the table scope periodically")
|
---|
867 | "Enumeration defining the extrapolation of time table interpolation";
|
---|
868 | annotation ( Documentation(info="<HTML>
|
---|
869 | <p>
|
---|
870 | In this package <b>types</b> and <b>constants</b> are defined that are used
|
---|
871 | in library Modelica.Blocks. The types have additional annotation choices
|
---|
872 | definitions that define the menus to be built up in the graphical
|
---|
873 | user interface when the type is used as parameter in a declaration.
|
---|
874 | </p>
|
---|
875 | </HTML>"));
|
---|
876 | end Types;
|
---|
877 | annotation (
|
---|
878 | Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}),
|
---|
879 | graphics={
|
---|
880 | Rectangle(extent={{-32,-6},{16,-35}}, lineColor={0,0,0}),
|
---|
881 | Rectangle(extent={{-32,-56},{16,-85}}, lineColor={0,0,0}),
|
---|
882 | Line(points={{16,-20},{49,-20},{49,-71},{16,-71}}, color={0,0,0}),
|
---|
883 | Line(points={{-32,-72},{-64,-72},{-64,-21},{-32,-21}}, color={0,0,0}),
|
---|
884 | Polygon(
|
---|
885 | points={{16,-71},{29,-67},{29,-74},{16,-71}},
|
---|
886 | lineColor={0,0,0},
|
---|
887 | fillColor={0,0,0},
|
---|
888 | fillPattern=FillPattern.Solid),
|
---|
889 | Polygon(
|
---|
890 | points={{-32,-21},{-46,-17},{-46,-25},{-32,-21}},
|
---|
891 | lineColor={0,0,0},
|
---|
892 | fillColor={0,0,0},
|
---|
893 | fillPattern=FillPattern.Solid)}),
|
---|
894 | Documentation(info="<html>
|
---|
895 | <p>
|
---|
896 | This library contains input/output blocks to build up block diagrams.
|
---|
897 | </p>
|
---|
898 |
|
---|
899 | <dl>
|
---|
900 | <dt><b>Main Author:</b>
|
---|
901 | <dd><a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a><br>
|
---|
902 | Deutsches Zentrum für Luft und Raumfahrt e. V. (DLR)<br>
|
---|
903 | Oberpfaffenhofen<br>
|
---|
904 | Postfach 1116<br>
|
---|
905 | D-82230 Wessling<br>
|
---|
906 | email: <A HREF=\"mailto:Martin.Otter@dlr.de\">Martin.Otter@dlr.de</A><br>
|
---|
907 | </dl>
|
---|
908 | <p>
|
---|
909 | Copyright © 1998-2010, Modelica Association and DLR.
|
---|
910 | </p>
|
---|
911 | <p>
|
---|
912 | <i>This Modelica package is <u>free</u> software and the use is completely at <u>your own risk</u>; it can be redistributed and/or modified under the terms of the Modelica License 2. For license conditions (including the disclaimer of warranty) see <a href=\"modelica://Modelica.UsersGuide.ModelicaLicense2\">Modelica.UsersGuide.ModelicaLicense2</a> or visit <a href=\"http://www.modelica.org/licenses/ModelicaLicense2\"> http://www.modelica.org/licenses/ModelicaLicense2</a>.</i>
|
---|
913 | </p>
|
---|
914 | </HTML>
|
---|
915 | ", revisions="<html>
|
---|
916 | <ul>
|
---|
917 | <li><i>June 23, 2004</i>
|
---|
918 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
|
---|
919 | Introduced new block connectors and adapated all blocks to the new connectors.
|
---|
920 | Included subpackages Continuous, Discrete, Logical, Nonlinear from
|
---|
921 | package ModelicaAdditions.Blocks.
|
---|
922 | Included subpackage ModelicaAdditions.Table in Modelica.Blocks.Sources
|
---|
923 | and in the new package Modelica.Blocks.Tables.
|
---|
924 | Added new blocks to Blocks.Sources and Blocks.Logical.
|
---|
925 | </li>
|
---|
926 | <li><i>October 21, 2002</i>
|
---|
927 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>
|
---|
928 | and <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br>
|
---|
929 | New subpackage Examples, additional components.
|
---|
930 | </li>
|
---|
931 | <li><i>June 20, 2000</i>
|
---|
932 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a> and
|
---|
933 | Michael Tiller:<br>
|
---|
934 | Introduced a replaceable signal type into
|
---|
935 | Blocks.Interfaces.RealInput/RealOutput:
|
---|
936 | <pre>
|
---|
937 | replaceable type SignalType = Real
|
---|
938 | </pre>
|
---|
939 | in order that the type of the signal of an input/output block
|
---|
940 | can be changed to a physical type, for example:
|
---|
941 | <pre>
|
---|
942 | Sine sin1(outPort(redeclare type SignalType=Modelica.SIunits.Torque))
|
---|
943 | </pre>
|
---|
944 | </li>
|
---|
945 | <li><i>Sept. 18, 1999</i>
|
---|
946 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
|
---|
947 | Renamed to Blocks. New subpackages Math, Nonlinear.
|
---|
948 | Additional components in subpackages Interfaces, Continuous
|
---|
949 | and Sources. </li>
|
---|
950 | <li><i>June 30, 1999</i>
|
---|
951 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
|
---|
952 | Realized a first version, based on an existing Dymola library
|
---|
953 | of Dieter Moormann and Hilding Elmqvist.</li>
|
---|
954 | </ul>
|
---|
955 | </html>"));
|
---|
956 | end Blocks;
|
---|
957 |
|
---|
958 | package Media "Library of media property models"
|
---|
959 | extends Modelica.Icons.Package;
|
---|
960 | import SI = Modelica.SIunits;
|
---|
961 |
|
---|
962 | package Interfaces "Interfaces for media models"
|
---|
963 | extends Modelica.Icons.InterfacesPackage;
|
---|
964 | import SI = Modelica.SIunits;
|
---|
965 |
|
---|
966 | partial package PartialMedium
|
---|
967 | "Partial medium properties (base package of all media packages)"
|
---|
968 |
|
---|
969 | import SI = Modelica.SIunits;
|
---|
970 | extends Modelica.Icons.MaterialPropertiesPackage;
|
---|
971 |
|
---|
972 | // Constants to be set in Medium
|
---|
973 | constant
|
---|
974 | Modelica.Media.Interfaces.PartialMedium.Choices.IndependentVariables
|
---|
975 | ThermoStates "Enumeration type for independent variables";
|
---|
976 | constant String mediumName = "unusablePartialMedium" "Name of the medium";
|
---|
977 | constant String substanceNames[:]={mediumName}
|
---|
978 | "Names of the mixture substances. Set substanceNames={mediumName} if only one substance.";
|
---|
979 | constant String extraPropertiesNames[:]=fill("", 0)
|
---|
980 | "Names of the additional (extra) transported properties. Set extraPropertiesNames=fill(\"\",0) if unused";
|
---|
981 | constant Boolean singleState
|
---|
982 | "= true, if u and d are not a function of pressure";
|
---|
983 | constant Boolean reducedX=true
|
---|
984 | "= true if medium contains the equation sum(X) = 1.0; set reducedX=true if only one substance (see docu for details)";
|
---|
985 | constant Boolean fixedX=false
|
---|
986 | "= true if medium contains the equation X = reference_X";
|
---|
987 | constant AbsolutePressure reference_p=101325
|
---|
988 | "Reference pressure of Medium: default 1 atmosphere";
|
---|
989 | constant Temperature reference_T=298.15
|
---|
990 | "Reference temperature of Medium: default 25 deg Celsius";
|
---|
991 | constant MassFraction reference_X[nX]= fill(1/nX, nX)
|
---|
992 | "Default mass fractions of medium";
|
---|
993 | constant AbsolutePressure p_default=101325
|
---|
994 | "Default value for pressure of medium (for initialization)";
|
---|
995 | constant Temperature T_default = Modelica.SIunits.Conversions.from_degC(20)
|
---|
996 | "Default value for temperature of medium (for initialization)";
|
---|
997 | constant SpecificEnthalpy h_default = specificEnthalpy_pTX(p_default, T_default, X_default)
|
---|
998 | "Default value for specific enthalpy of medium (for initialization)";
|
---|
999 | constant MassFraction X_default[nX]=reference_X
|
---|
1000 | "Default value for mass fractions of medium (for initialization)";
|
---|
1001 |
|
---|
1002 | final constant Integer nS=size(substanceNames, 1) "Number of substances" annotation(Evaluate=true);
|
---|
1003 | constant Integer nX = nS "Number of mass fractions"
|
---|
1004 | annotation(Evaluate=true);
|
---|
1005 | constant Integer nXi=if fixedX then 0 else if reducedX then nS - 1 else nS
|
---|
1006 | "Number of structurally independent mass fractions (see docu for details)"
|
---|
1007 | annotation(Evaluate=true);
|
---|
1008 |
|
---|
1009 | final constant Integer nC=size(extraPropertiesNames, 1)
|
---|
1010 | "Number of extra (outside of standard mass-balance) transported properties"
|
---|
1011 | annotation(Evaluate=true);
|
---|
1012 | constant Real C_nominal[nC](min=fill(Modelica.Constants.eps, nC)) = 1.0e-6*ones(nC)
|
---|
1013 | "Default for the nominal values for the extra properties";
|
---|
1014 | replaceable record FluidConstants
|
---|
1015 | "critical, triple, molecular and other standard data of fluid"
|
---|
1016 | extends Modelica.Icons.Record;
|
---|
1017 | String iupacName
|
---|
1018 | "complete IUPAC name (or common name, if non-existent)";
|
---|
1019 | String casRegistryNumber
|
---|
1020 | "chemical abstracts sequencing number (if it exists)";
|
---|
1021 | String chemicalFormula
|
---|
1022 | "Chemical formula, (brutto, nomenclature according to Hill";
|
---|
1023 | String structureFormula "Chemical structure formula";
|
---|
1024 | MolarMass molarMass "molar mass";
|
---|
1025 | end FluidConstants;
|
---|
1026 |
|
---|
1027 | replaceable record ThermodynamicState
|
---|
1028 | "Minimal variable set that is available as input argument to every medium function"
|
---|
1029 | extends Modelica.Icons.Record;
|
---|
1030 | end ThermodynamicState;
|
---|
1031 |
|
---|
1032 | replaceable partial model BaseProperties
|
---|
1033 | "Base properties (p, d, T, h, u, R, MM and, if applicable, X and Xi) of a medium"
|
---|
1034 | InputAbsolutePressure p "Absolute pressure of medium";
|
---|
1035 | InputMassFraction[nXi] Xi(start=reference_X[1:nXi])
|
---|
1036 | "Structurally independent mass fractions";
|
---|
1037 | InputSpecificEnthalpy h "Specific enthalpy of medium";
|
---|
1038 | Density d "Density of medium";
|
---|
1039 | Temperature T "Temperature of medium";
|
---|
1040 | MassFraction[nX] X(start=reference_X)
|
---|
1041 | "Mass fractions (= (component mass)/total mass m_i/m)";
|
---|
1042 | SpecificInternalEnergy u "Specific internal energy of medium";
|
---|
1043 | SpecificHeatCapacity R "Gas constant (of mixture if applicable)";
|
---|
1044 | MolarMass MM "Molar mass (of mixture or single fluid)";
|
---|
1045 | ThermodynamicState state
|
---|
1046 | "thermodynamic state record for optional functions";
|
---|
1047 | parameter Boolean preferredMediumStates=false
|
---|
1048 | "= true if StateSelect.prefer shall be used for the independent property variables of the medium"
|
---|
1049 | annotation (Evaluate=true, Dialog(tab="Advanced"));
|
---|
1050 | parameter Boolean standardOrderComponents = true
|
---|
1051 | "if true, and reducedX = true, the last element of X will be computed from the other ones";
|
---|
1052 | SI.Conversions.NonSIunits.Temperature_degC T_degC=
|
---|
1053 | Modelica.SIunits.Conversions.to_degC(T)
|
---|
1054 | "Temperature of medium in [degC]";
|
---|
1055 | SI.Conversions.NonSIunits.Pressure_bar p_bar=
|
---|
1056 | Modelica.SIunits.Conversions.to_bar(p)
|
---|
1057 | "Absolute pressure of medium in [bar]";
|
---|
1058 |
|
---|
1059 | // Local connector definition, used for equation balancing check
|
---|
1060 | connector InputAbsolutePressure = input SI.AbsolutePressure
|
---|
1061 | "Pressure as input signal connector";
|
---|
1062 | connector InputSpecificEnthalpy = input SI.SpecificEnthalpy
|
---|
1063 | "Specific enthalpy as input signal connector";
|
---|
1064 | connector InputMassFraction = input SI.MassFraction
|
---|
1065 | "Mass fraction as input signal connector";
|
---|
1066 |
|
---|
1067 | equation
|
---|
1068 | if standardOrderComponents then
|
---|
1069 | Xi = X[1:nXi];
|
---|
1070 |
|
---|
1071 | if fixedX then
|
---|
1072 | X = reference_X;
|
---|
1073 | end if;
|
---|
1074 | if reducedX and not fixedX then
|
---|
1075 | X[nX] = 1 - sum(Xi);
|
---|
1076 | end if;
|
---|
1077 | for i in 1:nX loop
|
---|
1078 | assert(X[i] >= -1.e-5 and X[i] <= 1 + 1.e-5, "Mass fraction X[" +
|
---|
1079 | String(i) + "] = " + String(X[i]) + "of substance "
|
---|
1080 | + substanceNames[i] + "\nof medium " + mediumName + " is not in the range 0..1");
|
---|
1081 | end for;
|
---|
1082 |
|
---|
1083 | end if;
|
---|
1084 |
|
---|
1085 | assert(p >= 0.0, "Pressure (= " + String(p) + " Pa) of medium \"" +
|
---|
1086 | mediumName + "\" is negative\n(Temperature = " + String(T) + " K)");
|
---|
1087 | annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,
|
---|
1088 | -100},{100,100}}), graphics={Rectangle(
|
---|
1089 | extent={{-100,100},{100,-100}},
|
---|
1090 | fillColor={255,255,255},
|
---|
1091 | fillPattern=FillPattern.Solid,
|
---|
1092 | lineColor={0,0,255}), Text(
|
---|
1093 | extent={{-152,164},{152,102}},
|
---|
1094 | textString="%name",
|
---|
1095 | lineColor={0,0,255})}),
|
---|
1096 | Documentation(info="<html>
|
---|
1097 | <p>
|
---|
1098 | Model <b>BaseProperties</b> is a model within package <b>PartialMedium</b>
|
---|
1099 | and contains the <b>declarations</b> of the minimum number of
|
---|
1100 | variables that every medium model is supposed to support.
|
---|
1101 | A specific medium inherits from model <b>BaseProperties</b> and provides
|
---|
1102 | the equations for the basic properties.</p>
|
---|
1103 | <p>
|
---|
1104 | The BaseProperties model contains the following <b>7+nXi variables</b>
|
---|
1105 | (nXi is the number of independent mass fractions defined in package
|
---|
1106 | PartialMedium):
|
---|
1107 | </p>
|
---|
1108 | <table border=1 cellspacing=0 cellpadding=2>
|
---|
1109 | <tr><td valign=\"top\"><b>Variable</b></td>
|
---|
1110 | <td valign=\"top\"><b>Unit</b></td>
|
---|
1111 | <td valign=\"top\"><b>Description</b></td></tr>
|
---|
1112 | <tr><td valign=\"top\">T</td>
|
---|
1113 | <td valign=\"top\">K</td>
|
---|
1114 | <td valign=\"top\">temperature</td></tr>
|
---|
1115 | <tr><td valign=\"top\">p</td>
|
---|
1116 | <td valign=\"top\">Pa</td>
|
---|
1117 | <td valign=\"top\">absolute pressure</td></tr>
|
---|
1118 | <tr><td valign=\"top\">d</td>
|
---|
1119 | <td valign=\"top\">kg/m3</td>
|
---|
1120 | <td valign=\"top\">density</td></tr>
|
---|
1121 | <tr><td valign=\"top\">h</td>
|
---|
1122 | <td valign=\"top\">J/kg</td>
|
---|
1123 | <td valign=\"top\">specific enthalpy</td></tr>
|
---|
1124 | <tr><td valign=\"top\">u</td>
|
---|
1125 | <td valign=\"top\">J/kg</td>
|
---|
1126 | <td valign=\"top\">specific internal energy</td></tr>
|
---|
1127 | <tr><td valign=\"top\">Xi[nXi]</td>
|
---|
1128 | <td valign=\"top\">kg/kg</td>
|
---|
1129 | <td valign=\"top\">independent mass fractions m_i/m</td></tr>
|
---|
1130 | <tr><td valign=\"top\">R</td>
|
---|
1131 | <td valign=\"top\">J/kg.K</td>
|
---|
1132 | <td valign=\"top\">gas constant</td></tr>
|
---|
1133 | <tr><td valign=\"top\">M</td>
|
---|
1134 | <td valign=\"top\">kg/mol</td>
|
---|
1135 | <td valign=\"top\">molar mass</td></tr>
|
---|
1136 | </table>
|
---|
1137 | <p>
|
---|
1138 | In order to implement an actual medium model, one can extend from this
|
---|
1139 | base model and add <b>5 equations</b> that provide relations among
|
---|
1140 | these variables. Equations will also have to be added in order to
|
---|
1141 | set all the variables within the ThermodynamicState record state.</p>
|
---|
1142 | <p>
|
---|
1143 | If standardOrderComponents=true, the full composition vector X[nX]
|
---|
1144 | is determined by the equations contained in this base class, depending
|
---|
1145 | on the independent mass fraction vector Xi[nXi].</p>
|
---|
1146 | <p>Additional <b>2 + nXi</b> equations will have to be provided
|
---|
1147 | when using the BaseProperties model, in order to fully specify the
|
---|
1148 | thermodynamic conditions. The input connector qualifier applied to
|
---|
1149 | p, h, and nXi indirectly declares the number of missing equations,
|
---|
1150 | permitting advanced equation balance checking by Modelica tools.
|
---|
1151 | Please note that this doesn't mean that the additional equations
|
---|
1152 | should be connection equations, nor that exactly those variables
|
---|
1153 | should be supplied, in order to complete the model.
|
---|
1154 | For further information, see the Modelica.Media User's guide, and
|
---|
1155 | Section 4.7 (Balanced Models) of the Modelica 3.0 specification.</p>
|
---|
1156 | </html>"));
|
---|
1157 | end BaseProperties;
|
---|
1158 |
|
---|
1159 | replaceable partial function setState_pTX
|
---|
1160 | "Return thermodynamic state as function of p, T and composition X or Xi"
|
---|
1161 | extends Modelica.Icons.Function;
|
---|
1162 | input AbsolutePressure p "Pressure";
|
---|
1163 | input Temperature T "Temperature";
|
---|
1164 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
1165 | output ThermodynamicState state "thermodynamic state record";
|
---|
1166 | end setState_pTX;
|
---|
1167 |
|
---|
1168 | replaceable partial function setState_phX
|
---|
1169 | "Return thermodynamic state as function of p, h and composition X or Xi"
|
---|
1170 | extends Modelica.Icons.Function;
|
---|
1171 | input AbsolutePressure p "Pressure";
|
---|
1172 | input SpecificEnthalpy h "Specific enthalpy";
|
---|
1173 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
1174 | output ThermodynamicState state "thermodynamic state record";
|
---|
1175 | end setState_phX;
|
---|
1176 |
|
---|
1177 | replaceable partial function setState_psX
|
---|
1178 | "Return thermodynamic state as function of p, s and composition X or Xi"
|
---|
1179 | extends Modelica.Icons.Function;
|
---|
1180 | input AbsolutePressure p "Pressure";
|
---|
1181 | input SpecificEntropy s "Specific entropy";
|
---|
1182 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
1183 | output ThermodynamicState state "thermodynamic state record";
|
---|
1184 | end setState_psX;
|
---|
1185 |
|
---|
1186 | replaceable partial function setState_dTX
|
---|
1187 | "Return thermodynamic state as function of d, T and composition X or Xi"
|
---|
1188 | extends Modelica.Icons.Function;
|
---|
1189 | input Density d "density";
|
---|
1190 | input Temperature T "Temperature";
|
---|
1191 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
1192 | output ThermodynamicState state "thermodynamic state record";
|
---|
1193 | end setState_dTX;
|
---|
1194 |
|
---|
1195 | replaceable partial function setSmoothState
|
---|
1196 | "Return thermodynamic state so that it smoothly approximates: if x > 0 then state_a else state_b"
|
---|
1197 | extends Modelica.Icons.Function;
|
---|
1198 | input Real x "m_flow or dp";
|
---|
1199 | input ThermodynamicState state_a "Thermodynamic state if x > 0";
|
---|
1200 | input ThermodynamicState state_b "Thermodynamic state if x < 0";
|
---|
1201 | input Real x_small(min=0)
|
---|
1202 | "Smooth transition in the region -x_small < x < x_small";
|
---|
1203 | output ThermodynamicState state
|
---|
1204 | "Smooth thermodynamic state for all x (continuous and differentiable)";
|
---|
1205 | annotation(Documentation(info="<html>
|
---|
1206 | <p>
|
---|
1207 | This function is used to approximate the equation
|
---|
1208 | </p>
|
---|
1209 | <pre>
|
---|
1210 | state = <b>if</b> x > 0 <b>then</b> state_a <b>else</b> state_b;
|
---|
1211 | </pre>
|
---|
1212 |
|
---|
1213 | <p>
|
---|
1214 | by a smooth characteristic, so that the expression is continuous and differentiable:
|
---|
1215 | </p>
|
---|
1216 |
|
---|
1217 | <pre>
|
---|
1218 | state := <b>smooth</b>(1, <b>if</b> x > x_small <b>then</b> state_a <b>else</b>
|
---|
1219 | <b>if</b> x < -x_small <b>then</b> state_b <b>else</b> f(state_a, state_b));
|
---|
1220 | </pre>
|
---|
1221 |
|
---|
1222 | <p>
|
---|
1223 | This is performed by applying function <b>Media.Common.smoothStep</b>(..)
|
---|
1224 | on every element of the thermodynamic state record.
|
---|
1225 | </p>
|
---|
1226 |
|
---|
1227 | <p>
|
---|
1228 | If <b>mass fractions</b> X[:] are approximated with this function then this can be performed
|
---|
1229 | for all <b>nX</b> mass fractions, instead of applying it for nX-1 mass fractions and computing
|
---|
1230 | the last one by the mass fraction constraint sum(X)=1. The reason is that the approximating function has the
|
---|
1231 | property that sum(state.X) = 1, provided sum(state_a.X) = sum(state_b.X) = 1.
|
---|
1232 | This can be shown by evaluating the approximating function in the abs(x) < x_small
|
---|
1233 | region (otherwise state.X is either state_a.X or state_b.X):
|
---|
1234 | </p>
|
---|
1235 |
|
---|
1236 | <pre>
|
---|
1237 | X[1] = smoothStep(x, X_a[1] , X_b[1] , x_small);
|
---|
1238 | X[2] = smoothStep(x, X_a[2] , X_b[2] , x_small);
|
---|
1239 | ...
|
---|
1240 | X[nX] = smoothStep(x, X_a[nX], X_b[nX], x_small);
|
---|
1241 | </pre>
|
---|
1242 |
|
---|
1243 | <p>
|
---|
1244 | or
|
---|
1245 | </p>
|
---|
1246 |
|
---|
1247 | <pre>
|
---|
1248 | X[1] = c*(X_a[1] - X_b[1]) + (X_a[1] + X_b[1])/2
|
---|
1249 | X[2] = c*(X_a[2] - X_b[2]) + (X_a[2] + X_b[2])/2;
|
---|
1250 | ...
|
---|
1251 | X[nX] = c*(X_a[nX] - X_b[nX]) + (X_a[nX] + X_b[nX])/2;
|
---|
1252 | c = (x/x_small)*((x/x_small)^2 - 3)/4
|
---|
1253 | </pre>
|
---|
1254 |
|
---|
1255 | <p>
|
---|
1256 | Summing all mass fractions together results in
|
---|
1257 | </p>
|
---|
1258 |
|
---|
1259 | <pre>
|
---|
1260 | sum(X) = c*(sum(X_a) - sum(X_b)) + (sum(X_a) + sum(X_b))/2
|
---|
1261 | = c*(1 - 1) + (1 + 1)/2
|
---|
1262 | = 1
|
---|
1263 | </pre>
|
---|
1264 |
|
---|
1265 | </html>"));
|
---|
1266 | end setSmoothState;
|
---|
1267 |
|
---|
1268 | replaceable partial function dynamicViscosity "Return dynamic viscosity"
|
---|
1269 | extends Modelica.Icons.Function;
|
---|
1270 | input ThermodynamicState state "thermodynamic state record";
|
---|
1271 | output DynamicViscosity eta "Dynamic viscosity";
|
---|
1272 | end dynamicViscosity;
|
---|
1273 |
|
---|
1274 | replaceable partial function thermalConductivity
|
---|
1275 | "Return thermal conductivity"
|
---|
1276 | extends Modelica.Icons.Function;
|
---|
1277 | input ThermodynamicState state "thermodynamic state record";
|
---|
1278 | output ThermalConductivity lambda "Thermal conductivity";
|
---|
1279 | end thermalConductivity;
|
---|
1280 |
|
---|
1281 | replaceable function prandtlNumber "Return the Prandtl number"
|
---|
1282 | extends Modelica.Icons.Function;
|
---|
1283 | input ThermodynamicState state "thermodynamic state record";
|
---|
1284 | output PrandtlNumber Pr "Prandtl number";
|
---|
1285 | algorithm
|
---|
1286 | Pr := dynamicViscosity(state)*specificHeatCapacityCp(state)/thermalConductivity(
|
---|
1287 | state);
|
---|
1288 | end prandtlNumber;
|
---|
1289 |
|
---|
1290 | replaceable partial function pressure "Return pressure"
|
---|
1291 | extends Modelica.Icons.Function;
|
---|
1292 | input ThermodynamicState state "thermodynamic state record";
|
---|
1293 | output AbsolutePressure p "Pressure";
|
---|
1294 | end pressure;
|
---|
1295 |
|
---|
1296 | replaceable partial function temperature "Return temperature"
|
---|
1297 | extends Modelica.Icons.Function;
|
---|
1298 | input ThermodynamicState state "thermodynamic state record";
|
---|
1299 | output Temperature T "Temperature";
|
---|
1300 | end temperature;
|
---|
1301 |
|
---|
1302 | replaceable partial function density "Return density"
|
---|
1303 | extends Modelica.Icons.Function;
|
---|
1304 | input ThermodynamicState state "thermodynamic state record";
|
---|
1305 | output Density d "Density";
|
---|
1306 | end density;
|
---|
1307 |
|
---|
1308 | replaceable partial function specificEnthalpy "Return specific enthalpy"
|
---|
1309 | extends Modelica.Icons.Function;
|
---|
1310 | input ThermodynamicState state "thermodynamic state record";
|
---|
1311 | output SpecificEnthalpy h "Specific enthalpy";
|
---|
1312 | end specificEnthalpy;
|
---|
1313 |
|
---|
1314 | replaceable partial function specificInternalEnergy
|
---|
1315 | "Return specific internal energy"
|
---|
1316 | extends Modelica.Icons.Function;
|
---|
1317 | input ThermodynamicState state "thermodynamic state record";
|
---|
1318 | output SpecificEnergy u "Specific internal energy";
|
---|
1319 | end specificInternalEnergy;
|
---|
1320 |
|
---|
1321 | replaceable partial function specificEntropy "Return specific entropy"
|
---|
1322 | extends Modelica.Icons.Function;
|
---|
1323 | input ThermodynamicState state "thermodynamic state record";
|
---|
1324 | output SpecificEntropy s "Specific entropy";
|
---|
1325 | end specificEntropy;
|
---|
1326 |
|
---|
1327 | replaceable partial function specificGibbsEnergy
|
---|
1328 | "Return specific Gibbs energy"
|
---|
1329 | extends Modelica.Icons.Function;
|
---|
1330 | input ThermodynamicState state "thermodynamic state record";
|
---|
1331 | output SpecificEnergy g "Specific Gibbs energy";
|
---|
1332 | end specificGibbsEnergy;
|
---|
1333 |
|
---|
1334 | replaceable partial function specificHelmholtzEnergy
|
---|
1335 | "Return specific Helmholtz energy"
|
---|
1336 | extends Modelica.Icons.Function;
|
---|
1337 | input ThermodynamicState state "thermodynamic state record";
|
---|
1338 | output SpecificEnergy f "Specific Helmholtz energy";
|
---|
1339 | end specificHelmholtzEnergy;
|
---|
1340 |
|
---|
1341 | replaceable partial function specificHeatCapacityCp
|
---|
1342 | "Return specific heat capacity at constant pressure"
|
---|
1343 | extends Modelica.Icons.Function;
|
---|
1344 | input ThermodynamicState state "thermodynamic state record";
|
---|
1345 | output SpecificHeatCapacity cp
|
---|
1346 | "Specific heat capacity at constant pressure";
|
---|
1347 | end specificHeatCapacityCp;
|
---|
1348 |
|
---|
1349 | function heatCapacity_cp = specificHeatCapacityCp
|
---|
1350 | "alias for deprecated name";
|
---|
1351 |
|
---|
1352 | replaceable partial function specificHeatCapacityCv
|
---|
1353 | "Return specific heat capacity at constant volume"
|
---|
1354 | extends Modelica.Icons.Function;
|
---|
1355 | input ThermodynamicState state "thermodynamic state record";
|
---|
1356 | output SpecificHeatCapacity cv
|
---|
1357 | "Specific heat capacity at constant volume";
|
---|
1358 | end specificHeatCapacityCv;
|
---|
1359 |
|
---|
1360 | function heatCapacity_cv = specificHeatCapacityCv
|
---|
1361 | "alias for deprecated name";
|
---|
1362 |
|
---|
1363 | replaceable partial function isentropicExponent
|
---|
1364 | "Return isentropic exponent"
|
---|
1365 | extends Modelica.Icons.Function;
|
---|
1366 | input ThermodynamicState state "thermodynamic state record";
|
---|
1367 | output IsentropicExponent gamma "Isentropic exponent";
|
---|
1368 | end isentropicExponent;
|
---|
1369 |
|
---|
1370 | replaceable partial function isentropicEnthalpy
|
---|
1371 | "Return isentropic enthalpy"
|
---|
1372 | extends Modelica.Icons.Function;
|
---|
1373 | input AbsolutePressure p_downstream "downstream pressure";
|
---|
1374 | input ThermodynamicState refState "reference state for entropy";
|
---|
1375 | output SpecificEnthalpy h_is "Isentropic enthalpy";
|
---|
1376 | annotation(Documentation(info="<html>
|
---|
1377 | <p>
|
---|
1378 | This function computes an isentropic state transformation:
|
---|
1379 | </p>
|
---|
1380 | <ol>
|
---|
1381 | <li> A medium is in a particular state, refState.</li>
|
---|
1382 | <li> The enhalpy at another state (h_is) shall be computed
|
---|
1383 | under the assumption that the state transformation from refState to h_is
|
---|
1384 | is performed with a change of specific entropy ds = 0 and the pressure of state h_is
|
---|
1385 | is p_downstream and the composition X upstream and downstream is assumed to be the same.</li>
|
---|
1386 | </ol>
|
---|
1387 |
|
---|
1388 | </html>"));
|
---|
1389 | end isentropicEnthalpy;
|
---|
1390 |
|
---|
1391 | replaceable partial function velocityOfSound "Return velocity of sound"
|
---|
1392 | extends Modelica.Icons.Function;
|
---|
1393 | input ThermodynamicState state "thermodynamic state record";
|
---|
1394 | output VelocityOfSound a "Velocity of sound";
|
---|
1395 | end velocityOfSound;
|
---|
1396 |
|
---|
1397 | replaceable partial function isobaricExpansionCoefficient
|
---|
1398 | "Return overall the isobaric expansion coefficient beta"
|
---|
1399 | extends Modelica.Icons.Function;
|
---|
1400 | input ThermodynamicState state "thermodynamic state record";
|
---|
1401 | output IsobaricExpansionCoefficient beta
|
---|
1402 | "Isobaric expansion coefficient";
|
---|
1403 | annotation(Documentation(info="<html>
|
---|
1404 | <pre>
|
---|
1405 | beta is defined as 1/v * der(v,T), with v = 1/d, at constant pressure p.
|
---|
1406 | </pre>
|
---|
1407 | </html>"));
|
---|
1408 | end isobaricExpansionCoefficient;
|
---|
1409 |
|
---|
1410 | function beta = isobaricExpansionCoefficient
|
---|
1411 | "alias for isobaricExpansionCoefficient for user convenience";
|
---|
1412 |
|
---|
1413 | replaceable partial function isothermalCompressibility
|
---|
1414 | "Return overall the isothermal compressibility factor"
|
---|
1415 | extends Modelica.Icons.Function;
|
---|
1416 | input ThermodynamicState state "thermodynamic state record";
|
---|
1417 | output SI.IsothermalCompressibility kappa "Isothermal compressibility";
|
---|
1418 | annotation(Documentation(info="<html>
|
---|
1419 | <pre>
|
---|
1420 |
|
---|
1421 | kappa is defined as - 1/v * der(v,p), with v = 1/d at constant temperature T.
|
---|
1422 |
|
---|
1423 | </pre>
|
---|
1424 | </html>"));
|
---|
1425 | end isothermalCompressibility;
|
---|
1426 |
|
---|
1427 | function kappa = isothermalCompressibility
|
---|
1428 | "alias of isothermalCompressibility for user convenience";
|
---|
1429 |
|
---|
1430 | // explicit derivative functions for finite element models
|
---|
1431 | replaceable partial function density_derp_h
|
---|
1432 | "Return density derivative w.r.t. pressure at const specific enthalpy"
|
---|
1433 | extends Modelica.Icons.Function;
|
---|
1434 | input ThermodynamicState state "thermodynamic state record";
|
---|
1435 | output DerDensityByPressure ddph "Density derivative w.r.t. pressure";
|
---|
1436 | end density_derp_h;
|
---|
1437 |
|
---|
1438 | replaceable partial function density_derh_p
|
---|
1439 | "Return density derivative w.r.t. specific enthalpy at constant pressure"
|
---|
1440 | extends Modelica.Icons.Function;
|
---|
1441 | input ThermodynamicState state "thermodynamic state record";
|
---|
1442 | output DerDensityByEnthalpy ddhp
|
---|
1443 | "Density derivative w.r.t. specific enthalpy";
|
---|
1444 | end density_derh_p;
|
---|
1445 |
|
---|
1446 | replaceable partial function density_derp_T
|
---|
1447 | "Return density derivative w.r.t. pressure at const temperature"
|
---|
1448 | extends Modelica.Icons.Function;
|
---|
1449 | input ThermodynamicState state "thermodynamic state record";
|
---|
1450 | output DerDensityByPressure ddpT "Density derivative w.r.t. pressure";
|
---|
1451 | end density_derp_T;
|
---|
1452 |
|
---|
1453 | replaceable partial function density_derT_p
|
---|
1454 | "Return density derivative w.r.t. temperature at constant pressure"
|
---|
1455 | extends Modelica.Icons.Function;
|
---|
1456 | input ThermodynamicState state "thermodynamic state record";
|
---|
1457 | output DerDensityByTemperature ddTp
|
---|
1458 | "Density derivative w.r.t. temperature";
|
---|
1459 | end density_derT_p;
|
---|
1460 |
|
---|
1461 | replaceable partial function density_derX
|
---|
1462 | "Return density derivative w.r.t. mass fraction"
|
---|
1463 | extends Modelica.Icons.Function;
|
---|
1464 | input ThermodynamicState state "thermodynamic state record";
|
---|
1465 | output Density[nX] dddX "Derivative of density w.r.t. mass fraction";
|
---|
1466 | end density_derX;
|
---|
1467 |
|
---|
1468 | replaceable partial function molarMass
|
---|
1469 | "Return the molar mass of the medium"
|
---|
1470 | extends Modelica.Icons.Function;
|
---|
1471 | input ThermodynamicState state "thermodynamic state record";
|
---|
1472 | output MolarMass MM "Mixture molar mass";
|
---|
1473 | end molarMass;
|
---|
1474 |
|
---|
1475 | replaceable function specificEnthalpy_pTX
|
---|
1476 | "Return specific enthalpy from p, T, and X or Xi"
|
---|
1477 | extends Modelica.Icons.Function;
|
---|
1478 | input AbsolutePressure p "Pressure";
|
---|
1479 | input Temperature T "Temperature";
|
---|
1480 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
1481 | output SpecificEnthalpy h "Specific enthalpy";
|
---|
1482 | algorithm
|
---|
1483 | h := specificEnthalpy(setState_pTX(p,T,X));
|
---|
1484 | annotation(inverse(T = temperature_phX(p,h,X)));
|
---|
1485 | end specificEnthalpy_pTX;
|
---|
1486 |
|
---|
1487 | replaceable function specificEntropy_pTX
|
---|
1488 | "Return specific enthalpy from p, T, and X or Xi"
|
---|
1489 | extends Modelica.Icons.Function;
|
---|
1490 | input AbsolutePressure p "Pressure";
|
---|
1491 | input Temperature T "Temperature";
|
---|
1492 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
1493 | output SpecificEntropy s "Specific entropy";
|
---|
1494 | algorithm
|
---|
1495 | s := specificEntropy(setState_pTX(p,T,X));
|
---|
1496 |
|
---|
1497 | annotation(inverse(T = temperature_psX(p,s,X)));
|
---|
1498 | end specificEntropy_pTX;
|
---|
1499 |
|
---|
1500 | replaceable function density_pTX "Return density from p, T, and X or Xi"
|
---|
1501 | extends Modelica.Icons.Function;
|
---|
1502 | input AbsolutePressure p "Pressure";
|
---|
1503 | input Temperature T "Temperature";
|
---|
1504 | input MassFraction X[:] "Mass fractions";
|
---|
1505 | output Density d "Density";
|
---|
1506 | algorithm
|
---|
1507 | d := density(setState_pTX(p,T,X));
|
---|
1508 | end density_pTX;
|
---|
1509 |
|
---|
1510 | replaceable function temperature_phX
|
---|
1511 | "Return temperature from p, h, and X or Xi"
|
---|
1512 | extends Modelica.Icons.Function;
|
---|
1513 | input AbsolutePressure p "Pressure";
|
---|
1514 | input SpecificEnthalpy h "Specific enthalpy";
|
---|
1515 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
1516 | output Temperature T "Temperature";
|
---|
1517 | algorithm
|
---|
1518 | T := temperature(setState_phX(p,h,X));
|
---|
1519 | end temperature_phX;
|
---|
1520 |
|
---|
1521 | replaceable function density_phX "Return density from p, h, and X or Xi"
|
---|
1522 | extends Modelica.Icons.Function;
|
---|
1523 | input AbsolutePressure p "Pressure";
|
---|
1524 | input SpecificEnthalpy h "Specific enthalpy";
|
---|
1525 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
1526 | output Density d "Density";
|
---|
1527 | algorithm
|
---|
1528 | d := density(setState_phX(p,h,X));
|
---|
1529 | end density_phX;
|
---|
1530 |
|
---|
1531 | replaceable function temperature_psX
|
---|
1532 | "Return temperature from p,s, and X or Xi"
|
---|
1533 | extends Modelica.Icons.Function;
|
---|
1534 | input AbsolutePressure p "Pressure";
|
---|
1535 | input SpecificEntropy s "Specific entropy";
|
---|
1536 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
1537 | output Temperature T "Temperature";
|
---|
1538 | algorithm
|
---|
1539 | T := temperature(setState_psX(p,s,X));
|
---|
1540 | annotation(inverse(s = specificEntropy_pTX(p,T,X)));
|
---|
1541 | end temperature_psX;
|
---|
1542 |
|
---|
1543 | replaceable function density_psX "Return density from p, s, and X or Xi"
|
---|
1544 | extends Modelica.Icons.Function;
|
---|
1545 | input AbsolutePressure p "Pressure";
|
---|
1546 | input SpecificEntropy s "Specific entropy";
|
---|
1547 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
1548 | output Density d "Density";
|
---|
1549 | algorithm
|
---|
1550 | d := density(setState_psX(p,s,X));
|
---|
1551 | end density_psX;
|
---|
1552 |
|
---|
1553 | replaceable function specificEnthalpy_psX
|
---|
1554 | "Return specific enthalpy from p, s, and X or Xi"
|
---|
1555 | extends Modelica.Icons.Function;
|
---|
1556 | input AbsolutePressure p "Pressure";
|
---|
1557 | input SpecificEntropy s "Specific entropy";
|
---|
1558 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
1559 | output SpecificEnthalpy h "Specific enthalpy";
|
---|
1560 | algorithm
|
---|
1561 | h := specificEnthalpy(setState_psX(p,s,X));
|
---|
1562 | end specificEnthalpy_psX;
|
---|
1563 |
|
---|
1564 | type AbsolutePressure = SI.AbsolutePressure (
|
---|
1565 | min=0,
|
---|
1566 | max=1.e8,
|
---|
1567 | nominal=1.e5,
|
---|
1568 | start=1.e5)
|
---|
1569 | "Type for absolute pressure with medium specific attributes";
|
---|
1570 |
|
---|
1571 | type Density = SI.Density (
|
---|
1572 | min=0,
|
---|
1573 | max=1.e5,
|
---|
1574 | nominal=1,
|
---|
1575 | start=1) "Type for density with medium specific attributes";
|
---|
1576 | type DynamicViscosity = SI.DynamicViscosity (
|
---|
1577 | min=0,
|
---|
1578 | max=1.e8,
|
---|
1579 | nominal=1.e-3,
|
---|
1580 | start=1.e-3)
|
---|
1581 | "Type for dynamic viscosity with medium specific attributes";
|
---|
1582 | type EnthalpyFlowRate = SI.EnthalpyFlowRate (
|
---|
1583 | nominal=1000.0,
|
---|
1584 | min=-1.0e8,
|
---|
1585 | max=1.e8)
|
---|
1586 | "Type for enthalpy flow rate with medium specific attributes";
|
---|
1587 | type MassFlowRate = SI.MassFlowRate (
|
---|
1588 | quantity="MassFlowRate." + mediumName,
|
---|
1589 | min=-1.0e5,
|
---|
1590 | max=1.e5) "Type for mass flow rate with medium specific attributes";
|
---|
1591 | type MassFraction = Real (
|
---|
1592 | quantity="MassFraction",
|
---|
1593 | final unit="kg/kg",
|
---|
1594 | min=0,
|
---|
1595 | max=1,
|
---|
1596 | nominal=0.1) "Type for mass fraction with medium specific attributes";
|
---|
1597 | type MoleFraction = Real (
|
---|
1598 | quantity="MoleFraction",
|
---|
1599 | final unit="mol/mol",
|
---|
1600 | min=0,
|
---|
1601 | max=1,
|
---|
1602 | nominal=0.1) "Type for mole fraction with medium specific attributes";
|
---|
1603 | type MolarMass = SI.MolarMass (
|
---|
1604 | min=0.001,
|
---|
1605 | max=0.25,
|
---|
1606 | nominal=0.032) "Type for molar mass with medium specific attributes";
|
---|
1607 | type MolarVolume = SI.MolarVolume (
|
---|
1608 | min=1e-6,
|
---|
1609 | max=1.0e6,
|
---|
1610 | nominal=1.0) "Type for molar volume with medium specific attributes";
|
---|
1611 | type IsentropicExponent = SI.RatioOfSpecificHeatCapacities (
|
---|
1612 | min=1,
|
---|
1613 | max=500000,
|
---|
1614 | nominal=1.2,
|
---|
1615 | start=1.2)
|
---|
1616 | "Type for isentropic exponent with medium specific attributes";
|
---|
1617 | type SpecificEnergy = SI.SpecificEnergy (
|
---|
1618 | min=-1.0e8,
|
---|
1619 | max=1.e8,
|
---|
1620 | nominal=1.e6)
|
---|
1621 | "Type for specific energy with medium specific attributes";
|
---|
1622 | type SpecificInternalEnergy = SpecificEnergy
|
---|
1623 | "Type for specific internal energy with medium specific attributes";
|
---|
1624 | type SpecificEnthalpy = SI.SpecificEnthalpy (
|
---|
1625 | min=-1.0e10,
|
---|
1626 | max=1.e10,
|
---|
1627 | nominal=1.e6)
|
---|
1628 | "Type for specific enthalpy with medium specific attributes";
|
---|
1629 | type SpecificEntropy = SI.SpecificEntropy (
|
---|
1630 | min=-1.e7,
|
---|
1631 | max=1.e7,
|
---|
1632 | nominal=1.e3)
|
---|
1633 | "Type for specific entropy with medium specific attributes";
|
---|
1634 | type SpecificHeatCapacity = SI.SpecificHeatCapacity (
|
---|
1635 | min=0,
|
---|
1636 | max=1.e7,
|
---|
1637 | nominal=1.e3,
|
---|
1638 | start=1.e3)
|
---|
1639 | "Type for specific heat capacity with medium specific attributes";
|
---|
1640 | type SurfaceTension = SI.SurfaceTension
|
---|
1641 | "Type for surface tension with medium specific attributes";
|
---|
1642 | type Temperature = SI.Temperature (
|
---|
1643 | min=1,
|
---|
1644 | max=1.e4,
|
---|
1645 | nominal=300,
|
---|
1646 | start=300) "Type for temperature with medium specific attributes";
|
---|
1647 | type ThermalConductivity = SI.ThermalConductivity (
|
---|
1648 | min=0,
|
---|
1649 | max=500,
|
---|
1650 | nominal=1,
|
---|
1651 | start=1)
|
---|
1652 | "Type for thermal conductivity with medium specific attributes";
|
---|
1653 | type PrandtlNumber = SI.PrandtlNumber (
|
---|
1654 | min=1e-3,
|
---|
1655 | max=1e5,
|
---|
1656 | nominal=1.0)
|
---|
1657 | "Type for Prandtl number with medium specific attributes";
|
---|
1658 | type VelocityOfSound = SI.Velocity (
|
---|
1659 | min=0,
|
---|
1660 | max=1.e5,
|
---|
1661 | nominal=1000,
|
---|
1662 | start=1000)
|
---|
1663 | "Type for velocity of sound with medium specific attributes";
|
---|
1664 | type ExtraProperty = Real (min=0.0, start=1.0)
|
---|
1665 | "Type for unspecified, mass-specific property transported by flow";
|
---|
1666 | type CumulativeExtraProperty = Real (min=0.0, start=1.0)
|
---|
1667 | "Type for conserved integral of unspecified, mass specific property";
|
---|
1668 | type ExtraPropertyFlowRate = Real(unit="kg/s")
|
---|
1669 | "Type for flow rate of unspecified, mass-specific property";
|
---|
1670 | type IsobaricExpansionCoefficient = Real (
|
---|
1671 | min=0,
|
---|
1672 | max=1.0e8,
|
---|
1673 | unit="1/K")
|
---|
1674 | "Type for isobaric expansion coefficient with medium specific attributes";
|
---|
1675 | type DipoleMoment = Real (
|
---|
1676 | min=0.0,
|
---|
1677 | max=2.0,
|
---|
1678 | unit="debye",
|
---|
1679 | quantity="ElectricDipoleMoment")
|
---|
1680 | "Type for dipole moment with medium specific attributes";
|
---|
1681 |
|
---|
1682 | type DerDensityByPressure = SI.DerDensityByPressure
|
---|
1683 | "Type for partial derivative of density with resect to pressure with medium specific attributes";
|
---|
1684 | type DerDensityByEnthalpy = SI.DerDensityByEnthalpy
|
---|
1685 | "Type for partial derivative of density with resect to enthalpy with medium specific attributes";
|
---|
1686 | type DerEnthalpyByPressure = SI.DerEnthalpyByPressure
|
---|
1687 | "Type for partial derivative of enthalpy with resect to pressure with medium specific attributes";
|
---|
1688 | type DerDensityByTemperature = SI.DerDensityByTemperature
|
---|
1689 | "Type for partial derivative of density with resect to temperature with medium specific attributes";
|
---|
1690 |
|
---|
1691 | package Choices "Types, constants to define menu choices"
|
---|
1692 |
|
---|
1693 | type IndependentVariables = enumeration(
|
---|
1694 | T "Temperature",
|
---|
1695 | pT "Pressure, Temperature",
|
---|
1696 | ph "Pressure, Specific Enthalpy",
|
---|
1697 | phX "Pressure, Specific Enthalpy, Mass Fraction",
|
---|
1698 | pTX "Pressure, Temperature, Mass Fractions",
|
---|
1699 | dTX "Density, Temperature, Mass Fractions")
|
---|
1700 | "Enumeration defining the independent variables of a medium";
|
---|
1701 |
|
---|
1702 | type Init = enumeration(
|
---|
1703 | NoInit "NoInit (no initialization)",
|
---|
1704 | InitialStates "InitialStates (initialize medium states)",
|
---|
1705 | SteadyState "SteadyState (initialize in steady state)",
|
---|
1706 | SteadyMass
|
---|
1707 | "SteadyMass (initialize density or pressure in steady state)")
|
---|
1708 | "Enumeration defining initialization for fluid flow"
|
---|
1709 | annotation (Evaluate=true);
|
---|
1710 |
|
---|
1711 | type ReferenceEnthalpy = enumeration(
|
---|
1712 | ZeroAt0K
|
---|
1713 | "The enthalpy is 0 at 0 K (default), if the enthalpy of formation is excluded",
|
---|
1714 |
|
---|
1715 | ZeroAt25C
|
---|
1716 | "The enthalpy is 0 at 25 degC, if the enthalpy of formation is excluded",
|
---|
1717 |
|
---|
1718 | UserDefined
|
---|
1719 | "The user-defined reference enthalpy is used at 293.15 K (25 degC)")
|
---|
1720 | "Enumeration defining the reference enthalpy of a medium"
|
---|
1721 | annotation (Evaluate=true);
|
---|
1722 |
|
---|
1723 | type ReferenceEntropy = enumeration(
|
---|
1724 | ZeroAt0K "The entropy is 0 at 0 K (default)",
|
---|
1725 | ZeroAt0C "The entropy is 0 at 0 degC",
|
---|
1726 | UserDefined
|
---|
1727 | "The user-defined reference entropy is used at 293.15 K (25 degC)")
|
---|
1728 | "Enumeration defining the reference entropy of a medium"
|
---|
1729 | annotation (Evaluate=true);
|
---|
1730 |
|
---|
1731 | type pd = enumeration(
|
---|
1732 | default "Default (no boundary condition for p or d)",
|
---|
1733 | p_known "p_known (pressure p is known)",
|
---|
1734 | d_known "d_known (density d is known)")
|
---|
1735 | "Enumeration defining whether p or d are known for the boundary condition"
|
---|
1736 | annotation (Evaluate=true);
|
---|
1737 |
|
---|
1738 | type Th = enumeration(
|
---|
1739 | default "Default (no boundary condition for T or h)",
|
---|
1740 | T_known "T_known (temperature T is known)",
|
---|
1741 | h_known "h_known (specific enthalpy h is known)")
|
---|
1742 | "Enumeration defining whether T or h are known as boundary condition"
|
---|
1743 | annotation (Evaluate=true);
|
---|
1744 |
|
---|
1745 | annotation (Documentation(info="<html>
|
---|
1746 | <p>
|
---|
1747 | Enumerations and data types for all types of fluids
|
---|
1748 | </p>
|
---|
1749 |
|
---|
1750 | <p>
|
---|
1751 | Note: Reference enthalpy might have to be extended with enthalpy of formation.
|
---|
1752 | </p>
|
---|
1753 | </html>"));
|
---|
1754 | end Choices;
|
---|
1755 |
|
---|
1756 | annotation (Documentation(info="<html>
|
---|
1757 | <p>
|
---|
1758 | <b>PartialMedium</b> is a package and contains all <b>declarations</b> for
|
---|
1759 | a medium. This means that constants, models, and functions
|
---|
1760 | are defined that every medium is supposed to support
|
---|
1761 | (some of them are optional). A medium package
|
---|
1762 | inherits from <b>PartialMedium</b> and provides the
|
---|
1763 | equations for the medium. The details of this package
|
---|
1764 | are described in
|
---|
1765 | <a href=\"modelica://Modelica.Media.UsersGuide\">Modelica.Media.UsersGuide</a>.
|
---|
1766 | </p>
|
---|
1767 | </html>
|
---|
1768 | ", revisions="<html>
|
---|
1769 |
|
---|
1770 | </html>"));
|
---|
1771 | end PartialMedium;
|
---|
1772 |
|
---|
1773 | partial package PartialPureSubstance
|
---|
1774 | "base class for pure substances of one chemical substance"
|
---|
1775 | extends PartialMedium(final reducedX = true, final fixedX=true);
|
---|
1776 |
|
---|
1777 | replaceable function setState_pT "Return thermodynamic state from p and T"
|
---|
1778 | extends Modelica.Icons.Function;
|
---|
1779 | input AbsolutePressure p "Pressure";
|
---|
1780 | input Temperature T "Temperature";
|
---|
1781 | output ThermodynamicState state "thermodynamic state record";
|
---|
1782 | algorithm
|
---|
1783 | state := setState_pTX(p,T,fill(0,0));
|
---|
1784 | end setState_pT;
|
---|
1785 |
|
---|
1786 | replaceable function setState_ph
|
---|
1787 | "Return thermodynamic state from p and h"
|
---|
1788 | extends Modelica.Icons.Function;
|
---|
1789 | input AbsolutePressure p "Pressure";
|
---|
1790 | input SpecificEnthalpy h "Specific enthalpy";
|
---|
1791 | output ThermodynamicState state "thermodynamic state record";
|
---|
1792 | algorithm
|
---|
1793 | state := setState_phX(p,h,fill(0, 0));
|
---|
1794 | end setState_ph;
|
---|
1795 |
|
---|
1796 | replaceable function setState_ps
|
---|
1797 | "Return thermodynamic state from p and s"
|
---|
1798 | extends Modelica.Icons.Function;
|
---|
1799 | input AbsolutePressure p "Pressure";
|
---|
1800 | input SpecificEntropy s "Specific entropy";
|
---|
1801 | output ThermodynamicState state "thermodynamic state record";
|
---|
1802 | algorithm
|
---|
1803 | state := setState_psX(p,s,fill(0,0));
|
---|
1804 | end setState_ps;
|
---|
1805 |
|
---|
1806 | replaceable function setState_dT
|
---|
1807 | "Return thermodynamic state from d and T"
|
---|
1808 | extends Modelica.Icons.Function;
|
---|
1809 | input Density d "density";
|
---|
1810 | input Temperature T "Temperature";
|
---|
1811 | output ThermodynamicState state "thermodynamic state record";
|
---|
1812 | algorithm
|
---|
1813 | state := setState_dTX(d,T,fill(0,0));
|
---|
1814 | end setState_dT;
|
---|
1815 |
|
---|
1816 | replaceable function density_ph "Return density from p and h"
|
---|
1817 | extends Modelica.Icons.Function;
|
---|
1818 | input AbsolutePressure p "Pressure";
|
---|
1819 | input SpecificEnthalpy h "Specific enthalpy";
|
---|
1820 | output Density d "Density";
|
---|
1821 | algorithm
|
---|
1822 | d := density_phX(p, h, fill(0,0));
|
---|
1823 | end density_ph;
|
---|
1824 |
|
---|
1825 | replaceable function temperature_ph "Return temperature from p and h"
|
---|
1826 | extends Modelica.Icons.Function;
|
---|
1827 | input AbsolutePressure p "Pressure";
|
---|
1828 | input SpecificEnthalpy h "Specific enthalpy";
|
---|
1829 | output Temperature T "Temperature";
|
---|
1830 | algorithm
|
---|
1831 | T := temperature_phX(p, h, fill(0,0));
|
---|
1832 | end temperature_ph;
|
---|
1833 |
|
---|
1834 | replaceable function pressure_dT "Return pressure from d and T"
|
---|
1835 | extends Modelica.Icons.Function;
|
---|
1836 | input Density d "Density";
|
---|
1837 | input Temperature T "Temperature";
|
---|
1838 | output AbsolutePressure p "Pressure";
|
---|
1839 | algorithm
|
---|
1840 | p := pressure(setState_dTX(d, T, fill(0,0)));
|
---|
1841 | end pressure_dT;
|
---|
1842 |
|
---|
1843 | replaceable function specificEnthalpy_dT
|
---|
1844 | "Return specific enthalpy from d and T"
|
---|
1845 | extends Modelica.Icons.Function;
|
---|
1846 | input Density d "Density";
|
---|
1847 | input Temperature T "Temperature";
|
---|
1848 | output SpecificEnthalpy h "specific enthalpy";
|
---|
1849 | algorithm
|
---|
1850 | h := specificEnthalpy(setState_dTX(d, T, fill(0,0)));
|
---|
1851 | end specificEnthalpy_dT;
|
---|
1852 |
|
---|
1853 | replaceable function specificEnthalpy_ps
|
---|
1854 | "Return specific enthalpy from p and s"
|
---|
1855 | extends Modelica.Icons.Function;
|
---|
1856 | input AbsolutePressure p "Pressure";
|
---|
1857 | input SpecificEntropy s "Specific entropy";
|
---|
1858 | output SpecificEnthalpy h "specific enthalpy";
|
---|
1859 | algorithm
|
---|
1860 | h := specificEnthalpy_psX(p,s,fill(0,0));
|
---|
1861 | end specificEnthalpy_ps;
|
---|
1862 |
|
---|
1863 | replaceable function temperature_ps "Return temperature from p and s"
|
---|
1864 | extends Modelica.Icons.Function;
|
---|
1865 | input AbsolutePressure p "Pressure";
|
---|
1866 | input SpecificEntropy s "Specific entropy";
|
---|
1867 | output Temperature T "Temperature";
|
---|
1868 | algorithm
|
---|
1869 | T := temperature_psX(p,s,fill(0,0));
|
---|
1870 | end temperature_ps;
|
---|
1871 |
|
---|
1872 | replaceable function density_ps "Return density from p and s"
|
---|
1873 | extends Modelica.Icons.Function;
|
---|
1874 | input AbsolutePressure p "Pressure";
|
---|
1875 | input SpecificEntropy s "Specific entropy";
|
---|
1876 | output Density d "Density";
|
---|
1877 | algorithm
|
---|
1878 | d := density_psX(p, s, fill(0,0));
|
---|
1879 | end density_ps;
|
---|
1880 |
|
---|
1881 | replaceable function specificEnthalpy_pT
|
---|
1882 | "Return specific enthalpy from p and T"
|
---|
1883 | extends Modelica.Icons.Function;
|
---|
1884 | input AbsolutePressure p "Pressure";
|
---|
1885 | input Temperature T "Temperature";
|
---|
1886 | output SpecificEnthalpy h "specific enthalpy";
|
---|
1887 | algorithm
|
---|
1888 | h := specificEnthalpy_pTX(p, T, fill(0,0));
|
---|
1889 | end specificEnthalpy_pT;
|
---|
1890 |
|
---|
1891 | replaceable function density_pT "Return density from p and T"
|
---|
1892 | extends Modelica.Icons.Function;
|
---|
1893 | input AbsolutePressure p "Pressure";
|
---|
1894 | input Temperature T "Temperature";
|
---|
1895 | output Density d "Density";
|
---|
1896 | algorithm
|
---|
1897 | d := density(setState_pTX(p, T, fill(0,0)));
|
---|
1898 | end density_pT;
|
---|
1899 |
|
---|
1900 | redeclare replaceable partial model extends BaseProperties(
|
---|
1901 | final standardOrderComponents=true)
|
---|
1902 | end BaseProperties;
|
---|
1903 | end PartialPureSubstance;
|
---|
1904 |
|
---|
1905 | partial package PartialMixtureMedium
|
---|
1906 | "Base class for pure substances of several chemical substances"
|
---|
1907 | extends PartialMedium;
|
---|
1908 |
|
---|
1909 | redeclare replaceable record extends ThermodynamicState
|
---|
1910 | "thermodynamic state variables"
|
---|
1911 | AbsolutePressure p "Absolute pressure of medium";
|
---|
1912 | Temperature T "Temperature of medium";
|
---|
1913 | MassFraction X[nX]
|
---|
1914 | "Mass fractions (= (component mass)/total mass m_i/m)";
|
---|
1915 | end ThermodynamicState;
|
---|
1916 |
|
---|
1917 | redeclare replaceable record extends FluidConstants
|
---|
1918 | "extended fluid constants"
|
---|
1919 | Temperature criticalTemperature "critical temperature";
|
---|
1920 | AbsolutePressure criticalPressure "critical pressure";
|
---|
1921 | MolarVolume criticalMolarVolume "critical molar Volume";
|
---|
1922 | Real acentricFactor "Pitzer acentric factor";
|
---|
1923 | Temperature triplePointTemperature "triple point temperature";
|
---|
1924 | AbsolutePressure triplePointPressure "triple point pressure";
|
---|
1925 | Temperature meltingPoint "melting point at 101325 Pa";
|
---|
1926 | Temperature normalBoilingPoint "normal boiling point (at 101325 Pa)";
|
---|
1927 | DipoleMoment dipoleMoment
|
---|
1928 | "dipole moment of molecule in Debye (1 debye = 3.33564e10-30 C.m)";
|
---|
1929 | Boolean hasIdealGasHeatCapacity=false
|
---|
1930 | "true if ideal gas heat capacity is available";
|
---|
1931 | Boolean hasCriticalData=false "true if critical data are known";
|
---|
1932 | Boolean hasDipoleMoment=false "true if a dipole moment known";
|
---|
1933 | Boolean hasFundamentalEquation=false "true if a fundamental equation";
|
---|
1934 | Boolean hasLiquidHeatCapacity=false
|
---|
1935 | "true if liquid heat capacity is available";
|
---|
1936 | Boolean hasSolidHeatCapacity=false
|
---|
1937 | "true if solid heat capacity is available";
|
---|
1938 | Boolean hasAccurateViscosityData=false
|
---|
1939 | "true if accurate data for a viscosity function is available";
|
---|
1940 | Boolean hasAccurateConductivityData=false
|
---|
1941 | "true if accurate data for thermal conductivity is available";
|
---|
1942 | Boolean hasVapourPressureCurve=false
|
---|
1943 | "true if vapour pressure data, e.g., Antoine coefficents are known";
|
---|
1944 | Boolean hasAcentricFactor=false
|
---|
1945 | "true if Pitzer accentric factor is known";
|
---|
1946 | SpecificEnthalpy HCRIT0=0.0
|
---|
1947 | "Critical specific enthalpy of the fundamental equation";
|
---|
1948 | SpecificEntropy SCRIT0=0.0
|
---|
1949 | "Critical specific entropy of the fundamental equation";
|
---|
1950 | SpecificEnthalpy deltah=0.0
|
---|
1951 | "Difference between specific enthalpy model (h_m) and f.eq. (h_f) (h_m - h_f)";
|
---|
1952 | SpecificEntropy deltas=0.0
|
---|
1953 | "Difference between specific enthalpy model (s_m) and f.eq. (s_f) (s_m - s_f)";
|
---|
1954 | end FluidConstants;
|
---|
1955 |
|
---|
1956 | constant FluidConstants[nS] fluidConstants "constant data for the fluid";
|
---|
1957 |
|
---|
1958 | replaceable function gasConstant
|
---|
1959 | "Return the gas constant of the mixture (also for liquids)"
|
---|
1960 | extends Modelica.Icons.Function;
|
---|
1961 | input ThermodynamicState state "thermodynamic state";
|
---|
1962 | output SI.SpecificHeatCapacity R "mixture gas constant";
|
---|
1963 | end gasConstant;
|
---|
1964 |
|
---|
1965 | function moleToMassFractions
|
---|
1966 | "Return mass fractions X from mole fractions"
|
---|
1967 | extends Modelica.Icons.Function;
|
---|
1968 | input SI.MoleFraction moleFractions[:] "Mole fractions of mixture";
|
---|
1969 | input MolarMass[:] MMX "molar masses of components";
|
---|
1970 | output SI.MassFraction X[size(moleFractions, 1)]
|
---|
1971 | "Mass fractions of gas mixture";
|
---|
1972 | protected
|
---|
1973 | MolarMass Mmix = moleFractions*MMX "molar mass of mixture";
|
---|
1974 | algorithm
|
---|
1975 | for i in 1:size(moleFractions, 1) loop
|
---|
1976 | X[i] := moleFractions[i]*MMX[i] /Mmix;
|
---|
1977 | end for;
|
---|
1978 | annotation(smoothOrder=5);
|
---|
1979 | end moleToMassFractions;
|
---|
1980 |
|
---|
1981 | function massToMoleFractions
|
---|
1982 | "Return mole fractions from mass fractions X"
|
---|
1983 | extends Modelica.Icons.Function;
|
---|
1984 | input SI.MassFraction X[:] "Mass fractions of mixture";
|
---|
1985 | input SI.MolarMass[:] MMX "molar masses of components";
|
---|
1986 | output SI.MoleFraction moleFractions[size(X, 1)]
|
---|
1987 | "Mole fractions of gas mixture";
|
---|
1988 | protected
|
---|
1989 | Real invMMX[size(X, 1)] "inverses of molar weights";
|
---|
1990 | SI.MolarMass Mmix "molar mass of mixture";
|
---|
1991 | algorithm
|
---|
1992 | for i in 1:size(X, 1) loop
|
---|
1993 | invMMX[i] := 1/MMX[i];
|
---|
1994 | end for;
|
---|
1995 | Mmix := 1/(X*invMMX);
|
---|
1996 | for i in 1:size(X, 1) loop
|
---|
1997 | moleFractions[i] := Mmix*X[i]/MMX[i];
|
---|
1998 | end for;
|
---|
1999 | annotation(smoothOrder=5);
|
---|
2000 | end massToMoleFractions;
|
---|
2001 |
|
---|
2002 | end PartialMixtureMedium;
|
---|
2003 |
|
---|
2004 | partial package PartialCondensingGases
|
---|
2005 | "Base class for mixtures of condensing and non-condensing gases"
|
---|
2006 | extends PartialMixtureMedium(
|
---|
2007 | ThermoStates = Choices.IndependentVariables.pTX);
|
---|
2008 |
|
---|
2009 | replaceable partial function saturationPressure
|
---|
2010 | "Return saturation pressure of condensing fluid"
|
---|
2011 | extends Modelica.Icons.Function;
|
---|
2012 | input Temperature Tsat "saturation temperature";
|
---|
2013 | output AbsolutePressure psat "saturation pressure";
|
---|
2014 | end saturationPressure;
|
---|
2015 |
|
---|
2016 | replaceable partial function enthalpyOfVaporization
|
---|
2017 | "Return vaporization enthalpy of condensing fluid"
|
---|
2018 | extends Modelica.Icons.Function;
|
---|
2019 | input Temperature T "temperature";
|
---|
2020 | output SpecificEnthalpy r0 "vaporization enthalpy";
|
---|
2021 | end enthalpyOfVaporization;
|
---|
2022 |
|
---|
2023 | replaceable partial function enthalpyOfLiquid
|
---|
2024 | "Return liquid enthalpy of condensing fluid"
|
---|
2025 | extends Modelica.Icons.Function;
|
---|
2026 | input Temperature T "temperature";
|
---|
2027 | output SpecificEnthalpy h "liquid enthalpy";
|
---|
2028 | end enthalpyOfLiquid;
|
---|
2029 |
|
---|
2030 | replaceable partial function enthalpyOfGas
|
---|
2031 | "Return enthalpy of non-condensing gas mixture"
|
---|
2032 | extends Modelica.Icons.Function;
|
---|
2033 | input Temperature T "temperature";
|
---|
2034 | input MassFraction[:] X "vector of mass fractions";
|
---|
2035 | output SpecificEnthalpy h "specific enthalpy";
|
---|
2036 | end enthalpyOfGas;
|
---|
2037 |
|
---|
2038 | replaceable partial function enthalpyOfCondensingGas
|
---|
2039 | "Return enthalpy of condensing gas (most often steam)"
|
---|
2040 | extends Modelica.Icons.Function;
|
---|
2041 | input Temperature T "temperature";
|
---|
2042 | output SpecificEnthalpy h "specific enthalpy";
|
---|
2043 | end enthalpyOfCondensingGas;
|
---|
2044 |
|
---|
2045 | replaceable partial function enthalpyOfNonCondensingGas
|
---|
2046 | "Return enthalpy of the non-condensing species"
|
---|
2047 | extends Modelica.Icons.Function;
|
---|
2048 | input Temperature T "temperature";
|
---|
2049 | output SpecificEnthalpy h "specific enthalpy";
|
---|
2050 | end enthalpyOfNonCondensingGas;
|
---|
2051 | end PartialCondensingGases;
|
---|
2052 | annotation (Documentation(info="<HTML>
|
---|
2053 | <p>
|
---|
2054 | This package provides basic interfaces definitions of media models for different
|
---|
2055 | kind of media.
|
---|
2056 | </p>
|
---|
2057 | </HTML>"));
|
---|
2058 | end Interfaces;
|
---|
2059 |
|
---|
2060 | package Common
|
---|
2061 | "data structures and fundamental functions for fluid properties"
|
---|
2062 | extends Modelica.Icons.Package;
|
---|
2063 |
|
---|
2064 | function smoothStep
|
---|
2065 | "Approximation of a general step, such that the characteristic is continuous and differentiable"
|
---|
2066 | extends Modelica.Icons.Function;
|
---|
2067 | input Real x "Abszissa value";
|
---|
2068 | input Real y1 "Ordinate value for x > 0";
|
---|
2069 | input Real y2 "Ordinate value for x < 0";
|
---|
2070 | input Real x_small(min=0) = 1e-5
|
---|
2071 | "Approximation of step for -x_small <= x <= x_small; x_small > 0 required";
|
---|
2072 | output Real y
|
---|
2073 | "Ordinate value to approximate y = if x > 0 then y1 else y2";
|
---|
2074 | algorithm
|
---|
2075 | y := smooth(1, if x > x_small then y1 else
|
---|
2076 | if x < -x_small then y2 else
|
---|
2077 | if abs(x_small)>0 then (x/x_small)*((x/x_small)^2 - 3)*(y2-y1)/4 + (y1+y2)/2 else (y1+y2)/2);
|
---|
2078 |
|
---|
2079 | annotation(Documentation(revisions="<html>
|
---|
2080 | <ul>
|
---|
2081 | <li><i>April 29, 2008</i>
|
---|
2082 | by <a href=\"mailto:Martin.Otter@DLR.de\">Martin Otter</a>:<br>
|
---|
2083 | Designed and implemented.</li>
|
---|
2084 | <li><i>August 12, 2008</i>
|
---|
2085 | by <a href=\"mailto:Michael.Sielemann@dlr.de\">Michael Sielemann</a>:<br>
|
---|
2086 | Minor modification to cover the limit case <code>x_small -> 0</code> without division by zero.</li>
|
---|
2087 | </ul>
|
---|
2088 | </html>", info="<html>
|
---|
2089 | <p>
|
---|
2090 | This function is used to approximate the equation
|
---|
2091 | </p>
|
---|
2092 | <pre>
|
---|
2093 | y = <b>if</b> x > 0 <b>then</b> y1 <b>else</b> y2;
|
---|
2094 | </pre>
|
---|
2095 |
|
---|
2096 | <p>
|
---|
2097 | by a smooth characteristic, so that the expression is continuous and differentiable:
|
---|
2098 | </p>
|
---|
2099 |
|
---|
2100 | <pre>
|
---|
2101 | y = <b>smooth</b>(1, <b>if</b> x > x_small <b>then</b> y1 <b>else</b>
|
---|
2102 | <b>if</b> x < -x_small <b>then</b> y2 <b>else</b> f(y1, y2));
|
---|
2103 | </pre>
|
---|
2104 |
|
---|
2105 | <p>
|
---|
2106 | In the region -x_small < x < x_small a 2nd order polynomial is used
|
---|
2107 | for a smooth transition from y1 to y2.
|
---|
2108 | </p>
|
---|
2109 |
|
---|
2110 | <p>
|
---|
2111 | If <b>mass fractions</b> X[:] are approximated with this function then this can be performed
|
---|
2112 | for all <b>nX</b> mass fractions, instead of applying it for nX-1 mass fractions and computing
|
---|
2113 | the last one by the mass fraction constraint sum(X)=1. The reason is that the approximating function has the
|
---|
2114 | property that sum(X) = 1, provided sum(X_a) = sum(X_b) = 1
|
---|
2115 | (and y1=X_a[i], y2=X_b[i]).
|
---|
2116 | This can be shown by evaluating the approximating function in the abs(x) < x_small
|
---|
2117 | region (otherwise X is either X_a or X_b):
|
---|
2118 | </p>
|
---|
2119 |
|
---|
2120 | <pre>
|
---|
2121 | X[1] = smoothStep(x, X_a[1] , X_b[1] , x_small);
|
---|
2122 | X[2] = smoothStep(x, X_a[2] , X_b[2] , x_small);
|
---|
2123 | ...
|
---|
2124 | X[nX] = smoothStep(x, X_a[nX], X_b[nX], x_small);
|
---|
2125 | </pre>
|
---|
2126 |
|
---|
2127 | <p>
|
---|
2128 | or
|
---|
2129 | </p>
|
---|
2130 |
|
---|
2131 | <pre>
|
---|
2132 | X[1] = c*(X_a[1] - X_b[1]) + (X_a[1] + X_b[1])/2
|
---|
2133 | X[2] = c*(X_a[2] - X_b[2]) + (X_a[2] + X_b[2])/2;
|
---|
2134 | ...
|
---|
2135 | X[nX] = c*(X_a[nX] - X_b[nX]) + (X_a[nX] + X_b[nX])/2;
|
---|
2136 | c = (x/x_small)*((x/x_small)^2 - 3)/4
|
---|
2137 | </pre>
|
---|
2138 |
|
---|
2139 | <p>
|
---|
2140 | Summing all mass fractions together results in
|
---|
2141 | </p>
|
---|
2142 |
|
---|
2143 | <pre>
|
---|
2144 | sum(X) = c*(sum(X_a) - sum(X_b)) + (sum(X_a) + sum(X_b))/2
|
---|
2145 | = c*(1 - 1) + (1 + 1)/2
|
---|
2146 | = 1
|
---|
2147 | </pre>
|
---|
2148 | </html>"));
|
---|
2149 | end smoothStep;
|
---|
2150 |
|
---|
2151 | package OneNonLinearEquation
|
---|
2152 | "Determine solution of a non-linear algebraic equation in one unknown without derivatives in a reliable and efficient way"
|
---|
2153 | extends Modelica.Icons.Package;
|
---|
2154 |
|
---|
2155 | replaceable record f_nonlinear_Data
|
---|
2156 | "Data specific for function f_nonlinear"
|
---|
2157 | extends Modelica.Icons.Record;
|
---|
2158 | end f_nonlinear_Data;
|
---|
2159 |
|
---|
2160 | replaceable partial function f_nonlinear
|
---|
2161 | "Nonlinear algebraic equation in one unknown: y = f_nonlinear(x,p,X)"
|
---|
2162 | extends Modelica.Icons.Function;
|
---|
2163 | input Real x "Independent variable of function";
|
---|
2164 | input Real p = 0.0
|
---|
2165 | "disregaded variables (here always used for pressure)";
|
---|
2166 | input Real[:] X = fill(0,0)
|
---|
2167 | "disregaded variables (her always used for composition)";
|
---|
2168 | input f_nonlinear_Data f_nonlinear_data
|
---|
2169 | "Additional data for the function";
|
---|
2170 | output Real y "= f_nonlinear(x)";
|
---|
2171 | // annotation(derivative(zeroDerivative=y)); // this must hold for all replaced functions
|
---|
2172 | end f_nonlinear;
|
---|
2173 |
|
---|
2174 | replaceable function solve
|
---|
2175 | "Solve f_nonlinear(x_zero)=y_zero; f_nonlinear(x_min) - y_zero and f_nonlinear(x_max)-y_zero must have different sign"
|
---|
2176 | import Modelica.Utilities.Streams.error;
|
---|
2177 | extends Modelica.Icons.Function;
|
---|
2178 | input Real y_zero
|
---|
2179 | "Determine x_zero, such that f_nonlinear(x_zero) = y_zero";
|
---|
2180 | input Real x_min "Minimum value of x";
|
---|
2181 | input Real x_max "Maximum value of x";
|
---|
2182 | input Real pressure = 0.0
|
---|
2183 | "disregaded variables (here always used for pressure)";
|
---|
2184 | input Real[:] X = fill(0,0)
|
---|
2185 | "disregaded variables (here always used for composition)";
|
---|
2186 | input f_nonlinear_Data f_nonlinear_data
|
---|
2187 | "Additional data for function f_nonlinear";
|
---|
2188 | input Real x_tol = 100*Modelica.Constants.eps
|
---|
2189 | "Relative tolerance of the result";
|
---|
2190 | output Real x_zero "f_nonlinear(x_zero) = y_zero";
|
---|
2191 | protected
|
---|
2192 | constant Real eps = Modelica.Constants.eps "machine epsilon";
|
---|
2193 | constant Real x_eps = 1e-10
|
---|
2194 | "Slight modification of x_min, x_max, since x_min, x_max are usually exactly at the borders T_min/h_min and then small numeric noise may make the interval invalid";
|
---|
2195 | Real x_min2 = x_min - x_eps;
|
---|
2196 | Real x_max2 = x_max + x_eps;
|
---|
2197 | Real a = x_min2 "Current best minimum interval value";
|
---|
2198 | Real b = x_max2 "Current best maximum interval value";
|
---|
2199 | Real c "Intermediate point a <= c <= b";
|
---|
2200 | Real d;
|
---|
2201 | Real e "b - a";
|
---|
2202 | Real m;
|
---|
2203 | Real s;
|
---|
2204 | Real p;
|
---|
2205 | Real q;
|
---|
2206 | Real r;
|
---|
2207 | Real tol;
|
---|
2208 | Real fa "= f_nonlinear(a) - y_zero";
|
---|
2209 | Real fb "= f_nonlinear(b) - y_zero";
|
---|
2210 | Real fc;
|
---|
2211 | Boolean found = false;
|
---|
2212 | algorithm
|
---|
2213 | // Check that f(x_min) and f(x_max) have different sign
|
---|
2214 | fa :=f_nonlinear(x_min2, pressure, X, f_nonlinear_data) - y_zero;
|
---|
2215 | fb :=f_nonlinear(x_max2, pressure, X, f_nonlinear_data) - y_zero;
|
---|
2216 | fc := fb;
|
---|
2217 | if fa > 0.0 and fb > 0.0 or
|
---|
2218 | fa < 0.0 and fb < 0.0 then
|
---|
2219 | error("The arguments x_min and x_max to OneNonLinearEquation.solve(..)\n" +
|
---|
2220 | "do not bracket the root of the single non-linear equation:\n" +
|
---|
2221 | " x_min = " + String(x_min2) + "\n" +
|
---|
2222 | " x_max = " + String(x_max2) + "\n" +
|
---|
2223 | " y_zero = " + String(y_zero) + "\n" +
|
---|
2224 | " fa = f(x_min) - y_zero = " + String(fa) + "\n" +
|
---|
2225 | " fb = f(x_max) - y_zero = " + String(fb) + "\n" +
|
---|
2226 | "fa and fb must have opposite sign which is not the case");
|
---|
2227 | end if;
|
---|
2228 |
|
---|
2229 | // Initialize variables
|
---|
2230 | c :=a;
|
---|
2231 | fc :=fa;
|
---|
2232 | e :=b - a;
|
---|
2233 | d :=e;
|
---|
2234 |
|
---|
2235 | // Search loop
|
---|
2236 | while not found loop
|
---|
2237 | if abs(fc) < abs(fb) then
|
---|
2238 | a :=b;
|
---|
2239 | b :=c;
|
---|
2240 | c :=a;
|
---|
2241 | fa :=fb;
|
---|
2242 | fb :=fc;
|
---|
2243 | fc :=fa;
|
---|
2244 | end if;
|
---|
2245 |
|
---|
2246 | tol :=2*eps*abs(b) + x_tol;
|
---|
2247 | m :=(c - b)/2;
|
---|
2248 |
|
---|
2249 | if abs(m) <= tol or fb == 0.0 then
|
---|
2250 | // root found (interval is small enough)
|
---|
2251 | found :=true;
|
---|
2252 | x_zero :=b;
|
---|
2253 | else
|
---|
2254 | // Determine if a bisection is needed
|
---|
2255 | if abs(e) < tol or abs(fa) <= abs(fb) then
|
---|
2256 | e :=m;
|
---|
2257 | d :=e;
|
---|
2258 | else
|
---|
2259 | s :=fb/fa;
|
---|
2260 | if a == c then
|
---|
2261 | // linear interpolation
|
---|
2262 | p :=2*m*s;
|
---|
2263 | q :=1 - s;
|
---|
2264 | else
|
---|
2265 | // inverse quadratic interpolation
|
---|
2266 | q :=fa/fc;
|
---|
2267 | r :=fb/fc;
|
---|
2268 | p :=s*(2*m*q*(q - r) - (b - a)*(r - 1));
|
---|
2269 | q :=(q - 1)*(r - 1)*(s - 1);
|
---|
2270 | end if;
|
---|
2271 |
|
---|
2272 | if p > 0 then
|
---|
2273 | q :=-q;
|
---|
2274 | else
|
---|
2275 | p :=-p;
|
---|
2276 | end if;
|
---|
2277 |
|
---|
2278 | s :=e;
|
---|
2279 | e :=d;
|
---|
2280 | if 2*p < 3*m*q-abs(tol*q) and p < abs(0.5*s*q) then
|
---|
2281 | // interpolation successful
|
---|
2282 | d :=p/q;
|
---|
2283 | else
|
---|
2284 | // use bi-section
|
---|
2285 | e :=m;
|
---|
2286 | d :=e;
|
---|
2287 | end if;
|
---|
2288 | end if;
|
---|
2289 |
|
---|
2290 | // Best guess value is defined as "a"
|
---|
2291 | a :=b;
|
---|
2292 | fa :=fb;
|
---|
2293 | b :=b + (if abs(d) > tol then d else if m > 0 then tol else -tol);
|
---|
2294 | fb :=f_nonlinear(b, pressure, X, f_nonlinear_data) - y_zero;
|
---|
2295 |
|
---|
2296 | if fb > 0 and fc > 0 or
|
---|
2297 | fb < 0 and fc < 0 then
|
---|
2298 | // initialize variables
|
---|
2299 | c :=a;
|
---|
2300 | fc :=fa;
|
---|
2301 | e :=b - a;
|
---|
2302 | d :=e;
|
---|
2303 | end if;
|
---|
2304 | end if;
|
---|
2305 | end while;
|
---|
2306 | end solve;
|
---|
2307 |
|
---|
2308 | annotation (Documentation(info="<html>
|
---|
2309 | <p>
|
---|
2310 | This function should currently only be used in Modelica.Media,
|
---|
2311 | since it might be replaced in the future by another strategy,
|
---|
2312 | where the tool is responsible for the solution of the non-linear
|
---|
2313 | equation.
|
---|
2314 | </p>
|
---|
2315 |
|
---|
2316 | <p>
|
---|
2317 | This library determines the solution of one non-linear algebraic equation \"y=f(x)\"
|
---|
2318 | in one unknown \"x\" in a reliable way. As input, the desired value y of the
|
---|
2319 | non-linear function has to be given, as well as an interval x_min, x_max that
|
---|
2320 | contains the solution, i.e., \"f(x_min) - y\" and \"f(x_max) - y\" must
|
---|
2321 | have a different sign. If possible, a smaller interval is computed by
|
---|
2322 | inverse quadratic interpolation (interpolating with a quadratic polynomial
|
---|
2323 | through the last 3 points and computing the zero). If this fails,
|
---|
2324 | bisection is used, which always reduces the interval by a factor of 2.
|
---|
2325 | The inverse quadratic interpolation method has superlinear convergence.
|
---|
2326 | This is roughly the same convergence rate as a globally convergent Newton
|
---|
2327 | method, but without the need to compute derivatives of the non-linear
|
---|
2328 | function. The solver function is a direct mapping of the Algol 60 procedure
|
---|
2329 | \"zero\" to Modelica, from:
|
---|
2330 | </p>
|
---|
2331 |
|
---|
2332 | <dl>
|
---|
2333 | <dt> Brent R.P.:</dt>
|
---|
2334 | <dd> <b>Algorithms for Minimization without derivatives</b>.
|
---|
2335 | Prentice Hall, 1973, pp. 58-59.</dd>
|
---|
2336 | </dl>
|
---|
2337 |
|
---|
2338 | <p>
|
---|
2339 | Due to current limitations of the
|
---|
2340 | Modelica language (not possible to pass a function reference to a function),
|
---|
2341 | the construction to use this solver on a user-defined function is a bit
|
---|
2342 | complicated (this method is from Hans Olsson, Dassault Systèmes AB). A user has to
|
---|
2343 | provide a package in the following way:
|
---|
2344 | </p>
|
---|
2345 |
|
---|
2346 | <pre>
|
---|
2347 | <b>package</b> MyNonLinearSolver
|
---|
2348 | <b>extends</b> OneNonLinearEquation;
|
---|
2349 |
|
---|
2350 | <b>redeclare record extends</b> Data
|
---|
2351 | // Define data to be passed to user function
|
---|
2352 | ...
|
---|
2353 | <b>end</b> Data;
|
---|
2354 |
|
---|
2355 | <b>redeclare function extends</b> f_nonlinear
|
---|
2356 | <b>algorithm</b>
|
---|
2357 | // Compute the non-linear equation: y = f(x, Data)
|
---|
2358 | <b>end</b> f_nonlinear;
|
---|
2359 |
|
---|
2360 | // Dummy definition that has to be present for current Dymola
|
---|
2361 | <b>redeclare function extends</b> solve
|
---|
2362 | <b>end</b> solve;
|
---|
2363 | <b>end</b> MyNonLinearSolver;
|
---|
2364 |
|
---|
2365 | x_zero = MyNonLinearSolver.solve(y_zero, x_min, x_max, data=data);
|
---|
2366 | </pre>
|
---|
2367 | </html>"));
|
---|
2368 | end OneNonLinearEquation;
|
---|
2369 | annotation (Documentation(info="<HTML><h4>Package description</h4>
|
---|
2370 | <p>Package Modelica.Media.Common provides records and functions shared by many of the property sub-packages.
|
---|
2371 | High accuracy fluid property models share a lot of common structure, even if the actual models are different.
|
---|
2372 | Common data structures and computations shared by these property models are collected in this library.
|
---|
2373 | </p>
|
---|
2374 |
|
---|
2375 | </HTML>
|
---|
2376 | ", revisions="<html>
|
---|
2377 | <ul>
|
---|
2378 | <li>First implemented: <i>July, 2000</i>
|
---|
2379 | by <a href=\"http://www.control.lth.se/~hubertus/\">Hubertus Tummescheit</a>
|
---|
2380 | for the ThermoFluid Library with help from Jonas Eborn and Falko Jens Wagner
|
---|
2381 | </li>
|
---|
2382 | <li>Code reorganization, enhanced documentation, additional functions: <i>December, 2002</i>
|
---|
2383 | by <a href=\"http://www.control.lth.se/~hubertus/\">Hubertus Tummescheit</a> and move to Modelica
|
---|
2384 | properties library.</li>
|
---|
2385 | <li>Inclusion into Modelica.Media: September 2003 </li>
|
---|
2386 | </ul>
|
---|
2387 |
|
---|
2388 | <address>Author: Hubertus Tummescheit, <br>
|
---|
2389 | Lund University<br>
|
---|
2390 | Department of Automatic Control<br>
|
---|
2391 | Box 118, 22100 Lund, Sweden<br>
|
---|
2392 | email: hubertus@control.lth.se
|
---|
2393 | </address>
|
---|
2394 | </html>"));
|
---|
2395 | end Common;
|
---|
2396 |
|
---|
2397 | package Air "Medium models for air"
|
---|
2398 | extends Modelica.Icons.MaterialPropertiesPackage;
|
---|
2399 |
|
---|
2400 | package MoistAir "Air: Moist air model (240 ... 400 K)"
|
---|
2401 | extends Interfaces.PartialCondensingGases(
|
---|
2402 | mediumName="Moist air",
|
---|
2403 | substanceNames={"water", "air"},
|
---|
2404 | final reducedX=true,
|
---|
2405 | final singleState=false,
|
---|
2406 | reference_X={0.01,0.99},
|
---|
2407 | fluidConstants = {IdealGases.Common.FluidData.H2O,IdealGases.Common.FluidData.N2});
|
---|
2408 |
|
---|
2409 | constant Integer Water=1
|
---|
2410 | "Index of water (in substanceNames, massFractions X, etc.)";
|
---|
2411 |
|
---|
2412 | constant Integer Air=2
|
---|
2413 | "Index of air (in substanceNames, massFractions X, etc.)";
|
---|
2414 |
|
---|
2415 | constant Real k_mair = steam.MM/dryair.MM "ratio of molar weights";
|
---|
2416 |
|
---|
2417 | constant IdealGases.Common.DataRecord dryair = IdealGases.Common.SingleGasesData.Air;
|
---|
2418 |
|
---|
2419 | constant IdealGases.Common.DataRecord steam = IdealGases.Common.SingleGasesData.H2O;
|
---|
2420 |
|
---|
2421 | constant SI.MolarMass[2] MMX = {steam.MM,dryair.MM}
|
---|
2422 | "Molar masses of components";
|
---|
2423 | import Modelica.Media.Interfaces;
|
---|
2424 | import Modelica.Math;
|
---|
2425 | import SI = Modelica.SIunits;
|
---|
2426 | import Cv = Modelica.SIunits.Conversions;
|
---|
2427 | import Modelica.Constants;
|
---|
2428 | import Modelica.Media.IdealGases.Common.SingleGasNasa;
|
---|
2429 |
|
---|
2430 | redeclare record extends ThermodynamicState
|
---|
2431 | "ThermodynamicState record for moist air"
|
---|
2432 | end ThermodynamicState;
|
---|
2433 |
|
---|
2434 | redeclare replaceable model extends BaseProperties(
|
---|
2435 | T(stateSelect=if preferredMediumStates then StateSelect.prefer else StateSelect.default),
|
---|
2436 | p(stateSelect=if preferredMediumStates then StateSelect.prefer else StateSelect.default),
|
---|
2437 | Xi(stateSelect=if preferredMediumStates then StateSelect.prefer else StateSelect.default),
|
---|
2438 | redeclare final constant Boolean standardOrderComponents=true)
|
---|
2439 | "Moist air base properties record"
|
---|
2440 |
|
---|
2441 | /* p, T, X = X[Water] are used as preferred states, since only then all
|
---|
2442 | other quantities can be computed in a recursive sequence.
|
---|
2443 | If other variables are selected as states, static state selection
|
---|
2444 | is no longer possible and non-linear algebraic equations occur.
|
---|
2445 | */
|
---|
2446 | MassFraction x_water "Mass of total water/mass of dry air";
|
---|
2447 | Real phi "Relative humidity";
|
---|
2448 |
|
---|
2449 | protected
|
---|
2450 | MassFraction X_liquid "Mass fraction of liquid or solid water";
|
---|
2451 | MassFraction X_steam "Mass fraction of steam water";
|
---|
2452 | MassFraction X_air "Mass fraction of air";
|
---|
2453 | MassFraction X_sat
|
---|
2454 | "Steam water mass fraction of saturation boundary in kg_water/kg_moistair";
|
---|
2455 | MassFraction x_sat
|
---|
2456 | "Steam water mass content of saturation boundary in kg_water/kg_dryair";
|
---|
2457 | AbsolutePressure p_steam_sat "Partial saturation pressure of steam";
|
---|
2458 | equation
|
---|
2459 | assert(T >= 200.0 and T <= 423.15, "
|
---|
2460 | Temperature T is not in the allowed range
|
---|
2461 | 200.0 K <= (T =" + String(T) + " K) <= 423.15 K
|
---|
2462 | required from medium model \"" + mediumName + "\".");
|
---|
2463 | MM = 1/(Xi[Water]/MMX[Water]+(1.0-Xi[Water])/MMX[Air]);
|
---|
2464 |
|
---|
2465 | p_steam_sat = min(saturationPressure(T),0.999*p);
|
---|
2466 | X_sat = min(p_steam_sat * k_mair/max(100*Constants.eps, p - p_steam_sat)*(1 - Xi[Water]), 1.0)
|
---|
2467 | "Water content at saturation with respect to actual water content";
|
---|
2468 | X_liquid = max(Xi[Water] - X_sat, 0.0);
|
---|
2469 | X_steam = Xi[Water]-X_liquid;
|
---|
2470 | X_air = 1-Xi[Water];
|
---|
2471 |
|
---|
2472 | h = specificEnthalpy_pTX(p,T,Xi);
|
---|
2473 | R = dryair.R*(X_air/(1 - X_liquid)) + steam.R*X_steam/(1 - X_liquid);
|
---|
2474 | //
|
---|
2475 | u = h - R*T;
|
---|
2476 | d = p/(R*T);
|
---|
2477 | /* Note, u and d are computed under the assumption that the volume of the liquid
|
---|
2478 | water is neglible with respect to the volume of air and of steam
|
---|
2479 | */
|
---|
2480 | state.p = p;
|
---|
2481 | state.T = T;
|
---|
2482 | state.X = X;
|
---|
2483 |
|
---|
2484 | // these x are per unit mass of DRY air!
|
---|
2485 | x_sat = k_mair*p_steam_sat/max(100*Constants.eps,p - p_steam_sat);
|
---|
2486 | x_water = Xi[Water]/max(X_air,100*Constants.eps);
|
---|
2487 | phi = p/p_steam_sat*Xi[Water]/(Xi[Water] + k_mair*X_air);
|
---|
2488 | annotation(Documentation(info="<html>
|
---|
2489 | <p>This model computes thermodynamic properties of moist air from three independent (thermodynamic or/and numerical) state variables. Preferred numerical states are temperature T, pressure p and the reduced composition vector Xi, which contains the water mass fraction only. As an EOS the <b>ideal gas law</b> is used and associated restrictions apply. The model can also be used in the <b>fog region</b>, when moisture is present in its liquid state. However, it is assumed that the liquid water volume is negligible compared to that of the gas phase. Computation of thermal properties is based on property data of <a href=\"modelica://Modelica.Media.Air.DryAirNasa\"> dry air</a> and water (source: VDI-Wärmeatlas), respectively. Besides the standard thermodynamic variables <b>absolute and relative humidity</b>, x_water and phi, respectively, are given by the model. Upper case X denotes absolute humidity with respect to mass of moist air while absolute humidity with respect to mass of dry air only is denoted by a lower case x throughout the model. See <a href=\"modelica://Modelica.Media.Air.MoistAir\">package description</a> for further information.</p>
|
---|
2490 | </html>"));
|
---|
2491 | end BaseProperties;
|
---|
2492 |
|
---|
2493 | redeclare function setState_pTX
|
---|
2494 | "Return thermodynamic state as function of pressure p, temperature T and composition X"
|
---|
2495 | extends Modelica.Icons.Function;
|
---|
2496 | input AbsolutePressure p "Pressure";
|
---|
2497 | input Temperature T "Temperature";
|
---|
2498 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
2499 | output ThermodynamicState state "Thermodynamic state";
|
---|
2500 | algorithm
|
---|
2501 | state := if size(X,1) == nX then ThermodynamicState(p=p,T=T, X=X) else
|
---|
2502 | ThermodynamicState(p=p,T=T, X=cat(1,X,{1-sum(X)}));
|
---|
2503 | annotation(smoothOrder=2,
|
---|
2504 | Documentation(info="<html>
|
---|
2505 | The <a href=\"modelica://Modelica.Media.Air.MoistAir.ThermodynamicState\">thermodynamic state record</a> is computed from pressure p, temperature T and composition X.
|
---|
2506 | </html>"));
|
---|
2507 | end setState_pTX;
|
---|
2508 |
|
---|
2509 | redeclare function setState_phX
|
---|
2510 | "Return thermodynamic state as function of pressure p, specific enthalpy h and composition X"
|
---|
2511 | extends Modelica.Icons.Function;
|
---|
2512 | input AbsolutePressure p "Pressure";
|
---|
2513 | input SpecificEnthalpy h "Specific enthalpy";
|
---|
2514 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
2515 | output ThermodynamicState state "Thermodynamic state";
|
---|
2516 | algorithm
|
---|
2517 | state := if size(X,1) == nX then ThermodynamicState(p=p,T=T_phX(p,h,X),X=X) else
|
---|
2518 | ThermodynamicState(p=p,T=T_phX(p,h,X), X=cat(1,X,{1-sum(X)}));
|
---|
2519 | annotation(smoothOrder=2,
|
---|
2520 | Documentation(info="<html>
|
---|
2521 | The <a href=\"modelica://Modelica.Media.Air.MoistAir.ThermodynamicState\">thermodynamic state record</a> is computed from pressure p, specific enthalpy h and composition X.
|
---|
2522 | </html>"));
|
---|
2523 | end setState_phX;
|
---|
2524 |
|
---|
2525 | redeclare function setState_dTX
|
---|
2526 | "Return thermodynamic state as function of density d, temperature T and composition X"
|
---|
2527 | extends Modelica.Icons.Function;
|
---|
2528 | input Density d "density";
|
---|
2529 | input Temperature T "Temperature";
|
---|
2530 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
2531 | output ThermodynamicState state "Thermodynamic state";
|
---|
2532 | algorithm
|
---|
2533 | state := if size(X,1) == nX then ThermodynamicState(p=d*({steam.R,dryair.R}*X)*T,T=T,X=X) else
|
---|
2534 | ThermodynamicState(p=d*({steam.R,dryair.R}*cat(1,X,{1-sum(X)}))*T,T=T, X=cat(1,X,{1-sum(X)}));
|
---|
2535 | annotation(smoothOrder=2,
|
---|
2536 | Documentation(info="<html>
|
---|
2537 | The <a href=\"modelica://Modelica.Media.Air.MoistAir.ThermodynamicState\">thermodynamic state record</a> is computed from density d, temperature T and composition X.
|
---|
2538 | </html>"));
|
---|
2539 | end setState_dTX;
|
---|
2540 |
|
---|
2541 | redeclare function extends setSmoothState
|
---|
2542 | "Return thermodynamic state so that it smoothly approximates: if x > 0 then state_a else state_b"
|
---|
2543 | algorithm
|
---|
2544 | state := ThermodynamicState(p=Media.Common.smoothStep(x, state_a.p, state_b.p, x_small),
|
---|
2545 | T=Media.Common.smoothStep(x, state_a.T, state_b.T, x_small),
|
---|
2546 | X=Media.Common.smoothStep(x, state_a.X, state_b.X, x_small));
|
---|
2547 | end setSmoothState;
|
---|
2548 |
|
---|
2549 | redeclare function extends gasConstant
|
---|
2550 | "Return ideal gas constant as a function from thermodynamic state, only valid for phi<1"
|
---|
2551 |
|
---|
2552 | algorithm
|
---|
2553 | R := dryair.R*(1-state.X[Water]) + steam.R*state.X[Water];
|
---|
2554 | annotation(smoothOrder=2,
|
---|
2555 | Documentation(info="<html>
|
---|
2556 | The ideal gas constant for moist air is computed from <a href=\"modelica://Modelica.Media.Air.MoistAir.ThermodynamicState\">thermodynamic state</a> assuming that all water is in the gas phase.
|
---|
2557 | </html>"));
|
---|
2558 | end gasConstant;
|
---|
2559 |
|
---|
2560 | function saturationPressureLiquid
|
---|
2561 | "Return saturation pressure of water as a function of temperature T in the range of 273.16 to 373.16 K"
|
---|
2562 |
|
---|
2563 | extends Modelica.Icons.Function;
|
---|
2564 | input SI.Temperature Tsat "saturation temperature";
|
---|
2565 | output SI.AbsolutePressure psat "saturation pressure";
|
---|
2566 | algorithm
|
---|
2567 | psat := 611.657*Math.exp(17.2799 - 4102.99/(Tsat - 35.719));
|
---|
2568 | annotation(Inline=false,smoothOrder=5,derivative=saturationPressureLiquid_der,
|
---|
2569 | Documentation(info="<html>
|
---|
2570 | Saturation pressure of water above the triple point temperature is computed from temperature. It's range of validity is between
|
---|
2571 | 273.16 and 373.16 K. Outside these limits a less accurate result is returned.
|
---|
2572 | </html>"));
|
---|
2573 | end saturationPressureLiquid;
|
---|
2574 |
|
---|
2575 | function saturationPressureLiquid_der
|
---|
2576 | "Time derivative of saturationPressureLiquid"
|
---|
2577 |
|
---|
2578 | extends Modelica.Icons.Function;
|
---|
2579 | input SI.Temperature Tsat "Saturation temperature";
|
---|
2580 | input Real dTsat(unit="K/s") "Saturation temperature derivative";
|
---|
2581 | output Real psat_der(unit="Pa/s") "Saturation pressure";
|
---|
2582 | algorithm
|
---|
2583 | /*psat := 611.657*Math.exp(17.2799 - 4102.99/(Tsat - 35.719));*/
|
---|
2584 | psat_der:=611.657*Math.exp(17.2799 - 4102.99/(Tsat - 35.719))*4102.99*dTsat/(Tsat - 35.719)/(Tsat - 35.719);
|
---|
2585 |
|
---|
2586 | annotation(Inline=false,smoothOrder=5,
|
---|
2587 | Documentation(info="<html>
|
---|
2588 | Derivative function of <a href=\"modelica://Modelica.Media.Air.MoistAir.saturationPressureLiquid\">saturationPressureLiquid</a>
|
---|
2589 | </html>"));
|
---|
2590 | end saturationPressureLiquid_der;
|
---|
2591 |
|
---|
2592 | function sublimationPressureIce
|
---|
2593 | "Return sublimation pressure of water as a function of temperature T between 223.16 and 273.16 K"
|
---|
2594 |
|
---|
2595 | extends Modelica.Icons.Function;
|
---|
2596 | input SI.Temperature Tsat "sublimation temperature";
|
---|
2597 | output SI.AbsolutePressure psat "sublimation pressure";
|
---|
2598 | algorithm
|
---|
2599 | psat := 611.657*Math.exp(22.5159*(1.0 - 273.16/Tsat));
|
---|
2600 | annotation(Inline=false,smoothOrder=5,derivative=sublimationPressureIce_der,
|
---|
2601 | Documentation(info="<html>
|
---|
2602 | Sublimation pressure of water below the triple point temperature is computed from temperature. It's range of validity is between
|
---|
2603 | 223.16 and 273.16 K. Outside of these limits a less accurate result is returned.
|
---|
2604 | </html>"));
|
---|
2605 | end sublimationPressureIce;
|
---|
2606 |
|
---|
2607 | function sublimationPressureIce_der
|
---|
2608 | "Derivative function for 'sublimationPressureIce'"
|
---|
2609 |
|
---|
2610 | extends Modelica.Icons.Function;
|
---|
2611 | input SI.Temperature Tsat "Sublimation temperature";
|
---|
2612 | input Real dTsat(unit="K/s")
|
---|
2613 | "Time derivative of sublimation temperature";
|
---|
2614 | output Real psat_der(unit="Pa/s") "Sublimation pressure";
|
---|
2615 | algorithm
|
---|
2616 | /*psat := 611.657*Math.exp(22.5159*(1.0 - 273.16/Tsat));*/
|
---|
2617 | psat_der:=611.657*Math.exp(22.5159*(1.0 - 273.16/Tsat))*22.5159*273.16*dTsat/Tsat/Tsat;
|
---|
2618 | annotation(Inline=false,smoothOrder=5,
|
---|
2619 | Documentation(info="<html>
|
---|
2620 | Derivative function of <a href=\"modelica://Modelica.Media.Air.MoistAir.sublimationPressureIce\">saturationPressureIce</a>
|
---|
2621 | </html>"));
|
---|
2622 | end sublimationPressureIce_der;
|
---|
2623 |
|
---|
2624 | redeclare function extends saturationPressure
|
---|
2625 | "Return saturation pressure of water as a function of temperature T between 223.16 and 373.16 K"
|
---|
2626 |
|
---|
2627 | algorithm
|
---|
2628 | psat := Utilities.spliceFunction(saturationPressureLiquid(Tsat),sublimationPressureIce(Tsat),Tsat-273.16,1.0);
|
---|
2629 | annotation(Inline=false,smoothOrder=5,derivative=saturationPressure_der,
|
---|
2630 | Documentation(info="<html>
|
---|
2631 | Saturation pressure of water in the liquid and the solid region is computed using an Antoine-type correlation. It's range of validity is between 223.16 and 373.16 K. Outside of these limits a (less accurate) result is returned. Functions for the
|
---|
2632 | <a href=\"modelica://Modelica.Media.Air.MoistAir.sublimationPressureIce\">solid</a> and the <a href=\"modelica://Modelica.Media.Air.MoistAir.saturationPressureLiquid\"> liquid</a> region, respectively, are combined using the first derivative continuous <a href=\"modelica://Modelica.Media.Air.MoistAir.Utilities.spliceFunction\">spliceFunction</a>.
|
---|
2633 | </html>"));
|
---|
2634 | end saturationPressure;
|
---|
2635 |
|
---|
2636 | function saturationPressure_der
|
---|
2637 | "Derivative function for 'saturationPressure'"
|
---|
2638 | input Temperature Tsat "Saturation temperature";
|
---|
2639 | input Real dTsat(unit="K/s")
|
---|
2640 | "Time derivative of saturation temperature";
|
---|
2641 | output Real psat_der(unit="Pa/s") "Saturation pressure";
|
---|
2642 |
|
---|
2643 | algorithm
|
---|
2644 | /*psat := Utilities.spliceFunction(saturationPressureLiquid(Tsat),sublimationPressureIce(Tsat),Tsat-273.16,1.0);*/
|
---|
2645 | psat_der := Utilities.spliceFunction_der(
|
---|
2646 | saturationPressureLiquid(Tsat),
|
---|
2647 | sublimationPressureIce(Tsat),
|
---|
2648 | Tsat - 273.16,
|
---|
2649 | 1.0,
|
---|
2650 | saturationPressureLiquid_der(Tsat=Tsat, dTsat=dTsat),
|
---|
2651 | sublimationPressureIce_der(Tsat=Tsat, dTsat=dTsat),
|
---|
2652 | dTsat,
|
---|
2653 | 0);
|
---|
2654 | annotation(Inline=false,smoothOrder=5,
|
---|
2655 | Documentation(info="<html>
|
---|
2656 | Derivative function of <a href=\"modelica://Modelica.Media.Air.MoistAir.saturationPressure\">saturationPressure</a>
|
---|
2657 | </html>"));
|
---|
2658 | end saturationPressure_der;
|
---|
2659 |
|
---|
2660 | redeclare function extends enthalpyOfVaporization
|
---|
2661 | "Return enthalpy of vaporization of water as a function of temperature T, 0 - 130 degC"
|
---|
2662 |
|
---|
2663 | algorithm
|
---|
2664 | /*r0 := 1e3*(2501.0145 - (T - 273.15)*(2.3853 + (T - 273.15)*(0.002969 - (T
|
---|
2665 | - 273.15)*(7.5293e-5 + (T - 273.15)*4.6084e-7))));*/
|
---|
2666 | //katrin: replaced by linear correlation, simpler and more accurate in the entire region
|
---|
2667 | //source VDI-Waermeatlas, linear inter- and extrapolation between values for 0.01 °C and 40 °C.
|
---|
2668 | r0:=(2405900-2500500)/(40-0)*(T-273.16)+2500500;
|
---|
2669 | annotation(smoothOrder=2,
|
---|
2670 | Documentation(info="<html>
|
---|
2671 | Enthalpy of vaporization of water is computed from temperature in the region of 0 to 130 °C.
|
---|
2672 | </html>"));
|
---|
2673 | end enthalpyOfVaporization;
|
---|
2674 |
|
---|
2675 | redeclare function extends enthalpyOfLiquid
|
---|
2676 | "Return enthalpy of liquid water as a function of temperature T(use enthalpyOfWater instead)"
|
---|
2677 |
|
---|
2678 | algorithm
|
---|
2679 | h := (T - 273.15)*1e3*(4.2166 - 0.5*(T - 273.15)*(0.0033166 + 0.333333*(T - 273.15)*(0.00010295
|
---|
2680 | - 0.25*(T - 273.15)*(1.3819e-6 + 0.2*(T - 273.15)*7.3221e-9))));
|
---|
2681 | annotation(Inline=false,smoothOrder=5,
|
---|
2682 | Documentation(info="<html>
|
---|
2683 | Specific enthalpy of liquid water is computed from temperature using a polynomial approach. Kept for compatibility reasons, better use <a href=\"modelica://Modelica.Media.Air.MoistAir.enthalpyOfWater\">enthalpyOfWater</a> instead.
|
---|
2684 | </html>"));
|
---|
2685 | end enthalpyOfLiquid;
|
---|
2686 |
|
---|
2687 | redeclare function extends enthalpyOfGas
|
---|
2688 | "Return specific enthalpy of gas (air and steam) as a function of temperature T and composition X"
|
---|
2689 |
|
---|
2690 | algorithm
|
---|
2691 | h := SingleGasNasa.h_Tlow(data=steam, T=T, refChoice=3, h_off=46479.819+2501014.5)*X[Water]
|
---|
2692 | + SingleGasNasa.h_Tlow(data=dryair, T=T, refChoice=3, h_off=25104.684)*(1.0-X[Water]);
|
---|
2693 | annotation(Inline=false,smoothOrder=5,
|
---|
2694 | Documentation(info="<html>
|
---|
2695 | Specific enthalpy of moist air is computed from temperature, provided all water is in the gaseous state. The first entry in the composition vector X must be the mass fraction of steam. For a function that also covers the fog region please refer to <a href=\"modelica://Modelica.Media.Air.MoistAir.h_pTX\">h_pTX</a>.
|
---|
2696 | </html>"));
|
---|
2697 | end enthalpyOfGas;
|
---|
2698 |
|
---|
2699 | redeclare function extends enthalpyOfCondensingGas
|
---|
2700 | "Return specific enthalpy of steam as a function of temperature T"
|
---|
2701 |
|
---|
2702 | algorithm
|
---|
2703 | h := SingleGasNasa.h_Tlow(data=steam, T=T, refChoice=3, h_off=46479.819+2501014.5);
|
---|
2704 | annotation(Inline=false,smoothOrder=5,
|
---|
2705 | Documentation(info="<html>
|
---|
2706 | Specific enthalpy of steam is computed from temperature.
|
---|
2707 | </html>"));
|
---|
2708 | end enthalpyOfCondensingGas;
|
---|
2709 |
|
---|
2710 | redeclare function extends enthalpyOfNonCondensingGas
|
---|
2711 | "Return specific enthalpy of dry air as a function of temperature T"
|
---|
2712 |
|
---|
2713 | algorithm
|
---|
2714 | h := SingleGasNasa.h_Tlow(data=dryair, T=T, refChoice=3, h_off=25104.684);
|
---|
2715 | annotation(Inline=false,smoothOrder=1,
|
---|
2716 | Documentation(info="<html>
|
---|
2717 | Specific enthalpy of dry air is computed from temperature.
|
---|
2718 | </html>"));
|
---|
2719 | end enthalpyOfNonCondensingGas;
|
---|
2720 |
|
---|
2721 | function enthalpyOfWater
|
---|
2722 | "Computes specific enthalpy of water (solid/liquid) near atmospheric pressure from temperature T"
|
---|
2723 | input SIunits.Temperature T "Temperature";
|
---|
2724 | output SIunits.SpecificEnthalpy h "Specific enthalpy of water";
|
---|
2725 | algorithm
|
---|
2726 | /*simple model assuming constant properties:
|
---|
2727 | heat capacity of liquid water:4200 J/kg
|
---|
2728 | heat capacity of solid water: 2050 J/kg
|
---|
2729 | enthalpy of fusion (liquid=>solid): 333000 J/kg*/
|
---|
2730 |
|
---|
2731 | h:=Utilities.spliceFunction(4200*(T-273.15),2050*(T-273.15)-333000,T-273.16,0.1);
|
---|
2732 | annotation (derivative=enthalpyOfWater_der, Documentation(info="<html>
|
---|
2733 | Specific enthalpy of water (liquid and solid) is computed from temperature using constant properties as follows:<br>
|
---|
2734 | <ul>
|
---|
2735 | <li> heat capacity of liquid water:4200 J/kg
|
---|
2736 | <li> heat capacity of solid water: 2050 J/kg
|
---|
2737 | <li> enthalpy of fusion (liquid=>solid): 333000 J/kg
|
---|
2738 | </ul>
|
---|
2739 | Pressure is assumed to be around 1 bar. This function is usually used to determine the specific enthalpy of the liquid or solid fraction of moist air.
|
---|
2740 | </html>"));
|
---|
2741 | end enthalpyOfWater;
|
---|
2742 |
|
---|
2743 | function enthalpyOfWater_der "Derivative function of enthalpyOfWater"
|
---|
2744 | input SIunits.Temperature T "Temperature";
|
---|
2745 | input Real dT(unit="K/s") "Time derivative of temperature";
|
---|
2746 | output Real dh(unit="J/(kg.s)") "Time derivative of specific enthalpy";
|
---|
2747 | algorithm
|
---|
2748 | /*simple model assuming constant properties:
|
---|
2749 | heat capacity of liquid water:4200 J/kg
|
---|
2750 | heat capacity of solid water: 2050 J/kg
|
---|
2751 | enthalpy of fusion (liquid=>solid): 333000 J/kg*/
|
---|
2752 |
|
---|
2753 | //h:=Utilities.spliceFunction(4200*(T-273.15),2050*(T-273.15)-333000,T-273.16,0.1);
|
---|
2754 | dh:=Utilities.spliceFunction_der(4200*(T-273.15),2050*(T-273.15)-333000,T-273.16,0.1,4200*dT,2050*dT,dT,0);
|
---|
2755 | annotation (Documentation(info="<html>
|
---|
2756 | Derivative function for <a href=\"modelica://Modelica.Media.Air.MoistAir.enthalpyOfWater\">enthalpyOfWater</a>.
|
---|
2757 |
|
---|
2758 | </html>"));
|
---|
2759 | end enthalpyOfWater_der;
|
---|
2760 |
|
---|
2761 | redeclare function extends pressure
|
---|
2762 | "Returns pressure of ideal gas as a function of the thermodynamic state record"
|
---|
2763 |
|
---|
2764 | algorithm
|
---|
2765 | p := state.p;
|
---|
2766 | annotation(smoothOrder=2,
|
---|
2767 | Documentation(info="<html>
|
---|
2768 | Pressure is returned from the thermodynamic state record input as a simple assignment.
|
---|
2769 | </html>"));
|
---|
2770 | end pressure;
|
---|
2771 |
|
---|
2772 | redeclare function extends temperature
|
---|
2773 | "Return temperature of ideal gas as a function of the thermodynamic state record"
|
---|
2774 |
|
---|
2775 | algorithm
|
---|
2776 | T := state.T;
|
---|
2777 | annotation(smoothOrder=2,
|
---|
2778 | Documentation(info="<html>
|
---|
2779 | Temperature is returned from the thermodynamic state record input as a simple assignment.
|
---|
2780 | </html>"));
|
---|
2781 | end temperature;
|
---|
2782 |
|
---|
2783 | function T_phX
|
---|
2784 | "Return temperature as a function of pressure p, specific enthalpy h and composition X"
|
---|
2785 | input AbsolutePressure p "Pressure";
|
---|
2786 | input SpecificEnthalpy h "Specific enthalpy";
|
---|
2787 | input MassFraction[:] X "Mass fractions of composition";
|
---|
2788 | output Temperature T "Temperature";
|
---|
2789 |
|
---|
2790 | protected
|
---|
2791 | package Internal
|
---|
2792 | "Solve h(data,T) for T with given h (use only indirectly via temperature_phX)"
|
---|
2793 | extends Modelica.Media.Common.OneNonLinearEquation;
|
---|
2794 | redeclare record extends f_nonlinear_Data
|
---|
2795 | "Data to be passed to non-linear function"
|
---|
2796 | extends Modelica.Media.IdealGases.Common.DataRecord;
|
---|
2797 | end f_nonlinear_Data;
|
---|
2798 |
|
---|
2799 | redeclare function extends f_nonlinear
|
---|
2800 | algorithm
|
---|
2801 | y := h_pTX(p,x,X);
|
---|
2802 | end f_nonlinear;
|
---|
2803 |
|
---|
2804 | // Dummy definition has to be added for current Dymola
|
---|
2805 | redeclare function extends solve
|
---|
2806 | end solve;
|
---|
2807 | end Internal;
|
---|
2808 |
|
---|
2809 | algorithm
|
---|
2810 | T := Internal.solve(h, 240, 400, p, X[1:nXi], steam);
|
---|
2811 | annotation (Documentation(info="<html>
|
---|
2812 | Temperature is computed from pressure, specific enthalpy and composition via numerical inversion of function <a href=\"modelica://Modelica.Media.Air.MoistAir.h_pTX\">h_pTX</a>.
|
---|
2813 | </html>"));
|
---|
2814 | end T_phX;
|
---|
2815 |
|
---|
2816 | redeclare function extends density
|
---|
2817 | "Returns density of ideal gas as a function of the thermodynamic state record"
|
---|
2818 |
|
---|
2819 | algorithm
|
---|
2820 | d := state.p/(gasConstant(state)*state.T);
|
---|
2821 | annotation(smoothOrder=2,
|
---|
2822 | Documentation(info="<html>
|
---|
2823 | Density is computed from pressure, temperature and composition in the thermodynamic state record applying the ideal gas law.
|
---|
2824 | </html>"));
|
---|
2825 | end density;
|
---|
2826 |
|
---|
2827 | redeclare function extends specificEnthalpy
|
---|
2828 | "Return specific enthalpy of moist air as a function of the thermodynamic state record"
|
---|
2829 |
|
---|
2830 | algorithm
|
---|
2831 | h := h_pTX(state.p, state.T, state.X);
|
---|
2832 | annotation(smoothOrder=2,
|
---|
2833 | Documentation(info="<html>
|
---|
2834 | Specific enthalpy of moist air is computed from the thermodynamic state record. The fog region is included for both, ice and liquid fog.
|
---|
2835 | </html>"));
|
---|
2836 | end specificEnthalpy;
|
---|
2837 |
|
---|
2838 | function h_pTX
|
---|
2839 | "Return specific enthalpy of moist air as a function of pressure p, temperature T and composition X"
|
---|
2840 | extends Modelica.Icons.Function;
|
---|
2841 | input SI.Pressure p "Pressure";
|
---|
2842 | input SI.Temperature T "Temperature";
|
---|
2843 | input SI.MassFraction X[:] "Mass fractions of moist air";
|
---|
2844 | output SI.SpecificEnthalpy h "Specific enthalpy at p, T, X";
|
---|
2845 | protected
|
---|
2846 | SI.AbsolutePressure p_steam_sat "Partial saturation pressure of steam";
|
---|
2847 | SI.MassFraction X_sat "Absolute humidity per unit mass of moist air";
|
---|
2848 | SI.MassFraction X_liquid "mass fraction of liquid water";
|
---|
2849 | SI.MassFraction X_steam "mass fraction of steam water";
|
---|
2850 | SI.MassFraction X_air "mass fraction of air";
|
---|
2851 | algorithm
|
---|
2852 | p_steam_sat :=saturationPressure(T);
|
---|
2853 | //p_steam_sat :=min(saturationPressure(T), 0.999*p);
|
---|
2854 | X_sat:=min(p_steam_sat*k_mair/max(100*Constants.eps, p - p_steam_sat)*(1 - X[
|
---|
2855 | Water]), 1.0);
|
---|
2856 | X_liquid :=max(X[Water] - X_sat, 0.0);
|
---|
2857 | X_steam :=X[Water] - X_liquid;
|
---|
2858 | X_air :=1 - X[Water];
|
---|
2859 | /* h := {SingleGasNasa.h_Tlow(data=steam, T=T, refChoice=3, h_off=46479.819+2501014.5),
|
---|
2860 | SingleGasNasa.h_Tlow(data=dryair, T=T, refChoice=3, h_off=25104.684)}*
|
---|
2861 | {X_steam, X_air} + enthalpyOfLiquid(T)*X_liquid;*/
|
---|
2862 | h := {SingleGasNasa.h_Tlow(data=steam, T=T, refChoice=3, h_off=46479.819+2501014.5),
|
---|
2863 | SingleGasNasa.h_Tlow(data=dryair, T=T, refChoice=3, h_off=25104.684)}*
|
---|
2864 | {X_steam, X_air} + enthalpyOfWater(T)*X_liquid;
|
---|
2865 | annotation(derivative=h_pTX_der, Inline=false,
|
---|
2866 | Documentation(info="<html>
|
---|
2867 | Specific enthalpy of moist air is computed from pressure, temperature and composition with X[1] as the total water mass fraction. The fog region is included for both, ice and liquid fog.
|
---|
2868 | </html>"));
|
---|
2869 | end h_pTX;
|
---|
2870 |
|
---|
2871 | function h_pTX_der "Derivative function of h_pTX"
|
---|
2872 | extends Modelica.Icons.Function;
|
---|
2873 | input SI.Pressure p "Pressure";
|
---|
2874 | input SI.Temperature T "Temperature";
|
---|
2875 | input SI.MassFraction X[:] "Mass fractions of moist air";
|
---|
2876 | input Real dp(unit="Pa/s") "Pressure derivative";
|
---|
2877 | input Real dT(unit="K/s") "Temperature derivative";
|
---|
2878 | input Real dX[:](each unit="1/s") "Composition derivative";
|
---|
2879 | output Real h_der(unit="J/(kg.s)")
|
---|
2880 | "Time derivative of specific enthalpy";
|
---|
2881 | protected
|
---|
2882 | SI.AbsolutePressure p_steam_sat "Partial saturation pressure of steam";
|
---|
2883 | SI.MassFraction X_sat "Absolute humidity per unit mass of moist air";
|
---|
2884 | SI.MassFraction X_liquid "Mass fraction of liquid water";
|
---|
2885 | SI.MassFraction X_steam "Mass fraction of steam water";
|
---|
2886 | SI.MassFraction X_air "Mass fraction of air";
|
---|
2887 | SI.MassFraction x_sat
|
---|
2888 | "Absolute humidity per unit mass of dry air at saturation";
|
---|
2889 | Real dX_steam(unit="1/s") "Time deriveative of steam mass fraction";
|
---|
2890 | Real dX_air(unit="1/s") "Time derivative of dry air mass fraction";
|
---|
2891 | Real dX_liq(unit="1/s")
|
---|
2892 | "Time derivative of liquid/solid water mass fraction";
|
---|
2893 | Real dps(unit="Pa/s") "Time derivative of saturation pressure";
|
---|
2894 | Real dx_sat(unit="1/s")
|
---|
2895 | "Time derivative of abolute humidity per unit mass of dry air";
|
---|
2896 | algorithm
|
---|
2897 | p_steam_sat :=saturationPressure(T);
|
---|
2898 | x_sat:=p_steam_sat*k_mair/max(100*Modelica.Constants.eps, p - p_steam_sat);
|
---|
2899 | X_sat:=min(x_sat*(1 - X[Water]), 1.0);
|
---|
2900 | X_liquid :=Utilities.spliceFunction(X[Water] - X_sat, 0.0, X[Water] - X_sat,1e-6);
|
---|
2901 | X_steam :=X[Water] - X_liquid;
|
---|
2902 | X_air :=1 - X[Water];
|
---|
2903 |
|
---|
2904 | dX_air:=-dX[Water];
|
---|
2905 | dps:=saturationPressure_der(Tsat=T, dTsat=dT);
|
---|
2906 | dx_sat:=k_mair*(dps*(p-p_steam_sat)-p_steam_sat*(dp-dps))/(p-p_steam_sat)/(p-p_steam_sat);
|
---|
2907 | dX_liq:=Utilities.spliceFunction_der(X[Water] - X_sat, 0.0, X[Water] - X_sat,1e-6,(1+x_sat)*dX[Water]-(1-X[Water])*dx_sat,0.0,(1+x_sat)*dX[Water]-(1-X[Water])*dx_sat,0.0);
|
---|
2908 | //dX_liq:=if X[Water]>=X_sat then (1+x_sat)*dX[Water]-(1-X[Water])*dx_sat else 0;
|
---|
2909 | dX_steam:=dX[Water]-dX_liq;
|
---|
2910 |
|
---|
2911 | h_der:= X_steam*Modelica.Media.IdealGases.Common.SingleGasNasa.h_Tlow_der(data=steam, T=T, refChoice=3, h_off=46479.819+2501014.5, dT=dT)+
|
---|
2912 | dX_steam*Modelica.Media.IdealGases.Common.SingleGasNasa.h_Tlow(data=steam, T=T, refChoice=3, h_off=46479.819+2501014.5) +
|
---|
2913 | X_air*Modelica.Media.IdealGases.Common.SingleGasNasa.h_Tlow_der(data=dryair, T=T, refChoice=3, h_off=25104.684, dT=dT) +
|
---|
2914 | dX_air*Modelica.Media.IdealGases.Common.SingleGasNasa.h_Tlow(data=dryair, T=T, refChoice=3, h_off=25104.684) +
|
---|
2915 | X_liquid*enthalpyOfWater_der(T=T, dT=dT) +
|
---|
2916 | dX_liq*enthalpyOfWater(T);
|
---|
2917 |
|
---|
2918 | annotation(Inline=false,smoothOrder=1,
|
---|
2919 | Documentation(info="<html>
|
---|
2920 | Derivative function for <a href=\"modelica://Modelica.Media.Air.MoistAir.h_pTX\">h_pTX</a>.
|
---|
2921 | </html>"));
|
---|
2922 | end h_pTX_der;
|
---|
2923 |
|
---|
2924 | redeclare function extends isentropicExponent
|
---|
2925 | "Return isentropic exponent (only for gas fraction!)"
|
---|
2926 | algorithm
|
---|
2927 | gamma := specificHeatCapacityCp(state)/specificHeatCapacityCv(state);
|
---|
2928 | end isentropicExponent;
|
---|
2929 |
|
---|
2930 | redeclare function extends specificInternalEnergy
|
---|
2931 | "Return specific internal energy of moist air as a function of the thermodynamic state record"
|
---|
2932 | extends Modelica.Icons.Function;
|
---|
2933 | output SI.SpecificInternalEnergy u "Specific internal energy";
|
---|
2934 | algorithm
|
---|
2935 | u := specificInternalEnergy_pTX(state.p,state.T,state.X);
|
---|
2936 |
|
---|
2937 | annotation(smoothOrder=2,
|
---|
2938 | Documentation(info="<html>
|
---|
2939 | Specific internal energy is determined from the thermodynamic state record, assuming that the liquid or solid water volume is negligible.
|
---|
2940 | </html>"));
|
---|
2941 | end specificInternalEnergy;
|
---|
2942 |
|
---|
2943 | function specificInternalEnergy_pTX
|
---|
2944 | "Return specific internal energy of moist air as a function of pressure p, temperature T and composition X"
|
---|
2945 | input SI.Pressure p "Pressure";
|
---|
2946 | input SI.Temperature T "Temperature";
|
---|
2947 | input SI.MassFraction X[:] "Mass fractions of moist air";
|
---|
2948 | output SI.SpecificInternalEnergy u "Specific internal energy";
|
---|
2949 | protected
|
---|
2950 | SI.AbsolutePressure p_steam_sat "Partial saturation pressure of steam";
|
---|
2951 | SI.MassFraction X_liquid "Mass fraction of liquid water";
|
---|
2952 | SI.MassFraction X_steam "Mass fraction of steam water";
|
---|
2953 | SI.MassFraction X_air "Mass fraction of air";
|
---|
2954 | SI.MassFraction X_sat "Absolute humidity per unit mass of moist air";
|
---|
2955 | Real R_gas "Ideal gas constant";
|
---|
2956 | algorithm
|
---|
2957 | p_steam_sat :=saturationPressure(T);
|
---|
2958 | X_sat:=min(p_steam_sat*k_mair/max(100*Constants.eps, p - p_steam_sat)*(1 - X[
|
---|
2959 | Water]), 1.0);
|
---|
2960 | X_liquid :=max(X[Water] - X_sat, 0.0);
|
---|
2961 | X_steam :=X[Water] - X_liquid;
|
---|
2962 | X_air :=1 - X[Water];
|
---|
2963 | R_gas:= dryair.R*X_air/(1-X_liquid)+steam.R* X_steam/(1-X_liquid);
|
---|
2964 | u := X_steam*SingleGasNasa.h_Tlow(data=steam, T=T, refChoice=3, h_off=46479.819+2501014.5)+
|
---|
2965 | X_air*SingleGasNasa.h_Tlow(data=dryair, T=T, refChoice=3, h_off=25104.684)
|
---|
2966 | + enthalpyOfWater(T)*X_liquid-R_gas*T;
|
---|
2967 |
|
---|
2968 | annotation (derivative=specificInternalEnergy_pTX_der, Documentation(info="<html>
|
---|
2969 | Specific internal energy is determined from pressure p, temperature T and composition X, assuming that the liquid or solid water volume is negligible.
|
---|
2970 | </html>"));
|
---|
2971 | end specificInternalEnergy_pTX;
|
---|
2972 |
|
---|
2973 | function specificInternalEnergy_pTX_der
|
---|
2974 | "Derivative function for specificInternalEnergy_pTX"
|
---|
2975 | input SI.Pressure p "Pressure";
|
---|
2976 | input SI.Temperature T "Temperature";
|
---|
2977 | input SI.MassFraction X[:] "Mass fractions of moist air";
|
---|
2978 | input Real dp(unit="Pa/s") "Pressure derivative";
|
---|
2979 | input Real dT(unit="K/s") "Temperature derivative";
|
---|
2980 | input Real dX[:](each unit="1/s") "Mass fraction derivatives";
|
---|
2981 | output Real u_der(unit="J/(kg.s)")
|
---|
2982 | "Specific internal energy derivative";
|
---|
2983 | protected
|
---|
2984 | SI.AbsolutePressure p_steam_sat "Partial saturation pressure of steam";
|
---|
2985 | SI.MassFraction X_liquid "Mass fraction of liquid water";
|
---|
2986 | SI.MassFraction X_steam "Mass fraction of steam water";
|
---|
2987 | SI.MassFraction X_air "Mass fraction of air";
|
---|
2988 | SI.MassFraction X_sat "Absolute humidity per unit mass of moist air";
|
---|
2989 | SI.SpecificHeatCapacity R_gas "Ideal gas constant";
|
---|
2990 |
|
---|
2991 | SI.MassFraction x_sat
|
---|
2992 | "Absolute humidity per unit mass of dry air at saturation";
|
---|
2993 | Real dX_steam(unit="1/s") "Time deriveative of steam mass fraction";
|
---|
2994 | Real dX_air(unit="1/s") "Time derivative of dry air mass fraction";
|
---|
2995 | Real dX_liq(unit="1/s")
|
---|
2996 | "Time derivative of liquid/solid water mass fraction";
|
---|
2997 | Real dps(unit="Pa/s") "Time derivative of saturation pressure";
|
---|
2998 | Real dx_sat(unit="1/s")
|
---|
2999 | "Time derivative of abolute humidity per unit mass of dry air";
|
---|
3000 | Real dR_gas(unit="J/(kg.K.s)") "Time derivative of ideal gas constant";
|
---|
3001 | algorithm
|
---|
3002 | p_steam_sat :=saturationPressure(T);
|
---|
3003 | x_sat:=p_steam_sat*k_mair/max(100*Modelica.Constants.eps, p - p_steam_sat);
|
---|
3004 | X_sat:=min(x_sat*(1 - X[Water]), 1.0);
|
---|
3005 | X_liquid :=Utilities.spliceFunction(X[Water] - X_sat, 0.0, X[Water] - X_sat,1e-6);
|
---|
3006 | X_steam :=X[Water] - X_liquid;
|
---|
3007 | X_air :=1 - X[Water];
|
---|
3008 | R_gas:= steam.R*X_steam/(1-X_liquid)+dryair.R* X_air/(1-X_liquid);
|
---|
3009 |
|
---|
3010 | dX_air:=-dX[Water];
|
---|
3011 | dps:=saturationPressure_der(Tsat=T, dTsat=dT);
|
---|
3012 | dx_sat:=k_mair*(dps*(p-p_steam_sat)-p_steam_sat*(dp-dps))/(p-p_steam_sat)/(p-p_steam_sat);
|
---|
3013 | dX_liq:=Utilities.spliceFunction_der(X[Water] - X_sat, 0.0, X[Water] - X_sat,1e-6,(1+x_sat)*dX[Water]-(1-X[Water])*dx_sat,0.0,(1+x_sat)*dX[Water]-(1-X[Water])*dx_sat,0.0);
|
---|
3014 | dX_steam:=dX[Water]-dX_liq;
|
---|
3015 | dR_gas:=(steam.R*(dX_steam*(1-X_liquid)+dX_liq*X_steam)+dryair.R*(dX_air*(1-X_liquid)+dX_liq*X_air))/(1-X_liquid)/(1-X_liquid);
|
---|
3016 |
|
---|
3017 | u_der:=X_steam*SingleGasNasa.h_Tlow_der(data=steam, T=T, refChoice=3, h_off=46479.819+2501014.5, dT=dT)+
|
---|
3018 | dX_steam*SingleGasNasa.h_Tlow(data=steam, T=T, refChoice=3, h_off=46479.819+2501014.5) +
|
---|
3019 | X_air*SingleGasNasa.h_Tlow_der(data=dryair, T=T, refChoice=3, h_off=25104.684, dT=dT) +
|
---|
3020 | dX_air*SingleGasNasa.h_Tlow(data=dryair, T=T, refChoice=3, h_off=25104.684) +
|
---|
3021 | X_liquid*enthalpyOfWater_der(T=T, dT=dT) +
|
---|
3022 | dX_liq*enthalpyOfWater(T) - dR_gas*T-R_gas*dT;
|
---|
3023 | annotation (Documentation(info="<html>
|
---|
3024 | Derivative function for <a href=\"modelica://Modelica.Media.Air.MoistAir.specificInternalEnergy_pTX\">specificInternalEnergy_pTX</a>.
|
---|
3025 | </html>"));
|
---|
3026 | end specificInternalEnergy_pTX_der;
|
---|
3027 |
|
---|
3028 | redeclare function extends specificEntropy
|
---|
3029 | "Return specific entropy from thermodynamic state record, only valid for phi<1"
|
---|
3030 |
|
---|
3031 | protected
|
---|
3032 | MoleFraction[2] Y = massToMoleFractions(state.X,{steam.MM,dryair.MM})
|
---|
3033 | "molar fraction";
|
---|
3034 | algorithm
|
---|
3035 | s:=SingleGasNasa.s0_Tlow(dryair, state.T)*(1-state.X[Water])
|
---|
3036 | + SingleGasNasa.s0_Tlow(steam, state.T)*state.X[Water]
|
---|
3037 | - (state.X[Water]*Modelica.Constants.R/MMX[Water]*(if state.X[Water]<Modelica.Constants.eps then state.X[Water] else Modelica.Math.log(Y[Water]*state.p/reference_p))
|
---|
3038 | + (1-state.X[Water])*Modelica.Constants.R/MMX[Air]*(if (1-state.X[Water])<Modelica.Constants.eps then (1-state.X[Water]) else Modelica.Math.log(Y[Air]*state.p/reference_p)));
|
---|
3039 | annotation(Inline=false,smoothOrder=2,
|
---|
3040 | Documentation(info="<html>
|
---|
3041 | Specific entropy is calculated from the thermodynamic state record, assuming ideal gas behavior and including entropy of mixing. Liquid or solid water is not taken into account, the entire water content X[1] is assumed to be in the vapor state (relative humidity below 1.0).
|
---|
3042 | </html>"));
|
---|
3043 | end specificEntropy;
|
---|
3044 |
|
---|
3045 | redeclare function extends specificGibbsEnergy
|
---|
3046 | "Return specific Gibbs energy as a function of the thermodynamic state record, only valid for phi<1"
|
---|
3047 | extends Modelica.Icons.Function;
|
---|
3048 | algorithm
|
---|
3049 | g := h_pTX(state.p,state.T,state.X) - state.T*specificEntropy(state);
|
---|
3050 | annotation(smoothOrder=2,
|
---|
3051 | Documentation(info="<html>
|
---|
3052 | The Gibbs Energy is computed from the thermodynamic state record for moist air with a water content below saturation.
|
---|
3053 | </html>"));
|
---|
3054 | end specificGibbsEnergy;
|
---|
3055 |
|
---|
3056 | redeclare function extends specificHelmholtzEnergy
|
---|
3057 | "Return specific Helmholtz energy as a function of the thermodynamic state record, only valid for phi<1"
|
---|
3058 | extends Modelica.Icons.Function;
|
---|
3059 | algorithm
|
---|
3060 | f := h_pTX(state.p,state.T,state.X) - gasConstant(state)*state.T - state.T*specificEntropy(state);
|
---|
3061 | annotation(smoothOrder=2,
|
---|
3062 | Documentation(info="<html>
|
---|
3063 | The Specific Helmholtz Energy is computed from the thermodynamic state record for moist air with a water content below saturation.
|
---|
3064 | </html>"));
|
---|
3065 | end specificHelmholtzEnergy;
|
---|
3066 |
|
---|
3067 | redeclare function extends specificHeatCapacityCp
|
---|
3068 | "Return specific heat capacity at constant pressure as a function of the thermodynamic state record"
|
---|
3069 |
|
---|
3070 | protected
|
---|
3071 | Real dT(unit="s/K") = 1.0;
|
---|
3072 | algorithm
|
---|
3073 | cp := h_pTX_der(state.p,state.T,state.X, 0.0, 1.0, zeros(size(state.X,1)))*dT
|
---|
3074 | "Definition of cp: dh/dT @ constant p";
|
---|
3075 | // cp:= SingleGasNasa.cp_Tlow(dryair, state.T)*(1-state.X[Water])
|
---|
3076 | // + SingleGasNasa.cp_Tlow(steam, state.T)*state.X[Water];
|
---|
3077 | annotation(Inline=false,smoothOrder=2,
|
---|
3078 | Documentation(info="<html>
|
---|
3079 | The specific heat capacity at constant pressure <b>cp</b> is computed from temperature and composition for a mixture of steam (X[1]) and dry air. All water is assumed to be in the vapor state.
|
---|
3080 | </html>"));
|
---|
3081 | end specificHeatCapacityCp;
|
---|
3082 |
|
---|
3083 | redeclare function extends specificHeatCapacityCv
|
---|
3084 | "Return specific heat capacity at constant volume as a function of the thermodynamic state record"
|
---|
3085 |
|
---|
3086 | algorithm
|
---|
3087 | cv:= SingleGasNasa.cp_Tlow(dryair, state.T)*(1-state.X[Water]) +
|
---|
3088 | SingleGasNasa.cp_Tlow(steam, state.T)*state.X[Water]
|
---|
3089 | - gasConstant(state);
|
---|
3090 | annotation(Inline=false,smoothOrder=2,
|
---|
3091 | Documentation(info="<html>
|
---|
3092 | The specific heat capacity at constant density <b>cv</b> is computed from temperature and composition for a mixture of steam (X[1]) and dry air. All water is assumed to be in the vapor state.
|
---|
3093 | </html>"));
|
---|
3094 | end specificHeatCapacityCv;
|
---|
3095 |
|
---|
3096 | redeclare function extends dynamicViscosity
|
---|
3097 | "Return dynamic viscosity as a function of the thermodynamic state record, valid from 73.15 K to 373.15 K"
|
---|
3098 |
|
---|
3099 | import Modelica.Media.Incompressible.TableBased.Polynomials_Temp;
|
---|
3100 | algorithm
|
---|
3101 | eta := Polynomials_Temp.evaluate({(-4.96717436974791E-011), 5.06626785714286E-008, 1.72937731092437E-005},
|
---|
3102 | Cv.to_degC(state.T));
|
---|
3103 | annotation(smoothOrder=2,
|
---|
3104 | Documentation(info="<html>
|
---|
3105 | Dynamic viscosity is computed from temperature using a simple polynomial for dry air, assuming that moisture influence is small. Range of validity is from 73.15 K to 373.15 K.
|
---|
3106 | </html>"));
|
---|
3107 | end dynamicViscosity;
|
---|
3108 |
|
---|
3109 | redeclare function extends thermalConductivity
|
---|
3110 | "Return thermal conductivity as a function of the thermodynamic state record, valid from 73.15 K to 373.15 K"
|
---|
3111 |
|
---|
3112 | import Modelica.Media.Incompressible.TableBased.Polynomials_Temp;
|
---|
3113 | algorithm
|
---|
3114 | lambda := Polynomials_Temp.evaluate({(-4.8737307422969E-008), 7.67803133753502E-005, 0.0241814385504202},
|
---|
3115 | Cv.to_degC(state.T));
|
---|
3116 | annotation(smoothOrder=2,
|
---|
3117 | Documentation(info="<html>
|
---|
3118 | Thermal conductivity is computed from temperature using a simple polynomial for dry air, assuming that moisture influence is small. Range of validity is from 73.15 K to 373.15 K.
|
---|
3119 | </html>"));
|
---|
3120 | end thermalConductivity;
|
---|
3121 |
|
---|
3122 | package Utilities "utility functions"
|
---|
3123 |
|
---|
3124 | function spliceFunction "Spline interpolation of two functions"
|
---|
3125 | input Real pos "Returned value for x-deltax >= 0";
|
---|
3126 | input Real neg "Returned value for x+deltax <= 0";
|
---|
3127 | input Real x "Function argument";
|
---|
3128 | input Real deltax=1 "Region around x with spline interpolation";
|
---|
3129 | output Real out;
|
---|
3130 | protected
|
---|
3131 | Real scaledX;
|
---|
3132 | Real scaledX1;
|
---|
3133 | Real y;
|
---|
3134 | algorithm
|
---|
3135 | scaledX1 := x/deltax;
|
---|
3136 | scaledX := scaledX1*Modelica.Math.asin(1);
|
---|
3137 | if scaledX1 <= -0.999999999 then
|
---|
3138 | y := 0;
|
---|
3139 | elseif scaledX1 >= 0.999999999 then
|
---|
3140 | y := 1;
|
---|
3141 | else
|
---|
3142 | y := (Modelica.Math.tanh(Modelica.Math.tan(scaledX)) + 1)/2;
|
---|
3143 | end if;
|
---|
3144 | out := pos*y + (1 - y)*neg;
|
---|
3145 | annotation (derivative=spliceFunction_der);
|
---|
3146 | end spliceFunction;
|
---|
3147 |
|
---|
3148 | function spliceFunction_der "Derivative of spliceFunction"
|
---|
3149 | input Real pos;
|
---|
3150 | input Real neg;
|
---|
3151 | input Real x;
|
---|
3152 | input Real deltax=1;
|
---|
3153 | input Real dpos;
|
---|
3154 | input Real dneg;
|
---|
3155 | input Real dx;
|
---|
3156 | input Real ddeltax=0;
|
---|
3157 | output Real out;
|
---|
3158 | protected
|
---|
3159 | Real scaledX;
|
---|
3160 | Real scaledX1;
|
---|
3161 | Real dscaledX1;
|
---|
3162 | Real y;
|
---|
3163 | algorithm
|
---|
3164 | scaledX1 := x/deltax;
|
---|
3165 | scaledX := scaledX1*Modelica.Math.asin(1);
|
---|
3166 | dscaledX1 := (dx - scaledX1*ddeltax)/deltax;
|
---|
3167 | if scaledX1 <= -0.99999999999 then
|
---|
3168 | y := 0;
|
---|
3169 | elseif scaledX1 >= 0.9999999999 then
|
---|
3170 | y := 1;
|
---|
3171 | else
|
---|
3172 | y := (Modelica.Math.tanh(Modelica.Math.tan(scaledX)) + 1)/2;
|
---|
3173 | end if;
|
---|
3174 | out := dpos*y + (1 - y)*dneg;
|
---|
3175 | if (abs(scaledX1) < 1) then
|
---|
3176 | out := out + (pos - neg)*dscaledX1*Modelica.Math.asin(1)/2/(
|
---|
3177 | Modelica.Math.cosh(Modelica.Math.tan(scaledX))*Modelica.Math.cos(
|
---|
3178 | scaledX))^2;
|
---|
3179 | end if;
|
---|
3180 | end spliceFunction_der;
|
---|
3181 | end Utilities;
|
---|
3182 | annotation (Documentation(info="<html>
|
---|
3183 | <h4>Thermodynamic Model</h4>
|
---|
3184 | <p>This package provides a full thermodynamic model of moist air including the fog region and temperatures below zero degC.
|
---|
3185 | The governing assumptions in this model are:</p>
|
---|
3186 | <ul>
|
---|
3187 | <li>the perfect gas law applies</li>
|
---|
3188 | <li>water volume other than that of steam is neglected</li></ul>
|
---|
3189 | <p>All extensive properties are expressed in terms of the total mass in order to comply with other media in this libary. However, for moist air it is rather common to express the absolute humidity in terms of mass of dry air only, which has advantages when working with charts. In addition, care must be taken, when working with mass fractions with respect to total mass, that all properties refer to the same water content when being used in mathematical operations (which is always the case if based on dry air only). Therefore two absolute humidities are computed in the <b>BaseProperties</b> model: <b>X</b> denotes the absolute humidity in terms of the total mass while <b>x</b> denotes the absolute humitity per unit mass of dry air. In addition, the relative humidity <b>phi</b> is also computed.</p>
|
---|
3190 | <p>At the triple point temperature of water of 0.01 °C or 273.16 K and a relative humidity greater than 1 fog may be present as liquid and as ice resulting in a specific enthalpy somewhere between those of the two isotherms for solid and liquid fog, respectively. For numerical reasons a coexisting mixture of 50% solid and 50% liquid fog is assumed in the fog region at the triple point in this model.</p>
|
---|
3191 |
|
---|
3192 | <h4>Range of validity</h4>
|
---|
3193 | <p>From the assumptions mentioned above it follows that the <b>pressure</b> should be in the region around <b>atmospheric</b> conditions or below (a few bars may still be fine though). Additionally a very high water content at low temperatures would yield incorrect densities, because the volume of the liquid or solid phase would not be negligible anymore. The model does not provide information on limits for water drop size in the fog region or transport information for the actual condensation or evaporation process in combination with surfaces. All excess water which is not in its vapour state is assumed to be still present in the air regarding its energy but not in terms of its spatial extent.<br><br>
|
---|
3194 | The thermodynamic model may be used for <b>temperatures</b> ranging from <b>240 - 400 K</b>. This holds for all functions unless otherwise stated in their description. However, although the model works at temperatures above the saturation temperature it is questionable to use the term \"relative humidity\" in this region. Please note, that although several functions compute pure water properties, they are designed to be used within the moist air medium model where properties are dominated by air and steam in their vapor states, and not for pure liquid water applications.</p>
|
---|
3195 |
|
---|
3196 | <h4>Transport Properties</h4>
|
---|
3197 | <p>Several additional functions that are not needed to describe the thermodynamic system, but are required to model transport processes, like heat and mass transfer, may be called. They usually neglect the moisture influence unless otherwise stated.</p>
|
---|
3198 |
|
---|
3199 | <h4>Application</h4>
|
---|
3200 | <p>The model's main area of application is all processes that involve moist air cooling under near atmospheric pressure with possible moisture condensation. This is the case in all domestic and industrial air conditioning applications. Another large domain of moist air applications covers all processes that deal with dehydration of bulk material using air as a transport medium. Engineering tasks involving moist air are often performed (or at least visualized) by using charts that contain all relevant thermodynamic data for a moist air system. These so called psychrometric charts can be generated from the medium properties in this package. The model <a href=\"modelica://Modelica.Media.Air.MoistAir.PsychrometricData\">PsychrometricData</a> may be used for this purpose in order to obtain data for figures like those below (the plotting itself is not part of the model though).</p>
|
---|
3201 |
|
---|
3202 | <img src=\"modelica://Modelica/Resources/Images/Media/Air/Mollier.png\">
|
---|
3203 |
|
---|
3204 | <img src=\"modelica://Modelica/Resources/Images/Media/Air/PsycroChart.png\">
|
---|
3205 |
|
---|
3206 | <p>
|
---|
3207 | <b>Legend:</b> blue - constant specific enthalpy, red - constant temperature, black - constant relative humidity</p>
|
---|
3208 |
|
---|
3209 | </html>"));
|
---|
3210 | end MoistAir;
|
---|
3211 | annotation (Documentation(info="<html>
|
---|
3212 | <p>This package contains different medium models for air:</p>
|
---|
3213 | <ul>
|
---|
3214 | <li><b>SimpleAir</b><br>
|
---|
3215 | Simple dry air medium in a limited temperature range.</li>
|
---|
3216 | <li><b>DryAirNasa</b><br>
|
---|
3217 | Dry air as an ideal gas from Media.IdealGases.MixtureGases.Air.</li>
|
---|
3218 | <li><b>MoistAir</b><br>
|
---|
3219 | Moist air as an ideal gas mixture of steam and dry air with fog below and above the triple point temperature.</li>
|
---|
3220 | </ul>
|
---|
3221 | </html>"));
|
---|
3222 | end Air;
|
---|
3223 |
|
---|
3224 | package IdealGases
|
---|
3225 | "Data and models of ideal gases (single, fixed and dynamic mixtures) from NASA source"
|
---|
3226 | extends Modelica.Icons.MaterialPropertiesPackage;
|
---|
3227 |
|
---|
3228 | package Common "Common packages and data for the ideal gas models"
|
---|
3229 | extends Modelica.Icons.Package;
|
---|
3230 |
|
---|
3231 | record DataRecord
|
---|
3232 | "Coefficient data record for properties of ideal gases based on NASA source"
|
---|
3233 | extends Modelica.Icons.Record;
|
---|
3234 | String name "Name of ideal gas";
|
---|
3235 | SI.MolarMass MM "Molar mass";
|
---|
3236 | SI.SpecificEnthalpy Hf "Enthalpy of formation at 298.15K";
|
---|
3237 | SI.SpecificEnthalpy H0 "H0(298.15K) - H0(0K)";
|
---|
3238 | SI.Temperature Tlimit
|
---|
3239 | "Temperature limit between low and high data sets";
|
---|
3240 | Real alow[7] "Low temperature coefficients a";
|
---|
3241 | Real blow[2] "Low temperature constants b";
|
---|
3242 | Real ahigh[7] "High temperature coefficients a";
|
---|
3243 | Real bhigh[2] "High temperature constants b";
|
---|
3244 | SI.SpecificHeatCapacity R "Gas constant";
|
---|
3245 | annotation (Documentation(info="<HTML>
|
---|
3246 | <p>
|
---|
3247 | This data record contains the coefficients for the
|
---|
3248 | ideal gas equations according to:
|
---|
3249 | </p>
|
---|
3250 | <blockquote>
|
---|
3251 | <p>McBride B.J., Zehe M.J., and Gordon S. (2002): <b>NASA Glenn Coefficients
|
---|
3252 | for Calculating Thermodynamic Properties of Individual Species</b>. NASA
|
---|
3253 | report TP-2002-211556</p>
|
---|
3254 | </blockquote>
|
---|
3255 | <p>
|
---|
3256 | The equations have the following structure:
|
---|
3257 | </p>
|
---|
3258 | <IMG src=\"modelica://Modelica/Resources/Images/Media/IdealGases/singleEquations.png\">
|
---|
3259 | <p>
|
---|
3260 | The polynomials for h(T) and s0(T) are derived via integration from the one for cp(T) and contain the integration constants b1, b2 that define the reference specific enthalpy and entropy. For entropy differences the reference pressure p0 is arbitrary, but not for absolute entropies. It is chosen as 1 standard atmosphere (101325 Pa).
|
---|
3261 | </p>
|
---|
3262 | <p>
|
---|
3263 | For most gases, the region of validity is from 200 K to 6000 K.
|
---|
3264 | The equations are splitted into two regions that are separated
|
---|
3265 | by Tlimit (usually 1000 K). In both regions the gas is described
|
---|
3266 | by the data above. The two branches are continuous and in most
|
---|
3267 | gases also differentiable at Tlimit.
|
---|
3268 | </p>
|
---|
3269 | </HTML>"));
|
---|
3270 | end DataRecord;
|
---|
3271 |
|
---|
3272 | partial package SingleGasNasa
|
---|
3273 | "Medium model of an ideal gas based on NASA source"
|
---|
3274 |
|
---|
3275 | extends Interfaces.PartialPureSubstance(
|
---|
3276 | ThermoStates = Choices.IndependentVariables.pT,
|
---|
3277 | mediumName=data.name,
|
---|
3278 | substanceNames={data.name},
|
---|
3279 | singleState=false,
|
---|
3280 | Temperature(min=200, max=6000, start=500, nominal=500),
|
---|
3281 | SpecificEnthalpy(start=if referenceChoice==ReferenceEnthalpy.ZeroAt0K then data.H0 else
|
---|
3282 | if referenceChoice==ReferenceEnthalpy.UserDefined then h_offset else 0, nominal=1.0e5),
|
---|
3283 | Density(start=10, nominal=10),
|
---|
3284 | AbsolutePressure(start=10e5, nominal=10e5));
|
---|
3285 |
|
---|
3286 | redeclare record extends ThermodynamicState
|
---|
3287 | "thermodynamic state variables for ideal gases"
|
---|
3288 | AbsolutePressure p "Absolute pressure of medium";
|
---|
3289 | Temperature T "Temperature of medium";
|
---|
3290 | end ThermodynamicState;
|
---|
3291 |
|
---|
3292 | redeclare record extends FluidConstants "Extended fluid constants"
|
---|
3293 | Temperature criticalTemperature "critical temperature";
|
---|
3294 | AbsolutePressure criticalPressure "critical pressure";
|
---|
3295 | MolarVolume criticalMolarVolume "critical molar Volume";
|
---|
3296 | Real acentricFactor "Pitzer acentric factor";
|
---|
3297 | Temperature triplePointTemperature "triple point temperature";
|
---|
3298 | AbsolutePressure triplePointPressure "triple point pressure";
|
---|
3299 | Temperature meltingPoint "melting point at 101325 Pa";
|
---|
3300 | Temperature normalBoilingPoint "normal boiling point (at 101325 Pa)";
|
---|
3301 | DipoleMoment dipoleMoment
|
---|
3302 | "dipole moment of molecule in Debye (1 debye = 3.33564e10-30 C.m)";
|
---|
3303 | Boolean hasIdealGasHeatCapacity=false
|
---|
3304 | "true if ideal gas heat capacity is available";
|
---|
3305 | Boolean hasCriticalData=false "true if critical data are known";
|
---|
3306 | Boolean hasDipoleMoment=false "true if a dipole moment known";
|
---|
3307 | Boolean hasFundamentalEquation=false "true if a fundamental equation";
|
---|
3308 | Boolean hasLiquidHeatCapacity=false
|
---|
3309 | "true if liquid heat capacity is available";
|
---|
3310 | Boolean hasSolidHeatCapacity=false
|
---|
3311 | "true if solid heat capacity is available";
|
---|
3312 | Boolean hasAccurateViscosityData=false
|
---|
3313 | "true if accurate data for a viscosity function is available";
|
---|
3314 | Boolean hasAccurateConductivityData=false
|
---|
3315 | "true if accurate data for thermal conductivity is available";
|
---|
3316 | Boolean hasVapourPressureCurve=false
|
---|
3317 | "true if vapour pressure data, e.g., Antoine coefficents are known";
|
---|
3318 | Boolean hasAcentricFactor=false
|
---|
3319 | "true if Pitzer accentric factor is known";
|
---|
3320 | SpecificEnthalpy HCRIT0=0.0
|
---|
3321 | "Critical specific enthalpy of the fundamental equation";
|
---|
3322 | SpecificEntropy SCRIT0=0.0
|
---|
3323 | "Critical specific entropy of the fundamental equation";
|
---|
3324 | SpecificEnthalpy deltah=0.0
|
---|
3325 | "Difference between specific enthalpy model (h_m) and f.eq. (h_f) (h_m - h_f)";
|
---|
3326 | SpecificEntropy deltas=0.0
|
---|
3327 | "Difference between specific enthalpy model (s_m) and f.eq. (s_f) (s_m - s_f)";
|
---|
3328 | end FluidConstants;
|
---|
3329 |
|
---|
3330 | import SI = Modelica.SIunits;
|
---|
3331 | import Modelica.Math;
|
---|
3332 | import Modelica.Media.Interfaces.PartialMedium.Choices.ReferenceEnthalpy;
|
---|
3333 |
|
---|
3334 | constant Boolean excludeEnthalpyOfFormation=true
|
---|
3335 | "If true, enthalpy of formation Hf is not included in specific enthalpy h";
|
---|
3336 | constant ReferenceEnthalpy referenceChoice=Choices.
|
---|
3337 | ReferenceEnthalpy.ZeroAt0K "Choice of reference enthalpy";
|
---|
3338 | constant SpecificEnthalpy h_offset=0.0
|
---|
3339 | "User defined offset for reference enthalpy, if referenceChoice = UserDefined";
|
---|
3340 |
|
---|
3341 | constant IdealGases.Common.DataRecord data
|
---|
3342 | "Data record of ideal gas substance";
|
---|
3343 |
|
---|
3344 | constant FluidConstants[nS] fluidConstants
|
---|
3345 | "constant data for the fluid";
|
---|
3346 |
|
---|
3347 | redeclare model extends BaseProperties(
|
---|
3348 | T(stateSelect=if preferredMediumStates then StateSelect.prefer else StateSelect.default),
|
---|
3349 | p(stateSelect=if preferredMediumStates then StateSelect.prefer else StateSelect.default))
|
---|
3350 | "Base properties of ideal gas medium"
|
---|
3351 | equation
|
---|
3352 | assert(T >= 200 and T <= 6000, "
|
---|
3353 | Temperature T (= " + String(T) + " K) is not in the allowed range
|
---|
3354 | 200 K <= T <= 6000 K required from medium model \"" + mediumName + "\".
|
---|
3355 | ");
|
---|
3356 | MM = data.MM;
|
---|
3357 | R = data.R;
|
---|
3358 | h = h_T(data, T, excludeEnthalpyOfFormation, referenceChoice, h_offset);
|
---|
3359 | u = h - R*T;
|
---|
3360 |
|
---|
3361 | // Has to be written in the form d=f(p,T) in order that static
|
---|
3362 | // state selection for p and T is possible
|
---|
3363 | d = p/(R*T);
|
---|
3364 | // connect state with BaseProperties
|
---|
3365 | state.T = T;
|
---|
3366 | state.p = p;
|
---|
3367 | end BaseProperties;
|
---|
3368 |
|
---|
3369 | redeclare function setState_pTX
|
---|
3370 | "Return thermodynamic state as function of p, T and composition X"
|
---|
3371 | extends Modelica.Icons.Function;
|
---|
3372 | input AbsolutePressure p "Pressure";
|
---|
3373 | input Temperature T "Temperature";
|
---|
3374 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
3375 | output ThermodynamicState state;
|
---|
3376 | algorithm
|
---|
3377 | state := ThermodynamicState(p=p,T=T);
|
---|
3378 | end setState_pTX;
|
---|
3379 |
|
---|
3380 | redeclare function setState_phX
|
---|
3381 | "Return thermodynamic state as function of p, h and composition X"
|
---|
3382 | extends Modelica.Icons.Function;
|
---|
3383 | input AbsolutePressure p "Pressure";
|
---|
3384 | input SpecificEnthalpy h "Specific enthalpy";
|
---|
3385 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
3386 | output ThermodynamicState state;
|
---|
3387 | algorithm
|
---|
3388 | state := ThermodynamicState(p=p,T=T_h(h));
|
---|
3389 | end setState_phX;
|
---|
3390 |
|
---|
3391 | redeclare function setState_psX
|
---|
3392 | "Return thermodynamic state as function of p, s and composition X"
|
---|
3393 | extends Modelica.Icons.Function;
|
---|
3394 | input AbsolutePressure p "Pressure";
|
---|
3395 | input SpecificEntropy s "Specific entropy";
|
---|
3396 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
3397 | output ThermodynamicState state;
|
---|
3398 | algorithm
|
---|
3399 | state := ThermodynamicState(p=p,T=T_ps(p,s));
|
---|
3400 | end setState_psX;
|
---|
3401 |
|
---|
3402 | redeclare function setState_dTX
|
---|
3403 | "Return thermodynamic state as function of d, T and composition X"
|
---|
3404 | extends Modelica.Icons.Function;
|
---|
3405 | input Density d "density";
|
---|
3406 | input Temperature T "Temperature";
|
---|
3407 | input MassFraction X[:]=reference_X "Mass fractions";
|
---|
3408 | output ThermodynamicState state;
|
---|
3409 | algorithm
|
---|
3410 | state := ThermodynamicState(p=d*data.R*T,T=T);
|
---|
3411 | end setState_dTX;
|
---|
3412 |
|
---|
3413 | redeclare function extends setSmoothState
|
---|
3414 | "Return thermodynamic state so that it smoothly approximates: if x > 0 then state_a else state_b"
|
---|
3415 | algorithm
|
---|
3416 | state := ThermodynamicState(p=Media.Common.smoothStep(x, state_a.p, state_b.p, x_small),
|
---|
3417 | T=Media.Common.smoothStep(x, state_a.T, state_b.T, x_small));
|
---|
3418 | end setSmoothState;
|
---|
3419 |
|
---|
3420 | redeclare function extends pressure "return pressure of ideal gas"
|
---|
3421 | algorithm
|
---|
3422 | p := state.p;
|
---|
3423 | end pressure;
|
---|
3424 |
|
---|
3425 | redeclare function extends temperature
|
---|
3426 | "return temperature of ideal gas"
|
---|
3427 | algorithm
|
---|
3428 | T := state.T;
|
---|
3429 | end temperature;
|
---|
3430 |
|
---|
3431 | redeclare function extends density "return density of ideal gas"
|
---|
3432 | algorithm
|
---|
3433 | d := state.p/(data.R*state.T);
|
---|
3434 | end density;
|
---|
3435 |
|
---|
3436 | redeclare function extends specificEnthalpy "Return specific enthalpy"
|
---|
3437 | extends Modelica.Icons.Function;
|
---|
3438 | algorithm
|
---|
3439 | h := h_T(data,state.T);
|
---|
3440 | end specificEnthalpy;
|
---|
3441 |
|
---|
3442 | redeclare function extends specificInternalEnergy
|
---|
3443 | "Return specific internal energy"
|
---|
3444 | extends Modelica.Icons.Function;
|
---|
3445 | algorithm
|
---|
3446 | u := h_T(data,state.T) - data.R*state.T;
|
---|
3447 | end specificInternalEnergy;
|
---|
3448 |
|
---|
3449 | redeclare function extends specificEntropy "Return specific entropy"
|
---|
3450 | extends Modelica.Icons.Function;
|
---|
3451 | algorithm
|
---|
3452 | s := s0_T(data, state.T) - data.R*Modelica.Math.log(state.p/reference_p);
|
---|
3453 | end specificEntropy;
|
---|
3454 |
|
---|
3455 | redeclare function extends specificGibbsEnergy
|
---|
3456 | "Return specific Gibbs energy"
|
---|
3457 | extends Modelica.Icons.Function;
|
---|
3458 | algorithm
|
---|
3459 | g := h_T(data,state.T) - state.T*specificEntropy(state);
|
---|
3460 | end specificGibbsEnergy;
|
---|
3461 |
|
---|
3462 | redeclare function extends specificHelmholtzEnergy
|
---|
3463 | "Return specific Helmholtz energy"
|
---|
3464 | extends Modelica.Icons.Function;
|
---|
3465 | algorithm
|
---|
3466 | f := h_T(data,state.T) - data.R*state.T - state.T*specificEntropy(state);
|
---|
3467 | end specificHelmholtzEnergy;
|
---|
3468 |
|
---|
3469 | redeclare function extends specificHeatCapacityCp
|
---|
3470 | "Return specific heat capacity at constant pressure"
|
---|
3471 | algorithm
|
---|
3472 | cp := cp_T(data, state.T);
|
---|
3473 | end specificHeatCapacityCp;
|
---|
3474 |
|
---|
3475 | redeclare function extends specificHeatCapacityCv
|
---|
3476 | "Compute specific heat capacity at constant volume from temperature and gas data"
|
---|
3477 | algorithm
|
---|
3478 | cv := cp_T(data, state.T) - data.R;
|
---|
3479 | end specificHeatCapacityCv;
|
---|
3480 |
|
---|
3481 | redeclare function extends isentropicExponent
|
---|
3482 | "Return isentropic exponent"
|
---|
3483 | algorithm
|
---|
3484 | gamma := specificHeatCapacityCp(state)/specificHeatCapacityCv(state);
|
---|
3485 | end isentropicExponent;
|
---|
3486 |
|
---|
3487 | redeclare function extends velocityOfSound "Return velocity of sound"
|
---|
3488 | extends Modelica.Icons.Function;
|
---|
3489 | algorithm
|
---|
3490 | a := sqrt(max(0,data.R*state.T*cp_T(data, state.T)/specificHeatCapacityCv(state)));
|
---|
3491 | end velocityOfSound;
|
---|
3492 |
|
---|
3493 | function isentropicEnthalpyApproximation
|
---|
3494 | "approximate method of calculating h_is from upstream properties and downstream pressure"
|
---|
3495 | extends Modelica.Icons.Function;
|
---|
3496 | input SI.Pressure p2 "downstream pressure";
|
---|
3497 | input ThermodynamicState state "properties at upstream location";
|
---|
3498 | input Boolean exclEnthForm=excludeEnthalpyOfFormation
|
---|
3499 | "If true, enthalpy of formation Hf is not included in specific enthalpy h";
|
---|
3500 | input ReferenceEnthalpy refChoice=referenceChoice
|
---|
3501 | "Choice of reference enthalpy";
|
---|
3502 | input SpecificEnthalpy h_off=h_offset
|
---|
3503 | "User defined offset for reference enthalpy, if referenceChoice = UserDefined";
|
---|
3504 | output SI.SpecificEnthalpy h_is "isentropic enthalpy";
|
---|
3505 | protected
|
---|
3506 | IsentropicExponent gamma = isentropicExponent(state)
|
---|
3507 | "Isentropic exponent";
|
---|
3508 | algorithm
|
---|
3509 | h_is := h_T(data,state.T,exclEnthForm,refChoice,h_off) +
|
---|
3510 | gamma/(gamma - 1.0)*state.p/density(state)*((p2/state.p)^((gamma - 1)/gamma) - 1.0);
|
---|
3511 | end isentropicEnthalpyApproximation;
|
---|
3512 |
|
---|
3513 | redeclare function extends isentropicEnthalpy
|
---|
3514 | "Return isentropic enthalpy"
|
---|
3515 | input Boolean exclEnthForm=excludeEnthalpyOfFormation
|
---|
3516 | "If true, enthalpy of formation Hf is not included in specific enthalpy h";
|
---|
3517 | input ReferenceEnthalpy refChoice=referenceChoice
|
---|
3518 | "Choice of reference enthalpy";
|
---|
3519 | input SpecificEnthalpy h_off=h_offset
|
---|
3520 | "User defined offset for reference enthalpy, if referenceChoice = UserDefined";
|
---|
3521 | algorithm
|
---|
3522 | h_is := isentropicEnthalpyApproximation(p_downstream,refState,exclEnthForm,refChoice,h_off);
|
---|
3523 | end isentropicEnthalpy;
|
---|
3524 |
|
---|
3525 | redeclare function extends isobaricExpansionCoefficient
|
---|
3526 | "Returns overall the isobaric expansion coefficient beta"
|
---|
3527 | algorithm
|
---|
3528 | beta := 1/state.T;
|
---|
3529 | end isobaricExpansionCoefficient;
|
---|
3530 |
|
---|
3531 | redeclare function extends isothermalCompressibility
|
---|
3532 | "Returns overall the isothermal compressibility factor"
|
---|
3533 | algorithm
|
---|
3534 | kappa := 1.0/state.p;
|
---|
3535 | end isothermalCompressibility;
|
---|
3536 |
|
---|
3537 | redeclare function extends density_derp_T
|
---|
3538 | "Returns the partial derivative of density with respect to pressure at constant temperature"
|
---|
3539 | algorithm
|
---|
3540 | ddpT := 1/(state.T*data.R);
|
---|
3541 | end density_derp_T;
|
---|
3542 |
|
---|
3543 | redeclare function extends density_derT_p
|
---|
3544 | "Returns the partial derivative of density with respect to temperature at constant pressure"
|
---|
3545 | algorithm
|
---|
3546 | ddTp := -state.p/(state.T*state.T*data.R);
|
---|
3547 | end density_derT_p;
|
---|
3548 |
|
---|
3549 | redeclare function extends density_derX
|
---|
3550 | "Returns the partial derivative of density with respect to mass fractions at constant pressure and temperature"
|
---|
3551 | algorithm
|
---|
3552 | dddX := fill(0,nX);
|
---|
3553 | end density_derX;
|
---|
3554 |
|
---|
3555 | function cp_T
|
---|
3556 | "Compute specific heat capacity at constant pressure from temperature and gas data"
|
---|
3557 | extends Modelica.Icons.Function;
|
---|
3558 | input IdealGases.Common.DataRecord data "Ideal gas data";
|
---|
3559 | input SI.Temperature T "Temperature";
|
---|
3560 | output SI.SpecificHeatCapacity cp
|
---|
3561 | "Specific heat capacity at temperature T";
|
---|
3562 | algorithm
|
---|
3563 | cp := smooth(0,if T < data.Tlimit then data.R*(1/(T*T)*(data.alow[1] + T*(
|
---|
3564 | data.alow[2] + T*(1.*data.alow[3] + T*(data.alow[4] + T*(data.alow[5] + T
|
---|
3565 | *(data.alow[6] + data.alow[7]*T))))))) else data.R*(1/(T*T)*(data.ahigh[1]
|
---|
3566 | + T*(data.ahigh[2] + T*(1.*data.ahigh[3] + T*(data.ahigh[4] + T*(data.
|
---|
3567 | ahigh[5] + T*(data.ahigh[6] + data.ahigh[7]*T))))))));
|
---|
3568 | annotation (InlineNoEvent=false,smoothOrder=2);
|
---|
3569 | end cp_T;
|
---|
3570 |
|
---|
3571 | function cp_Tlow
|
---|
3572 | "Compute specific heat capacity at constant pressure, low T region"
|
---|
3573 | extends Modelica.Icons.Function;
|
---|
3574 | input IdealGases.Common.DataRecord data "Ideal gas data";
|
---|
3575 | input SI.Temperature T "Temperature";
|
---|
3576 | output SI.SpecificHeatCapacity cp
|
---|
3577 | "Specific heat capacity at temperature T";
|
---|
3578 | algorithm
|
---|
3579 | cp := data.R*(1/(T*T)*(data.alow[1] + T*(
|
---|
3580 | data.alow[2] + T*(1.*data.alow[3] + T*(data.alow[4] + T*(data.alow[5] + T
|
---|
3581 | *(data.alow[6] + data.alow[7]*T)))))));
|
---|
3582 | annotation (Inline=false, derivative(zeroDerivative=data) = cp_Tlow_der);
|
---|
3583 | end cp_Tlow;
|
---|
3584 |
|
---|
3585 | function cp_Tlow_der
|
---|
3586 | "Compute specific heat capacity at constant pressure, low T region"
|
---|
3587 | extends Modelica.Icons.Function;
|
---|
3588 | input IdealGases.Common.DataRecord data "Ideal gas data";
|
---|
3589 | input SI.Temperature T "Temperature";
|
---|
3590 | input Real dT "Temperature derivative";
|
---|
3591 | output Real cp_der "Derivative of specific heat capacity";
|
---|
3592 | algorithm
|
---|
3593 | cp_der := dT*data.R/(T*T*T)*(-2*data.alow[1] + T*(
|
---|
3594 | -data.alow[2] + T*T*(data.alow[4] + T*(2.*data.alow[5] + T
|
---|
3595 | *(3.*data.alow[6] + 4.*data.alow[7]*T)))));
|
---|
3596 | end cp_Tlow_der;
|
---|
3597 |
|
---|
3598 | function h_T "Compute specific enthalpy from temperature and gas data; reference is decided by the
|
---|
3599 | refChoice input, or by the referenceChoice package constant by default"
|
---|
3600 | import Modelica.Media.Interfaces.PartialMedium.Choices;
|
---|
3601 | extends Modelica.Icons.Function;
|
---|
3602 | input IdealGases.Common.DataRecord data "Ideal gas data";
|
---|
3603 | input SI.Temperature T "Temperature";
|
---|
3604 | input Boolean exclEnthForm=excludeEnthalpyOfFormation
|
---|
3605 | "If true, enthalpy of formation Hf is not included in specific enthalpy h";
|
---|
3606 | input Choices.ReferenceEnthalpy refChoice=referenceChoice
|
---|
3607 | "Choice of reference enthalpy";
|
---|
3608 | input SI.SpecificEnthalpy h_off=h_offset
|
---|
3609 | "User defined offset for reference enthalpy, if referenceChoice = UserDefined";
|
---|
3610 | output SI.SpecificEnthalpy h "Specific enthalpy at temperature T";
|
---|
3611 | // annotation (InlineNoEvent=false, Inline=false,
|
---|
3612 | // derivative(zeroDerivative=data,
|
---|
3613 | // zeroDerivative=exclEnthForm,
|
---|
3614 | // zeroDerivative=refChoice,
|
---|
3615 | // zeroDerivative=h_off) = h_T_der);
|
---|
3616 | algorithm
|
---|
3617 | h := smooth(0,(if T < data.Tlimit then data.R*((-data.alow[1] + T*(data.
|
---|
3618 | blow[1] + data.alow[2]*Math.log(T) + T*(1.*data.alow[3] + T*(0.5*data.
|
---|
3619 | alow[4] + T*(1/3*data.alow[5] + T*(0.25*data.alow[6] + 0.2*data.alow[7]*T))))))
|
---|
3620 | /T) else data.R*((-data.ahigh[1] + T*(data.bhigh[1] + data.ahigh[2]*
|
---|
3621 | Math.log(T) + T*(1.*data.ahigh[3] + T*(0.5*data.ahigh[4] + T*(1/3*data.
|
---|
3622 | ahigh[5] + T*(0.25*data.ahigh[6] + 0.2*data.ahigh[7]*T))))))/T)) + (if
|
---|
3623 | exclEnthForm then -data.Hf else 0.0) + (if (refChoice
|
---|
3624 | == Choices.ReferenceEnthalpy.ZeroAt0K) then data.H0 else 0.0) + (if
|
---|
3625 | refChoice == Choices.ReferenceEnthalpy.UserDefined then h_off else
|
---|
3626 | 0.0));
|
---|
3627 | annotation (Inline=false,smoothOrder=2);
|
---|
3628 | end h_T;
|
---|
3629 |
|
---|
3630 | function h_T_der "derivative function for h_T"
|
---|
3631 | import Modelica.Media.Interfaces.PartialMedium.Choices;
|
---|
3632 | extends Modelica.Icons.Function;
|
---|
3633 | input IdealGases.Common.DataRecord data "Ideal gas data";
|
---|
3634 | input SI.Temperature T "Temperature";
|
---|
3635 | input Boolean exclEnthForm=excludeEnthalpyOfFormation
|
---|
3636 | "If true, enthalpy of formation Hf is not included in specific enthalpy h";
|
---|
3637 | input Choices.ReferenceEnthalpy refChoice=referenceChoice
|
---|
3638 | "Choice of reference enthalpy";
|
---|
3639 | input SI.SpecificEnthalpy h_off=h_offset
|
---|
3640 | "User defined offset for reference enthalpy, if referenceChoice = UserDefined";
|
---|
3641 | input Real dT "Temperature derivative";
|
---|
3642 | output Real h_der "Specific enthalpy at temperature T";
|
---|
3643 | algorithm
|
---|
3644 | h_der := dT*cp_T(data,T);
|
---|
3645 | end h_T_der;
|
---|
3646 |
|
---|
3647 | function h_Tlow "Compute specific enthalpy, low T region; reference is decided by the
|
---|
3648 | refChoice input, or by the referenceChoice package constant by default"
|
---|
3649 | import Modelica.Media.Interfaces.PartialMedium.Choices;
|
---|
3650 | extends Modelica.Icons.Function;
|
---|
3651 | input IdealGases.Common.DataRecord data "Ideal gas data";
|
---|
3652 | input SI.Temperature T "Temperature";
|
---|
3653 | input Boolean exclEnthForm=excludeEnthalpyOfFormation
|
---|
3654 | "If true, enthalpy of formation Hf is not included in specific enthalpy h";
|
---|
3655 | input Choices.ReferenceEnthalpy refChoice=referenceChoice
|
---|
3656 | "Choice of reference enthalpy";
|
---|
3657 | input SI.SpecificEnthalpy h_off=h_offset
|
---|
3658 | "User defined offset for reference enthalpy, if referenceChoice = UserDefined";
|
---|
3659 | output SI.SpecificEnthalpy h "Specific enthalpy at temperature T";
|
---|
3660 | // annotation (Inline=false,InlineNoEvent=false, derivative(zeroDerivative=data,
|
---|
3661 | // zeroDerivative=exclEnthForm,
|
---|
3662 | // zeroDerivative=refChoice,
|
---|
3663 | // zeroDerivative=h_off) = h_Tlow_der);
|
---|
3664 | algorithm
|
---|
3665 | h := data.R*((-data.alow[1] + T*(data.
|
---|
3666 | blow[1] + data.alow[2]*Math.log(T) + T*(1.*data.alow[3] + T*(0.5*data.
|
---|
3667 | alow[4] + T*(1/3*data.alow[5] + T*(0.25*data.alow[6] + 0.2*data.alow[7]*T))))))
|
---|
3668 | /T) + (if
|
---|
3669 | exclEnthForm then -data.Hf else 0.0) + (if (refChoice
|
---|
3670 | == Choices.ReferenceEnthalpy.ZeroAt0K) then data.H0 else 0.0) + (if
|
---|
3671 | refChoice == Choices.ReferenceEnthalpy.UserDefined then h_off else
|
---|
3672 | 0.0);
|
---|
3673 | annotation(Inline=false,InlineNoEvent=false,smoothOrder=2);
|
---|
3674 | end h_Tlow;
|
---|
3675 |
|
---|
3676 | function h_Tlow_der "Compute specific enthalpy, low T region; reference is decided by the
|
---|
3677 | refChoice input, or by the referenceChoice package constant by default"
|
---|
3678 | import Modelica.Media.Interfaces.PartialMedium.Choices;
|
---|
3679 | extends Modelica.Icons.Function;
|
---|
3680 | input IdealGases.Common.DataRecord data "Ideal gas data";
|
---|
3681 | input SI.Temperature T "Temperature";
|
---|
3682 | input Boolean exclEnthForm=excludeEnthalpyOfFormation
|
---|
3683 | "If true, enthalpy of formation Hf is not included in specific enthalpy h";
|
---|
3684 | input Choices.ReferenceEnthalpy refChoice=referenceChoice
|
---|
3685 | "Choice of reference enthalpy";
|
---|
3686 | input SI.SpecificEnthalpy h_off=h_offset
|
---|
3687 | "User defined offset for reference enthalpy, if referenceChoice = UserDefined";
|
---|
3688 | input Real dT(unit="K/s") "Temperature derivative";
|
---|
3689 | output Real h_der(unit="J/(kg.s)")
|
---|
3690 | "Derivative of specific enthalpy at temperature T";
|
---|
3691 | algorithm
|
---|
3692 | h_der := dT*cp_Tlow(data,T);
|
---|
3693 | end h_Tlow_der;
|
---|
3694 |
|
---|
3695 | function s0_T "Compute specific entropy from temperature and gas data"
|
---|
3696 | extends Modelica.Icons.Function;
|
---|
3697 | input IdealGases.Common.DataRecord data "Ideal gas data";
|
---|
3698 | input SI.Temperature T "Temperature";
|
---|
3699 | output SI.SpecificEntropy s "Specific entropy at temperature T";
|
---|
3700 | algorithm
|
---|
3701 | s := noEvent(if T < data.Tlimit then data.R*(data.blow[2] - 0.5*data.alow[
|
---|
3702 | 1]/(T*T) - data.alow[2]/T + data.alow[3]*Math.log(T) + T*(
|
---|
3703 | data.alow[4] + T*(0.5*data.alow[5] + T*(1/3*data.alow[6] + 0.25*data.alow[
|
---|
3704 | 7]*T)))) else data.R*(data.bhigh[2] - 0.5*data.ahigh[1]/(T*T) - data.
|
---|
3705 | ahigh[2]/T + data.ahigh[3]*Math.log(T) + T*(data.ahigh[4]
|
---|
3706 | + T*(0.5*data.ahigh[5] + T*(1/3*data.ahigh[6] + 0.25*data.ahigh[7]*T)))));
|
---|
3707 | annotation (InlineNoEvent=false,smoothOrder=1);
|
---|
3708 | end s0_T;
|
---|
3709 |
|
---|
3710 | function s0_Tlow "Compute specific entropy, low T region"
|
---|
3711 | extends Modelica.Icons.Function;
|
---|
3712 | input IdealGases.Common.DataRecord data "Ideal gas data";
|
---|
3713 | input SI.Temperature T "Temperature";
|
---|
3714 | output SI.SpecificEntropy s "Specific entropy at temperature T";
|
---|
3715 | algorithm
|
---|
3716 | s := data.R*(data.blow[2] - 0.5*data.alow[
|
---|
3717 | 1]/(T*T) - data.alow[2]/T + data.alow[3]*Math.log(T) + T*(
|
---|
3718 | data.alow[4] + T*(0.5*data.alow[5] + T*(1/3*data.alow[6] + 0.25*data.alow[
|
---|
3719 | 7]*T))));
|
---|
3720 | annotation (InlineNoEvent=false,smoothOrder=1);
|
---|
3721 | end s0_Tlow;
|
---|
3722 |
|
---|
3723 | function dynamicViscosityLowPressure
|
---|
3724 | "Dynamic viscosity of low pressure gases"
|
---|
3725 | extends Modelica.Icons.Function;
|
---|
3726 | input SI.Temp_K T "Gas temperature";
|
---|
3727 | input SI.Temp_K Tc "Critical temperature of gas";
|
---|
3728 | input SI.MolarMass M "Molar mass of gas";
|
---|
3729 | input SI.MolarVolume Vc "Critical molar volume of gas";
|
---|
3730 | input Real w "Acentric factor of gas";
|
---|
3731 | input DipoleMoment mu "Dipole moment of gas molecule";
|
---|
3732 | input Real k = 0.0 "Special correction for highly polar substances";
|
---|
3733 | output SI.DynamicViscosity eta "Dynamic viscosity of gas";
|
---|
3734 | protected
|
---|
3735 | parameter Real Const1_SI=40.785*10^(-9.5)
|
---|
3736 | "Constant in formula for eta converted to SI units";
|
---|
3737 | parameter Real Const2_SI=131.3/1000.0
|
---|
3738 | "Constant in formula for mur converted to SI units";
|
---|
3739 | Real mur=Const2_SI*mu/sqrt(Vc*Tc)
|
---|
3740 | "Dimensionless dipole moment of gas molecule";
|
---|
3741 | Real Fc=1 - 0.2756*w + 0.059035*mur^4 + k
|
---|
3742 | "Factor to account for molecular shape and polarities of gas";
|
---|
3743 | Real Tstar "Dimensionless temperature defined by equation below";
|
---|
3744 | Real Ov "Viscosity collision integral for the gas";
|
---|
3745 |
|
---|
3746 | algorithm
|
---|
3747 | Tstar := 1.2593*T/Tc;
|
---|
3748 | Ov := 1.16145*Tstar^(-0.14874) + 0.52487*exp(-0.7732*Tstar) + 2.16178*exp(-2.43787
|
---|
3749 | *Tstar);
|
---|
3750 | eta := Const1_SI*Fc*sqrt(M*T)/(Vc^(2/3)*Ov);
|
---|
3751 | annotation (smoothOrder=2,
|
---|
3752 | Documentation(info="<html>
|
---|
3753 | <p>
|
---|
3754 | The used formula are based on the method of Chung et al (1984, 1988) referred to in ref [1] chapter 9.
|
---|
3755 | The formula 9-4.10 is the one being used. The Formula is given in non-SI units, the follwong onversion constants were used to
|
---|
3756 | transform the formula to SI units:
|
---|
3757 | </p>
|
---|
3758 |
|
---|
3759 | <ul>
|
---|
3760 | <li> <b>Const1_SI:</b> The factor 10^(-9.5) =10^(-2.5)*1e-7 where the
|
---|
3761 | factor 10^(-2.5) originates from the conversion of g/mol->kg/mol + cm^3/mol->m^3/mol
|
---|
3762 | and the factor 1e-7 is due to conversionfrom microPoise->Pa.s.</li>
|
---|
3763 | <li> <b>Const2_SI:</b> The factor 1/3.335641e-27 = 1e-3/3.335641e-30
|
---|
3764 | where the factor 3.335641e-30 comes from debye->C.m and
|
---|
3765 | 1e-3 is due to conversion from cm^3/mol->m^3/mol</li>
|
---|
3766 | </ul>
|
---|
3767 |
|
---|
3768 | <h4>References:</h4>
|
---|
3769 | <p>
|
---|
3770 | [1] Bruce E. Poling, John E. Prausnitz, John P. O'Connell, \"The Properties of Gases and Liquids\" 5th Ed. Mc Graw Hill.
|
---|
3771 | </p>
|
---|
3772 |
|
---|
3773 | <h4>Author</h4>
|
---|
3774 | <p>T. Skoglund, Lund, Sweden, 2004-08-31</p>
|
---|
3775 |
|
---|
3776 | </html>"));
|
---|
3777 | end dynamicViscosityLowPressure;
|
---|
3778 |
|
---|
3779 | redeclare replaceable function extends dynamicViscosity
|
---|
3780 | "dynamic viscosity"
|
---|
3781 | algorithm
|
---|
3782 | assert(fluidConstants[1].hasCriticalData,
|
---|
3783 | "Failed to compute dynamicViscosity: For the species \"" + mediumName + "\" no critical data is available.");
|
---|
3784 | assert(fluidConstants[1].hasDipoleMoment,
|
---|
3785 | "Failed to compute dynamicViscosity: For the species \"" + mediumName + "\" no critical data is available.");
|
---|
3786 | eta := dynamicViscosityLowPressure(state.T,
|
---|
3787 | fluidConstants[1].criticalTemperature,
|
---|
3788 | fluidConstants[1].molarMass,
|
---|
3789 | fluidConstants[1].criticalMolarVolume,
|
---|
3790 | fluidConstants[1].acentricFactor,
|
---|
3791 | fluidConstants[1].dipoleMoment);
|
---|
3792 | annotation (smoothOrder=2);
|
---|
3793 | end dynamicViscosity;
|
---|
3794 |
|
---|
3795 | function thermalConductivityEstimate
|
---|
3796 | "Thermal conductivity of polyatomic gases(Eucken and Modified Eucken correlation)"
|
---|
3797 | extends Modelica.Icons.Function;
|
---|
3798 | input SpecificHeatCapacity Cp "Constant pressure heat capacity";
|
---|
3799 | input DynamicViscosity eta "Dynamic viscosity";
|
---|
3800 | input Integer method(min=1,max=2)=1
|
---|
3801 | "1: Eucken Method, 2: Modified Eucken Method";
|
---|
3802 | output ThermalConductivity lambda "Thermal conductivity [W/(m.k)]";
|
---|
3803 | algorithm
|
---|
3804 | lambda := if method == 1 then eta*(Cp - data.R + (9/4)*data.R) else eta*(Cp
|
---|
3805 | - data.R)*(1.32 + 1.77/((Cp/Modelica.Constants.R) - 1.0));
|
---|
3806 | annotation (smoothOrder=2,
|
---|
3807 | Documentation(info="<html>
|
---|
3808 | <p>
|
---|
3809 | This function provides two similar methods for estimating the
|
---|
3810 | thermal conductivity of polyatomic gases.
|
---|
3811 | The Eucken method (input method == 1) gives good results for low temperatures,
|
---|
3812 | but it tends to give an underestimated value of the thermal conductivity
|
---|
3813 | (lambda) at higher temperatures.<br>
|
---|
3814 | The Modified Eucken method (input method == 2) gives good results for
|
---|
3815 | high-temperatures, but it tends to give an overestimated value of the
|
---|
3816 | thermal conductivity (lambda) at low temperatures.
|
---|
3817 | </p>
|
---|
3818 | </html>"));
|
---|
3819 | end thermalConductivityEstimate;
|
---|
3820 |
|
---|
3821 | redeclare replaceable function extends thermalConductivity
|
---|
3822 | "thermal conductivity of gas"
|
---|
3823 | input Integer method=1 "1: Eucken Method, 2: Modified Eucken Method";
|
---|
3824 | algorithm
|
---|
3825 | assert(fluidConstants[1].hasCriticalData,
|
---|
3826 | "Failed to compute thermalConductivity: For the species \"" + mediumName + "\" no critical data is available.");
|
---|
3827 | lambda := thermalConductivityEstimate(specificHeatCapacityCp(state),
|
---|
3828 | dynamicViscosity(state), method=method);
|
---|
3829 | annotation (smoothOrder=2);
|
---|
3830 | end thermalConductivity;
|
---|
3831 |
|
---|
3832 | redeclare function extends molarMass
|
---|
3833 | "return the molar mass of the medium"
|
---|
3834 | algorithm
|
---|
3835 | MM := data.MM;
|
---|
3836 | end molarMass;
|
---|
3837 |
|
---|
3838 | function T_h "Compute temperature from specific enthalpy"
|
---|
3839 | input SpecificEnthalpy h "Specific enthalpy";
|
---|
3840 | output Temperature T "Temperature";
|
---|
3841 |
|
---|
3842 | protected
|
---|
3843 | package Internal
|
---|
3844 | "Solve h(data,T) for T with given h (use only indirectly via temperature_phX)"
|
---|
3845 | extends Modelica.Media.Common.OneNonLinearEquation;
|
---|
3846 | redeclare record extends f_nonlinear_Data
|
---|
3847 | "Data to be passed to non-linear function"
|
---|
3848 | extends Modelica.Media.IdealGases.Common.DataRecord;
|
---|
3849 | end f_nonlinear_Data;
|
---|
3850 |
|
---|
3851 | redeclare function extends f_nonlinear
|
---|
3852 | algorithm
|
---|
3853 | y := h_T(f_nonlinear_data,x);
|
---|
3854 | end f_nonlinear;
|
---|
3855 |
|
---|
3856 | // Dummy definition has to be added for current Dymola
|
---|
3857 | redeclare function extends solve
|
---|
3858 | end solve;
|
---|
3859 | end Internal;
|
---|
3860 |
|
---|
3861 | algorithm
|
---|
3862 | T := Internal.solve(h, 200, 6000, 1.0e5, {1}, data);
|
---|
3863 | end T_h;
|
---|
3864 |
|
---|
3865 | function T_ps "Compute temperature from pressure and specific entropy"
|
---|
3866 | input AbsolutePressure p "Pressure";
|
---|
3867 | input SpecificEntropy s "Specific entropy";
|
---|
3868 | output Temperature T "Temperature";
|
---|
3869 |
|
---|
3870 | protected
|
---|
3871 | package Internal
|
---|
3872 | "Solve h(data,T) for T with given h (use only indirectly via temperature_phX)"
|
---|
3873 | extends Modelica.Media.Common.OneNonLinearEquation;
|
---|
3874 | redeclare record extends f_nonlinear_Data
|
---|
3875 | "Data to be passed to non-linear function"
|
---|
3876 | extends Modelica.Media.IdealGases.Common.DataRecord;
|
---|
3877 | end f_nonlinear_Data;
|
---|
3878 |
|
---|
3879 | redeclare function extends f_nonlinear
|
---|
3880 | algorithm
|
---|
3881 | y := s0_T(f_nonlinear_data,x)- data.R*Modelica.Math.log(p/reference_p);
|
---|
3882 | end f_nonlinear;
|
---|
3883 |
|
---|
3884 | // Dummy definition has to be added for current Dymola
|
---|
3885 | redeclare function extends solve
|
---|
3886 | end solve;
|
---|
3887 | end Internal;
|
---|
3888 |
|
---|
3889 | algorithm
|
---|
3890 | T := Internal.solve(s, 200, 6000, p, {1}, data);
|
---|
3891 | end T_ps;
|
---|
3892 |
|
---|
3893 | annotation (
|
---|
3894 | Documentation(info="<HTML>
|
---|
3895 | <p>
|
---|
3896 | This model calculates medium properties
|
---|
3897 | for an ideal gas of a single substance, or for an ideal
|
---|
3898 | gas consisting of several substances where the
|
---|
3899 | mass fractions are fixed. Independent variables
|
---|
3900 | are temperature <b>T</b> and pressure <b>p</b>.
|
---|
3901 | Only density is a function of T and p. All other quantities
|
---|
3902 | are solely a function of T. The properties
|
---|
3903 | are valid in the range:
|
---|
3904 | </p>
|
---|
3905 | <pre>
|
---|
3906 | 200 K ≤ T ≤ 6000 K
|
---|
3907 | </pre>
|
---|
3908 | <p>
|
---|
3909 | The following quantities are always computed:
|
---|
3910 | </p>
|
---|
3911 | <table border=1 cellspacing=0 cellpadding=2>
|
---|
3912 | <tr><td valign=\"top\"><b>Variable</b></td>
|
---|
3913 | <td valign=\"top\"><b>Unit</b></td>
|
---|
3914 | <td valign=\"top\"><b>Description</b></td></tr>
|
---|
3915 | <tr><td valign=\"top\">h</td>
|
---|
3916 | <td valign=\"top\">J/kg</td>
|
---|
3917 | <td valign=\"top\">specific enthalpy h = h(T)</td></tr>
|
---|
3918 | <tr><td valign=\"top\">u</td>
|
---|
3919 | <td valign=\"top\">J/kg</td>
|
---|
3920 | <td valign=\"top\">specific internal energy u = u(T)</b></td></tr>
|
---|
3921 | <tr><td valign=\"top\">d</td>
|
---|
3922 | <td valign=\"top\">kg/m^3</td>
|
---|
3923 | <td valign=\"top\">density d = d(p,T)</td></tr>
|
---|
3924 | </table>
|
---|
3925 | <p>
|
---|
3926 | For the other variables, see the functions in
|
---|
3927 | Modelica.Media.IdealGases.Common.SingleGasNasa.
|
---|
3928 | Note, dynamic viscosity and thermal conductivity are only provided
|
---|
3929 | for gases that use a data record from Modelica.Media.IdealGases.FluidData.
|
---|
3930 | Currently these are the following gases:
|
---|
3931 | </p>
|
---|
3932 | <pre>
|
---|
3933 | Ar
|
---|
3934 | C2H2_vinylidene
|
---|
3935 | C2H4
|
---|
3936 | C2H5OH
|
---|
3937 | C2H6
|
---|
3938 | C3H6_propylene
|
---|
3939 | C3H7OH
|
---|
3940 | C3H8
|
---|
3941 | C4H8_1_butene
|
---|
3942 | C4H9OH
|
---|
3943 | C4H10_n_butane
|
---|
3944 | C5H10_1_pentene
|
---|
3945 | C5H12_n_pentane
|
---|
3946 | C6H6
|
---|
3947 | C6H12_1_hexene
|
---|
3948 | C6H14_n_heptane
|
---|
3949 | C7H14_1_heptene
|
---|
3950 | C8H10_ethylbenz
|
---|
3951 | CH3OH
|
---|
3952 | CH4
|
---|
3953 | CL2
|
---|
3954 | CO
|
---|
3955 | CO2
|
---|
3956 | F2
|
---|
3957 | H2
|
---|
3958 | H2O
|
---|
3959 | He
|
---|
3960 | N2
|
---|
3961 | N2O
|
---|
3962 | NH3
|
---|
3963 | NO
|
---|
3964 | O2
|
---|
3965 | SO2
|
---|
3966 | SO3
|
---|
3967 | </pre>
|
---|
3968 | <p>
|
---|
3969 | <b>Sources for model and literature:</b><br>
|
---|
3970 | Original Data: Computer program for calculation of complex chemical
|
---|
3971 | equilibrium compositions and applications. Part 1: Analysis
|
---|
3972 | Document ID: 19950013764 N (95N20180) File Series: NASA Technical Reports
|
---|
3973 | Report Number: NASA-RP-1311 E-8017 NAS 1.61:1311
|
---|
3974 | Authors: Gordon, Sanford (NASA Lewis Research Center)
|
---|
3975 | Mcbride, Bonnie J. (NASA Lewis Research Center)
|
---|
3976 | Published: Oct 01, 1994.
|
---|
3977 | </p>
|
---|
3978 | <p><b>Known limits of validity:</b></br>
|
---|
3979 | The data is valid for
|
---|
3980 | temperatures between 200 K and 6000 K. A few of the data sets for
|
---|
3981 | monatomic gases have a discontinuous 1st derivative at 1000 K, but
|
---|
3982 | this never caused problems so far.
|
---|
3983 | </p>
|
---|
3984 | <p>
|
---|
3985 | This model has been copied from the ThermoFluid library
|
---|
3986 | and adapted to the Modelica.Media package.
|
---|
3987 | </p>
|
---|
3988 | </HTML>"),Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
|
---|
3989 | 100}}),
|
---|
3990 | graphics),
|
---|
3991 | Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
|
---|
3992 | 100}}),
|
---|
3993 | graphics));
|
---|
3994 | end SingleGasNasa;
|
---|
3995 |
|
---|
3996 | package FluidData "Critical data, dipole moments and related data"
|
---|
3997 | extends Modelica.Icons.Package;
|
---|
3998 | import Modelica.Media.Interfaces.PartialMedium;
|
---|
3999 | import Modelica.Media.IdealGases.Common.SingleGasesData;
|
---|
4000 |
|
---|
4001 | constant SingleGasNasa.FluidConstants N2(
|
---|
4002 | chemicalFormula = "N2",
|
---|
4003 | iupacName = "unknown",
|
---|
4004 | structureFormula = "unknown",
|
---|
4005 | casRegistryNumber = "7727-37-9",
|
---|
4006 | meltingPoint = 63.15,
|
---|
4007 | normalBoilingPoint = 77.35,
|
---|
4008 | criticalTemperature = 126.20,
|
---|
4009 | criticalPressure = 33.98e5,
|
---|
4010 | criticalMolarVolume = 90.10e-6,
|
---|
4011 | acentricFactor = 0.037,
|
---|
4012 | dipoleMoment = 0.0,
|
---|
4013 | molarMass = SingleGasesData.N2.MM,
|
---|
4014 | hasDipoleMoment = true,
|
---|
4015 | hasIdealGasHeatCapacity=true,
|
---|
4016 | hasCriticalData = true,
|
---|
4017 | hasAcentricFactor = true);
|
---|
4018 |
|
---|
4019 | constant SingleGasNasa.FluidConstants H2O(
|
---|
4020 | chemicalFormula = "H2O",
|
---|
4021 | iupacName = "unknown",
|
---|
4022 | structureFormula = "unknown",
|
---|
4023 | casRegistryNumber = "7732-18-5",
|
---|
4024 | meltingPoint = 273.15,
|
---|
4025 | normalBoilingPoint = 373.15,
|
---|
4026 | criticalTemperature = 647.14,
|
---|
4027 | criticalPressure = 220.64e5,
|
---|
4028 | criticalMolarVolume = 55.95e-6,
|
---|
4029 | acentricFactor = 0.344,
|
---|
4030 | dipoleMoment = 1.8,
|
---|
4031 | molarMass = SingleGasesData.H2O.MM,
|
---|
4032 | hasDipoleMoment = true,
|
---|
4033 | hasIdealGasHeatCapacity=true,
|
---|
4034 | hasCriticalData = true,
|
---|
4035 | hasAcentricFactor = true);
|
---|
4036 | annotation (Documentation(info="<html>
|
---|
4037 | <p>
|
---|
4038 | This package contains FluidConstants data records for the following 37 gases
|
---|
4039 | (see also the description in
|
---|
4040 | <a href=\"modelica://Modelica.Media.IdealGases\">Modelica.Media.IdealGases</a>):
|
---|
4041 | </p>
|
---|
4042 | <pre>
|
---|
4043 | Argon Methane Methanol Carbon Monoxide Carbon Dioxide
|
---|
4044 | Acetylene Ethylene Ethanol Ethane Propylene
|
---|
4045 | Propane 1-Propanol 1-Butene N-Butane 1-Pentene
|
---|
4046 | N-Pentane Benzene 1-Hexene N-Hexane 1-Heptane
|
---|
4047 | N-Heptane Ethylbenzene N-Octane Chlorine Fluorine
|
---|
4048 | Hydrogen Steam Helium Ammonia Nitric Oxide
|
---|
4049 | Nitrogen Dioxide Nitrogen Nitrous Oxide Neon Oxygen
|
---|
4050 | Sulfur Dioxide Sulfur Trioxide
|
---|
4051 | </pre>
|
---|
4052 |
|
---|
4053 | </html>"));
|
---|
4054 | end FluidData;
|
---|
4055 |
|
---|
4056 | package SingleGasesData
|
---|
4057 | "Ideal gas data based on the NASA Glenn coefficients"
|
---|
4058 | extends Modelica.Icons.Package;
|
---|
4059 |
|
---|
4060 | constant IdealGases.Common.DataRecord Air(
|
---|
4061 | name="Air",
|
---|
4062 | MM=0.0289651159,
|
---|
4063 | Hf=-4333.833858403446,
|
---|
4064 | H0=298609.6803431054,
|
---|
4065 | Tlimit=1000,
|
---|
4066 | alow={10099.5016,-196.827561,5.00915511,-0.00576101373,1.06685993e-005,-7.94029797e-009,
|
---|
4067 | 2.18523191e-012},
|
---|
4068 | blow={-176.796731,-3.921504225},
|
---|
4069 | ahigh={241521.443,-1257.8746,5.14455867,-0.000213854179,7.06522784e-008,-1.07148349e-011,
|
---|
4070 | 6.57780015e-016},
|
---|
4071 | bhigh={6462.26319,-8.147411905},
|
---|
4072 | R=287.0512249529787);
|
---|
4073 |
|
---|
4074 | constant IdealGases.Common.DataRecord H2O(
|
---|
4075 | name="H2O",
|
---|
4076 | MM=0.01801528,
|
---|
4077 | Hf=-13423382.81725291,
|
---|
4078 | H0=549760.6476280135,
|
---|
4079 | Tlimit=1000,
|
---|
4080 | alow={-39479.6083,575.573102,0.931782653,0.00722271286,-7.34255737e-006,
|
---|
4081 | 4.95504349e-009,-1.336933246e-012},
|
---|
4082 | blow={-33039.7431,17.24205775},
|
---|
4083 | ahigh={1034972.096,-2412.698562,4.64611078,0.002291998307,-6.836830479999999e-007,
|
---|
4084 | 9.426468930000001e-011,-4.82238053e-015},
|
---|
4085 | bhigh={-13842.86509,-7.97814851},
|
---|
4086 | R=461.5233290850878);
|
---|
4087 |
|
---|
4088 | constant IdealGases.Common.DataRecord N2(
|
---|
4089 | name="N2",
|
---|
4090 | MM=0.0280134,
|
---|
4091 | Hf=0,
|
---|
4092 | H0=309498.4543111511,
|
---|
4093 | Tlimit=1000,
|
---|
4094 | alow={22103.71497,-381.846182,6.08273836,-0.00853091441,1.384646189e-005,-9.62579362e-009,
|
---|
4095 | 2.519705809e-012},
|
---|
4096 | blow={710.846086,-10.76003744},
|
---|
4097 | ahigh={587712.406,-2239.249073,6.06694922,-0.00061396855,1.491806679e-007,-1.923105485e-011,
|
---|
4098 | 1.061954386e-015},
|
---|
4099 | bhigh={12832.10415,-15.86640027},
|
---|
4100 | R=296.8033869505308);
|
---|
4101 | annotation ( Documentation(info="<HTML>
|
---|
4102 | <p>This package contains ideal gas models for the 1241 ideal gases from</p>
|
---|
4103 | <blockquote>
|
---|
4104 | <p>McBride B.J., Zehe M.J., and Gordon S. (2002): <b>NASA Glenn Coefficients
|
---|
4105 | for Calculating Thermodynamic Properties of Individual Species</b>. NASA
|
---|
4106 | report TP-2002-211556</p>
|
---|
4107 | </blockquote>
|
---|
4108 |
|
---|
4109 | <pre>
|
---|
4110 | Ag BaOH+ C2H4O_ethylen_o DF In2I4 Nb ScO2
|
---|
4111 | Ag+ Ba_OH_2 CH3CHO_ethanal DOCl In2I6 Nb+ Sc2O
|
---|
4112 | Ag- BaS CH3COOH DO2 In2O Nb- Sc2O2
|
---|
4113 | Air Ba2 OHCH2COOH DO2- K NbCl5 Si
|
---|
4114 | Al Be C2H5 D2 K+ NbO Si+
|
---|
4115 | Al+ Be+ C2H5Br D2+ K- NbOCl3 Si-
|
---|
4116 | Al- Be++ C2H6 D2- KAlF4 NbO2 SiBr
|
---|
4117 | AlBr BeBr CH3N2CH3 D2O KBO2 Ne SiBr2
|
---|
4118 | AlBr2 BeBr2 C2H5OH D2O2 KBr Ne+ SiBr3
|
---|
4119 | AlBr3 BeCl CH3OCH3 D2S KCN Ni SiBr4
|
---|
4120 | AlC BeCl2 CH3O2CH3 e- KCl Ni+ SiC
|
---|
4121 | AlC2 BeF CCN F KF Ni- SiC2
|
---|
4122 | AlCl BeF2 CNC F+ KH NiCl SiCl
|
---|
4123 | AlCl+ BeH OCCN F- KI NiCl2 SiCl2
|
---|
4124 | AlCl2 BeH+ C2N2 FCN Kli NiO SiCl3
|
---|
4125 | AlCl3 BeH2 C2O FCO KNO2 NiS SiCl4
|
---|
4126 | AlF BeI C3 FO KNO3 O SiF
|
---|
4127 | AlF+ BeI2 C3H3_1_propynl FO2_FOO KNa O+ SiFCl
|
---|
4128 | AlFCl BeN C3H3_2_propynl FO2_OFO KO O- SiF2
|
---|
4129 | AlFCl2 BeO C3H4_allene F2 KOH OD SiF3
|
---|
4130 | AlF2 BeOH C3H4_propyne F2O K2 OD- SiF4
|
---|
4131 | AlF2- BeOH+ C3H4_cyclo F2O2 K2+ OH SiH
|
---|
4132 | AlF2Cl Be_OH_2 C3H5_allyl FS2F K2Br2 OH+ SiH+
|
---|
4133 | AlF3 BeS C3H6_propylene Fe K2CO3 OH- SiHBr3
|
---|
4134 | AlF4- Be2 C3H6_cyclo Fe+ K2C2N2 O2 SiHCl
|
---|
4135 | AlH Be2Cl4 C3H6O_propylox Fe_CO_5 K2Cl2 O2+ SiHCl3
|
---|
4136 | AlHCl Be2F4 C3H6O_acetone FeCl K2F2 O2- SiHF
|
---|
4137 | AlHCl2 Be2O C3H6O_propanal FeCl2 K2I2 O3 SiHF3
|
---|
4138 | AlHF Be2OF2 C3H7_n_propyl FeCl3 K2O P SiHI3
|
---|
4139 | AlHFCl Be2O2 C3H7_i_propyl FeO K2O+ P+ SiH2
|
---|
4140 | AlHF2 Be3O3 C3H8 Fe_OH_2 K2O2 P- SiH2Br2
|
---|
4141 | AlH2 Be4O4 C3H8O_1propanol Fe2Cl4 K2O2H2 PCl SiH2Cl2
|
---|
4142 | AlH2Cl Br C3H8O_2propanol Fe2Cl6 K2SO4 PCl2 SiH2F2
|
---|
4143 | AlH2F Br+ CNCOCN Ga Kr PCl2- SiH2I2
|
---|
4144 | AlH3 Br- C3O2 Ga+ Kr+ PCl3 SiH3
|
---|
4145 | AlI BrCl C4 GaBr li PCl5 SiH3Br
|
---|
4146 | AlI2 BrF C4H2_butadiyne GaBr2 li+ PF SiH3Cl
|
---|
4147 | AlI3 BrF3 C4H4_1_3-cyclo GaBr3 li- PF+ SiH3F
|
---|
4148 | AlN BrF5 C4H6_butadiene GaCl liAlF4 PF- SiH3I
|
---|
4149 | AlO BrO C4H6_1butyne GaCl2 liBO2 PFCl SiH4
|
---|
4150 | AlO+ OBrO C4H6_2butyne GaCl3 liBr PFCl- SiI
|
---|
4151 | AlO- BrOO C4H6_cyclo GaF liCl PFCl2 SiI2
|
---|
4152 | AlOCl BrO3 C4H8_1_butene GaF2 liF PFCl4 SiN
|
---|
4153 | AlOCl2 Br2 C4H8_cis2_buten GaF3 liH PF2 SiO
|
---|
4154 | AlOF BrBrO C4H8_isobutene GaH liI PF2- SiO2
|
---|
4155 | AlOF2 BrOBr C4H8_cyclo GaI liN PF2Cl SiS
|
---|
4156 | AlOF2- C C4H9_n_butyl GaI2 liNO2 PF2Cl3 SiS2
|
---|
4157 | AlOH C+ C4H9_i_butyl GaI3 liNO3 PF3 Si2
|
---|
4158 | AlOHCl C- C4H9_s_butyl GaO liO PF3Cl2 Si2C
|
---|
4159 | AlOHCl2 CBr C4H9_t_butyl GaOH liOF PF4Cl Si2F6
|
---|
4160 | AlOHF CBr2 C4H10_n_butane Ga2Br2 liOH PF5 Si2N
|
---|
4161 | AlOHF2 CBr3 C4H10_isobutane Ga2Br4 liON PH Si3
|
---|
4162 | AlO2 CBr4 C4N2 Ga2Br6 li2 PH2 Sn
|
---|
4163 | AlO2- CCl C5 Ga2Cl2 li2+ PH2- Sn+
|
---|
4164 | Al_OH_2 CCl2 C5H6_1_3cyclo Ga2Cl4 li2Br2 PH3 Sn-
|
---|
4165 | Al_OH_2Cl CCl2Br2 C5H8_cyclo Ga2Cl6 li2F2 PN SnBr
|
---|
4166 | Al_OH_2F CCl3 C5H10_1_pentene Ga2F2 li2I2 PO SnBr2
|
---|
4167 | Al_OH_3 CCl3Br C5H10_cyclo Ga2F4 li2O PO- SnBr3
|
---|
4168 | AlS CCl4 C5H11_pentyl Ga2F6 li2O+ POCl3 SnBr4
|
---|
4169 | AlS2 CF C5H11_t_pentyl Ga2I2 li2O2 POFCl2 SnCl
|
---|
4170 | Al2 CF+ C5H12_n_pentane Ga2I4 li2O2H2 POF2Cl SnCl2
|
---|
4171 | Al2Br6 CFBr3 C5H12_i_pentane Ga2I6 li2SO4 POF3 SnCl3
|
---|
4172 | Al2C2 CFCl CH3C_CH3_2CH3 Ga2O li3+ PO2 SnCl4
|
---|
4173 | Al2Cl6 CFClBr2 C6D5_phenyl Ge li3Br3 PO2- SnF
|
---|
4174 | Al2F6 CFCl2 C6D6 Ge+ li3Cl3 PS SnF2
|
---|
4175 | Al2I6 CFCl2Br C6H2 Ge- li3F3 P2 SnF3
|
---|
4176 | Al2O CFCl3 C6H5_phenyl GeBr li3I3 P2O3 SnF4
|
---|
4177 | Al2O+ CF2 C6H5O_phenoxy GeBr2 Mg P2O4 SnI
|
---|
4178 | Al2O2 CF2+ C6H6 GeBr3 Mg+ P2O5 SnI2
|
---|
4179 | Al2O2+ CF2Br2 C6H5OH_phenol GeBr4 MgBr P3 SnI3
|
---|
4180 | Al2O3 CF2Cl C6H10_cyclo GeCl MgBr2 P3O6 SnI4
|
---|
4181 | Al2S CF2ClBr C6H12_1_hexene GeCl2 MgCl P4 SnO
|
---|
4182 | Al2S2 CF2Cl2 C6H12_cyclo GeCl3 MgCl+ P4O6 SnO2
|
---|
4183 | Ar CF3 C6H13_n_hexyl GeCl4 MgCl2 P4O7 SnS
|
---|
4184 | Ar+ CF3+ C6H14_n_hexane GeF MgF P4O8 SnS2
|
---|
4185 | B CF3Br C7H7_benzyl GeF2 MgF+ P4O9 Sn2
|
---|
4186 | B+ CF3Cl C7H8 GeF3 MgF2 P4O10 Sr
|
---|
4187 | B- CF4 C7H8O_cresol_mx GeF4 MgF2+ Pb Sr+
|
---|
4188 | BBr CH+ C7H14_1_heptene GeH4 MgH Pb+ SrBr
|
---|
4189 | BBr2 CHBr3 C7H15_n_heptyl GeI MgI Pb- SrBr2
|
---|
4190 | BBr3 CHCl C7H16_n_heptane GeO MgI2 PbBr SrCl
|
---|
4191 | BC CHClBr2 C7H16_2_methylh GeO2 MgN PbBr2 SrCl+
|
---|
4192 | BC2 CHCl2 C8H8_styrene GeS MgO PbBr3 SrCl2
|
---|
4193 | BCl CHCl2Br C8H10_ethylbenz GeS2 MgOH PbBr4 SrF
|
---|
4194 | BCl+ CHCl3 C8H16_1_octene Ge2 MgOH+ PbCl SrF+
|
---|
4195 | BClOH CHF C8H17_n_octyl H Mg_OH_2 PbCl2 SrF2
|
---|
4196 | BCl_OH_2 CHFBr2 C8H18_n_octane H+ MgS PbCl3 SrH
|
---|
4197 | BCl2 CHFCl C8H18_isooctane H- Mg2 PbCl4 SrI
|
---|
4198 | BCl2+ CHFClBr C9H19_n_nonyl HAlO Mg2F4 PbF SrI2
|
---|
4199 | BCl2OH CHFCl2 C10H8_naphthale HAlO2 Mn PbF2 SrO
|
---|
4200 | BF CHF2 C10H21_n_decyl HBO Mn+ PbF3 SrOH
|
---|
4201 | BFCl CHF2Br C12H9_o_bipheny HBO+ Mo PbF4 SrOH+
|
---|
4202 | BFCl2 CHF2Cl C12H10_biphenyl HBO2 Mo+ PbI Sr_OH_2
|
---|
4203 | BFOH CHF3 Ca HBS Mo- PbI2 SrS
|
---|
4204 | BF_OH_2 CHI3 Ca+ HBS+ MoO PbI3 Sr2
|
---|
4205 | BF2 CH2 CaBr HCN MoO2 PbI4 Ta
|
---|
4206 | BF2+ CH2Br2 CaBr2 HCO MoO3 PbO Ta+
|
---|
4207 | BF2- CH2Cl CaCl HCO+ MoO3- PbO2 Ta-
|
---|
4208 | BF2Cl CH2ClBr CaCl+ HCCN Mo2O6 PbS TaCl5
|
---|
4209 | BF2OH CH2Cl2 CaCl2 HCCO Mo3O9 PbS2 TaO
|
---|
4210 | BF3 CH2F CaF HCl Mo4O12 Rb TaO2
|
---|
4211 | BF4- CH2FBr CaF+ HD Mo5O15 Rb+ Ti
|
---|
4212 | BH CH2FCl CaF2 HD+ N Rb- Ti+
|
---|
4213 | BHCl CH2F2 CaH HDO N+ RbBO2 Ti-
|
---|
4214 | BHCl2 CH2I2 CaI HDO2 N- RbBr TiCl
|
---|
4215 | BHF CH3 CaI2 HF NCO RbCl TiCl2
|
---|
4216 | BHFCl CH3Br CaO HI ND RbF TiCl3
|
---|
4217 | BHF2 CH3Cl CaO+ HNC ND2 RbH TiCl4
|
---|
4218 | BH2 CH3F CaOH HNCO ND3 RbI TiO
|
---|
4219 | BH2Cl CH3I CaOH+ HNO NF RbK TiO+
|
---|
4220 | BH2F CH2OH Ca_OH_2 HNO2 NF2 Rbli TiOCl
|
---|
4221 | BH3 CH2OH+ CaS HNO3 NF3 RbNO2 TiOCl2
|
---|
4222 | BH3NH3 CH3O Ca2 HOCl NH RbNO3 TiO2
|
---|
4223 | BH4 CH4 Cd HOF NH+ RbNa U
|
---|
4224 | BI CH3OH Cd+ HO2 NHF RbO UF
|
---|
4225 | BI2 CH3OOH Cl HO2- NHF2 RbOH UF+
|
---|
4226 | BI3 CI Cl+ HPO NH2 Rb2Br2 UF-
|
---|
4227 | BN CI2 Cl- HSO3F NH2F Rb2Cl2 UF2
|
---|
4228 | BO CI3 ClCN H2 NH3 Rb2F2 UF2+
|
---|
4229 | BO- CI4 ClF H2+ NH2OH Rb2I2 UF2-
|
---|
4230 | BOCl CN ClF3 H2- NH4+ Rb2O UF3
|
---|
4231 | BOCl2 CN+ ClF5 HBOH NO Rb2O2 UF3+
|
---|
4232 | BOF CN- ClO HCOOH NOCl Rb2O2H2 UF3-
|
---|
4233 | BOF2 CNN ClO2 H2F2 NOF Rb2SO4 UF4
|
---|
4234 | BOH CO Cl2 H2O NOF3 Rn UF4+
|
---|
4235 | BO2 CO+ Cl2O H2O+ NO2 Rn+ UF4-
|
---|
4236 | BO2- COCl Co H2O2 NO2- S UF5
|
---|
4237 | B_OH_2 COCl2 Co+ H2S NO2Cl S+ UF5+
|
---|
4238 | BS COFCl Co- H2SO4 NO2F S- UF5-
|
---|
4239 | BS2 COF2 Cr H2BOH NO3 SCl UF6
|
---|
4240 | B2 COHCl Cr+ HB_OH_2 NO3- SCl2 UF6-
|
---|
4241 | B2C COHF Cr- H3BO3 NO3F SCl2+ UO
|
---|
4242 | B2Cl4 COS CrN H3B3O3 N2 SD UO+
|
---|
4243 | B2F4 CO2 CrO H3B3O6 N2+ SF UOF
|
---|
4244 | B2H CO2+ CrO2 H3F3 N2- SF+ UOF2
|
---|
4245 | B2H2 COOH CrO3 H3O+ NCN SF- UOF3
|
---|
4246 | B2H3 CP CrO3- H4F4 N2D2_cis SF2 UOF4
|
---|
4247 | B2H3_db CS Cs H5F5 N2F2 SF2+ UO2
|
---|
4248 | B2H4 CS2 Cs+ H6F6 N2F4 SF2- UO2+
|
---|
4249 | B2H4_db C2 Cs- H7F7 N2H2 SF3 UO2-
|
---|
4250 | B2H5 C2+ CsBO2 He NH2NO2 SF3+ UO2F
|
---|
4251 | B2H5_db C2- CsBr He+ N2H4 SF3- UO2F2
|
---|
4252 | B2H6 C2Cl CsCl Hg N2O SF4 UO3
|
---|
4253 | B2O C2Cl2 CsF Hg+ N2O+ SF4+ UO3-
|
---|
4254 | B2O2 C2Cl3 CsH HgBr2 N2O3 SF4- V
|
---|
4255 | B2O3 C2Cl4 CsI I N2O4 SF5 V+
|
---|
4256 | B2_OH_4 C2Cl6 Csli I+ N2O5 SF5+ V-
|
---|
4257 | B2S C2F CsNO2 I- N3 SF5- VCl4
|
---|
4258 | B2S2 C2FCl CsNO3 IF5 N3H SF6 VN
|
---|
4259 | B2S3 C2FCl3 CsNa IF7 Na SF6- VO
|
---|
4260 | B3H7_C2v C2F2 CsO I2 Na+ SH VO2
|
---|
4261 | B3H7_Cs C2F2Cl2 CsOH In Na- SH- V4O10
|
---|
4262 | B3H9 C2F3 CsRb In+ NaAlF4 SN W
|
---|
4263 | B3N3H6 C2F3Cl Cs2 InBr NaBO2 SO W+
|
---|
4264 | B3O3Cl3 C2F4 Cs2Br2 InBr2 NaBr SO- W-
|
---|
4265 | B3O3FCl2 C2F6 Cs2CO3 InBr3 NaCN SOF2 WCl6
|
---|
4266 | B3O3F2Cl C2H Cs2Cl2 InCl NaCl SO2 WO
|
---|
4267 | B3O3F3 C2HCl Cs2F2 InCl2 NaF SO2- WOCl4
|
---|
4268 | B4H4 C2HCl3 Cs2I2 InCl3 NaH SO2Cl2 WO2
|
---|
4269 | B4H10 C2HF Cs2O InF NaI SO2FCl WO2Cl2
|
---|
4270 | B4H12 C2HFCl2 Cs2O+ InF2 Nali SO2F2 WO3
|
---|
4271 | B5H9 C2HF2Cl Cs2O2 InF3 NaNO2 SO3 WO3-
|
---|
4272 | Ba C2HF3 Cs2O2H2 InH NaNO3 S2 Xe
|
---|
4273 | Ba+ C2H2_vinylidene Cs2SO4 InI NaO S2- Xe+
|
---|
4274 | BaBr C2H2Cl2 Cu InI2 NaOH S2Cl2 Zn
|
---|
4275 | BaBr2 C2H2FCl Cu+ InI3 NaOH+ S2F2 Zn+
|
---|
4276 | BaCl C2H2F2 Cu- InO Na2 S2O Zr
|
---|
4277 | BaCl+ CH2CO_ketene CuCl InOH Na2Br2 S3 Zr+
|
---|
4278 | BaCl2 O_CH_2O CuF In2Br2 Na2Cl2 S4 Zr-
|
---|
4279 | BaF HO_CO_2OH CuF2 In2Br4 Na2F2 S5 ZrN
|
---|
4280 | BaF+ C2H3_vinyl CuO In2Br6 Na2I2 S6 ZrO
|
---|
4281 | BaF2 CH2Br-COOH Cu2 In2Cl2 Na2O S7 ZrO+
|
---|
4282 | BaH C2H3Cl Cu3Cl3 In2Cl4 Na2O+ S8 ZrO2
|
---|
4283 | BaI CH2Cl-COOH D In2Cl6 Na2O2 Sc
|
---|
4284 | BaI2 C2H3F D+ In2F2 Na2O2H2 Sc+
|
---|
4285 | BaO CH3CN D- In2F4 Na2SO4 Sc-
|
---|
4286 | BaO+ CH3CO_acetyl DBr In2F6 Na3Cl3 ScO
|
---|
4287 | BaOH C2H4 DCl In2I2 Na3F3 ScO+
|
---|
4288 | </pre>
|
---|
4289 |
|
---|
4290 | </HTML>"));
|
---|
4291 | end SingleGasesData;
|
---|
4292 | annotation (Documentation(info="<html>
|
---|
4293 |
|
---|
4294 | </html>"));
|
---|
4295 | end Common;
|
---|
4296 | annotation (
|
---|
4297 | __Dymola_classOrder={"Common", "SingleGases", "MixtureGases"},
|
---|
4298 | Documentation(info="<HTML>
|
---|
4299 | <p>This package contains data for the 1241 ideal gases from</p>
|
---|
4300 | <blockquote>
|
---|
4301 | <p>McBride B.J., Zehe M.J., and Gordon S. (2002): <b>NASA Glenn Coefficients
|
---|
4302 | for Calculating Thermodynamic Properties of Individual Species</b>. NASA
|
---|
4303 | report TP-2002-211556</p>
|
---|
4304 | </blockquote>
|
---|
4305 | <p>Medium models for some of these gases are available in package
|
---|
4306 | <a href=\"modelica://Modelica.Media.IdealGases.SingleGases\">IdealGases.SingleGases</a>
|
---|
4307 | and some examples for mixtures are available in package <a href=\"modelica://Modelica.Media.IdealGases.MixtureGases\">IdealGases.MixtureGases</a>
|
---|
4308 | </p>
|
---|
4309 | <h4>Using and Adapting Medium Models</h4>
|
---|
4310 | <p>
|
---|
4311 | The data records allow computing the ideal gas specific enthalpy, specific entropy and heat capacity of the substances listed below. From them, even the Gibbs energy and equilibrium constants for reactions can be computed. Critical data that is needed for computing the viscosity and thermal conductivity is not included. In order to add mixtures or single substance medium packages that are
|
---|
4312 | subtypes of
|
---|
4313 | <a href=\"modelica://Modelica.Media.Interfaces.PartialMedium\">Interfaces.PartialMedium</a>
|
---|
4314 | (i.e., can be utilized at all places where PartialMedium is defined),
|
---|
4315 | a few additional steps have to be performed:
|
---|
4316 | <ol>
|
---|
4317 | <li>
|
---|
4318 | All single gas media need to define a constant instance of record
|
---|
4319 | <a href=\"modelica://Modelica.Media.IdealGases.Common.SingleGasNasa.FluidConstants\">IdealGases.Common.SingleGasNasa.FluidConstants</a>.
|
---|
4320 | For 37 ideal gases such records are provided in package
|
---|
4321 | <a href=\"modelica://Modelica.Media.IdealGases.Common.FluidData\">IdealGases.Common.FluidData</a>.
|
---|
4322 | For the other gases, such a record instance has to be provided by the user, e.g., by getting
|
---|
4323 | the data from a commercial or public data base. A public source of the needed data is for example the <a href=\"http://webbook.nist.gov/chemistry/\"> NIST Chemistry WebBook</a></li>
|
---|
4324 |
|
---|
4325 | <li>When the data is available, and a user has an instance of a
|
---|
4326 | <a href=\"modelica://Modelica.Media.IdealGases.Common.SingleGasNasa.FluidConstants\">FluidConstants</a> record filled with data, a medium package has to be written. Note that only the dipole moment, the accentric factor and critical data are necessary for the viscosity and thermal conductivity functions.</li>
|
---|
4327 | <ul>
|
---|
4328 | <li>For single components, a new package following the pattern in
|
---|
4329 | <a href=\"modelica://Modelica.Media.IdealGases.SingleGases\">IdealGases.SingleGases</a> has to be created, pointing both to a data record for cp and to a user-defined fluidContants record.</li>
|
---|
4330 | <li>For mixtures of several components, a new package following the pattern in
|
---|
4331 | <a href=\"modelica://Modelica.Media.IdealGases.MixtureGases\">IdealGases.MixtureGases</a> has to be created, building an array of data records for cp and an array of (partly) user-defined fluidContants records.</li>
|
---|
4332 | </ul>
|
---|
4333 | </ol>
|
---|
4334 | <p>Note that many properties can computed for the full set of 1241 gases listed below, but due to the missing viscosity and thermal conductivity functions, no fully Modelica.Media-compliant media can be defined.</p>
|
---|
4335 | </p>
|
---|
4336 | <p>
|
---|
4337 | Data records for heat capacity, specific enthalpy and specific entropy exist for the following substances and ions:
|
---|
4338 | </p>
|
---|
4339 | <pre>
|
---|
4340 | Ag BaOH+ C2H4O_ethylen_o DF In2I4 Nb ScO2
|
---|
4341 | Ag+ Ba_OH_2 CH3CHO_ethanal DOCl In2I6 Nb+ Sc2O
|
---|
4342 | Ag- BaS CH3COOH DO2 In2O Nb- Sc2O2
|
---|
4343 | Air Ba2 OHCH2COOH DO2- K NbCl5 Si
|
---|
4344 | Al Be C2H5 D2 K+ NbO Si+
|
---|
4345 | Al+ Be+ C2H5Br D2+ K- NbOCl3 Si-
|
---|
4346 | Al- Be++ C2H6 D2- KAlF4 NbO2 SiBr
|
---|
4347 | AlBr BeBr CH3N2CH3 D2O KBO2 Ne SiBr2
|
---|
4348 | AlBr2 BeBr2 C2H5OH D2O2 KBr Ne+ SiBr3
|
---|
4349 | AlBr3 BeCl CH3OCH3 D2S KCN Ni SiBr4
|
---|
4350 | AlC BeCl2 CH3O2CH3 e- KCl Ni+ SiC
|
---|
4351 | AlC2 BeF CCN F KF Ni- SiC2
|
---|
4352 | AlCl BeF2 CNC F+ KH NiCl SiCl
|
---|
4353 | AlCl+ BeH OCCN F- KI NiCl2 SiCl2
|
---|
4354 | AlCl2 BeH+ C2N2 FCN Kli NiO SiCl3
|
---|
4355 | AlCl3 BeH2 C2O FCO KNO2 NiS SiCl4
|
---|
4356 | AlF BeI C3 FO KNO3 O SiF
|
---|
4357 | AlF+ BeI2 C3H3_1_propynl FO2_FOO KNa O+ SiFCl
|
---|
4358 | AlFCl BeN C3H3_2_propynl FO2_OFO KO O- SiF2
|
---|
4359 | AlFCl2 BeO C3H4_allene F2 KOH OD SiF3
|
---|
4360 | AlF2 BeOH C3H4_propyne F2O K2 OD- SiF4
|
---|
4361 | AlF2- BeOH+ C3H4_cyclo F2O2 K2+ OH SiH
|
---|
4362 | AlF2Cl Be_OH_2 C3H5_allyl FS2F K2Br2 OH+ SiH+
|
---|
4363 | AlF3 BeS C3H6_propylene Fe K2CO3 OH- SiHBr3
|
---|
4364 | AlF4- Be2 C3H6_cyclo Fe+ K2C2N2 O2 SiHCl
|
---|
4365 | AlH Be2Cl4 C3H6O_propylox Fe_CO_5 K2Cl2 O2+ SiHCl3
|
---|
4366 | AlHCl Be2F4 C3H6O_acetone FeCl K2F2 O2- SiHF
|
---|
4367 | AlHCl2 Be2O C3H6O_propanal FeCl2 K2I2 O3 SiHF3
|
---|
4368 | AlHF Be2OF2 C3H7_n_propyl FeCl3 K2O P SiHI3
|
---|
4369 | AlHFCl Be2O2 C3H7_i_propyl FeO K2O+ P+ SiH2
|
---|
4370 | AlHF2 Be3O3 C3H8 Fe_OH_2 K2O2 P- SiH2Br2
|
---|
4371 | AlH2 Be4O4 C3H8O_1propanol Fe2Cl4 K2O2H2 PCl SiH2Cl2
|
---|
4372 | AlH2Cl Br C3H8O_2propanol Fe2Cl6 K2SO4 PCl2 SiH2F2
|
---|
4373 | AlH2F Br+ CNCOCN Ga Kr PCl2- SiH2I2
|
---|
4374 | AlH3 Br- C3O2 Ga+ Kr+ PCl3 SiH3
|
---|
4375 | AlI BrCl C4 GaBr li PCl5 SiH3Br
|
---|
4376 | AlI2 BrF C4H2_butadiyne GaBr2 li+ PF SiH3Cl
|
---|
4377 | AlI3 BrF3 C4H4_1_3-cyclo GaBr3 li- PF+ SiH3F
|
---|
4378 | AlN BrF5 C4H6_butadiene GaCl liAlF4 PF- SiH3I
|
---|
4379 | AlO BrO C4H6_1butyne GaCl2 liBO2 PFCl SiH4
|
---|
4380 | AlO+ OBrO C4H6_2butyne GaCl3 liBr PFCl- SiI
|
---|
4381 | AlO- BrOO C4H6_cyclo GaF liCl PFCl2 SiI2
|
---|
4382 | AlOCl BrO3 C4H8_1_butene GaF2 liF PFCl4 SiN
|
---|
4383 | AlOCl2 Br2 C4H8_cis2_buten GaF3 liH PF2 SiO
|
---|
4384 | AlOF BrBrO C4H8_isobutene GaH liI PF2- SiO2
|
---|
4385 | AlOF2 BrOBr C4H8_cyclo GaI liN PF2Cl SiS
|
---|
4386 | AlOF2- C C4H9_n_butyl GaI2 liNO2 PF2Cl3 SiS2
|
---|
4387 | AlOH C+ C4H9_i_butyl GaI3 liNO3 PF3 Si2
|
---|
4388 | AlOHCl C- C4H9_s_butyl GaO liO PF3Cl2 Si2C
|
---|
4389 | AlOHCl2 CBr C4H9_t_butyl GaOH liOF PF4Cl Si2F6
|
---|
4390 | AlOHF CBr2 C4H10_n_butane Ga2Br2 liOH PF5 Si2N
|
---|
4391 | AlOHF2 CBr3 C4H10_isobutane Ga2Br4 liON PH Si3
|
---|
4392 | AlO2 CBr4 C4N2 Ga2Br6 li2 PH2 Sn
|
---|
4393 | AlO2- CCl C5 Ga2Cl2 li2+ PH2- Sn+
|
---|
4394 | Al_OH_2 CCl2 C5H6_1_3cyclo Ga2Cl4 li2Br2 PH3 Sn-
|
---|
4395 | Al_OH_2Cl CCl2Br2 C5H8_cyclo Ga2Cl6 li2F2 PN SnBr
|
---|
4396 | Al_OH_2F CCl3 C5H10_1_pentene Ga2F2 li2I2 PO SnBr2
|
---|
4397 | Al_OH_3 CCl3Br C5H10_cyclo Ga2F4 li2O PO- SnBr3
|
---|
4398 | AlS CCl4 C5H11_pentyl Ga2F6 li2O+ POCl3 SnBr4
|
---|
4399 | AlS2 CF C5H11_t_pentyl Ga2I2 li2O2 POFCl2 SnCl
|
---|
4400 | Al2 CF+ C5H12_n_pentane Ga2I4 li2O2H2 POF2Cl SnCl2
|
---|
4401 | Al2Br6 CFBr3 C5H12_i_pentane Ga2I6 li2SO4 POF3 SnCl3
|
---|
4402 | Al2C2 CFCl CH3C_CH3_2CH3 Ga2O li3+ PO2 SnCl4
|
---|
4403 | Al2Cl6 CFClBr2 C6D5_phenyl Ge li3Br3 PO2- SnF
|
---|
4404 | Al2F6 CFCl2 C6D6 Ge+ li3Cl3 PS SnF2
|
---|
4405 | Al2I6 CFCl2Br C6H2 Ge- li3F3 P2 SnF3
|
---|
4406 | Al2O CFCl3 C6H5_phenyl GeBr li3I3 P2O3 SnF4
|
---|
4407 | Al2O+ CF2 C6H5O_phenoxy GeBr2 Mg P2O4 SnI
|
---|
4408 | Al2O2 CF2+ C6H6 GeBr3 Mg+ P2O5 SnI2
|
---|
4409 | Al2O2+ CF2Br2 C6H5OH_phenol GeBr4 MgBr P3 SnI3
|
---|
4410 | Al2O3 CF2Cl C6H10_cyclo GeCl MgBr2 P3O6 SnI4
|
---|
4411 | Al2S CF2ClBr C6H12_1_hexene GeCl2 MgCl P4 SnO
|
---|
4412 | Al2S2 CF2Cl2 C6H12_cyclo GeCl3 MgCl+ P4O6 SnO2
|
---|
4413 | Ar CF3 C6H13_n_hexyl GeCl4 MgCl2 P4O7 SnS
|
---|
4414 | Ar+ CF3+ C6H14_n_hexane GeF MgF P4O8 SnS2
|
---|
4415 | B CF3Br C7H7_benzyl GeF2 MgF+ P4O9 Sn2
|
---|
4416 | B+ CF3Cl C7H8 GeF3 MgF2 P4O10 Sr
|
---|
4417 | B- CF4 C7H8O_cresol_mx GeF4 MgF2+ Pb Sr+
|
---|
4418 | BBr CH+ C7H14_1_heptene GeH4 MgH Pb+ SrBr
|
---|
4419 | BBr2 CHBr3 C7H15_n_heptyl GeI MgI Pb- SrBr2
|
---|
4420 | BBr3 CHCl C7H16_n_heptane GeO MgI2 PbBr SrCl
|
---|
4421 | BC CHClBr2 C7H16_2_methylh GeO2 MgN PbBr2 SrCl+
|
---|
4422 | BC2 CHCl2 C8H8_styrene GeS MgO PbBr3 SrCl2
|
---|
4423 | BCl CHCl2Br C8H10_ethylbenz GeS2 MgOH PbBr4 SrF
|
---|
4424 | BCl+ CHCl3 C8H16_1_octene Ge2 MgOH+ PbCl SrF+
|
---|
4425 | BClOH CHF C8H17_n_octyl H Mg_OH_2 PbCl2 SrF2
|
---|
4426 | BCl_OH_2 CHFBr2 C8H18_n_octane H+ MgS PbCl3 SrH
|
---|
4427 | BCl2 CHFCl C8H18_isooctane H- Mg2 PbCl4 SrI
|
---|
4428 | BCl2+ CHFClBr C9H19_n_nonyl HAlO Mg2F4 PbF SrI2
|
---|
4429 | BCl2OH CHFCl2 C10H8_naphthale HAlO2 Mn PbF2 SrO
|
---|
4430 | BF CHF2 C10H21_n_decyl HBO Mn+ PbF3 SrOH
|
---|
4431 | BFCl CHF2Br C12H9_o_bipheny HBO+ Mo PbF4 SrOH+
|
---|
4432 | BFCl2 CHF2Cl C12H10_biphenyl HBO2 Mo+ PbI Sr_OH_2
|
---|
4433 | BFOH CHF3 Ca HBS Mo- PbI2 SrS
|
---|
4434 | BF_OH_2 CHI3 Ca+ HBS+ MoO PbI3 Sr2
|
---|
4435 | BF2 CH2 CaBr HCN MoO2 PbI4 Ta
|
---|
4436 | BF2+ CH2Br2 CaBr2 HCO MoO3 PbO Ta+
|
---|
4437 | BF2- CH2Cl CaCl HCO+ MoO3- PbO2 Ta-
|
---|
4438 | BF2Cl CH2ClBr CaCl+ HCCN Mo2O6 PbS TaCl5
|
---|
4439 | BF2OH CH2Cl2 CaCl2 HCCO Mo3O9 PbS2 TaO
|
---|
4440 | BF3 CH2F CaF HCl Mo4O12 Rb TaO2
|
---|
4441 | BF4- CH2FBr CaF+ HD Mo5O15 Rb+ Ti
|
---|
4442 | BH CH2FCl CaF2 HD+ N Rb- Ti+
|
---|
4443 | BHCl CH2F2 CaH HDO N+ RbBO2 Ti-
|
---|
4444 | BHCl2 CH2I2 CaI HDO2 N- RbBr TiCl
|
---|
4445 | BHF CH3 CaI2 HF NCO RbCl TiCl2
|
---|
4446 | BHFCl CH3Br CaO HI ND RbF TiCl3
|
---|
4447 | BHF2 CH3Cl CaO+ HNC ND2 RbH TiCl4
|
---|
4448 | BH2 CH3F CaOH HNCO ND3 RbI TiO
|
---|
4449 | BH2Cl CH3I CaOH+ HNO NF RbK TiO+
|
---|
4450 | BH2F CH2OH Ca_OH_2 HNO2 NF2 Rbli TiOCl
|
---|
4451 | BH3 CH2OH+ CaS HNO3 NF3 RbNO2 TiOCl2
|
---|
4452 | BH3NH3 CH3O Ca2 HOCl NH RbNO3 TiO2
|
---|
4453 | BH4 CH4 Cd HOF NH+ RbNa U
|
---|
4454 | BI CH3OH Cd+ HO2 NHF RbO UF
|
---|
4455 | BI2 CH3OOH Cl HO2- NHF2 RbOH UF+
|
---|
4456 | BI3 CI Cl+ HPO NH2 Rb2Br2 UF-
|
---|
4457 | BN CI2 Cl- HSO3F NH2F Rb2Cl2 UF2
|
---|
4458 | BO CI3 ClCN H2 NH3 Rb2F2 UF2+
|
---|
4459 | BO- CI4 ClF H2+ NH2OH Rb2I2 UF2-
|
---|
4460 | BOCl CN ClF3 H2- NH4+ Rb2O UF3
|
---|
4461 | BOCl2 CN+ ClF5 HBOH NO Rb2O2 UF3+
|
---|
4462 | BOF CN- ClO HCOOH NOCl Rb2O2H2 UF3-
|
---|
4463 | BOF2 CNN ClO2 H2F2 NOF Rb2SO4 UF4
|
---|
4464 | BOH CO Cl2 H2O NOF3 Rn UF4+
|
---|
4465 | BO2 CO+ Cl2O H2O+ NO2 Rn+ UF4-
|
---|
4466 | BO2- COCl Co H2O2 NO2- S UF5
|
---|
4467 | B_OH_2 COCl2 Co+ H2S NO2Cl S+ UF5+
|
---|
4468 | BS COFCl Co- H2SO4 NO2F S- UF5-
|
---|
4469 | BS2 COF2 Cr H2BOH NO3 SCl UF6
|
---|
4470 | B2 COHCl Cr+ HB_OH_2 NO3- SCl2 UF6-
|
---|
4471 | B2C COHF Cr- H3BO3 NO3F SCl2+ UO
|
---|
4472 | B2Cl4 COS CrN H3B3O3 N2 SD UO+
|
---|
4473 | B2F4 CO2 CrO H3B3O6 N2+ SF UOF
|
---|
4474 | B2H CO2+ CrO2 H3F3 N2- SF+ UOF2
|
---|
4475 | B2H2 COOH CrO3 H3O+ NCN SF- UOF3
|
---|
4476 | B2H3 CP CrO3- H4F4 N2D2_cis SF2 UOF4
|
---|
4477 | B2H3_db CS Cs H5F5 N2F2 SF2+ UO2
|
---|
4478 | B2H4 CS2 Cs+ H6F6 N2F4 SF2- UO2+
|
---|
4479 | B2H4_db C2 Cs- H7F7 N2H2 SF3 UO2-
|
---|
4480 | B2H5 C2+ CsBO2 He NH2NO2 SF3+ UO2F
|
---|
4481 | B2H5_db C2- CsBr He+ N2H4 SF3- UO2F2
|
---|
4482 | B2H6 C2Cl CsCl Hg N2O SF4 UO3
|
---|
4483 | B2O C2Cl2 CsF Hg+ N2O+ SF4+ UO3-
|
---|
4484 | B2O2 C2Cl3 CsH HgBr2 N2O3 SF4- V
|
---|
4485 | B2O3 C2Cl4 CsI I N2O4 SF5 V+
|
---|
4486 | B2_OH_4 C2Cl6 Csli I+ N2O5 SF5+ V-
|
---|
4487 | B2S C2F CsNO2 I- N3 SF5- VCl4
|
---|
4488 | B2S2 C2FCl CsNO3 IF5 N3H SF6 VN
|
---|
4489 | B2S3 C2FCl3 CsNa IF7 Na SF6- VO
|
---|
4490 | B3H7_C2v C2F2 CsO I2 Na+ SH VO2
|
---|
4491 | B3H7_Cs C2F2Cl2 CsOH In Na- SH- V4O10
|
---|
4492 | B3H9 C2F3 CsRb In+ NaAlF4 SN W
|
---|
4493 | B3N3H6 C2F3Cl Cs2 InBr NaBO2 SO W+
|
---|
4494 | B3O3Cl3 C2F4 Cs2Br2 InBr2 NaBr SO- W-
|
---|
4495 | B3O3FCl2 C2F6 Cs2CO3 InBr3 NaCN SOF2 WCl6
|
---|
4496 | B3O3F2Cl C2H Cs2Cl2 InCl NaCl SO2 WO
|
---|
4497 | B3O3F3 C2HCl Cs2F2 InCl2 NaF SO2- WOCl4
|
---|
4498 | B4H4 C2HCl3 Cs2I2 InCl3 NaH SO2Cl2 WO2
|
---|
4499 | B4H10 C2HF Cs2O InF NaI SO2FCl WO2Cl2
|
---|
4500 | B4H12 C2HFCl2 Cs2O+ InF2 Nali SO2F2 WO3
|
---|
4501 | B5H9 C2HF2Cl Cs2O2 InF3 NaNO2 SO3 WO3-
|
---|
4502 | Ba C2HF3 Cs2O2H2 InH NaNO3 S2 Xe
|
---|
4503 | Ba+ C2H2_vinylidene Cs2SO4 InI NaO S2- Xe+
|
---|
4504 | BaBr C2H2Cl2 Cu InI2 NaOH S2Cl2 Zn
|
---|
4505 | BaBr2 C2H2FCl Cu+ InI3 NaOH+ S2F2 Zn+
|
---|
4506 | BaCl C2H2F2 Cu- InO Na2 S2O Zr
|
---|
4507 | BaCl+ CH2CO_ketene CuCl InOH Na2Br2 S3 Zr+
|
---|
4508 | BaCl2 O_CH_2O CuF In2Br2 Na2Cl2 S4 Zr-
|
---|
4509 | BaF HO_CO_2OH CuF2 In2Br4 Na2F2 S5 ZrN
|
---|
4510 | BaF+ C2H3_vinyl CuO In2Br6 Na2I2 S6 ZrO
|
---|
4511 | BaF2 CH2Br-COOH Cu2 In2Cl2 Na2O S7 ZrO+
|
---|
4512 | BaH C2H3Cl Cu3Cl3 In2Cl4 Na2O+ S8 ZrO2
|
---|
4513 | BaI CH2Cl-COOH D In2Cl6 Na2O2 Sc
|
---|
4514 | BaI2 C2H3F D+ In2F2 Na2O2H2 Sc+
|
---|
4515 | BaO CH3CN D- In2F4 Na2SO4 Sc-
|
---|
4516 | BaO+ CH3CO_acetyl DBr In2F6 Na3Cl3 ScO
|
---|
4517 | BaOH C2H4 DCl In2I2 Na3F3 ScO+
|
---|
4518 | </pre></HTML>"));
|
---|
4519 | end IdealGases;
|
---|
4520 |
|
---|
4521 | package Incompressible
|
---|
4522 | "Medium model for T-dependent properties, defined by tables or polynomials"
|
---|
4523 | extends Modelica.Icons.MaterialPropertiesPackage;
|
---|
4524 | import SI = Modelica.SIunits;
|
---|
4525 | import Cv = Modelica.SIunits.Conversions;
|
---|
4526 | import Modelica.Constants;
|
---|
4527 | import Modelica.Math;
|
---|
4528 |
|
---|
4529 | package Common "Common data structures"
|
---|
4530 | extends Modelica.Icons.Package;
|
---|
4531 |
|
---|
4532 | record BaseProps_Tpoly "Fluid state record"
|
---|
4533 | extends Modelica.Icons.Record;
|
---|
4534 | SI.Temperature T "temperature";
|
---|
4535 | SI.Pressure p "pressure";
|
---|
4536 | // SI.Density d "density";
|
---|
4537 | end BaseProps_Tpoly;
|
---|
4538 | end Common;
|
---|
4539 |
|
---|
4540 | package TableBased "Incompressible medium properties based on tables"
|
---|
4541 | import Poly = Modelica.Media.Incompressible.TableBased.Polynomials_Temp;
|
---|
4542 | extends Modelica.Media.Interfaces.PartialMedium(
|
---|
4543 | ThermoStates = if enthalpyOfT then Choices.IndependentVariables.T else Choices.IndependentVariables.pT,
|
---|
4544 | final reducedX=true,
|
---|
4545 | final fixedX = true,
|
---|
4546 | mediumName="tableMedium",
|
---|
4547 | redeclare record ThermodynamicState=Common.BaseProps_Tpoly,
|
---|
4548 | singleState=true);
|
---|
4549 |
|
---|
4550 | constant Boolean enthalpyOfT=true
|
---|
4551 | "true if enthalpy is approximated as a function of T only, (p-dependence neglected)";
|
---|
4552 |
|
---|
4553 | constant Boolean densityOfT = size(tableDensity,1) > 1
|
---|
4554 | "true if density is a function of temperature";
|
---|
4555 |
|
---|
4556 | constant Temperature T_min "Minimum temperature valid for medium model";
|
---|
4557 |
|
---|
4558 | constant Temperature T_max "Maximum temperature valid for medium model";
|
---|
4559 |
|
---|
4560 | constant Temperature T0=273.15 "reference Temperature";
|
---|
4561 |
|
---|
4562 | constant SpecificEnthalpy h0=0 "reference enthalpy at T0, reference_p";
|
---|
4563 |
|
---|
4564 | constant SpecificEntropy s0=0 "reference entropy at T0, reference_p";
|
---|
4565 |
|
---|
4566 | constant MolarMass MM_const=0.1 "Molar mass";
|
---|
4567 |
|
---|
4568 | constant Integer npol=2 "degree of polynomial used for fitting";
|
---|
4569 |
|
---|
4570 | constant Integer neta=size(tableViscosity,1)
|
---|
4571 | "number of data points for viscosity";
|
---|
4572 |
|
---|
4573 | constant Real[:,2] tableDensity "Table for rho(T)";
|
---|
4574 |
|
---|
4575 | constant Real[:,2] tableHeatCapacity "Table for Cp(T)";
|
---|
4576 |
|
---|
4577 | constant Real[:,2] tableViscosity "Table for eta(T)";
|
---|
4578 |
|
---|
4579 | constant Real[:,2] tableConductivity "Table for lambda(T)";
|
---|
4580 |
|
---|
4581 | constant Boolean TinK "true if T[K],Kelvin used for table temperatures";
|
---|
4582 |
|
---|
4583 | constant Boolean hasDensity = not (size(tableDensity,1)==0)
|
---|
4584 | "true if table tableDensity is present";
|
---|
4585 |
|
---|
4586 | constant Boolean hasHeatCapacity = not (size(tableHeatCapacity,1)==0)
|
---|
4587 | "true if table tableHeatCapacity is present";
|
---|
4588 |
|
---|
4589 | constant Boolean hasViscosity = not (size(tableViscosity,1)==0)
|
---|
4590 | "true if table tableViscosity is present";
|
---|
4591 |
|
---|
4592 | final constant Real invTK[neta] = if size(tableViscosity,1) > 0 then
|
---|
4593 | invertTemp(tableViscosity[:,1],TinK) else fill(0,0);
|
---|
4594 |
|
---|
4595 | final constant Real poly_rho[:] = if hasDensity then
|
---|
4596 | Poly.fitting(tableDensity[:,1],tableDensity[:,2],npol) else
|
---|
4597 | zeros(npol+1) annotation(__Dymola_keepConstant = true);
|
---|
4598 |
|
---|
4599 | final constant Real poly_Cp[:] = if hasHeatCapacity then
|
---|
4600 | Poly.fitting(tableHeatCapacity[:,1],tableHeatCapacity[:,2],npol) else
|
---|
4601 | zeros(npol+1) annotation(__Dymola_keepConstant = true);
|
---|
4602 |
|
---|
4603 | final constant Real poly_eta[:] = if hasViscosity then
|
---|
4604 | Poly.fitting(invTK, Math.log(tableViscosity[:,2]),npol) else
|
---|
4605 | zeros(npol+1) annotation(__Dymola_keepConstant = true);
|
---|
4606 |
|
---|
4607 | final constant Real poly_lam[:] = if size(tableConductivity,1)>0 then
|
---|
4608 | Poly.fitting(tableConductivity[:,1],tableConductivity[:,2],npol) else
|
---|
4609 | zeros(npol+1) annotation(__Dymola_keepConstant = true);
|
---|
4610 |
|
---|
4611 | function invertTemp "function to invert temperatures"
|
---|
4612 | input Real[:] table "table temperature data";
|
---|
4613 | input Boolean Tink "flag for Celsius or Kelvin";
|
---|
4614 | output Real invTable[size(table,1)] "inverted temperatures";
|
---|
4615 | algorithm
|
---|
4616 | for i in 1:size(table,1) loop
|
---|
4617 | invTable[i] := if TinK then 1/table[i] else 1/Cv.from_degC(table[i]);
|
---|
4618 | end for;
|
---|
4619 | end invertTemp;
|
---|
4620 |
|
---|
4621 | redeclare model extends BaseProperties(
|
---|
4622 | final standardOrderComponents=true,
|
---|
4623 | p_bar=Cv.to_bar(p),
|
---|
4624 | T_degC(start = T_start-273.15)=Cv.to_degC(T),
|
---|
4625 | T(start = T_start,
|
---|
4626 | stateSelect=if preferredMediumStates then StateSelect.prefer else StateSelect.default))
|
---|
4627 | "Base properties of T dependent medium"
|
---|
4628 | // redeclare parameter SpecificHeatCapacity R=Modelica.Constants.R,
|
---|
4629 |
|
---|
4630 | SI.SpecificHeatCapacity cp "specific heat capacity";
|
---|
4631 | parameter SI.Temperature T_start = 298.15 "initial temperature";
|
---|
4632 | equation
|
---|
4633 | assert(hasDensity,"Medium " + mediumName +
|
---|
4634 | " can not be used without assigning tableDensity.");
|
---|
4635 | assert(T >= T_min and T <= T_max, "Temperature T (= " + String(T) +
|
---|
4636 | " K) is not in the allowed range (" + String(T_min) +
|
---|
4637 | " K <= T <= " + String(T_max) + " K) required from medium model \""
|
---|
4638 | + mediumName + "\".");
|
---|
4639 | R = Modelica.Constants.R;
|
---|
4640 | cp = Poly.evaluate(poly_Cp,if TinK then T else T_degC);
|
---|
4641 | h = if enthalpyOfT then h_T(T) else h_pT(p,T,densityOfT);
|
---|
4642 | if singleState then
|
---|
4643 | u = h_T(T) - reference_p/d;
|
---|
4644 | else
|
---|
4645 | u = h - p/d;
|
---|
4646 | end if;
|
---|
4647 | d = Poly.evaluate(poly_rho,if TinK then T else T_degC);
|
---|
4648 | state.T = T;
|
---|
4649 | state.p = p;
|
---|
4650 | MM = MM_const;
|
---|
4651 | annotation(Documentation(info="<html>
|
---|
4652 | <p>
|
---|
4653 | Note that the inner energy neglects the pressure dependence, which is only
|
---|
4654 | true for an incompressible medium with d = constant. The neglected term is
|
---|
4655 | p-reference_p)/rho*(T/rho)*(partial rho /partial T). This is very small for
|
---|
4656 | liquids due to proportionality to 1/d^2, but can be problematic for gases that are
|
---|
4657 | modeled incompressible.
|
---|
4658 | </p>
|
---|
4659 | <p>It should be noted that incompressible media only have 1 state per control volume (usually T),
|
---|
4660 | but have both T and p as inputs for fully correct properties. The error of using only T-dependent
|
---|
4661 | properties is small, therefore a Boolean flag enthalpyOfT exists. If it is true, the
|
---|
4662 | enumeration Choices.independentVariables is set to Choices.independentVariables.T otherwise
|
---|
4663 | it is set to Choices.independentVariables.pT.</p>
|
---|
4664 | <p>
|
---|
4665 | Enthalpy is never a function of T only (h = h(T) + (p-reference_p)/d), but the
|
---|
4666 | error is also small and non-linear systems can be avoided. In particular,
|
---|
4667 | non-linear systems are small and local as opposed to large and over all volumes.
|
---|
4668 | </p>
|
---|
4669 |
|
---|
4670 | <p>
|
---|
4671 | Entropy is calculated as
|
---|
4672 | </p>
|
---|
4673 | <pre>
|
---|
4674 | s = s0 + integral(Cp(T)/T,dt)
|
---|
4675 | </pre>
|
---|
4676 | <p>
|
---|
4677 | which is only exactly true for a fluid with constant density d=d0.
|
---|
4678 | </p>
|
---|
4679 | </html>
|
---|
4680 | "));
|
---|
4681 | end BaseProperties;
|
---|
4682 |
|
---|
4683 | redeclare function extends setState_pTX
|
---|
4684 | "Returns state record, given pressure and temperature"
|
---|
4685 | algorithm
|
---|
4686 | state := ThermodynamicState(p=p,T=T);
|
---|
4687 | end setState_pTX;
|
---|
4688 |
|
---|
4689 | redeclare function extends setState_dTX
|
---|
4690 | "Returns state record, given pressure and temperature"
|
---|
4691 | algorithm
|
---|
4692 | assert(false, "for incompressible media with d(T) only, state can not be set from density and temperature");
|
---|
4693 | end setState_dTX;
|
---|
4694 |
|
---|
4695 | redeclare function extends setState_phX
|
---|
4696 | "Returns state record, given pressure and specific enthalpy"
|
---|
4697 | algorithm
|
---|
4698 | state :=ThermodynamicState(p=p,T=T_ph(p,h));
|
---|
4699 | end setState_phX;
|
---|
4700 |
|
---|
4701 | redeclare function extends setState_psX
|
---|
4702 | "Returns state record, given pressure and specific entropy"
|
---|
4703 | algorithm
|
---|
4704 | state :=ThermodynamicState(p=p,T=T_ps(p,s));
|
---|
4705 | end setState_psX;
|
---|
4706 |
|
---|
4707 | redeclare function extends setSmoothState
|
---|
4708 | "Return thermodynamic state so that it smoothly approximates: if x > 0 then state_a else state_b"
|
---|
4709 | algorithm
|
---|
4710 | state :=ThermodynamicState(p=Media.Common.smoothStep(x, state_a.p, state_b.p, x_small),
|
---|
4711 | T=Media.Common.smoothStep(x, state_a.T, state_b.T, x_small));
|
---|
4712 | end setSmoothState;
|
---|
4713 |
|
---|
4714 | redeclare function extends specificHeatCapacityCv
|
---|
4715 | "Specific heat capacity at constant volume (or pressure) of medium"
|
---|
4716 |
|
---|
4717 | algorithm
|
---|
4718 | assert(hasHeatCapacity,"Specific Heat Capacity, Cv, is not defined for medium "
|
---|
4719 | + mediumName + ".");
|
---|
4720 | cv := Poly.evaluate(poly_Cp,if TinK then state.T else state.T - 273.15);
|
---|
4721 | annotation(smoothOrder=2);
|
---|
4722 | end specificHeatCapacityCv;
|
---|
4723 |
|
---|
4724 | redeclare function extends specificHeatCapacityCp
|
---|
4725 | "Specific heat capacity at constant volume (or pressure) of medium"
|
---|
4726 |
|
---|
4727 | algorithm
|
---|
4728 | assert(hasHeatCapacity,"Specific Heat Capacity, Cv, is not defined for medium "
|
---|
4729 | + mediumName + ".");
|
---|
4730 | cp := Poly.evaluate(poly_Cp,if TinK then state.T else state.T - 273.15);
|
---|
4731 | annotation(smoothOrder=2);
|
---|
4732 | end specificHeatCapacityCp;
|
---|
4733 |
|
---|
4734 | redeclare function extends dynamicViscosity
|
---|
4735 | "Return dynamic viscosity as a function of the thermodynamic state record"
|
---|
4736 |
|
---|
4737 | algorithm
|
---|
4738 | assert(size(tableViscosity,1)>0,"DynamicViscosity, eta, is not defined for medium "
|
---|
4739 | + mediumName + ".");
|
---|
4740 | eta := Math.exp(Poly.evaluate(poly_eta, 1/state.T));
|
---|
4741 | annotation(smoothOrder=2);
|
---|
4742 | end dynamicViscosity;
|
---|
4743 |
|
---|
4744 | redeclare function extends thermalConductivity
|
---|
4745 | "Return thermal conductivity as a function of the thermodynamic state record"
|
---|
4746 |
|
---|
4747 | algorithm
|
---|
4748 | assert(size(tableConductivity,1)>0,"ThermalConductivity, lambda, is not defined for medium "
|
---|
4749 | + mediumName + ".");
|
---|
4750 | lambda := Poly.evaluate(poly_lam,if TinK then state.T else Cv.to_degC(state.T));
|
---|
4751 | annotation(smoothOrder=2);
|
---|
4752 | end thermalConductivity;
|
---|
4753 |
|
---|
4754 | function s_T "compute specific entropy"
|
---|
4755 | input Temperature T "temperature";
|
---|
4756 | output SpecificEntropy s "specific entropy";
|
---|
4757 | algorithm
|
---|
4758 | s := s0 + (if TinK then
|
---|
4759 | Poly.integralValue(poly_Cp[1:npol],T, T0) else
|
---|
4760 | Poly.integralValue(poly_Cp[1:npol],Cv.to_degC(T),Cv.to_degC(T0)))
|
---|
4761 | + Modelica.Math.log(T/T0)*
|
---|
4762 | Poly.evaluate(poly_Cp,if TinK then 0 else Modelica.Constants.T_zero);
|
---|
4763 | annotation(smoothOrder=2);
|
---|
4764 | end s_T;
|
---|
4765 |
|
---|
4766 | redeclare function extends specificEntropy "Return specific entropy
|
---|
4767 | as a function of the thermodynamic state record"
|
---|
4768 |
|
---|
4769 | protected
|
---|
4770 | Integer npol=size(poly_Cp,1)-1;
|
---|
4771 | algorithm
|
---|
4772 | assert(hasHeatCapacity,"Specific Entropy, s(T), is not defined for medium "
|
---|
4773 | + mediumName + ".");
|
---|
4774 | s := s_T(state.T);
|
---|
4775 | annotation(smoothOrder=2);
|
---|
4776 | end specificEntropy;
|
---|
4777 |
|
---|
4778 | function h_T "Compute specific enthalpy from temperature"
|
---|
4779 | import Modelica.SIunits.Conversions.to_degC;
|
---|
4780 | extends Modelica.Icons.Function;
|
---|
4781 | input SI.Temperature T "Temperature";
|
---|
4782 | output SI.SpecificEnthalpy h "Specific enthalpy at p, T";
|
---|
4783 | algorithm
|
---|
4784 | h :=h0 + Poly.integralValue(poly_Cp, if TinK then T else Cv.to_degC(T), if TinK then
|
---|
4785 | T0 else Cv.to_degC(T0));
|
---|
4786 | annotation(derivative=h_T_der);
|
---|
4787 | end h_T;
|
---|
4788 |
|
---|
4789 | function h_T_der "Compute specific enthalpy from temperature"
|
---|
4790 | import Modelica.SIunits.Conversions.to_degC;
|
---|
4791 | extends Modelica.Icons.Function;
|
---|
4792 | input SI.Temperature T "Temperature";
|
---|
4793 | input Real dT "temperature derivative";
|
---|
4794 | output Real dh "derivative of Specific enthalpy at T";
|
---|
4795 | algorithm
|
---|
4796 | dh :=Poly.evaluate(poly_Cp, if TinK then T else Cv.to_degC(T))*dT;
|
---|
4797 | annotation(smoothOrder=1);
|
---|
4798 | end h_T_der;
|
---|
4799 |
|
---|
4800 | function h_pT "Compute specific enthalpy from pressure and temperature"
|
---|
4801 | import Modelica.SIunits.Conversions.to_degC;
|
---|
4802 | extends Modelica.Icons.Function;
|
---|
4803 | input SI.Pressure p "Pressure";
|
---|
4804 | input SI.Temperature T "Temperature";
|
---|
4805 | input Boolean densityOfT = false
|
---|
4806 | "include or neglect density derivative dependence of enthalpy" annotation(Evaluate);
|
---|
4807 | output SI.SpecificEnthalpy h "Specific enthalpy at p, T";
|
---|
4808 | algorithm
|
---|
4809 | h :=h0 + Poly.integralValue(poly_Cp, if TinK then T else Cv.to_degC(T), if TinK then
|
---|
4810 | T0 else Cv.to_degC(T0)) + (p - reference_p)/Poly.evaluate(poly_rho, if TinK then
|
---|
4811 | T else Cv.to_degC(T))
|
---|
4812 | *(if densityOfT then (1 + T/Poly.evaluate(poly_rho, if TinK then T else Cv.to_degC(T))
|
---|
4813 | *Poly.derivativeValue(poly_rho,if TinK then T else Cv.to_degC(T))) else 1.0);
|
---|
4814 | annotation(smoothOrder=2);
|
---|
4815 | end h_pT;
|
---|
4816 |
|
---|
4817 | redeclare function extends temperature
|
---|
4818 | "Return temperature as a function of the thermodynamic state record"
|
---|
4819 | algorithm
|
---|
4820 | T := state.T;
|
---|
4821 | annotation(smoothOrder=2);
|
---|
4822 | end temperature;
|
---|
4823 |
|
---|
4824 | redeclare function extends pressure
|
---|
4825 | "Return pressure as a function of the thermodynamic state record"
|
---|
4826 | algorithm
|
---|
4827 | p := state.p;
|
---|
4828 | annotation(smoothOrder=2);
|
---|
4829 | end pressure;
|
---|
4830 |
|
---|
4831 | redeclare function extends density
|
---|
4832 | "Return density as a function of the thermodynamic state record"
|
---|
4833 | algorithm
|
---|
4834 | d := Poly.evaluate(poly_rho,if TinK then state.T else Cv.to_degC(state.T));
|
---|
4835 | annotation(smoothOrder=2);
|
---|
4836 | end density;
|
---|
4837 |
|
---|
4838 | redeclare function extends specificEnthalpy
|
---|
4839 | "Return specific enthalpy as a function of the thermodynamic state record"
|
---|
4840 | algorithm
|
---|
4841 | h := if enthalpyOfT then h_T(state.T) else h_pT(state.p,state.T);
|
---|
4842 | annotation(smoothOrder=2);
|
---|
4843 | end specificEnthalpy;
|
---|
4844 |
|
---|
4845 | redeclare function extends specificInternalEnergy
|
---|
4846 | "Return specific internal energy as a function of the thermodynamic state record"
|
---|
4847 | algorithm
|
---|
4848 | u := if enthalpyOfT then h_T(state.T) else h_pT(state.p,state.T)
|
---|
4849 | - (if singleState then reference_p/density(state) else state.p/density(state));
|
---|
4850 | annotation(smoothOrder=2);
|
---|
4851 | end specificInternalEnergy;
|
---|
4852 |
|
---|
4853 | function T_ph "Compute temperature from pressure and specific enthalpy"
|
---|
4854 | input AbsolutePressure p "pressure";
|
---|
4855 | input SpecificEnthalpy h "specific enthalpy";
|
---|
4856 | output Temperature T "temperature";
|
---|
4857 | protected
|
---|
4858 | package Internal
|
---|
4859 | "Solve h(T) for T with given h (use only indirectly via temperature_phX)"
|
---|
4860 | extends Modelica.Media.Common.OneNonLinearEquation;
|
---|
4861 |
|
---|
4862 | redeclare record extends f_nonlinear_Data
|
---|
4863 | "superfluous record, fix later when better structure of inverse functions exists"
|
---|
4864 | constant Real[5] dummy = {1,2,3,4,5};
|
---|
4865 | end f_nonlinear_Data;
|
---|
4866 |
|
---|
4867 | redeclare function extends f_nonlinear
|
---|
4868 | "p is smuggled in via vector"
|
---|
4869 | algorithm
|
---|
4870 | y := if singleState then h_T(x) else h_pT(p,x);
|
---|
4871 | end f_nonlinear;
|
---|
4872 |
|
---|
4873 | // Dummy definition has to be added for current Dymola
|
---|
4874 | redeclare function extends solve
|
---|
4875 | end solve;
|
---|
4876 | end Internal;
|
---|
4877 | algorithm
|
---|
4878 | T := Internal.solve(h, T_min, T_max, p, {1}, Internal.f_nonlinear_Data());
|
---|
4879 | annotation(Inline=false, LateInline=true, inverse=h_pT(p,T));
|
---|
4880 | end T_ph;
|
---|
4881 |
|
---|
4882 | function T_ps "Compute temperature from pressure and specific enthalpy"
|
---|
4883 | input AbsolutePressure p "pressure";
|
---|
4884 | input SpecificEntropy s "specific entropy";
|
---|
4885 | output Temperature T "temperature";
|
---|
4886 | protected
|
---|
4887 | package Internal
|
---|
4888 | "Solve h(T) for T with given h (use only indirectly via temperature_phX)"
|
---|
4889 | extends Modelica.Media.Common.OneNonLinearEquation;
|
---|
4890 |
|
---|
4891 | redeclare record extends f_nonlinear_Data
|
---|
4892 | "superfluous record, fix later when better structure of inverse functions exists"
|
---|
4893 | constant Real[5] dummy = {1,2,3,4,5};
|
---|
4894 | end f_nonlinear_Data;
|
---|
4895 |
|
---|
4896 | redeclare function extends f_nonlinear
|
---|
4897 | "p is smuggled in via vector"
|
---|
4898 | algorithm
|
---|
4899 | y := s_T(x);
|
---|
4900 | end f_nonlinear;
|
---|
4901 |
|
---|
4902 | // Dummy definition has to be added for current Dymola
|
---|
4903 | redeclare function extends solve
|
---|
4904 | end solve;
|
---|
4905 | end Internal;
|
---|
4906 | algorithm
|
---|
4907 | T := Internal.solve(s, T_min, T_max, p, {1}, Internal.f_nonlinear_Data());
|
---|
4908 | end T_ps;
|
---|
4909 |
|
---|
4910 | package Polynomials_Temp
|
---|
4911 | "Temporary Functions operating on polynomials (including polynomial fitting); only to be used in Modelica.Media.Incompressible.TableBased"
|
---|
4912 | extends Modelica.Icons.Package;
|
---|
4913 |
|
---|
4914 | function evaluate "Evaluate polynomial at a given abszissa value"
|
---|
4915 | extends Modelica.Icons.Function;
|
---|
4916 | input Real p[:]
|
---|
4917 | "Polynomial coefficients (p[1] is coefficient of highest power)";
|
---|
4918 | input Real u "Abszissa value";
|
---|
4919 | output Real y "Value of polynomial at u";
|
---|
4920 | algorithm
|
---|
4921 | y := p[1];
|
---|
4922 | for j in 2:size(p, 1) loop
|
---|
4923 | y := p[j] + u*y;
|
---|
4924 | end for;
|
---|
4925 | annotation(derivative(zeroDerivative=p)=evaluate_der);
|
---|
4926 | end evaluate;
|
---|
4927 |
|
---|
4928 | function derivativeValue
|
---|
4929 | "Value of derivative of polynomial at abszissa value u"
|
---|
4930 | extends Modelica.Icons.Function;
|
---|
4931 | input Real p[:]
|
---|
4932 | "Polynomial coefficients (p[1] is coefficient of highest power)";
|
---|
4933 | input Real u "Abszissa value";
|
---|
4934 | output Real y "Value of derivative of polynomial at u";
|
---|
4935 | protected
|
---|
4936 | Integer n=size(p, 1);
|
---|
4937 | algorithm
|
---|
4938 | y := p[1]*(n - 1);
|
---|
4939 | for j in 2:size(p, 1)-1 loop
|
---|
4940 | y := p[j]*(n - j) + u*y;
|
---|
4941 | end for;
|
---|
4942 | annotation(derivative(zeroDerivative=p)=derivativeValue_der);
|
---|
4943 | end derivativeValue;
|
---|
4944 |
|
---|
4945 | function secondDerivativeValue
|
---|
4946 | "Value of 2nd derivative of polynomial at abszissa value u"
|
---|
4947 | extends Modelica.Icons.Function;
|
---|
4948 | input Real p[:]
|
---|
4949 | "Polynomial coefficients (p[1] is coefficient of highest power)";
|
---|
4950 | input Real u "Abszissa value";
|
---|
4951 | output Real y "Value of 2nd derivative of polynomial at u";
|
---|
4952 | protected
|
---|
4953 | Integer n=size(p, 1);
|
---|
4954 | algorithm
|
---|
4955 | y := p[1]*(n - 1)*(n - 2);
|
---|
4956 | for j in 2:size(p, 1)-2 loop
|
---|
4957 | y := p[j]*(n - j)*(n - j - 1) + u*y;
|
---|
4958 | end for;
|
---|
4959 | end secondDerivativeValue;
|
---|
4960 |
|
---|
4961 | function integralValue
|
---|
4962 | "Integral of polynomial p(u) from u_low to u_high"
|
---|
4963 | extends Modelica.Icons.Function;
|
---|
4964 | input Real p[:] "Polynomial coefficients";
|
---|
4965 | input Real u_high "High integrand value";
|
---|
4966 | input Real u_low=0 "Low integrand value, default 0";
|
---|
4967 | output Real integral=0.0
|
---|
4968 | "Integral of polynomial p from u_low to u_high";
|
---|
4969 | protected
|
---|
4970 | Integer n=size(p, 1) "degree of integrated polynomial";
|
---|
4971 | Real y_low=0 "value at lower integrand";
|
---|
4972 | algorithm
|
---|
4973 | for j in 1:n loop
|
---|
4974 | integral := u_high*(p[j]/(n - j + 1) + integral);
|
---|
4975 | y_low := u_low*(p[j]/(n - j + 1) + y_low);
|
---|
4976 | end for;
|
---|
4977 | integral := integral - y_low;
|
---|
4978 | annotation(derivative(zeroDerivative=p)=integralValue_der);
|
---|
4979 | end integralValue;
|
---|
4980 |
|
---|
4981 | function fitting
|
---|
4982 | "Computes the coefficients of a polynomial that fits a set of data points in a least-squares sense"
|
---|
4983 | extends Modelica.Icons.Function;
|
---|
4984 | input Real u[:] "Abscissa data values";
|
---|
4985 | input Real y[size(u, 1)] "Ordinate data values";
|
---|
4986 | input Integer n(min=1)
|
---|
4987 | "Order of desired polynomial that fits the data points (u,y)";
|
---|
4988 | output Real p[n + 1]
|
---|
4989 | "Polynomial coefficients of polynomial that fits the date points";
|
---|
4990 | protected
|
---|
4991 | Real V[size(u, 1), n + 1] "Vandermonde matrix";
|
---|
4992 | algorithm
|
---|
4993 | // Construct Vandermonde matrix
|
---|
4994 | V[:, n + 1] := ones(size(u, 1));
|
---|
4995 | for j in n:-1:1 loop
|
---|
4996 | V[:, j] := {u[i] * V[i, j + 1] for i in 1:size(u,1)};
|
---|
4997 | end for;
|
---|
4998 |
|
---|
4999 | // Solve least squares problem
|
---|
5000 | p :=Modelica.Math.Matrices.leastSquares(V, y);
|
---|
5001 | annotation (Documentation(info="<HTML>
|
---|
5002 | <p>
|
---|
5003 | Polynomials.fitting(u,y,n) computes the coefficients of a polynomial
|
---|
5004 | p(u) of degree \"n\" that fits the data \"p(u[i]) - y[i]\"
|
---|
5005 | in a least squares sense. The polynomial is
|
---|
5006 | returned as a vector p[n+1] that has the following definition:
|
---|
5007 | </p>
|
---|
5008 | <pre>
|
---|
5009 | p(u) = p[1]*u^n + p[2]*u^(n-1) + ... + p[n]*u + p[n+1];
|
---|
5010 | </pre>
|
---|
5011 | </HTML>"));
|
---|
5012 | end fitting;
|
---|
5013 |
|
---|
5014 | function evaluate_der "Evaluate polynomial at a given abszissa value"
|
---|
5015 | extends Modelica.Icons.Function;
|
---|
5016 | input Real p[:]
|
---|
5017 | "Polynomial coefficients (p[1] is coefficient of highest power)";
|
---|
5018 | input Real u "Abszissa value";
|
---|
5019 | input Real du "Abszissa value";
|
---|
5020 | output Real dy "Value of polynomial at u";
|
---|
5021 | protected
|
---|
5022 | Integer n=size(p, 1);
|
---|
5023 | algorithm
|
---|
5024 | dy := p[1]*(n - 1);
|
---|
5025 | for j in 2:size(p, 1)-1 loop
|
---|
5026 | dy := p[j]*(n - j) + u*dy;
|
---|
5027 | end for;
|
---|
5028 | dy := dy*du;
|
---|
5029 | end evaluate_der;
|
---|
5030 |
|
---|
5031 | function integralValue_der
|
---|
5032 | "Time derivative of integral of polynomial p(u) from u_low to u_high, assuming only u_high as time-dependent (Leibnitz rule)"
|
---|
5033 | extends Modelica.Icons.Function;
|
---|
5034 | input Real p[:] "Polynomial coefficients";
|
---|
5035 | input Real u_high "High integrand value";
|
---|
5036 | input Real u_low=0 "Low integrand value, default 0";
|
---|
5037 | input Real du_high "High integrand value";
|
---|
5038 | input Real du_low=0 "Low integrand value, default 0";
|
---|
5039 | output Real dintegral=0.0
|
---|
5040 | "Integral of polynomial p from u_low to u_high";
|
---|
5041 | algorithm
|
---|
5042 | dintegral := evaluate(p,u_high)*du_high;
|
---|
5043 | end integralValue_der;
|
---|
5044 |
|
---|
5045 | function derivativeValue_der
|
---|
5046 | "time derivative of derivative of polynomial"
|
---|
5047 | extends Modelica.Icons.Function;
|
---|
5048 | input Real p[:]
|
---|
5049 | "Polynomial coefficients (p[1] is coefficient of highest power)";
|
---|
5050 | input Real u "Abszissa value";
|
---|
5051 | input Real du "delta of abszissa value";
|
---|
5052 | output Real dy
|
---|
5053 | "time-derivative of derivative of polynomial w.r.t. input variable at u";
|
---|
5054 | protected
|
---|
5055 | Integer n=size(p, 1);
|
---|
5056 | algorithm
|
---|
5057 | dy := secondDerivativeValue(p,u)*du;
|
---|
5058 | end derivativeValue_der;
|
---|
5059 | annotation (Documentation(info="<HTML>
|
---|
5060 | <p>
|
---|
5061 | This package contains functions to operate on polynomials,
|
---|
5062 | in particular to determine the derivative and the integral
|
---|
5063 | of a polynomial and to use a polynomial to fit a given set
|
---|
5064 | of data points.
|
---|
5065 | </p>
|
---|
5066 | <p>
|
---|
5067 |
|
---|
5068 | <p><b>Copyright © 2004-2010, Modelica Association and DLR.</b></p>
|
---|
5069 |
|
---|
5070 | <p><i>
|
---|
5071 | This package is <b>free</b> software. It can be redistributed and/or modified
|
---|
5072 | under the terms of the <b>Modelica license</b>, see the license conditions
|
---|
5073 | and the accompanying <b>disclaimer</b> in the documentation of package
|
---|
5074 | Modelica in file \"Modelica/package.mo\".
|
---|
5075 | </i>
|
---|
5076 | </p>
|
---|
5077 |
|
---|
5078 | </HTML>
|
---|
5079 | ", revisions="<html>
|
---|
5080 | <ul>
|
---|
5081 | <li><i>Oct. 22, 2004</i> by Martin Otter (DLR):<br>
|
---|
5082 | Renamed functions to not have abbrevations.<br>
|
---|
5083 | Based fitting on LAPACK<br>
|
---|
5084 | New function to return the polynomial of an indefinite integral<li>
|
---|
5085 | <li><i>Sept. 3, 2004</i> by Jonas Eborn (Scynamics):<br>
|
---|
5086 | polyderval, polyintval added<li>
|
---|
5087 | <li><i>March 1, 2004</i> by Martin Otter (DLR):<br>
|
---|
5088 | first version implemented
|
---|
5089 | </li>
|
---|
5090 | </ul>
|
---|
5091 | </html>"));
|
---|
5092 | end Polynomials_Temp;
|
---|
5093 | annotation(__Dymola_keepConstant = true, Documentation(info="<HTML>
|
---|
5094 | <p>
|
---|
5095 | This is the base package for medium models of incompressible fluids based on
|
---|
5096 | tables. The minimal data to provide for a useful medium description is tables
|
---|
5097 | of density and heat capacity as functions of temperature.
|
---|
5098 | </p>
|
---|
5099 |
|
---|
5100 | <p>It should be noted that incompressible media only have 1 state per control volume (usually T),
|
---|
5101 | but have both T and p as inputs for fully correct properties. The error of using only T-dependent
|
---|
5102 | properties is small, therefore a Boolean flag enthalpyOfT exists. If it is true, the
|
---|
5103 | enumeration Choices.independentVariables is set to Choices.independentVariables.T otherwise
|
---|
5104 | it is set to Choices.independentVariables.pT.</p>
|
---|
5105 |
|
---|
5106 | <h4>Using the package TableBased</h4>
|
---|
5107 | <p>
|
---|
5108 | To implement a new medium model, create a package that <b>extends</b> TableBased
|
---|
5109 | and provides one or more of the constant tables:
|
---|
5110 | </p>
|
---|
5111 |
|
---|
5112 | <pre>
|
---|
5113 | tableDensity = [T, d];
|
---|
5114 | tableHeatCapacity = [T, Cp];
|
---|
5115 | tableConductivity = [T, lam];
|
---|
5116 | tableViscosity = [T, eta];
|
---|
5117 | tableVaporPressure = [T, pVap];
|
---|
5118 | </pre>
|
---|
5119 |
|
---|
5120 | <p>
|
---|
5121 | The table data is used to fit constant polynomials of order <b>npol</b>, the
|
---|
5122 | temperature data points do not need to be same for different properties. Properties
|
---|
5123 | like enthalpy, inner energy and entropy are calculated consistently from integrals
|
---|
5124 | and derivatives of d(T) and Cp(T). The minimal
|
---|
5125 | data for a useful medium model is thus density and heat capacity. Transport
|
---|
5126 | properties and vapor pressure are optional, if the data tables are empty the corresponding
|
---|
5127 | function calls can not be used.
|
---|
5128 | </p>
|
---|
5129 | </HTML>"),
|
---|
5130 | Documentation(info="<HTML>
|
---|
5131 | <h4>Table based media</h4>
|
---|
5132 | <p>
|
---|
5133 | This is the base package for medium models of incompressible fluids based on
|
---|
5134 | tables. The minimal data to provide for a useful medium description is tables
|
---|
5135 | of density and heat capacity as functions of temperature.
|
---|
5136 | </p>
|
---|
5137 | <h4>Using the package TableBased</h4>
|
---|
5138 | <p>
|
---|
5139 | To implement a new medium model, create a package that <b>extends</b> TableBased
|
---|
5140 | and provides one or more of the constant tables:
|
---|
5141 | <pre>
|
---|
5142 | tableDensity = [T, d];
|
---|
5143 | tableHeatCapacity = [T, Cp];
|
---|
5144 | tableConductivity = [T, lam];
|
---|
5145 | tableViscosity = [T, eta];
|
---|
5146 | tableVaporPressure = [T, pVap];
|
---|
5147 | </pre>
|
---|
5148 | The table data is used to fit constant polynomials of order <b>npol</b>, the
|
---|
5149 | temperature data points do not need to be same for different properties. Properties
|
---|
5150 | like enthalpy, inner energy and entropy are calculated consistently from integrals
|
---|
5151 | and derivatives of d(T) and Cp(T). The minimal
|
---|
5152 | data for a useful medium model is thus density and heat capacity. Transport
|
---|
5153 | properties and vapor pressure are optional, if the data tables are empty the corresponding
|
---|
5154 | function calls can not be used.
|
---|
5155 | </HTML>"));
|
---|
5156 | end TableBased;
|
---|
5157 | annotation (
|
---|
5158 | Documentation(info="<HTML>
|
---|
5159 | <h4>Incompressible media package</h4>
|
---|
5160 | <p>
|
---|
5161 | This package provides a structure and examples of how to create simple
|
---|
5162 | medium models of incompressible fluids, meaning fluids with very little
|
---|
5163 | pressure influence on density. The medium properties is typically described
|
---|
5164 | in terms of tables, functions or polynomial coefficients.
|
---|
5165 | </p>
|
---|
5166 | <h4>Definitions</h4>
|
---|
5167 | <p>
|
---|
5168 | The common meaning of <em>incompressible</em> is that properties like density
|
---|
5169 | and enthalpy are independent of pressure. Thus properties are conveniently
|
---|
5170 | described as functions of temperature, e.g., as polynomials density(T) and cp(T).
|
---|
5171 | However, enthalpy can not be independent of pressure since h = u - p/d. For liquids
|
---|
5172 | it is anyway
|
---|
5173 | common to neglect this dependence since for constant density the neglected term
|
---|
5174 | is (p - p0)/d, which in comparison with cp is very small for most liquids. For
|
---|
5175 | water, the equivalent change of temperature to increasing pressure 1 bar is
|
---|
5176 | 0.025 Kelvin.
|
---|
5177 | </p>
|
---|
5178 | <p>
|
---|
5179 | Two boolean flags are used to choose how enthalpy and inner energy is calculated:
|
---|
5180 | <ul>
|
---|
5181 | <li><b>enthalpyOfT</b>=true, means assuming that enthalpy is only a function
|
---|
5182 | of temperature, neglecting the pressure dependent term.</li>
|
---|
5183 | <li><b>singleState</b>=true, means also neglect the pressure influence on inner
|
---|
5184 | energy, which makes all medium properties pure functions of temperature.</li>
|
---|
5185 | </ul>
|
---|
5186 | The default setting for both these flags is true, which enables the simulation tool
|
---|
5187 | to choose temperature as the only medium state and avoids non-linear equation
|
---|
5188 | systems, see the section about
|
---|
5189 | <a href=\"modelica://Modelica.Media.UsersGuide.MediumDefinition.StaticStateSelection\">Static
|
---|
5190 | state selection</a> in the Modelica.Media User's Guide.
|
---|
5191 |
|
---|
5192 | </p>
|
---|
5193 | <h4>Contents</h4>
|
---|
5194 | <p>
|
---|
5195 | Currently, the package contains the following parts:
|
---|
5196 | </p>
|
---|
5197 | <ol>
|
---|
5198 | <li> <a href=\"modelica://Modelica.Media.Incompressible.TableBased\">
|
---|
5199 | Table based medium models</a></li>
|
---|
5200 | <li> <a href=\"modelica://Modelica.Media.Incompressible.Examples\">
|
---|
5201 | Example medium models</a></li>
|
---|
5202 | </ol>
|
---|
5203 |
|
---|
5204 | <p>
|
---|
5205 | A few examples are given in the Examples package. The model
|
---|
5206 | <a href=\"modelica://Modelica.Media.Incompressible.Examples.Glycol47\">
|
---|
5207 | Examples.Glycol47</a> shows how the medium models can be used. For more
|
---|
5208 | realistic examples of how to implement volume models with medium properties
|
---|
5209 | look in the <a href=\"modelica://Modelica.Media.UsersGuide.MediumUsage\">Medium
|
---|
5210 | usage section</a> of the User's Guide.
|
---|
5211 | </p>
|
---|
5212 |
|
---|
5213 | </HTML>"));
|
---|
5214 | end Incompressible;
|
---|
5215 | annotation (
|
---|
5216 | Documentation(info="<HTML>
|
---|
5217 | <p>
|
---|
5218 | This library contains <a href=\"modelica://Modelica.Media.Interfaces\">interface</a>
|
---|
5219 | definitions for media and the following <b>property</b> models for
|
---|
5220 | single and multiple substance fluids with one and multiple phases:
|
---|
5221 | </p>
|
---|
5222 | <ul>
|
---|
5223 | <li> <a href=\"modelica://Modelica.Media.IdealGases\">Ideal gases:</a><br>
|
---|
5224 | 1241 high precision gas models based on the
|
---|
5225 | NASA Glenn coefficients, plus ideal gas mixture models based
|
---|
5226 | on the same data.</li>
|
---|
5227 | <li> <a href=\"modelica://Modelica.Media.Water\">Water models:</a><br>
|
---|
5228 | ConstantPropertyLiquidWater, WaterIF97 (high precision
|
---|
5229 | water model according to the IAPWS/IF97 standard)</li>
|
---|
5230 | <li> <a href=\"modelica://Modelica.Media.Air\">Air models:</a><br>
|
---|
5231 | SimpleAir, DryAirNasa, and MoistAir</li>
|
---|
5232 | <li> <a href=\"modelica://Modelica.Media.Incompressible\">
|
---|
5233 | Incompressible media:</a><br>
|
---|
5234 | TableBased incompressible fluid models (properties are defined by tables rho(T),
|
---|
5235 | HeatCapacity_cp(T), etc.)</li>
|
---|
5236 | <li> <a href=\"modelica://Modelica.Media.CompressibleLiquids\">
|
---|
5237 | Compressible liquids:</a><br>
|
---|
5238 | Simple liquid models with linear compressibility</li>
|
---|
5239 | </ul>
|
---|
5240 | <p>
|
---|
5241 | The following parts are useful, when newly starting with this library:
|
---|
5242 | <ul>
|
---|
5243 | <li> <a href=\"modelica://Modelica.Media.UsersGuide\">Modelica.Media.UsersGuide</a>.</li>
|
---|
5244 | <li> <a href=\"modelica://Modelica.Media.UsersGuide.MediumUsage\">Modelica.Media.UsersGuide.MediumUsage</a>
|
---|
5245 | describes how to use a medium model in a component model.</li>
|
---|
5246 | <li> <a href=\"modelica://Modelica.Media.UsersGuide.MediumDefinition\">
|
---|
5247 | Modelica.Media.UsersGuide.MediumDefinition</a>
|
---|
5248 | describes how a new fluid medium model has to be implemented.</li>
|
---|
5249 | <li> <a href=\"modelica://Modelica.Media.UsersGuide.ReleaseNotes\">Modelica.Media.UsersGuide.ReleaseNotes</a>
|
---|
5250 | summarizes the changes of the library releases.</li>
|
---|
5251 | <li> <a href=\"modelica://Modelica.Media.Examples\">Modelica.Media.Examples</a>
|
---|
5252 | contains examples that demonstrate the usage of this library.</li>
|
---|
5253 | </ul>
|
---|
5254 | <p>
|
---|
5255 | Copyright © 1998-2010, Modelica Association.
|
---|
5256 | </p>
|
---|
5257 | <p>
|
---|
5258 | <i>This Modelica package is <u>free</u> software and the use is completely at <u>your own risk</u>; it can be redistributed and/or modified under the terms of the Modelica License 2. For license conditions (including the disclaimer of warranty) see <a href=\"modelica://Modelica.UsersGuide.ModelicaLicense2\">Modelica.UsersGuide.ModelicaLicense2</a> or visit <a href=\"http://www.modelica.org/licenses/ModelicaLicense2\"> http://www.modelica.org/licenses/ModelicaLicense2</a>.</i>
|
---|
5259 | </p>
|
---|
5260 | </HTML>"));
|
---|
5261 | end Media;
|
---|
5262 |
|
---|
5263 | package Thermal
|
---|
5264 | "Library of thermal system components to model heat transfer and simple thermo-fluid pipe flow"
|
---|
5265 | extends Modelica.Icons.Package;
|
---|
5266 |
|
---|
5267 | package HeatTransfer
|
---|
5268 | "Library of 1-dimensional heat transfer with lumped elements"
|
---|
5269 | import Modelica.SIunits.Conversions.*;
|
---|
5270 | extends Modelica.Icons.Package;
|
---|
5271 |
|
---|
5272 | package Sources "Thermal sources"
|
---|
5273 | extends Modelica.Icons.SourcesPackage;
|
---|
5274 |
|
---|
5275 | model FixedTemperature "Fixed temperature boundary condition in Kelvin"
|
---|
5276 |
|
---|
5277 | parameter Modelica.SIunits.Temperature T "Fixed temperature at port";
|
---|
5278 | Interfaces.HeatPort_b port annotation (Placement(transformation(extent={{90,
|
---|
5279 | -10},{110,10}}, rotation=0)));
|
---|
5280 | equation
|
---|
5281 | port.T = T;
|
---|
5282 | annotation (
|
---|
5283 | Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
|
---|
5284 | 100,100}}), graphics={
|
---|
5285 | Text(
|
---|
5286 | extent={{-150,150},{150,110}},
|
---|
5287 | textString="%name",
|
---|
5288 | lineColor={0,0,255}),
|
---|
5289 | Text(
|
---|
5290 | extent={{-150,-110},{150,-140}},
|
---|
5291 | lineColor={0,0,0},
|
---|
5292 | textString="T=%T"),
|
---|
5293 | Rectangle(
|
---|
5294 | extent={{-100,100},{100,-100}},
|
---|
5295 | lineColor={0,0,0},
|
---|
5296 | pattern=LinePattern.None,
|
---|
5297 | fillColor={159,159,223},
|
---|
5298 | fillPattern=FillPattern.Backward),
|
---|
5299 | Text(
|
---|
5300 | extent={{0,0},{-100,-100}},
|
---|
5301 | lineColor={0,0,0},
|
---|
5302 | textString="K"),
|
---|
5303 | Line(
|
---|
5304 | points={{-52,0},{56,0}},
|
---|
5305 | color={191,0,0},
|
---|
5306 | thickness=0.5),
|
---|
5307 | Polygon(
|
---|
5308 | points={{50,-20},{50,20},{90,0},{50,-20}},
|
---|
5309 | lineColor={191,0,0},
|
---|
5310 | fillColor={191,0,0},
|
---|
5311 | fillPattern=FillPattern.Solid)}),
|
---|
5312 | Documentation(info="<HTML>
|
---|
5313 | <p>
|
---|
5314 | This model defines a fixed temperature T at its port in Kelvin,
|
---|
5315 | i.e., it defines a fixed temperature as a boundary condition.
|
---|
5316 | </p>
|
---|
5317 | </HTML>
|
---|
5318 | "), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
|
---|
5319 | 100,100}}), graphics={
|
---|
5320 | Rectangle(
|
---|
5321 | extent={{-100,100},{100,-101}},
|
---|
5322 | lineColor={0,0,0},
|
---|
5323 | pattern=LinePattern.None,
|
---|
5324 | fillColor={159,159,223},
|
---|
5325 | fillPattern=FillPattern.Backward),
|
---|
5326 | Line(
|
---|
5327 | points={{-52,0},{56,0}},
|
---|
5328 | color={191,0,0},
|
---|
5329 | thickness=0.5),
|
---|
5330 | Text(
|
---|
5331 | extent={{0,0},{-100,-100}},
|
---|
5332 | lineColor={0,0,0},
|
---|
5333 | textString="K"),
|
---|
5334 | Polygon(
|
---|
5335 | points={{52,-20},{52,20},{90,0},{52,-20}},
|
---|
5336 | lineColor={191,0,0},
|
---|
5337 | fillColor={191,0,0},
|
---|
5338 | fillPattern=FillPattern.Solid)}));
|
---|
5339 | end FixedTemperature;
|
---|
5340 |
|
---|
5341 | model FixedHeatFlow "Fixed heat flow boundary condition"
|
---|
5342 | parameter Modelica.SIunits.HeatFlowRate Q_flow
|
---|
5343 | "Fixed heat flow rate at port";
|
---|
5344 | parameter Modelica.SIunits.Temperature T_ref=293.15
|
---|
5345 | "Reference temperature";
|
---|
5346 | parameter Modelica.SIunits.LinearTemperatureCoefficient alpha=0
|
---|
5347 | "Temperature coefficient of heat flow rate";
|
---|
5348 | Interfaces.HeatPort_b port annotation (Placement(transformation(extent={{90,
|
---|
5349 | -10},{110,10}}, rotation=0)));
|
---|
5350 | equation
|
---|
5351 | port.Q_flow = -Q_flow*(1 + alpha*(port.T - T_ref));
|
---|
5352 | annotation (
|
---|
5353 | Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
|
---|
5354 | 100,100}}), graphics={
|
---|
5355 | Text(
|
---|
5356 | extent={{-150,100},{150,60}},
|
---|
5357 | textString="%name",
|
---|
5358 | lineColor={0,0,255}),
|
---|
5359 | Text(
|
---|
5360 | extent={{-150,-55},{150,-85}},
|
---|
5361 | lineColor={0,0,0},
|
---|
5362 | textString="Q_flow=%Q_flow"),
|
---|
5363 | Line(
|
---|
5364 | points={{-100,-20},{48,-20}},
|
---|
5365 | color={191,0,0},
|
---|
5366 | thickness=0.5),
|
---|
5367 | Line(
|
---|
5368 | points={{-100,20},{46,20}},
|
---|
5369 | color={191,0,0},
|
---|
5370 | thickness=0.5),
|
---|
5371 | Polygon(
|
---|
5372 | points={{40,0},{40,40},{70,20},{40,0}},
|
---|
5373 | lineColor={191,0,0},
|
---|
5374 | fillColor={191,0,0},
|
---|
5375 | fillPattern=FillPattern.Solid),
|
---|
5376 | Polygon(
|
---|
5377 | points={{40,-40},{40,0},{70,-20},{40,-40}},
|
---|
5378 | lineColor={191,0,0},
|
---|
5379 | fillColor={191,0,0},
|
---|
5380 | fillPattern=FillPattern.Solid),
|
---|
5381 | Rectangle(
|
---|
5382 | extent={{70,40},{90,-40}},
|
---|
5383 | lineColor={191,0,0},
|
---|
5384 | fillColor={191,0,0},
|
---|
5385 | fillPattern=FillPattern.Solid)}),
|
---|
5386 | Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},
|
---|
5387 | {100,100}}), graphics={
|
---|
5388 | Text(
|
---|
5389 | extent={{-100,40},{0,-36}},
|
---|
5390 | lineColor={0,0,0},
|
---|
5391 | textString="Q_flow=const."),
|
---|
5392 | Line(
|
---|
5393 | points={{-48,-20},{60,-20}},
|
---|
5394 | color={191,0,0},
|
---|
5395 | thickness=0.5),
|
---|
5396 | Line(
|
---|
5397 | points={{-48,20},{60,20}},
|
---|
5398 | color={191,0,0},
|
---|
5399 | thickness=0.5),
|
---|
5400 | Polygon(
|
---|
5401 | points={{60,0},{60,40},{90,20},{60,0}},
|
---|
5402 | lineColor={191,0,0},
|
---|
5403 | fillColor={191,0,0},
|
---|
5404 | fillPattern=FillPattern.Solid),
|
---|
5405 | Polygon(
|
---|
5406 | points={{60,-40},{60,0},{90,-20},{60,-40}},
|
---|
5407 | lineColor={191,0,0},
|
---|
5408 | fillColor={191,0,0},
|
---|
5409 | fillPattern=FillPattern.Solid)}),
|
---|
5410 | Documentation(info="<HTML>
|
---|
5411 | <p>
|
---|
5412 | This model allows a specified amount of heat flow rate to be \"injected\"
|
---|
5413 | into a thermal system at a given port. The constant amount of heat
|
---|
5414 | flow rate Q_flow is given as a parameter. The heat flows into the
|
---|
5415 | component to which the component FixedHeatFlow is connected,
|
---|
5416 | if parameter Q_flow is positive.
|
---|
5417 | </p>
|
---|
5418 | <p>
|
---|
5419 | If parameter alpha is > 0, the heat flow is mulitplied by (1 + alpha*(port.T - T_ref))
|
---|
5420 | in order to simulate temperature dependent losses (which are given an reference temperature T_ref).
|
---|
5421 | </p>
|
---|
5422 | </HTML>
|
---|
5423 | "));
|
---|
5424 | end FixedHeatFlow;
|
---|
5425 | annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,
|
---|
5426 | -100},{100,100}}), graphics), Documentation(info="<html>
|
---|
5427 |
|
---|
5428 | </html>"));
|
---|
5429 | end Sources;
|
---|
5430 |
|
---|
5431 | package Interfaces "Connectors and partial models"
|
---|
5432 | extends Modelica.Icons.InterfacesPackage;
|
---|
5433 |
|
---|
5434 | partial connector HeatPort "Thermal port for 1-dim. heat transfer"
|
---|
5435 | Modelica.SIunits.Temperature T "Port temperature";
|
---|
5436 | flow Modelica.SIunits.HeatFlowRate Q_flow
|
---|
5437 | "Heat flow rate (positive if flowing from outside into the component)";
|
---|
5438 | annotation (Documentation(info="<html>
|
---|
5439 |
|
---|
5440 | </html>"));
|
---|
5441 | end HeatPort;
|
---|
5442 |
|
---|
5443 | connector HeatPort_a
|
---|
5444 | "Thermal port for 1-dim. heat transfer (filled rectangular icon)"
|
---|
5445 |
|
---|
5446 | extends HeatPort;
|
---|
5447 |
|
---|
5448 | annotation(defaultComponentName = "port_a",
|
---|
5449 | Documentation(info="<HTML>
|
---|
5450 | <p>This connector is used for 1-dimensional heat flow between components.
|
---|
5451 | The variables in the connector are:</p>
|
---|
5452 | <pre>
|
---|
5453 | T Temperature in [Kelvin].
|
---|
5454 | Q_flow Heat flow rate in [Watt].
|
---|
5455 | </pre>
|
---|
5456 | <p>According to the Modelica sign convention, a <b>positive</b> heat flow
|
---|
5457 | rate <b>Q_flow</b> is considered to flow <b>into</b> a component. This
|
---|
5458 | convention has to be used whenever this connector is used in a model
|
---|
5459 | class.</p>
|
---|
5460 | <p>Note, that the two connector classes <b>HeatPort_a</b> and
|
---|
5461 | <b>HeatPort_b</b> are identical with the only exception of the different
|
---|
5462 | <b>icon layout</b>.</p></HTML>
|
---|
5463 | "), Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
|
---|
5464 | 100,100}}), graphics={Rectangle(
|
---|
5465 | extent={{-100,100},{100,-100}},
|
---|
5466 | lineColor={191,0,0},
|
---|
5467 | fillColor={191,0,0},
|
---|
5468 | fillPattern=FillPattern.Solid)}),
|
---|
5469 | Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},
|
---|
5470 | {100,100}}), graphics={Rectangle(
|
---|
5471 | extent={{-50,50},{50,-50}},
|
---|
5472 | lineColor={191,0,0},
|
---|
5473 | fillColor={191,0,0},
|
---|
5474 | fillPattern=FillPattern.Solid), Text(
|
---|
5475 | extent={{-120,120},{100,60}},
|
---|
5476 | lineColor={191,0,0},
|
---|
5477 | textString="%name")}));
|
---|
5478 | end HeatPort_a;
|
---|
5479 |
|
---|
5480 | connector HeatPort_b
|
---|
5481 | "Thermal port for 1-dim. heat transfer (unfilled rectangular icon)"
|
---|
5482 |
|
---|
5483 | extends HeatPort;
|
---|
5484 |
|
---|
5485 | annotation(defaultComponentName = "port_b",
|
---|
5486 | Documentation(info="<HTML>
|
---|
5487 | <p>This connector is used for 1-dimensional heat flow between components.
|
---|
5488 | The variables in the connector are:</p>
|
---|
5489 | <pre>
|
---|
5490 | T Temperature in [Kelvin].
|
---|
5491 | Q_flow Heat flow rate in [Watt].
|
---|
5492 | </pre>
|
---|
5493 | <p>According to the Modelica sign convention, a <b>positive</b> heat flow
|
---|
5494 | rate <b>Q_flow</b> is considered to flow <b>into</b> a component. This
|
---|
5495 | convention has to be used whenever this connector is used in a model
|
---|
5496 | class.</p>
|
---|
5497 | <p>Note, that the two connector classes <b>HeatPort_a</b> and
|
---|
5498 | <b>HeatPort_b</b> are identical with the only exception of the different
|
---|
5499 | <b>icon layout</b>.</p></HTML>
|
---|
5500 | "), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},
|
---|
5501 | {100,100}}), graphics={Rectangle(
|
---|
5502 | extent={{-50,50},{50,-50}},
|
---|
5503 | lineColor={191,0,0},
|
---|
5504 | fillColor={255,255,255},
|
---|
5505 | fillPattern=FillPattern.Solid), Text(
|
---|
5506 | extent={{-100,120},{120,60}},
|
---|
5507 | lineColor={191,0,0},
|
---|
5508 | textString="%name")}),
|
---|
5509 | Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
|
---|
5510 | 100,100}}), graphics={Rectangle(
|
---|
5511 | extent={{-100,100},{100,-100}},
|
---|
5512 | lineColor={191,0,0},
|
---|
5513 | fillColor={255,255,255},
|
---|
5514 | fillPattern=FillPattern.Solid)}));
|
---|
5515 | end HeatPort_b;
|
---|
5516 | annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,
|
---|
5517 | -100},{100,100}}), graphics),
|
---|
5518 | Documentation(info="<html>
|
---|
5519 |
|
---|
5520 | </html>"));
|
---|
5521 | end Interfaces;
|
---|
5522 | annotation (
|
---|
5523 | Icon(coordinateSystem(preserveAspectRatio=true,
|
---|
5524 | extent={{-100,-100},{100,100}}), graphics={
|
---|
5525 | Polygon(
|
---|
5526 | points={{-54,-6},{-61,-7},{-75,-15},{-79,-24},{-80,-34},{-78,-42},{-73,
|
---|
5527 | -49},{-64,-51},{-57,-51},{-47,-50},{-41,-43},{-38,-35},{-40,-27},
|
---|
5528 | {-40,-20},{-42,-13},{-47,-7},{-54,-5},{-54,-6}},
|
---|
5529 | lineColor={128,128,128},
|
---|
5530 | fillColor={192,192,192},
|
---|
5531 | fillPattern=FillPattern.Solid),
|
---|
5532 | Polygon(
|
---|
5533 | points={{-75,-15},{-79,-25},{-80,-34},{-78,-42},{-72,-49},{-64,-51},{
|
---|
5534 | -57,-51},{-47,-50},{-57,-47},{-65,-45},{-71,-40},{-74,-33},{-76,-23},
|
---|
5535 | {-75,-15},{-75,-15}},
|
---|
5536 | lineColor={0,0,0},
|
---|
5537 | fillColor={160,160,164},
|
---|
5538 | fillPattern=FillPattern.Solid),
|
---|
5539 | Polygon(
|
---|
5540 | points={{39,-6},{32,-7},{18,-15},{14,-24},{13,-34},{15,-42},{20,-49},
|
---|
5541 | {29,-51},{36,-51},{46,-50},{52,-43},{55,-35},{53,-27},{53,-20},{
|
---|
5542 | 51,-13},{46,-7},{39,-5},{39,-6}},
|
---|
5543 | lineColor={160,160,164},
|
---|
5544 | fillColor={192,192,192},
|
---|
5545 | fillPattern=FillPattern.Solid),
|
---|
5546 | Polygon(
|
---|
5547 | points={{18,-15},{14,-25},{13,-34},{15,-42},{21,-49},{29,-51},{36,-51},
|
---|
5548 | {46,-50},{36,-47},{28,-45},{22,-40},{19,-33},{17,-23},{18,-15},{
|
---|
5549 | 18,-15}},
|
---|
5550 | lineColor={0,0,0},
|
---|
5551 | fillColor={160,160,164},
|
---|
5552 | fillPattern=FillPattern.Solid),
|
---|
5553 | Polygon(
|
---|
5554 | points={{-9,-23},{-9,-10},{18,-17},{-9,-23}},
|
---|
5555 | lineColor={191,0,0},
|
---|
5556 | fillColor={191,0,0},
|
---|
5557 | fillPattern=FillPattern.Solid),
|
---|
5558 | Line(
|
---|
5559 | points={{-41,-17},{-9,-17}},
|
---|
5560 | color={191,0,0},
|
---|
5561 | thickness=0.5),
|
---|
5562 | Line(
|
---|
5563 | points={{-17,-40},{15,-40}},
|
---|
5564 | color={191,0,0},
|
---|
5565 | thickness=0.5),
|
---|
5566 | Polygon(
|
---|
5567 | points={{-17,-46},{-17,-34},{-40,-40},{-17,-46}},
|
---|
5568 | lineColor={191,0,0},
|
---|
5569 | fillColor={191,0,0},
|
---|
5570 | fillPattern=FillPattern.Solid)}),
|
---|
5571 | Documentation(info="<HTML>
|
---|
5572 | <p>
|
---|
5573 | This package contains components to model <b>1-dimensional heat transfer</b>
|
---|
5574 | with lumped elements. This allows especially to model heat transfer in
|
---|
5575 | machines provided the parameters of the lumped elements, such as
|
---|
5576 | the heat capacity of a part, can be determined by measurements
|
---|
5577 | (due to the complex geometries and many materials used in machines,
|
---|
5578 | calculating the lumped element parameters from some basic analytic
|
---|
5579 | formulas is usually not possible).
|
---|
5580 | </p>
|
---|
5581 | <p>
|
---|
5582 | Example models how to use this library are given in subpackage <b>Examples</b>.<br>
|
---|
5583 | For a first simple example, see <b>Examples.TwoMasses</b> where two masses
|
---|
5584 | with different initial temperatures are getting in contact to each
|
---|
5585 | other and arriving after some time at a common temperature.<br>
|
---|
5586 | <b>Examples.ControlledTemperature</b> shows how to hold a temperature
|
---|
5587 | within desired limits by switching on and off an electric resistor.<br>
|
---|
5588 | A more realistic example is provided in <b>Examples.Motor</b> where the
|
---|
5589 | heating of an electrical motor is modelled, see the following screen shot
|
---|
5590 | of this example:
|
---|
5591 | </p>
|
---|
5592 | <img src=\"modelica://Modelica/Resources/Images/Thermal/HeatTransfer/driveWithHeatTransfer.png\" ALT=\"driveWithHeatTransfer\">
|
---|
5593 | <p>
|
---|
5594 | The <b>filled</b> and <b>non-filled red squares</b> at the left and
|
---|
5595 | right side of a component represent <b>thermal ports</b> (connector HeatPort).
|
---|
5596 | Drawing a line between such squares means that they are thermally connected.
|
---|
5597 | The variables of a HeatPort connector are the temperature <b>T</b> at the port
|
---|
5598 | and the heat flow rate <b>Q_flow</b> flowing into the component (if Q_flow is positive,
|
---|
5599 | the heat flows into the element, otherwise it flows out of the element):
|
---|
5600 | </p>
|
---|
5601 | <pre> Modelica.SIunits.Temperature T \"absolute temperature at port in Kelvin\";
|
---|
5602 | Modelica.SIunits.HeatFlowRate Q_flow \"flow rate at the port in Watt\";
|
---|
5603 | </pre>
|
---|
5604 | <p>
|
---|
5605 | Note, that all temperatures of this package, including initial conditions,
|
---|
5606 | are given in Kelvin. For convenience, in subpackages <b>HeatTransfer.Celsius</b>,
|
---|
5607 | <b>HeatTransfer.Fahrenheit</b> and <b>HeatTransfer.Rankine</b> components are provided such that source and
|
---|
5608 | sensor information is available in degree Celsius, degree Fahrenheit, or degree Rankine,
|
---|
5609 | respectively. Additionally, in package <b>SIunits.Conversions</b> conversion
|
---|
5610 | functions between the units Kelvin and Celsius, Fahrenheit, Rankine are
|
---|
5611 | provided. These functions may be used in the following way:
|
---|
5612 | </p>
|
---|
5613 | <pre> <b>import</b> SI=Modelica.SIunits;
|
---|
5614 | <b>import</b> Modelica.SIunits.Conversions.*;
|
---|
5615 | ...
|
---|
5616 | <b>parameter</b> SI.Temperature T = from_degC(25); // convert 25 degree Celsius to Kelvin
|
---|
5617 | </pre>
|
---|
5618 |
|
---|
5619 | <p>
|
---|
5620 | There are several other components available, such as AxialConduction (discretized PDE in
|
---|
5621 | axial direction), which have been temporarily removed from this library. The reason is that
|
---|
5622 | these components reference material properties, such as thermal conductivity, and currently
|
---|
5623 | the Modelica design group is discussing a general scheme to describe material properties.
|
---|
5624 | </p>
|
---|
5625 | <p>
|
---|
5626 | For technical details in the design of this library, see the following reference:<br>
|
---|
5627 | <b>Michael Tiller (2001)</b>: <a href=\"http://www.amazon.de\">
|
---|
5628 | Introduction to Physical Modeling with Modelica</a>.
|
---|
5629 | Kluwer Academic Publishers Boston.
|
---|
5630 | </p>
|
---|
5631 | <p>
|
---|
5632 | <b>Acknowledgements:</b><br>
|
---|
5633 | Several helpful remarks from the following persons are acknowledged:
|
---|
5634 | John Batteh, Ford Motors, Dearborn, U.S.A;
|
---|
5635 | <a href=\"http://www.haumer.at/\">Anton Haumer</a>, Technical Consulting & Electrical Engineering, Austria;
|
---|
5636 | Ludwig Marvan, VA TECH ELIN EBG Elektronik GmbH, Wien, Austria;
|
---|
5637 | Hans Olsson, Dassault Systèmes AB, Sweden;
|
---|
5638 | Hubertus Tummescheit, Lund Institute of Technology, Lund, Sweden.
|
---|
5639 | </p>
|
---|
5640 | <dl>
|
---|
5641 | <dt><b>Main Authors:</b></dt>
|
---|
5642 | <dd>
|
---|
5643 | <p>
|
---|
5644 | <a href=\"http://www.haumer.at/\">Anton Haumer</a><br>
|
---|
5645 | Technical Consulting & Electrical Engineering<br>
|
---|
5646 | A-3423 St.Andrae-Woerdern, Austria<br>
|
---|
5647 | email: <a href=\"mailto:a.haumer@haumer.at\">a.haumer@haumer.at</a>
|
---|
5648 | </p>
|
---|
5649 | </dd>
|
---|
5650 | </dl>
|
---|
5651 | <p><b>Copyright © 2001-2010, Modelica Association, Michael Tiller and DLR.</b></p>
|
---|
5652 |
|
---|
5653 | <p>
|
---|
5654 | <i>This Modelica package is <u>free</u> software and the use is completely at <u>your own risk</u>; it can be redistributed and/or modified under the terms of the Modelica License 2. For license conditions (including the disclaimer of warranty) see <a href=\"modelica://Modelica.UsersGuide.ModelicaLicense2\">Modelica.UsersGuide.ModelicaLicense2</a> or visit <a href=\"http://www.modelica.org/licenses/ModelicaLicense2\"> http://www.modelica.org/licenses/ModelicaLicense2</a>.</i>
|
---|
5655 | </p>
|
---|
5656 | </HTML>
|
---|
5657 | ", revisions="<html>
|
---|
5658 | <ul>
|
---|
5659 | <li><i>July 15, 2002</i>
|
---|
5660 | by Michael Tiller, <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>
|
---|
5661 | and <a href=\"http://www.robotic.dlr.de/Nikolaus.Schuermann/\">Nikolaus Schürmann</a>:<br>
|
---|
5662 | Implemented.
|
---|
5663 | </li>
|
---|
5664 | <li><i>June 13, 2005</i>
|
---|
5665 | by <a href=\"http://www.haumer.at/\">Anton Haumer</a><br>
|
---|
5666 | Refined placing of connectors (cosmetic).<br>
|
---|
5667 | Refined all Examples; removed Examples.FrequencyInverter, introducing Examples.Motor<br>
|
---|
5668 | Introduced temperature dependent correction (1 + alpha*(T - T_ref)) in Fixed/PrescribedHeatFlow<br>
|
---|
5669 | </li>
|
---|
5670 | <li> v1.1.1 2007/11/13 Anton Haumer<br>
|
---|
5671 | componentes moved to sub-packages</li>
|
---|
5672 | <li> v1.2.0 2009/08/26 Anton Haumer<br>
|
---|
5673 | added component ThermalCollector</li>
|
---|
5674 |
|
---|
5675 | </ul>
|
---|
5676 | </html>"));
|
---|
5677 | end HeatTransfer;
|
---|
5678 | annotation (Documentation(info="<html>
|
---|
5679 | <p>
|
---|
5680 | This package contains libraries to model heat transfer
|
---|
5681 | and fluid heat flow.
|
---|
5682 | </p>
|
---|
5683 | </html>"));
|
---|
5684 | end Thermal;
|
---|
5685 |
|
---|
5686 | package Math
|
---|
5687 | "Library of mathematical functions (e.g., sin, cos) and of functions operating on vectors and matrices"
|
---|
5688 | import SI = Modelica.SIunits;
|
---|
5689 | extends Modelica.Icons.Package;
|
---|
5690 |
|
---|
5691 | package Matrices "Library of functions operating on matrices"
|
---|
5692 | extends Modelica.Icons.Package;
|
---|
5693 |
|
---|
5694 | function leastSquares
|
---|
5695 | "Solve linear equation A*x = b (exactly if possible, or otherwise in a least square sense; A may be non-square and may be rank deficient)"
|
---|
5696 | extends Modelica.Icons.Function;
|
---|
5697 | input Real A[:, :] "Matrix A";
|
---|
5698 | input Real b[size(A, 1)] "Vector b";
|
---|
5699 | input Real rcond=100*Modelica.Constants.eps
|
---|
5700 | "Reciprocal condition number to estimate the rank of A";
|
---|
5701 | output Real x[size(A, 2)]
|
---|
5702 | "Vector x such that min|A*x-b|^2 if size(A,1) >= size(A,2) or min|x|^2 and A*x=b, if size(A,1) < size(A,2)";
|
---|
5703 | output Integer rank "Rank of A";
|
---|
5704 | protected
|
---|
5705 | Integer info;
|
---|
5706 | Real xx[max(size(A,1),size(A,2))];
|
---|
5707 | algorithm
|
---|
5708 | if min(size(A)) > 0 then
|
---|
5709 | (xx,info,rank) := LAPACK.dgelsx_vec(A, b, rcond);
|
---|
5710 | x := xx[1:size(A,2)];
|
---|
5711 | assert(info == 0, "Solving an overdetermined or underdetermined linear system\n" +
|
---|
5712 | "of equations with function \"Matrices.leastSquares\" failed.");
|
---|
5713 | else
|
---|
5714 | x := fill(0.0, size(A, 2));
|
---|
5715 | end if;
|
---|
5716 | annotation (
|
---|
5717 | Documentation(info="<html>
|
---|
5718 | <h4>Syntax</h4>
|
---|
5719 | <blockquote><pre>
|
---|
5720 | x = Matrices.<b>leastSquares</b>(A,b);
|
---|
5721 | </pre></blockquote>
|
---|
5722 | <h4>Description</h4>
|
---|
5723 | <p>
|
---|
5724 | Returns a solution of equation A*x = b in a least
|
---|
5725 | square sense (A may be rank deficient):
|
---|
5726 | </p>
|
---|
5727 | <pre>
|
---|
5728 | minimize | A*x - b |
|
---|
5729 | </pre>
|
---|
5730 |
|
---|
5731 | <p>
|
---|
5732 | Several different cases can be distinguished (note, <b>rank</b> is an
|
---|
5733 | output argument of this function):
|
---|
5734 | </p>
|
---|
5735 |
|
---|
5736 | <p>
|
---|
5737 | <b>size(A,1) = size(A,2)</b>
|
---|
5738 | </p>
|
---|
5739 |
|
---|
5740 | <p> A solution is returned for a regular, as well as a singular matrix A:
|
---|
5741 | </p>
|
---|
5742 |
|
---|
5743 | <ul>
|
---|
5744 | <li> <b>rank</b> = size(A,1):<br>
|
---|
5745 | A is <b>regular</b> and the returned solution x fulfills the equation
|
---|
5746 | A*x = b uniquely.</li>
|
---|
5747 |
|
---|
5748 | <li> <b>rank</b> < size(A,1):<br>
|
---|
5749 | A is <b>singular</b> and no unique solution for equation A*x = b exists.
|
---|
5750 | <ul>
|
---|
5751 | <li> If an infinite number of solutions exists, the one is selected that fulfills
|
---|
5752 | the equation and at the same time has the minimum norm |x| for all solution
|
---|
5753 | vectors that fulfill the equation.</li>
|
---|
5754 | <li> If no solution exists, x is selected such that |A*x - b| is as small as
|
---|
5755 | possible (but A*x - b is not zero).</li>
|
---|
5756 | </ul>
|
---|
5757 | </ul>
|
---|
5758 |
|
---|
5759 | <p>
|
---|
5760 | <b>size(A,1) > size(A,2):</b>
|
---|
5761 | </p>
|
---|
5762 |
|
---|
5763 | <p>
|
---|
5764 | The equation A*x = b has no unique solution. The solution x is selected such that
|
---|
5765 | |A*x - b| is as small as possible. If rank = size(A,2), this minimum norm solution is
|
---|
5766 | unique. If rank < size(A,2), there are an infinite number of solutions leading to the
|
---|
5767 | same minimum value of |A*x - b|. From these infinite number of solutions, the one with the
|
---|
5768 | minimum norm |x| is selected. This gives a unique solution that minimizes both
|
---|
5769 | |A*x - b| and |x|.
|
---|
5770 | </p>
|
---|
5771 |
|
---|
5772 | <p>
|
---|
5773 | <b>size(A,1) < size(A,2):</b>
|
---|
5774 | </p>
|
---|
5775 |
|
---|
5776 | <ul>
|
---|
5777 | <li> <b>rank</b> = size(A,1):<br>
|
---|
5778 | There are an infinite number of solutions that fulfill the equation A*x = b.
|
---|
5779 | From this infinite number, the unique solution is selected that minimizes |x|.
|
---|
5780 | </li>
|
---|
5781 |
|
---|
5782 | <li> <b>rank</b> < size(A,1):<br>
|
---|
5783 | There is either no solution of equation A*x = b, or there are again an infinite
|
---|
5784 | number of solutions. The unique solution x is returned that minimizes
|
---|
5785 | both |A*x - b| and |x|.</li>
|
---|
5786 | </ul>
|
---|
5787 |
|
---|
5788 | <p>
|
---|
5789 | Note, the solution is computed with the LAPACK function \"dgelsx\",
|
---|
5790 | i.e., QR or LQ factorization of A with column pivoting.
|
---|
5791 | </p>
|
---|
5792 |
|
---|
5793 | <h4>Algorithmic details</h4>
|
---|
5794 |
|
---|
5795 | <p>
|
---|
5796 | The function first computes a QR factorization with column pivoting:
|
---|
5797 | </p>
|
---|
5798 |
|
---|
5799 | <pre>
|
---|
5800 | A * P = Q * [ R11 R12 ]
|
---|
5801 | [ 0 R22 ]
|
---|
5802 | </pre>
|
---|
5803 |
|
---|
5804 | <p>
|
---|
5805 | with R11 defined as the largest leading submatrix whose estimated
|
---|
5806 | condition number is less than 1/rcond. The order of R11, <b>rank</b>,
|
---|
5807 | is the effective rank of A.
|
---|
5808 | </p>
|
---|
5809 |
|
---|
5810 | <p>
|
---|
5811 | Then, R22 is considered to be negligible, and R12 is annihilated
|
---|
5812 | by orthogonal transformations from the right, arriving at the
|
---|
5813 | complete orthogonal factorization:
|
---|
5814 | </p>
|
---|
5815 |
|
---|
5816 | <pre>
|
---|
5817 | A * P = Q * [ T11 0 ] * Z
|
---|
5818 | [ 0 0 ]
|
---|
5819 | </pre>
|
---|
5820 |
|
---|
5821 | <p>
|
---|
5822 | The minimum-norm solution is then
|
---|
5823 | </p>
|
---|
5824 |
|
---|
5825 | <pre>
|
---|
5826 | x = P * Z' [ inv(T11)*Q1'*b ]
|
---|
5827 | [ 0 ]
|
---|
5828 | </pre>
|
---|
5829 |
|
---|
5830 | <p>
|
---|
5831 | where Q1 consists of the first \"rank\" columns of Q.
|
---|
5832 | </p>
|
---|
5833 |
|
---|
5834 | <h4>See also</h4>
|
---|
5835 |
|
---|
5836 | <p>
|
---|
5837 | <a href=\"modelica://Modelica.Math.Matrices.leastSquares2\">Matrices.leastSquares2</a>
|
---|
5838 | (same as leastSquares, but with a right hand side matrix), <br>
|
---|
5839 | <a href=\"modelica://Modelica.Math.Matrices.solve\">Matrices.solve</a>
|
---|
5840 | (for square, regular matrices A)
|
---|
5841 | </p>
|
---|
5842 |
|
---|
5843 | </html>"));
|
---|
5844 | end leastSquares;
|
---|
5845 |
|
---|
5846 | package LAPACK
|
---|
5847 | "Interface to LAPACK library (should usually not directly be used but only indirectly via Modelica.Math.Matrices)"
|
---|
5848 | extends Modelica.Icons.Package;
|
---|
5849 |
|
---|
5850 | function dgelsx_vec
|
---|
5851 | "Computes the minimum-norm solution to a real linear least squares problem with rank deficient A"
|
---|
5852 |
|
---|
5853 | extends Modelica.Icons.Function;
|
---|
5854 | input Real A[:, :];
|
---|
5855 | input Real b[size(A,1)];
|
---|
5856 | input Real rcond=0.0 "Reciprocal condition number to estimate rank";
|
---|
5857 | output Real x[max(nrow,ncol)]= cat(1,b,zeros(max(nrow,ncol)-nrow))
|
---|
5858 | "solution is in first size(A,2) rows";
|
---|
5859 | output Integer info;
|
---|
5860 | output Integer rank "Effective rank of A";
|
---|
5861 | protected
|
---|
5862 | Integer nrow=size(A,1);
|
---|
5863 | Integer ncol=size(A,2);
|
---|
5864 | Integer nx=max(nrow,ncol);
|
---|
5865 | Integer lwork=max( min(nrow,ncol)+3*ncol, 2*min(nrow,ncol)+1);
|
---|
5866 | Real work[lwork];
|
---|
5867 | Real Awork[nrow,ncol]=A;
|
---|
5868 | Integer jpvt[ncol]=zeros(ncol);
|
---|
5869 | external "FORTRAN 77" dgelsx(nrow, ncol, 1, Awork, nrow, x, nx, jpvt,
|
---|
5870 | rcond, rank, work, lwork, info) annotation (Library="Lapack");
|
---|
5871 |
|
---|
5872 | annotation (
|
---|
5873 | Documentation(info="Lapack documentation
|
---|
5874 | Purpose
|
---|
5875 | =======
|
---|
5876 |
|
---|
5877 | DGELSX computes the minimum-norm solution to a real linear least
|
---|
5878 | squares problem:
|
---|
5879 | minimize || A * X - B ||
|
---|
5880 | using a complete orthogonal factorization of A. A is an M-by-N
|
---|
5881 | matrix which may be rank-deficient.
|
---|
5882 |
|
---|
5883 | Several right hand side vectors b and solution vectors x can be
|
---|
5884 | handled in a single call; they are stored as the columns of the
|
---|
5885 | M-by-NRHS right hand side matrix B and the N-by-NRHS solution
|
---|
5886 | matrix X.
|
---|
5887 |
|
---|
5888 | The routine first computes a QR factorization with column pivoting:
|
---|
5889 | A * P = Q * [ R11 R12 ]
|
---|
5890 | [ 0 R22 ]
|
---|
5891 | with R11 defined as the largest leading submatrix whose estimated
|
---|
5892 | condition number is less than 1/RCOND. The order of R11, RANK,
|
---|
5893 | is the effective rank of A.
|
---|
5894 |
|
---|
5895 | Then, R22 is considered to be negligible, and R12 is annihilated
|
---|
5896 | by orthogonal transformations from the right, arriving at the
|
---|
5897 | complete orthogonal factorization:
|
---|
5898 | A * P = Q * [ T11 0 ] * Z
|
---|
5899 | [ 0 0 ]
|
---|
5900 | The minimum-norm solution is then
|
---|
5901 | X = P * Z' [ inv(T11)*Q1'*B ]
|
---|
5902 | [ 0 ]
|
---|
5903 | where Q1 consists of the first RANK columns of Q.
|
---|
5904 |
|
---|
5905 | Arguments
|
---|
5906 | =========
|
---|
5907 |
|
---|
5908 | M (input) INTEGER
|
---|
5909 | The number of rows of the matrix A. M >= 0.
|
---|
5910 |
|
---|
5911 | N (input) INTEGER
|
---|
5912 | The number of columns of the matrix A. N >= 0.
|
---|
5913 |
|
---|
5914 | NRHS (input) INTEGER
|
---|
5915 | The number of right hand sides, i.e., the number of
|
---|
5916 | columns of matrices B and X. NRHS >= 0.
|
---|
5917 |
|
---|
5918 | A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
|
---|
5919 | On entry, the M-by-N matrix A.
|
---|
5920 | On exit, A has been overwritten by details of its
|
---|
5921 | complete orthogonal factorization.
|
---|
5922 |
|
---|
5923 | LDA (input) INTEGER
|
---|
5924 | The leading dimension of the array A. LDA >= max(1,M).
|
---|
5925 |
|
---|
5926 | B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
|
---|
5927 | On entry, the M-by-NRHS right hand side matrix B.
|
---|
5928 | On exit, the N-by-NRHS solution matrix X.
|
---|
5929 | If m >= n and RANK = n, the residual sum-of-squares for
|
---|
5930 | the solution in the i-th column is given by the sum of
|
---|
5931 | squares of elements N+1:M in that column.
|
---|
5932 |
|
---|
5933 | LDB (input) INTEGER
|
---|
5934 | The leading dimension of the array B. LDB >= max(1,M,N).
|
---|
5935 |
|
---|
5936 | JPVT (input/output) INTEGER array, dimension (N)
|
---|
5937 | On entry, if JPVT(i) .ne. 0, the i-th column of A is an
|
---|
5938 | initial column, otherwise it is a free column. Before
|
---|
5939 | the QR factorization of A, all initial columns are
|
---|
5940 | permuted to the leading positions; only the remaining
|
---|
5941 | free columns are moved as a result of column pivoting
|
---|
5942 | during the factorization.
|
---|
5943 | On exit, if JPVT(i) = k, then the i-th column of A*P
|
---|
5944 | was the k-th column of A.
|
---|
5945 |
|
---|
5946 | RCOND (input) DOUBLE PRECISION
|
---|
5947 | RCOND is used to determine the effective rank of A, which
|
---|
5948 | is defined as the order of the largest leading triangular
|
---|
5949 | submatrix R11 in the QR factorization with pivoting of A,
|
---|
5950 | whose estimated condition number < 1/RCOND.
|
---|
5951 |
|
---|
5952 | RANK (output) INTEGER
|
---|
5953 | The effective rank of A, i.e., the order of the submatrix
|
---|
5954 | R11. This is the same as the order of the submatrix T11
|
---|
5955 | in the complete orthogonal factorization of A.
|
---|
5956 |
|
---|
5957 | WORK (workspace) DOUBLE PRECISION array, dimension
|
---|
5958 | (max( min(M,N)+3*N, 2*min(M,N)+NRHS )),
|
---|
5959 |
|
---|
5960 | INFO (output) INTEGER
|
---|
5961 | = 0: successful exit
|
---|
5962 | < 0: if INFO = -i, the i-th argument had an illegal value "));
|
---|
5963 |
|
---|
5964 | end dgelsx_vec;
|
---|
5965 | annotation (Documentation(info="<html>
|
---|
5966 | <p>
|
---|
5967 | This package contains external Modelica functions as interface to the
|
---|
5968 | LAPACK library
|
---|
5969 | (<a href=\"http://www.netlib.org/lapack\">http://www.netlib.org/lapack</a>)
|
---|
5970 | that provides FORTRAN subroutines to solve linear algebra
|
---|
5971 | tasks. Usually, these functions are not directly called, but only via
|
---|
5972 | the much more convenient interface of
|
---|
5973 | <a href=\"modelica://Modelica.Math.Matrices\">Modelica.Math.Matrices</a>.
|
---|
5974 | The documentation of the LAPACK functions is a copy of the original
|
---|
5975 | FORTRAN code. The details of LAPACK are described in:
|
---|
5976 | </p>
|
---|
5977 |
|
---|
5978 | <dl>
|
---|
5979 | <dt>Anderson E., Bai Z., Bischof C., Blackford S., Demmel J., Dongarra J.,
|
---|
5980 | Du Croz J., Greenbaum A., Hammarling S., McKenney A., and Sorensen D.:</dt>
|
---|
5981 | <dd> <a href=\"http://www.netlib.org/lapack/lug/lapack_lug.html\">Lapack Users' Guide</a>.
|
---|
5982 | Third Edition, SIAM, 1999.</dd>
|
---|
5983 | </dl>
|
---|
5984 |
|
---|
5985 | <p>
|
---|
5986 | See also <a href=\"http://en.wikipedia.org/wiki/Lapack\">http://en.wikipedia.org/wiki/Lapack</a>.
|
---|
5987 | </p>
|
---|
5988 |
|
---|
5989 | <p>
|
---|
5990 | This package contains a direct interface to the LAPACK subroutines
|
---|
5991 | </p>
|
---|
5992 |
|
---|
5993 | </html>"));
|
---|
5994 | end LAPACK;
|
---|
5995 | annotation (
|
---|
5996 | Documentation(info="<HTML>
|
---|
5997 | <h4>Library content</h4>
|
---|
5998 | <p>
|
---|
5999 | This library provides functions operating on matrices. Below, the
|
---|
6000 | functions are ordered according to categories and a typical
|
---|
6001 | call of the respective function is shown.
|
---|
6002 | Most functions are solely an interface to the external
|
---|
6003 | <a href=\"modelica://Modelica.Math.Matrices.LAPACK\">LAPACK</a> library.
|
---|
6004 | </p>
|
---|
6005 |
|
---|
6006 | <p>
|
---|
6007 | Note: A' is a short hand notation of transpose(A):
|
---|
6008 | </p>
|
---|
6009 |
|
---|
6010 | <p><b>Basic Information</b></p>
|
---|
6011 | <ul>
|
---|
6012 | <li> <a href=\"modelica://Modelica.Math.Matrices.toString\">toString</a>(A)
|
---|
6013 | - returns the string representation of matrix A.</li>
|
---|
6014 |
|
---|
6015 | <li> <a href=\"modelica://Modelica.Math.Matrices.isEqual\">isEqual</a>(M1, M2)
|
---|
6016 | - returns true if matrices M1 and M2 have the same size and the same elements.</li>
|
---|
6017 | </ul>
|
---|
6018 |
|
---|
6019 | <p><b>Linear Equations</b></p>
|
---|
6020 | <ul>
|
---|
6021 | <li> <a href=\"modelica://Modelica.Math.Matrices.solve\">solve</a>(A,b)
|
---|
6022 | - returns solution x of the linear equation A*x=b (where b is a vector,
|
---|
6023 | and A is a square matrix that must be regular).</li>
|
---|
6024 |
|
---|
6025 | <li> <a href=\"modelica://Modelica.Math.Matrices.solve2\">solve2</a>(A,B)
|
---|
6026 | - returns solution X of the linear equation A*X=B (where B is a matrix,
|
---|
6027 | and A is a square matrix that must be regular)</li>
|
---|
6028 |
|
---|
6029 | <li> <a href=\"modelica://Modelica.Math.Matrices.leastSquares\">leastSquares</a>(A,b)
|
---|
6030 | - returns solution x of the linear equation A*x=b in a least squares sense
|
---|
6031 | (where b is a vector and A may be non-square and may be rank deficient)</li>
|
---|
6032 |
|
---|
6033 | <li> <a href=\"modelica://Modelica.Math.Matrices.leastSquares2\">leastSquares2</a>(A,B)
|
---|
6034 | - returns solution X of the linear equation A*X=B in a least squares sense
|
---|
6035 | (where B is a matrix and A may be non-square and may be rank deficient)</li>
|
---|
6036 |
|
---|
6037 | <li> <a href=\"modelica://Modelica.Math.Matrices.equalityLeastSquares\">equalityLeastSquares</a>(A,a,B,b)
|
---|
6038 | - returns solution x of a linear equality constrained least squares problem:
|
---|
6039 | min|A*x-a|^2 subject to B*x=b</<li>
|
---|
6040 |
|
---|
6041 | <li> (LU,p,info) = <a href=\"modelica://Modelica.Math.Matrices.LU\">LU</a>(A)
|
---|
6042 | - returns the LU decomposition with row pivoting of a rectangular matrix A.</li>
|
---|
6043 |
|
---|
6044 | <li> <a href=\"modelica://Modelica.Math.Matrices.LU_solve\">LU_solve</a>(LU,p,b)
|
---|
6045 | - returns solution x of the linear equation L*U*x[p]=b with a b
|
---|
6046 | vector and an LU decomposition from \"LU(..)\".</li>
|
---|
6047 |
|
---|
6048 | <li> <a href=\"modelica://Modelica.Math.Matrices.LU_solve2\">LU_solve2</a>(LU,p,B)
|
---|
6049 | - returns solution X of the linear equation L*U*X[p,:]=B with a B
|
---|
6050 | matrix and an LU decomposition from \"LU(..)\".</li>
|
---|
6051 | </ul>
|
---|
6052 |
|
---|
6053 | <p><b>Matrix Factorizations</b></p>
|
---|
6054 | <ul>
|
---|
6055 | <li> (eval,evec) = <a href=\"modelica://Modelica.Math.Matrices.eigenValues\">eigenValues</a>(A)
|
---|
6056 | - returns eigen values \"eval\" and eigen vectors \"evec\" for a real,
|
---|
6057 | nonsymmetric matrix A in a Real representation.</li>
|
---|
6058 |
|
---|
6059 | <li> <a href=\"modelica://Modelica.Math.Matrices.eigenValueMatrix\">eigenValueMatrix</a>(eval)
|
---|
6060 | - returns real valued block diagonal matrix of the eigenvalues \"eval\" of matrix A.</li>
|
---|
6061 |
|
---|
6062 | <li> (sigma,U,VT) = <a href=\"modelica://Modelica.Math.Matrices.singularValues\">singularValues</a>(A)
|
---|
6063 | - returns singular values \"sigma\" and left and right singular vectors U and VT
|
---|
6064 | of a rectangular matrix A.</li>
|
---|
6065 |
|
---|
6066 | <li> (Q,R,p) = <a href=\"modelica://Modelica.Math.Matrices.QR\">QR</a>(A)
|
---|
6067 | - returns the QR decomposition with column pivoting of a rectangular matrix A
|
---|
6068 | such that Q*R = A[:,p].</li>
|
---|
6069 |
|
---|
6070 | <li> (H,U) = <a href=\"modelica://Modelica.Math.Matrices.hessenberg\">hessenberg</a>(A)
|
---|
6071 | - returns the upper Hessenberg form H and the orthogonal transformation matrix U
|
---|
6072 | of a square matrix A such that H = U'*A*U.</li>
|
---|
6073 |
|
---|
6074 | <li> <a href=\"modelica://Modelica.Math.Matrices.realSchur\">realSchur</a>(A)
|
---|
6075 | - returns the real Schur form of a square matrix A.</li>
|
---|
6076 |
|
---|
6077 | <li> <a href=\"modelica://Modelica.Math.Matrices.cholesky\">cholesky</a>(A)
|
---|
6078 | - returns the cholesky factor H of a real symmetric positive definite matrix A so that A = H'*H.</li>
|
---|
6079 |
|
---|
6080 | <li> (D,Aimproved) = <a href=\"modelica://Modelica.Math.Matrices.balance\">balance</a>(A)
|
---|
6081 | - returns an improved form Aimproved of a square matrix A that has a smaller condition as A,
|
---|
6082 | with Aimproved = inv(diagonal(D))*A*diagonal(D).</li>
|
---|
6083 | </ul>
|
---|
6084 |
|
---|
6085 | <p><b>Matrix Properties</b></p>
|
---|
6086 | <ul>
|
---|
6087 | <li> <a href=\"modelica://Modelica.Math.Matrices.trace\">trace</a>(A)
|
---|
6088 | - returns the trace of square matrix A, i.e., the sum of the diagonal elements.</li>
|
---|
6089 |
|
---|
6090 | <li> <a href=\"modelica://Modelica.Math.Matrices.det\">det</a>(A)
|
---|
6091 | - returns the determinant of square matrix A (using LU decomposition; try to avoid det(..))</li>
|
---|
6092 |
|
---|
6093 | <li> <a href=\"modelica://Modelica.Math.Matrices.inv\">inv</a>(A)
|
---|
6094 | - returns the inverse of square matrix A (try to avoid, use instead \"solve2(..) with B=identity(..))</li>
|
---|
6095 |
|
---|
6096 | <li> <a href=\"modelica://Modelica.Math.Matrices.rank\">rank</a>(A)
|
---|
6097 | - returns the rank of square matrix A (computed with singular value decomposition)</li>
|
---|
6098 |
|
---|
6099 | <li> <a href=\"modelica://Modelica.Math.Matrices.conditionNumber\">conditionNumber</a>(A)
|
---|
6100 | - returns the condition number norm(A)*norm(inv(A)) of a square matrix A in the range 1..∞.</li>
|
---|
6101 |
|
---|
6102 | <li> <a href=\"modelica://Modelica.Math.Matrices.rcond\">rcond</a>(A)
|
---|
6103 | - returns the reciprocal condition number 1/conditionNumber(A) of a square matrix A in the range 0..1.</li>
|
---|
6104 |
|
---|
6105 | <li> <a href=\"modelica://Modelica.Math.Matrices.norm\">norm</a>(A)
|
---|
6106 | - returns the 1-, 2-, or infinity-norm of matrix A.</li>
|
---|
6107 |
|
---|
6108 | <li> <a href=\"modelica://Modelica.Math.Matrices.frobeniusNorm\">frobeniusNorm</a>(A)
|
---|
6109 | - returns the Frobenius norm of matrix A.</li>
|
---|
6110 |
|
---|
6111 | <li> <a href=\"modelica://Modelica.Math.Matrices.nullSpace\">nullSpace</a>(A)
|
---|
6112 | - returns the null space of matrix A.</li>
|
---|
6113 | </ul>
|
---|
6114 |
|
---|
6115 | <p><b>Matrix Exponentials</b></p>
|
---|
6116 | <ul>
|
---|
6117 | <li> <a href=\"modelica://Modelica.Math.Matrices.exp\">exp</a>(A)
|
---|
6118 | - returns the exponential e^A of a matrix A by adaptive Taylor series
|
---|
6119 | expansion with scaling and balancing</li>
|
---|
6120 |
|
---|
6121 | <li> (phi, gamma) = <a href=\"modelica://Modelica.Math.Matrices.integralExp\">integralExp</a>(A,B)
|
---|
6122 | - returns the exponential phi=e^A and the integral gamma=integral(exp(A*t)*dt)*B as needed
|
---|
6123 | for a discretized system with zero order hold.</li>
|
---|
6124 |
|
---|
6125 | <li> (phi, gamma, gamma1) = <a href=\"modelica://Modelica.Math.Matrices.integralExpT\">integralExpT</a>(A,B)
|
---|
6126 | - returns the exponential phi=e^A, the integral gamma=integral(exp(A*t)*dt)*B,
|
---|
6127 | and the time-weighted integral gamma1 = integral((T-t)*exp(A*t)*dt)*B as needed
|
---|
6128 | for a discretized system with first order hold.</li>
|
---|
6129 | </ul>
|
---|
6130 |
|
---|
6131 | <p><b>Matrix Equations</b></p>
|
---|
6132 | <ul>
|
---|
6133 | <li> <a href=\"modelica://Modelica.Math.Matrices.continuousLyapunov\">continuousLyapunov</a>(A,C)
|
---|
6134 | - returns solution X of the continuous-time Lyapunov equation X*A + A'*X = C</li>
|
---|
6135 |
|
---|
6136 | <li> <a href=\"modelica://Modelica.Math.Matrices.continuousSylvester\">continuousSylvester</a>(A,B,C)
|
---|
6137 | - returns solution X of the continuous-time Sylvester equation A*X + X*B = C</li>
|
---|
6138 |
|
---|
6139 | <li> <a href=\"modelica://Modelica.Math.Matrices.continuousRiccati\">continuousRiccati</a>(A,B,R,Q)
|
---|
6140 | - returns solution X of the continuous-time algebraic Riccat equation
|
---|
6141 | A'*X + X*A - X*B*inv(R)*B'*X + Q = 0</li>
|
---|
6142 |
|
---|
6143 | <li> <a href=\"modelica://Modelica.Math.Matrices.discreteLyapunov\">discreteLyapunov</a>(A,C)
|
---|
6144 | - returns solution X of the discretes-time Lyapunov equation A'*X*A + sgn*X = C</li>
|
---|
6145 |
|
---|
6146 | <li> <a href=\"modelica://Modelica.Math.Matrices.discreteSylvester\">discreteSylvester</a>(A,B,C)
|
---|
6147 | - returns solution X of the discrete-time Sylvester equation A*X*B + sgn*X = C</li>
|
---|
6148 |
|
---|
6149 | <li> <a href=\"modelica://Modelica.Math.Matrices.discreteRiccati\">discreteRiccati</a>(A,B,R,Q)
|
---|
6150 | - returns solution X of the discrete-time algebraic Riccat equation
|
---|
6151 | A'*X*A - X - A'*X*B*inv(R + B'*X*B)*B'*X*A + Q = 0</li>
|
---|
6152 | </ul>
|
---|
6153 |
|
---|
6154 | <p><b>Matrix Manipulation</b></p>
|
---|
6155 | <ul>
|
---|
6156 | <li> <a href=\"modelica://Modelica.Math.Matrices.sort\">sort</a>(M)
|
---|
6157 | - returns the sorted rows or columns of matrix M in ascending or descending order.</li>
|
---|
6158 |
|
---|
6159 | <li> <a href=\"modelica://Modelica.Math.Matrices.flipLeftRight\">flipLeftRight</a>(M)
|
---|
6160 | - returns matrix M so that the columns of M are flipped in left/right direction.</li>
|
---|
6161 |
|
---|
6162 | <li> <a href=\"modelica://Modelica.Math.Matrices.flipUpDown\">flipUpDown</a>(M)
|
---|
6163 | - returns matrix M so that the rows of M are flipped in up/down direction.</li>
|
---|
6164 | </ul>
|
---|
6165 |
|
---|
6166 | <h4>See also</h4>
|
---|
6167 | <a href=\"modelica://Modelica.Math.Vectors\">Vectors</a>
|
---|
6168 |
|
---|
6169 | </HTML>
|
---|
6170 | "));
|
---|
6171 | end Matrices;
|
---|
6172 |
|
---|
6173 | function sin "Sine"
|
---|
6174 | extends baseIcon1;
|
---|
6175 | input Modelica.SIunits.Angle u;
|
---|
6176 | output Real y;
|
---|
6177 |
|
---|
6178 | external "builtin" y= sin(u);
|
---|
6179 | annotation (
|
---|
6180 | Icon(coordinateSystem(
|
---|
6181 | preserveAspectRatio=true,
|
---|
6182 | extent={{-100,-100},{100,100}},
|
---|
6183 | grid={2,2}), graphics={
|
---|
6184 | Line(points={{-90,0},{68,0}}, color={192,192,192}),
|
---|
6185 | Polygon(
|
---|
6186 | points={{90,0},{68,8},{68,-8},{90,0}},
|
---|
6187 | lineColor={192,192,192},
|
---|
6188 | fillColor={192,192,192},
|
---|
6189 | fillPattern=FillPattern.Solid),
|
---|
6190 | Line(points={{-80,0},{-68.7,34.2},{-61.5,53.1},{-55.1,66.4},{-49.4,74.6},
|
---|
6191 | {-43.8,79.1},{-38.2,79.8},{-32.6,76.6},{-26.9,69.7},{-21.3,59.4},
|
---|
6192 | {-14.9,44.1},{-6.83,21.2},{10.1,-30.8},{17.3,-50.2},{23.7,-64.2},
|
---|
6193 | {29.3,-73.1},{35,-78.4},{40.6,-80},{46.2,-77.6},{51.9,-71.5},{
|
---|
6194 | 57.5,-61.9},{63.9,-47.2},{72,-24.8},{80,0}}, color={0,0,0}),
|
---|
6195 | Text(
|
---|
6196 | extent={{12,84},{84,36}},
|
---|
6197 | lineColor={192,192,192},
|
---|
6198 | textString="sin")}),
|
---|
6199 | Diagram(coordinateSystem(
|
---|
6200 | preserveAspectRatio=true,
|
---|
6201 | extent={{-100,-100},{100,100}},
|
---|
6202 | grid={2,2}), graphics={
|
---|
6203 | Line(points={{-100,0},{84,0}}, color={95,95,95}),
|
---|
6204 | Polygon(
|
---|
6205 | points={{100,0},{84,6},{84,-6},{100,0}},
|
---|
6206 | lineColor={95,95,95},
|
---|
6207 | fillColor={95,95,95},
|
---|
6208 | fillPattern=FillPattern.Solid),
|
---|
6209 | Line(
|
---|
6210 | points={{-80,0},{-68.7,34.2},{-61.5,53.1},{-55.1,66.4},{-49.4,74.6},{
|
---|
6211 | -43.8,79.1},{-38.2,79.8},{-32.6,76.6},{-26.9,69.7},{-21.3,59.4},{
|
---|
6212 | -14.9,44.1},{-6.83,21.2},{10.1,-30.8},{17.3,-50.2},{23.7,-64.2},{
|
---|
6213 | 29.3,-73.1},{35,-78.4},{40.6,-80},{46.2,-77.6},{51.9,-71.5},{57.5,
|
---|
6214 | -61.9},{63.9,-47.2},{72,-24.8},{80,0}},
|
---|
6215 | color={0,0,255},
|
---|
6216 | thickness=0.5),
|
---|
6217 | Text(
|
---|
6218 | extent={{-105,72},{-85,88}},
|
---|
6219 | textString="1",
|
---|
6220 | lineColor={0,0,255}),
|
---|
6221 | Text(
|
---|
6222 | extent={{70,25},{90,5}},
|
---|
6223 | textString="2*pi",
|
---|
6224 | lineColor={0,0,255}),
|
---|
6225 | Text(
|
---|
6226 | extent={{-103,-72},{-83,-88}},
|
---|
6227 | textString="-1",
|
---|
6228 | lineColor={0,0,255}),
|
---|
6229 | Text(
|
---|
6230 | extent={{82,-6},{102,-26}},
|
---|
6231 | lineColor={95,95,95},
|
---|
6232 | textString="u"),
|
---|
6233 | Line(
|
---|
6234 | points={{-80,80},{-28,80}},
|
---|
6235 | color={175,175,175},
|
---|
6236 | smooth=Smooth.None),
|
---|
6237 | Line(
|
---|
6238 | points={{-80,-80},{50,-80}},
|
---|
6239 | color={175,175,175},
|
---|
6240 | smooth=Smooth.None)}),
|
---|
6241 | Documentation(info="<html>
|
---|
6242 | <p>
|
---|
6243 | This function returns y = sin(u), with -∞ < u < ∞:
|
---|
6244 | </p>
|
---|
6245 |
|
---|
6246 | <p>
|
---|
6247 | <img src=\"modelica://Modelica/Resources/Images/Math/sin.png\">
|
---|
6248 | </p>
|
---|
6249 | </html>"), Library="ModelicaExternalC");
|
---|
6250 | end sin;
|
---|
6251 |
|
---|
6252 | function cos "Cosine"
|
---|
6253 | extends baseIcon1;
|
---|
6254 | input SI.Angle u;
|
---|
6255 | output Real y;
|
---|
6256 |
|
---|
6257 | external "builtin" y= cos(u);
|
---|
6258 | annotation (
|
---|
6259 | Icon(coordinateSystem(
|
---|
6260 | preserveAspectRatio=true,
|
---|
6261 | extent={{-100,-100},{100,100}},
|
---|
6262 | grid={2,2}), graphics={
|
---|
6263 | Line(points={{-90,0},{68,0}}, color={192,192,192}),
|
---|
6264 | Polygon(
|
---|
6265 | points={{90,0},{68,8},{68,-8},{90,0}},
|
---|
6266 | lineColor={192,192,192},
|
---|
6267 | fillColor={192,192,192},
|
---|
6268 | fillPattern=FillPattern.Solid),
|
---|
6269 | Line(points={{-80,80},{-74.4,78.1},{-68.7,72.3},{-63.1,63},{-56.7,48.7},
|
---|
6270 | {-48.6,26.6},{-29.3,-32.5},{-22.1,-51.7},{-15.7,-65.3},{-10.1,-73.8},
|
---|
6271 | {-4.42,-78.8},{1.21,-79.9},{6.83,-77.1},{12.5,-70.6},{18.1,-60.6},
|
---|
6272 | {24.5,-45.7},{32.6,-23},{50.3,31.3},{57.5,50.7},{63.9,64.6},{69.5,
|
---|
6273 | 73.4},{75.2,78.6},{80,80}}, color={0,0,0}),
|
---|
6274 | Text(
|
---|
6275 | extent={{-36,82},{36,34}},
|
---|
6276 | lineColor={192,192,192},
|
---|
6277 | textString="cos")}),
|
---|
6278 | Diagram(coordinateSystem(
|
---|
6279 | preserveAspectRatio=true,
|
---|
6280 | extent={{-100,-100},{100,100}},
|
---|
6281 | grid={2,2}), graphics={
|
---|
6282 | Text(
|
---|
6283 | extent={{-103,72},{-83,88}},
|
---|
6284 | textString="1",
|
---|
6285 | lineColor={0,0,255}),
|
---|
6286 | Text(
|
---|
6287 | extent={{-103,-72},{-83,-88}},
|
---|
6288 | textString="-1",
|
---|
6289 | lineColor={0,0,255}),
|
---|
6290 | Text(
|
---|
6291 | extent={{70,25},{90,5}},
|
---|
6292 | textString="2*pi",
|
---|
6293 | lineColor={0,0,255}),
|
---|
6294 | Line(points={{-100,0},{84,0}}, color={95,95,95}),
|
---|
6295 | Polygon(
|
---|
6296 | points={{98,0},{82,6},{82,-6},{98,0}},
|
---|
6297 | lineColor={95,95,95},
|
---|
6298 | fillColor={95,95,95},
|
---|
6299 | fillPattern=FillPattern.Solid),
|
---|
6300 | Line(
|
---|
6301 | points={{-80,80},{-74.4,78.1},{-68.7,72.3},{-63.1,63},{-56.7,48.7},{-48.6,
|
---|
6302 | 26.6},{-29.3,-32.5},{-22.1,-51.7},{-15.7,-65.3},{-10.1,-73.8},{-4.42,
|
---|
6303 | -78.8},{1.21,-79.9},{6.83,-77.1},{12.5,-70.6},{18.1,-60.6},{24.5,
|
---|
6304 | -45.7},{32.6,-23},{50.3,31.3},{57.5,50.7},{63.9,64.6},{69.5,73.4},
|
---|
6305 | {75.2,78.6},{80,80}},
|
---|
6306 | color={0,0,255},
|
---|
6307 | thickness=0.5),
|
---|
6308 | Text(
|
---|
6309 | extent={{78,-6},{98,-26}},
|
---|
6310 | lineColor={95,95,95},
|
---|
6311 | textString="u"),
|
---|
6312 | Line(
|
---|
6313 | points={{-80,-80},{18,-80}},
|
---|
6314 | color={175,175,175},
|
---|
6315 | smooth=Smooth.None)}),
|
---|
6316 | Documentation(info="<html>
|
---|
6317 | <p>
|
---|
6318 | This function returns y = cos(u), with -∞ < u < ∞:
|
---|
6319 | </p>
|
---|
6320 |
|
---|
6321 | <p>
|
---|
6322 | <img src=\"modelica://Modelica/Resources/Images/Math/cos.png\">
|
---|
6323 | </p>
|
---|
6324 | </html>"), Library="ModelicaExternalC");
|
---|
6325 | end cos;
|
---|
6326 |
|
---|
6327 | function tan "Tangent (u shall not be -pi/2, pi/2, 3*pi/2, ...)"
|
---|
6328 | extends baseIcon2;
|
---|
6329 | input SI.Angle u;
|
---|
6330 | output Real y;
|
---|
6331 |
|
---|
6332 | external "builtin" y= tan(u);
|
---|
6333 | annotation (
|
---|
6334 | Icon(coordinateSystem(
|
---|
6335 | preserveAspectRatio=true,
|
---|
6336 | extent={{-100,-100},{100,100}},
|
---|
6337 | grid={2,2}), graphics={
|
---|
6338 | Line(points={{-90,0},{68,0}}, color={192,192,192}),
|
---|
6339 | Polygon(
|
---|
6340 | points={{90,0},{68,8},{68,-8},{90,0}},
|
---|
6341 | lineColor={192,192,192},
|
---|
6342 | fillColor={192,192,192},
|
---|
6343 | fillPattern=FillPattern.Solid),
|
---|
6344 | Line(points={{-80,-80},{-78.4,-68.4},{-76.8,-59.7},{-74.4,-50},{-71.2,-40.9},
|
---|
6345 | {-67.1,-33},{-60.7,-24.8},{-51.1,-17.2},{-35.8,-9.98},{-4.42,-1.07},
|
---|
6346 | {33.4,9.12},{49.4,16.2},{59.1,23.2},{65.5,30.6},{70.4,39.1},{73.6,
|
---|
6347 | 47.4},{76,56.1},{77.6,63.8},{80,80}}, color={0,0,0}),
|
---|
6348 | Text(
|
---|
6349 | extent={{-90,72},{-18,24}},
|
---|
6350 | lineColor={192,192,192},
|
---|
6351 | textString="tan")}),
|
---|
6352 | Diagram(coordinateSystem(
|
---|
6353 | preserveAspectRatio=true,
|
---|
6354 | extent={{-100,-100},{100,100}},
|
---|
6355 | grid={2,2}), graphics={
|
---|
6356 | Text(
|
---|
6357 | extent={{-37,-72},{-17,-88}},
|
---|
6358 | textString="-5.8",
|
---|
6359 | lineColor={0,0,255}),
|
---|
6360 | Text(
|
---|
6361 | extent={{-33,86},{-13,70}},
|
---|
6362 | textString=" 5.8",
|
---|
6363 | lineColor={0,0,255}),
|
---|
6364 | Text(
|
---|
6365 | extent={{68,-13},{88,-33}},
|
---|
6366 | textString="1.4",
|
---|
6367 | lineColor={0,0,255}),
|
---|
6368 | Line(points={{-100,0},{84,0}}, color={95,95,95}),
|
---|
6369 | Polygon(
|
---|
6370 | points={{98,0},{82,6},{82,-6},{98,0}},
|
---|
6371 | lineColor={95,95,95},
|
---|
6372 | fillColor={95,95,95},
|
---|
6373 | fillPattern=FillPattern.Solid),
|
---|
6374 | Line(
|
---|
6375 | points={{-80,-80},{-78.4,-68.4},{-76.8,-59.7},{-74.4,-50},{-71.2,-40.9},
|
---|
6376 | {-67.1,-33},{-60.7,-24.8},{-51.1,-17.2},{-35.8,-9.98},{-4.42,-1.07},
|
---|
6377 | {33.4,9.12},{49.4,16.2},{59.1,23.2},{65.5,30.6},{70.4,39.1},{73.6,
|
---|
6378 | 47.4},{76,56.1},{77.6,63.8},{80,80}},
|
---|
6379 | color={0,0,255},
|
---|
6380 | thickness=0.5),
|
---|
6381 | Text(
|
---|
6382 | extent={{82,22},{102,2}},
|
---|
6383 | lineColor={95,95,95},
|
---|
6384 | textString="u"),
|
---|
6385 | Line(
|
---|
6386 | points={{0,80},{86,80}},
|
---|
6387 | color={175,175,175},
|
---|
6388 | smooth=Smooth.None),
|
---|
6389 | Line(
|
---|
6390 | points={{80,88},{80,-16}},
|
---|
6391 | color={175,175,175},
|
---|
6392 | smooth=Smooth.None)}),
|
---|
6393 | Documentation(info="<html>
|
---|
6394 | <p>
|
---|
6395 | This function returns y = tan(u), with -∞ < u < ∞
|
---|
6396 | (if u is a multiple of (2n-1)*pi/2, y = tan(u) is +/- infinity).
|
---|
6397 | </p>
|
---|
6398 |
|
---|
6399 | <p>
|
---|
6400 | <img src=\"modelica://Modelica/Resources/Images/Math/tan.png\">
|
---|
6401 | </p>
|
---|
6402 | </html>"), Library="ModelicaExternalC");
|
---|
6403 | end tan;
|
---|
6404 |
|
---|
6405 | function asin "Inverse sine (-1 <= u <= 1)"
|
---|
6406 | extends baseIcon2;
|
---|
6407 | input Real u;
|
---|
6408 | output SI.Angle y;
|
---|
6409 |
|
---|
6410 | external "builtin" y= asin(u);
|
---|
6411 | annotation (
|
---|
6412 | Icon(coordinateSystem(
|
---|
6413 | preserveAspectRatio=true,
|
---|
6414 | extent={{-100,-100},{100,100}},
|
---|
6415 | grid={2,2}), graphics={
|
---|
6416 | Line(points={{-90,0},{68,0}}, color={192,192,192}),
|
---|
6417 | Polygon(
|
---|
6418 | points={{90,0},{68,8},{68,-8},{90,0}},
|
---|
6419 | lineColor={192,192,192},
|
---|
6420 | fillColor={192,192,192},
|
---|
6421 | fillPattern=FillPattern.Solid),
|
---|
6422 | Line(points={{-80,-80},{-79.2,-72.8},{-77.6,-67.5},{-73.6,-59.4},{-66.3,
|
---|
6423 | -49.8},{-53.5,-37.3},{-30.2,-19.7},{37.4,24.8},{57.5,40.8},{68.7,
|
---|
6424 | 52.7},{75.2,62.2},{77.6,67.5},{80,80}}, color={0,0,0}),
|
---|
6425 | Text(
|
---|
6426 | extent={{-88,78},{-16,30}},
|
---|
6427 | lineColor={192,192,192},
|
---|
6428 | textString="asin")}),
|
---|
6429 | Diagram(coordinateSystem(
|
---|
6430 | preserveAspectRatio=true,
|
---|
6431 | extent={{-100,-100},{100,100}},
|
---|
6432 | grid={2,2}), graphics={
|
---|
6433 | Text(
|
---|
6434 | extent={{-40,-72},{-15,-88}},
|
---|
6435 | textString="-pi/2",
|
---|
6436 | lineColor={0,0,255}),
|
---|
6437 | Text(
|
---|
6438 | extent={{-38,88},{-13,72}},
|
---|
6439 | textString=" pi/2",
|
---|
6440 | lineColor={0,0,255}),
|
---|
6441 | Text(
|
---|
6442 | extent={{68,-9},{88,-29}},
|
---|
6443 | textString="+1",
|
---|
6444 | lineColor={0,0,255}),
|
---|
6445 | Text(
|
---|
6446 | extent={{-90,21},{-70,1}},
|
---|
6447 | textString="-1",
|
---|
6448 | lineColor={0,0,255}),
|
---|
6449 | Line(points={{-100,0},{84,0}}, color={95,95,95}),
|
---|
6450 | Polygon(
|
---|
6451 | points={{98,0},{82,6},{82,-6},{98,0}},
|
---|
6452 | lineColor={95,95,95},
|
---|
6453 | fillColor={95,95,95},
|
---|
6454 | fillPattern=FillPattern.Solid),
|
---|
6455 | Line(
|
---|
6456 | points={{-80,-80},{-79.2,-72.8},{-77.6,-67.5},{-73.6,-59.4},{-66.3,-49.8},
|
---|
6457 | {-53.5,-37.3},{-30.2,-19.7},{37.4,24.8},{57.5,40.8},{68.7,52.7},{
|
---|
6458 | 75.2,62.2},{77.6,67.5},{80,80}},
|
---|
6459 | color={0,0,255},
|
---|
6460 | thickness=0.5),
|
---|
6461 | Text(
|
---|
6462 | extent={{82,24},{102,4}},
|
---|
6463 | lineColor={95,95,95},
|
---|
6464 | textString="u"),
|
---|
6465 | Line(
|
---|
6466 | points={{0,80},{86,80}},
|
---|
6467 | color={175,175,175},
|
---|
6468 | smooth=Smooth.None),
|
---|
6469 | Line(
|
---|
6470 | points={{80,86},{80,-10}},
|
---|
6471 | color={175,175,175},
|
---|
6472 | smooth=Smooth.None)}),
|
---|
6473 | Documentation(info="<html>
|
---|
6474 | <p>
|
---|
6475 | This function returns y = asin(u), with -1 ≤ u ≤ +1:
|
---|
6476 | </p>
|
---|
6477 |
|
---|
6478 | <p>
|
---|
6479 | <img src=\"modelica://Modelica/Resources/Images/Math/asin.png\">
|
---|
6480 | </p>
|
---|
6481 | </html>"), Library="ModelicaExternalC");
|
---|
6482 | end asin;
|
---|
6483 |
|
---|
6484 | function cosh "Hyperbolic cosine"
|
---|
6485 | extends baseIcon2;
|
---|
6486 | input Real u;
|
---|
6487 | output Real y;
|
---|
6488 |
|
---|
6489 | external "builtin" y= cosh(u);
|
---|
6490 | annotation (
|
---|
6491 | Icon(coordinateSystem(
|
---|
6492 | preserveAspectRatio=true,
|
---|
6493 | extent={{-100,-100},{100,100}},
|
---|
6494 | grid={2,2}), graphics={
|
---|
6495 | Line(points={{-90,-86.083},{68,-86.083}}, color={192,192,192}),
|
---|
6496 | Polygon(
|
---|
6497 | points={{90,-86.083},{68,-78.083},{68,-94.083},{90,-86.083}},
|
---|
6498 | lineColor={192,192,192},
|
---|
6499 | fillColor={192,192,192},
|
---|
6500 | fillPattern=FillPattern.Solid),
|
---|
6501 | Line(points={{-80,80},{-77.6,61.1},{-74.4,39.3},{-71.2,20.7},{-67.1,
|
---|
6502 | 1.29},{-63.1,-14.6},{-58.3,-29.8},{-52.7,-43.5},{-46.2,-55.1},{-39,
|
---|
6503 | -64.3},{-30.2,-71.7},{-18.9,-77.1},{-4.42,-79.9},{10.9,-79.1},{
|
---|
6504 | 23.7,-75.2},{34.2,-68.7},{42.2,-60.6},{48.6,-51.2},{54.3,-40},{
|
---|
6505 | 59.1,-27.5},{63.1,-14.6},{67.1,1.29},{71.2,20.7},{74.4,39.3},{
|
---|
6506 | 77.6,61.1},{80,80}}, color={0,0,0}),
|
---|
6507 | Text(
|
---|
6508 | extent={{4,66},{66,20}},
|
---|
6509 | lineColor={192,192,192},
|
---|
6510 | textString="cosh")}),
|
---|
6511 | Diagram(coordinateSystem(
|
---|
6512 | preserveAspectRatio=true,
|
---|
6513 | extent={{-100,-100},{100,100}},
|
---|
6514 | grid={2,2}), graphics={
|
---|
6515 | Line(points={{-100,-84.083},{84,-84.083}}, color={95,95,95}),
|
---|
6516 | Polygon(
|
---|
6517 | points={{98,-84.083},{82,-78.083},{82,-90.083},{98,-84.083}},
|
---|
6518 | lineColor={95,95,95},
|
---|
6519 | fillColor={95,95,95},
|
---|
6520 | fillPattern=FillPattern.Solid),
|
---|
6521 | Line(
|
---|
6522 | points={{-80,80},{-77.6,61.1},{-74.4,39.3},{-71.2,20.7},{-67.1,1.29},
|
---|
6523 | {-63.1,-14.6},{-58.3,-29.8},{-52.7,-43.5},{-46.2,-55.1},{-39,-64.3},
|
---|
6524 | {-30.2,-71.7},{-18.9,-77.1},{-4.42,-79.9},{10.9,-79.1},{23.7,-75.2},
|
---|
6525 | {34.2,-68.7},{42.2,-60.6},{48.6,-51.2},{54.3,-40},{59.1,-27.5},{
|
---|
6526 | 63.1,-14.6},{67.1,1.29},{71.2,20.7},{74.4,39.3},{77.6,61.1},{80,
|
---|
6527 | 80}},
|
---|
6528 | color={0,0,255},
|
---|
6529 | thickness=0.5),
|
---|
6530 | Text(
|
---|
6531 | extent={{-31,72},{-11,88}},
|
---|
6532 | textString="27",
|
---|
6533 | lineColor={0,0,255}),
|
---|
6534 | Text(
|
---|
6535 | extent={{64,-83},{84,-103}},
|
---|
6536 | textString="4",
|
---|
6537 | lineColor={0,0,255}),
|
---|
6538 | Text(
|
---|
6539 | extent={{-94,-63},{-74,-83}},
|
---|
6540 | textString="-4",
|
---|
6541 | lineColor={0,0,255}),
|
---|
6542 | Text(
|
---|
6543 | extent={{80,-60},{100,-80}},
|
---|
6544 | lineColor={95,95,95},
|
---|
6545 | textString="u"),
|
---|
6546 | Line(
|
---|
6547 | points={{0,80},{88,80}},
|
---|
6548 | color={175,175,175},
|
---|
6549 | smooth=Smooth.None),
|
---|
6550 | Line(
|
---|
6551 | points={{80,84},{80,-90}},
|
---|
6552 | color={175,175,175},
|
---|
6553 | smooth=Smooth.None)}),
|
---|
6554 | Documentation(info="<html>
|
---|
6555 | <p>
|
---|
6556 | This function returns y = cosh(u), with -∞ < u < ∞:
|
---|
6557 | </p>
|
---|
6558 |
|
---|
6559 | <p>
|
---|
6560 | <img src=\"modelica://Modelica/Resources/Images/Math/cosh.png\">
|
---|
6561 | </p>
|
---|
6562 | </html>"), Library="ModelicaExternalC");
|
---|
6563 | end cosh;
|
---|
6564 |
|
---|
6565 | function tanh "Hyperbolic tangent"
|
---|
6566 | extends baseIcon2;
|
---|
6567 | input Real u;
|
---|
6568 | output Real y;
|
---|
6569 |
|
---|
6570 | external "builtin" y= tanh(u);
|
---|
6571 | annotation (
|
---|
6572 | Icon(coordinateSystem(
|
---|
6573 | preserveAspectRatio=true,
|
---|
6574 | extent={{-100,-100},{100,100}},
|
---|
6575 | grid={0.5,0.5}), graphics={
|
---|
6576 | Line(points={{-90,0},{68,0}}, color={192,192,192}),
|
---|
6577 | Polygon(
|
---|
6578 | points={{90,0},{68,8},{68,-8},{90,0}},
|
---|
6579 | lineColor={192,192,192},
|
---|
6580 | fillColor={192,192,192},
|
---|
6581 | fillPattern=FillPattern.Solid),
|
---|
6582 | Line(points={{-80,-80},{-47.8,-78.7},{-35.8,-75.7},{-27.7,-70.6},{-22.1,
|
---|
6583 | -64.2},{-17.3,-55.9},{-12.5,-44.3},{-7.64,-29.2},{-1.21,-4.82},{
|
---|
6584 | 6.83,26.3},{11.7,42},{16.5,54.2},{21.3,63.1},{26.9,69.9},{34.2,75},
|
---|
6585 | {45.4,78.4},{72,79.9},{80,80}}, color={0,0,0}),
|
---|
6586 | Text(
|
---|
6587 | extent={{-88,72},{-16,24}},
|
---|
6588 | lineColor={192,192,192},
|
---|
6589 | textString="tanh")}),
|
---|
6590 | Diagram(coordinateSystem(
|
---|
6591 | preserveAspectRatio=true,
|
---|
6592 | extent={{-100,-100},{100,100}},
|
---|
6593 | grid={0.5,0.5}), graphics={
|
---|
6594 | Line(points={{-100,0},{84,0}}, color={95,95,95}),
|
---|
6595 | Polygon(
|
---|
6596 | points={{96,0},{80,6},{80,-6},{96,0}},
|
---|
6597 | lineColor={95,95,95},
|
---|
6598 | fillColor={95,95,95},
|
---|
6599 | fillPattern=FillPattern.Solid),
|
---|
6600 | Line(
|
---|
6601 | points={{-80,-80.5},{-47.8,-79.2},{-35.8,-76.2},{-27.7,-71.1},{-22.1,
|
---|
6602 | -64.7},{-17.3,-56.4},{-12.5,-44.8},{-7.64,-29.7},{-1.21,-5.32},{
|
---|
6603 | 6.83,25.8},{11.7,41.5},{16.5,53.7},{21.3,62.6},{26.9,69.4},{34.2,
|
---|
6604 | 74.5},{45.4,77.9},{72,79.4},{80,79.5}},
|
---|
6605 | color={0,0,255},
|
---|
6606 | thickness=0.5),
|
---|
6607 | Text(
|
---|
6608 | extent={{-29,72},{-9,88}},
|
---|
6609 | textString="1",
|
---|
6610 | lineColor={0,0,255}),
|
---|
6611 | Text(
|
---|
6612 | extent={{3,-72},{23,-88}},
|
---|
6613 | textString="-1",
|
---|
6614 | lineColor={0,0,255}),
|
---|
6615 | Text(
|
---|
6616 | extent={{82,-2},{102,-22}},
|
---|
6617 | lineColor={95,95,95},
|
---|
6618 | textString="u"),
|
---|
6619 | Line(
|
---|
6620 | points={{0,80},{88,80}},
|
---|
6621 | color={175,175,175},
|
---|
6622 | smooth=Smooth.None)}),
|
---|
6623 | Documentation(info="<html>
|
---|
6624 | <p>
|
---|
6625 | This function returns y = tanh(u), with -∞ < u < ∞:
|
---|
6626 | </p>
|
---|
6627 |
|
---|
6628 | <p>
|
---|
6629 | <img src=\"modelica://Modelica/Resources/Images/Math/tanh.png\">
|
---|
6630 | </p>
|
---|
6631 | </html>"), Library="ModelicaExternalC");
|
---|
6632 | end tanh;
|
---|
6633 |
|
---|
6634 | function exp "Exponential, base e"
|
---|
6635 | extends baseIcon2;
|
---|
6636 | input Real u;
|
---|
6637 | output Real y;
|
---|
6638 |
|
---|
6639 | external "builtin" y= exp(u);
|
---|
6640 | annotation (
|
---|
6641 | Icon(coordinateSystem(
|
---|
6642 | preserveAspectRatio=true,
|
---|
6643 | extent={{-100,-100},{100,100}},
|
---|
6644 | grid={2,2}), graphics={
|
---|
6645 | Line(points={{-90,-80.3976},{68,-80.3976}}, color={192,192,192}),
|
---|
6646 | Polygon(
|
---|
6647 | points={{90,-80.3976},{68,-72.3976},{68,-88.3976},{90,-80.3976}},
|
---|
6648 | lineColor={192,192,192},
|
---|
6649 | fillColor={192,192,192},
|
---|
6650 | fillPattern=FillPattern.Solid),
|
---|
6651 | Line(points={{-80,-80},{-31,-77.9},{-6.03,-74},{10.9,-68.4},{23.7,-61},
|
---|
6652 | {34.2,-51.6},{43,-40.3},{50.3,-27.8},{56.7,-13.5},{62.3,2.23},{
|
---|
6653 | 67.1,18.6},{72,38.2},{76,57.6},{80,80}}, color={0,0,0}),
|
---|
6654 | Text(
|
---|
6655 | extent={{-86,50},{-14,2}},
|
---|
6656 | lineColor={192,192,192},
|
---|
6657 | textString="exp")}),
|
---|
6658 | Diagram(coordinateSystem(
|
---|
6659 | preserveAspectRatio=true,
|
---|
6660 | extent={{-100,-100},{100,100}},
|
---|
6661 | grid={2,2}), graphics={
|
---|
6662 | Line(points={{-100,-80.3976},{84,-80.3976}}, color={95,95,95}),
|
---|
6663 | Polygon(
|
---|
6664 | points={{98,-80.3976},{82,-74.3976},{82,-86.3976},{98,-80.3976}},
|
---|
6665 | lineColor={95,95,95},
|
---|
6666 | fillColor={95,95,95},
|
---|
6667 | fillPattern=FillPattern.Solid),
|
---|
6668 | Line(
|
---|
6669 | points={{-80,-80},{-31,-77.9},{-6.03,-74},{10.9,-68.4},{23.7,-61},{
|
---|
6670 | 34.2,-51.6},{43,-40.3},{50.3,-27.8},{56.7,-13.5},{62.3,2.23},{
|
---|
6671 | 67.1,18.6},{72,38.2},{76,57.6},{80,80}},
|
---|
6672 | color={0,0,255},
|
---|
6673 | thickness=0.5),
|
---|
6674 | Text(
|
---|
6675 | extent={{-31,72},{-11,88}},
|
---|
6676 | textString="20",
|
---|
6677 | lineColor={0,0,255}),
|
---|
6678 | Text(
|
---|
6679 | extent={{-92,-81},{-72,-101}},
|
---|
6680 | textString="-3",
|
---|
6681 | lineColor={0,0,255}),
|
---|
6682 | Text(
|
---|
6683 | extent={{66,-81},{86,-101}},
|
---|
6684 | textString="3",
|
---|
6685 | lineColor={0,0,255}),
|
---|
6686 | Text(
|
---|
6687 | extent={{2,-69},{22,-89}},
|
---|
6688 | textString="1",
|
---|
6689 | lineColor={0,0,255}),
|
---|
6690 | Text(
|
---|
6691 | extent={{78,-54},{98,-74}},
|
---|
6692 | lineColor={95,95,95},
|
---|
6693 | textString="u"),
|
---|
6694 | Line(
|
---|
6695 | points={{0,80},{88,80}},
|
---|
6696 | color={175,175,175},
|
---|
6697 | smooth=Smooth.None),
|
---|
6698 | Line(
|
---|
6699 | points={{80,84},{80,-84}},
|
---|
6700 | color={175,175,175},
|
---|
6701 | smooth=Smooth.None)}),
|
---|
6702 | Documentation(info="<html>
|
---|
6703 | <p>
|
---|
6704 | This function returns y = exp(u), with -∞ < u < ∞:
|
---|
6705 | </p>
|
---|
6706 |
|
---|
6707 | <p>
|
---|
6708 | <img src=\"modelica://Modelica/Resources/Images/Math/exp.png\">
|
---|
6709 | </p>
|
---|
6710 | </html>"), Library="ModelicaExternalC");
|
---|
6711 | end exp;
|
---|
6712 |
|
---|
6713 | function log "Natural (base e) logarithm (u shall be > 0)"
|
---|
6714 | extends baseIcon1;
|
---|
6715 | input Real u;
|
---|
6716 | output Real y;
|
---|
6717 |
|
---|
6718 | external "builtin" y= log(u);
|
---|
6719 | annotation (
|
---|
6720 | Icon(coordinateSystem(
|
---|
6721 | preserveAspectRatio=true,
|
---|
6722 | extent={{-100,-100},{100,100}},
|
---|
6723 | grid={2,2}), graphics={
|
---|
6724 | Line(points={{-90,0},{68,0}}, color={192,192,192}),
|
---|
6725 | Polygon(
|
---|
6726 | points={{90,0},{68,8},{68,-8},{90,0}},
|
---|
6727 | lineColor={192,192,192},
|
---|
6728 | fillColor={192,192,192},
|
---|
6729 | fillPattern=FillPattern.Solid),
|
---|
6730 | Line(points={{-80,-80},{-79.2,-50.6},{-78.4,-37},{-77.6,-28},{-76.8,-21.3},
|
---|
6731 | {-75.2,-11.4},{-72.8,-1.31},{-69.5,8.08},{-64.7,17.9},{-57.5,28},
|
---|
6732 | {-47,38.1},{-31.8,48.1},{-10.1,58},{22.1,68},{68.7,78.1},{80,80}},
|
---|
6733 | color={0,0,0}),
|
---|
6734 | Text(
|
---|
6735 | extent={{-6,-24},{66,-72}},
|
---|
6736 | lineColor={192,192,192},
|
---|
6737 | textString="log")}),
|
---|
6738 | Diagram(coordinateSystem(
|
---|
6739 | preserveAspectRatio=true,
|
---|
6740 | extent={{-100,-100},{100,100}},
|
---|
6741 | grid={2,2}), graphics={
|
---|
6742 | Line(points={{-100,0},{84,0}}, color={95,95,95}),
|
---|
6743 | Polygon(
|
---|
6744 | points={{100,0},{84,6},{84,-6},{100,0}},
|
---|
6745 | lineColor={95,95,95},
|
---|
6746 | fillColor={95,95,95},
|
---|
6747 | fillPattern=FillPattern.Solid),
|
---|
6748 | Line(
|
---|
6749 | points={{-78,-80},{-77.2,-50.6},{-76.4,-37},{-75.6,-28},{-74.8,-21.3},
|
---|
6750 | {-73.2,-11.4},{-70.8,-1.31},{-67.5,8.08},{-62.7,17.9},{-55.5,28},
|
---|
6751 | {-45,38.1},{-29.8,48.1},{-8.1,58},{24.1,68},{70.7,78.1},{82,80}},
|
---|
6752 | color={0,0,255},
|
---|
6753 | thickness=0.5),
|
---|
6754 | Text(
|
---|
6755 | extent={{-105,72},{-85,88}},
|
---|
6756 | textString="3",
|
---|
6757 | lineColor={0,0,255}),
|
---|
6758 | Text(
|
---|
6759 | extent={{60,-3},{80,-23}},
|
---|
6760 | textString="20",
|
---|
6761 | lineColor={0,0,255}),
|
---|
6762 | Text(
|
---|
6763 | extent={{-78,-7},{-58,-27}},
|
---|
6764 | textString="1",
|
---|
6765 | lineColor={0,0,255}),
|
---|
6766 | Text(
|
---|
6767 | extent={{84,26},{104,6}},
|
---|
6768 | lineColor={95,95,95},
|
---|
6769 | textString="u"),
|
---|
6770 | Text(
|
---|
6771 | extent={{-100,9},{-80,-11}},
|
---|
6772 | textString="0",
|
---|
6773 | lineColor={0,0,255}),
|
---|
6774 | Line(
|
---|
6775 | points={{-80,80},{84,80}},
|
---|
6776 | color={175,175,175},
|
---|
6777 | smooth=Smooth.None),
|
---|
6778 | Line(
|
---|
6779 | points={{82,82},{82,-6}},
|
---|
6780 | color={175,175,175},
|
---|
6781 | smooth=Smooth.None)}),
|
---|
6782 | Documentation(info="<html>
|
---|
6783 | <p>
|
---|
6784 | This function returns y = log(10) (the natural logarithm of u),
|
---|
6785 | with u > 0:
|
---|
6786 | </p>
|
---|
6787 |
|
---|
6788 | <p>
|
---|
6789 | <img src=\"modelica://Modelica/Resources/Images/Math/log.png\">
|
---|
6790 | </p>
|
---|
6791 | </html>"), Library="ModelicaExternalC");
|
---|
6792 | end log;
|
---|
6793 |
|
---|
6794 | partial function baseIcon1
|
---|
6795 | "Basic icon for mathematical function with y-axis on left side"
|
---|
6796 |
|
---|
6797 | annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,
|
---|
6798 | -100},{100,100}}), graphics={
|
---|
6799 | Rectangle(
|
---|
6800 | extent={{-100,100},{100,-100}},
|
---|
6801 | lineColor={0,0,0},
|
---|
6802 | fillColor={255,255,255},
|
---|
6803 | fillPattern=FillPattern.Solid),
|
---|
6804 | Line(points={{-80,-80},{-80,68}}, color={192,192,192}),
|
---|
6805 | Polygon(
|
---|
6806 | points={{-80,90},{-88,68},{-72,68},{-80,90}},
|
---|
6807 | lineColor={192,192,192},
|
---|
6808 | fillColor={192,192,192},
|
---|
6809 | fillPattern=FillPattern.Solid),
|
---|
6810 | Text(
|
---|
6811 | extent={{-150,150},{150,110}},
|
---|
6812 | textString="%name",
|
---|
6813 | lineColor={0,0,255})}), Diagram(
|
---|
6814 | coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
|
---|
6815 | 100}}), graphics={
|
---|
6816 | Line(points={{-80,80},{-88,80}}, color={95,95,95}),
|
---|
6817 | Line(points={{-80,-80},{-88,-80}}, color={95,95,95}),
|
---|
6818 | Line(points={{-80,-90},{-80,84}}, color={95,95,95}),
|
---|
6819 | Text(
|
---|
6820 | extent={{-75,104},{-55,84}},
|
---|
6821 | lineColor={95,95,95},
|
---|
6822 | textString="y"),
|
---|
6823 | Polygon(
|
---|
6824 | points={{-80,98},{-86,82},{-74,82},{-80,98}},
|
---|
6825 | lineColor={95,95,95},
|
---|
6826 | fillColor={95,95,95},
|
---|
6827 | fillPattern=FillPattern.Solid)}),
|
---|
6828 | Documentation(info="<html>
|
---|
6829 | <p>
|
---|
6830 | Icon for a mathematical function, consisting of an y-axis on the left side.
|
---|
6831 | It is expected, that an x-axis is added and a plot of the function.
|
---|
6832 | </p>
|
---|
6833 | </html>"));
|
---|
6834 | end baseIcon1;
|
---|
6835 |
|
---|
6836 | partial function baseIcon2
|
---|
6837 | "Basic icon for mathematical function with y-axis in middle"
|
---|
6838 |
|
---|
6839 | annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,
|
---|
6840 | -100},{100,100}}), graphics={
|
---|
6841 | Rectangle(
|
---|
6842 | extent={{-100,100},{100,-100}},
|
---|
6843 | lineColor={0,0,0},
|
---|
6844 | fillColor={255,255,255},
|
---|
6845 | fillPattern=FillPattern.Solid),
|
---|
6846 | Line(points={{0,-80},{0,68}}, color={192,192,192}),
|
---|
6847 | Polygon(
|
---|
6848 | points={{0,90},{-8,68},{8,68},{0,90}},
|
---|
6849 | lineColor={192,192,192},
|
---|
6850 | fillColor={192,192,192},
|
---|
6851 | fillPattern=FillPattern.Solid),
|
---|
6852 | Text(
|
---|
6853 | extent={{-150,150},{150,110}},
|
---|
6854 | textString="%name",
|
---|
6855 | lineColor={0,0,255})}), Diagram(graphics={
|
---|
6856 | Line(points={{0,80},{-8,80}}, color={95,95,95}),
|
---|
6857 | Line(points={{0,-80},{-8,-80}}, color={95,95,95}),
|
---|
6858 | Line(points={{0,-90},{0,84}}, color={95,95,95}),
|
---|
6859 | Text(
|
---|
6860 | extent={{5,104},{25,84}},
|
---|
6861 | lineColor={95,95,95},
|
---|
6862 | textString="y"),
|
---|
6863 | Polygon(
|
---|
6864 | points={{0,98},{-6,82},{6,82},{0,98}},
|
---|
6865 | lineColor={95,95,95},
|
---|
6866 | fillColor={95,95,95},
|
---|
6867 | fillPattern=FillPattern.Solid)}),
|
---|
6868 | Documentation(info="<html>
|
---|
6869 | <p>
|
---|
6870 | Icon for a mathematical function, consisting of an y-axis in the middle.
|
---|
6871 | It is expected, that an x-axis is added and a plot of the function.
|
---|
6872 | </p>
|
---|
6873 | </html>"));
|
---|
6874 | end baseIcon2;
|
---|
6875 | annotation (
|
---|
6876 | Invisible=true,
|
---|
6877 | Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}),
|
---|
6878 | graphics={Text(
|
---|
6879 | extent={{-59,-9},{42,-56}},
|
---|
6880 | lineColor={0,0,0},
|
---|
6881 | textString="f(x)")}),
|
---|
6882 | Documentation(info="<HTML>
|
---|
6883 | <p>
|
---|
6884 | This package contains <b>basic mathematical functions</b> (such as sin(..)),
|
---|
6885 | as well as functions operating on
|
---|
6886 | <a href=\"modelica://Modelica.Math.Vectors\">vectors</a>,
|
---|
6887 | <a href=\"modelica://Modelica.Math.Matrices\">matrices</a>,
|
---|
6888 | <a href=\"modelica://Modelica.Math.Nonlinear\">nonlinear functions</a>, and
|
---|
6889 | <a href=\"modelica://Modelica.Math.BooleanVectors\">Boolean vectors</a>.
|
---|
6890 | </p>
|
---|
6891 |
|
---|
6892 | <dl>
|
---|
6893 | <dt><b>Main Authors:</b>
|
---|
6894 | <dd><a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a> and
|
---|
6895 | Marcus Baur<br>
|
---|
6896 | Deutsches Zentrum für Luft und Raumfahrt e.V. (DLR)<br>
|
---|
6897 | Institut für Robotik und Mechatronik<br>
|
---|
6898 | Postfach 1116<br>
|
---|
6899 | D-82230 Wessling<br>
|
---|
6900 | Germany<br>
|
---|
6901 | email: <A HREF=\"mailto:Martin.Otter@dlr.de\">Martin.Otter@dlr.de</A><br>
|
---|
6902 | </dl>
|
---|
6903 |
|
---|
6904 | <p>
|
---|
6905 | Copyright © 1998-2010, Modelica Association and DLR.
|
---|
6906 | </p>
|
---|
6907 | <p>
|
---|
6908 | <i>This Modelica package is <u>free</u> software and the use is completely at <u>your own risk</u>; it can be redistributed and/or modified under the terms of the Modelica License 2. For license conditions (including the disclaimer of warranty) see <a href=\"modelica://Modelica.UsersGuide.ModelicaLicense2\">Modelica.UsersGuide.ModelicaLicense2</a> or visit <a href=\"http://www.modelica.org/licenses/ModelicaLicense2\"> http://www.modelica.org/licenses/ModelicaLicense2</a>.</i>
|
---|
6909 | </p>
|
---|
6910 | </HTML>
|
---|
6911 | ", revisions="<html>
|
---|
6912 | <ul>
|
---|
6913 | <li><i>October 21, 2002</i>
|
---|
6914 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>
|
---|
6915 | and <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br>
|
---|
6916 | Function tempInterpol2 added.</li>
|
---|
6917 | <li><i>Oct. 24, 1999</i>
|
---|
6918 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
|
---|
6919 | Icons for icon and diagram level introduced.</li>
|
---|
6920 | <li><i>June 30, 1999</i>
|
---|
6921 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
|
---|
6922 | Realized.</li>
|
---|
6923 | </ul>
|
---|
6924 |
|
---|
6925 | </html>"));
|
---|
6926 | end Math;
|
---|
6927 |
|
---|
6928 | package Utilities
|
---|
6929 | "Library of utility functions dedicated to scripting (operating on files, streams, strings, system)"
|
---|
6930 | extends Modelica.Icons.Package;
|
---|
6931 |
|
---|
6932 | package Streams "Read from files and write to files"
|
---|
6933 | extends Modelica.Icons.Package;
|
---|
6934 |
|
---|
6935 | function error "Print error message and cancel all actions"
|
---|
6936 | extends Modelica.Icons.Function;
|
---|
6937 | input String string "String to be printed to error message window";
|
---|
6938 | external "C" ModelicaError(string);
|
---|
6939 | annotation (Library="ModelicaExternalC",
|
---|
6940 | Documentation(info="<html>
|
---|
6941 | <h4>Syntax</h4>
|
---|
6942 | <blockquote><pre>
|
---|
6943 | Streams.<b>error</b>(string);
|
---|
6944 | </pre></blockquote>
|
---|
6945 | <h4>Description</h4>
|
---|
6946 | <p>
|
---|
6947 | Print the string \"string\" as error message and
|
---|
6948 | cancel all actions. Line breaks are characterized
|
---|
6949 | by \"\\n\" in the string.
|
---|
6950 | </p>
|
---|
6951 | <h4>Example</h4>
|
---|
6952 | <blockquote><pre>
|
---|
6953 | Streams.error(\"x (= \" + String(x) + \")\\nhas to be in the range 0 .. 1\");
|
---|
6954 | </pre></blockquote>
|
---|
6955 | <h4>See also</h4>
|
---|
6956 | <p>
|
---|
6957 | <a href=\"modelica://Modelica.Utilities.Streams\">Streams</a>,
|
---|
6958 | <a href=\"modelica://Modelica.Utilities.Streams.print\">Streams.print</a>,
|
---|
6959 | <a href=\"modelica://ModelicaReference.Operators.string\">String</a>
|
---|
6960 | </p>
|
---|
6961 | </html>"));
|
---|
6962 | end error;
|
---|
6963 | annotation (
|
---|
6964 | Documentation(info="<HTML>
|
---|
6965 | <h4>Library content</h4>
|
---|
6966 | <p>
|
---|
6967 | Package <b>Streams</b> contains functions to input and output strings
|
---|
6968 | to a message window or on files. Note that a string is interpreted
|
---|
6969 | and displayed as html text (e.g., with print(..) or error(..))
|
---|
6970 | if it is enclosed with the Modelica html quotation, e.g.,
|
---|
6971 | </p>
|
---|
6972 | <center>
|
---|
6973 | string = \"<html> first line <br> second line </html>\".
|
---|
6974 | </center>
|
---|
6975 | <p>
|
---|
6976 | It is a quality of implementation, whether (a) all tags of html are supported
|
---|
6977 | or only a subset, (b) how html tags are interpreted if the output device
|
---|
6978 | does not allow to display formatted text.
|
---|
6979 | </p>
|
---|
6980 | <p>
|
---|
6981 | In the table below an example call to every function is given:
|
---|
6982 | </p>
|
---|
6983 | <table border=1 cellspacing=0 cellpadding=2>
|
---|
6984 | <tr><th><b><i>Function/type</i></b></th><th><b><i>Description</i></b></th></tr>
|
---|
6985 | <tr><td valign=\"top\"><a href=\"modelica://Modelica.Utilities.Streams.print\">print</a>(string)<br>
|
---|
6986 | <a href=\"modelica://Modelica.Utilities.Streams.print\">print</a>(string,fileName)</td>
|
---|
6987 | <td valign=\"top\"> Print string \"string\" or vector of strings to message window or on
|
---|
6988 | file \"fileName\".</td>
|
---|
6989 | </tr>
|
---|
6990 | <tr><td valign=\"top\">stringVector =
|
---|
6991 | <a href=\"modelica://Modelica.Utilities.Streams.readFile\">readFile</a>(fileName)</td>
|
---|
6992 | <td valign=\"top\"> Read complete text file and return it as a vector of strings.</td>
|
---|
6993 | </tr>
|
---|
6994 | <tr><td valign=\"top\">(string, endOfFile) =
|
---|
6995 | <a href=\"modelica://Modelica.Utilities.Streams.readLine\">readLine</a>(fileName, lineNumber)</td>
|
---|
6996 | <td valign=\"top\">Returns from the file the content of line lineNumber.</td>
|
---|
6997 | </tr>
|
---|
6998 | <tr><td valign=\"top\">lines =
|
---|
6999 | <a href=\"modelica://Modelica.Utilities.Streams.countLines\">countLines</a>(fileName)</td>
|
---|
7000 | <td valign=\"top\">Returns the number of lines in a file.</td>
|
---|
7001 | </tr>
|
---|
7002 | <tr><td valign=\"top\"><a href=\"modelica://Modelica.Utilities.Streams.error\">error</a>(string)</td>
|
---|
7003 | <td valign=\"top\"> Print error message \"string\" to message window
|
---|
7004 | and cancel all actions</td>
|
---|
7005 | </tr>
|
---|
7006 | <tr><td valign=\"top\"><a href=\"modelica://Modelica.Utilities.Streams.close\">close</a>(fileName)</td>
|
---|
7007 | <td valign=\"top\"> Close file if it is still open. Ignore call if
|
---|
7008 | file is already closed or does not exist. </td>
|
---|
7009 | </tr>
|
---|
7010 | </table>
|
---|
7011 | <p>
|
---|
7012 | Use functions <b>scanXXX</b> from package
|
---|
7013 | <a href=\"modelica://Modelica.Utilities.Strings\">Strings</a>
|
---|
7014 | to parse a string.
|
---|
7015 | </p>
|
---|
7016 | <p>
|
---|
7017 | If Real, Integer or Boolean values shall be printed
|
---|
7018 | or used in an error message, they have to be first converted
|
---|
7019 | to strings with the builtin operator
|
---|
7020 | <a href=\"modelica://ModelicaReference.Operators.string\">String</a>(...).
|
---|
7021 | Example:
|
---|
7022 | </p>
|
---|
7023 | <pre>
|
---|
7024 | <b>if</b> x < 0 <b>or</b> x > 1 <b>then</b>
|
---|
7025 | Streams.error(\"x (= \" + String(x) + \") has to be in the range 0 .. 1\");
|
---|
7026 | <b>end if</b>;
|
---|
7027 | </pre>
|
---|
7028 | </HTML>
|
---|
7029 | "));
|
---|
7030 | end Streams;
|
---|
7031 |
|
---|
7032 | package Strings "Operations on strings"
|
---|
7033 | extends Modelica.Icons.Package;
|
---|
7034 |
|
---|
7035 | function compare "Compare two strings lexicographically"
|
---|
7036 | extends Modelica.Icons.Function;
|
---|
7037 | input String string1;
|
---|
7038 | input String string2;
|
---|
7039 | input Boolean caseSensitive=true
|
---|
7040 | "= false, if case of letters is ignored";
|
---|
7041 | output Modelica.Utilities.Types.Compare result "Result of comparison";
|
---|
7042 | external "C" result = ModelicaStrings_compare(string1, string2, caseSensitive);
|
---|
7043 | annotation (Library="ModelicaExternalC", Documentation(info="<html>
|
---|
7044 | <h4>Syntax</h4>
|
---|
7045 | <blockquote><pre>
|
---|
7046 | result = Strings.<b>compare</b>(string1, string2);
|
---|
7047 | result = Strings.<b>compare</b>(string1, string2, caseSensitive=true);
|
---|
7048 | </pre></blockquote>
|
---|
7049 | <h4>Description</h4>
|
---|
7050 | <p>
|
---|
7051 | Compares two strings. If the optional argument caseSensitive=false,
|
---|
7052 | upper case letters are treated as if they would be lower case letters.
|
---|
7053 | The result of the comparison is returned as:
|
---|
7054 | </p>
|
---|
7055 | <pre>
|
---|
7056 | result = Modelica.Utilities.Types.Compare.Less // string1 < string2
|
---|
7057 | = Modelica.Utilities.Types.Compare.Equal // string1 = string2
|
---|
7058 | = Modelica.Utilities.Types.Compare.Greater // string1 > string2
|
---|
7059 | </pre>
|
---|
7060 | <p>
|
---|
7061 | Comparison is with regards to lexicographical order,
|
---|
7062 | e.g., \"a\" < \"b\";
|
---|
7063 | </p>
|
---|
7064 | </html>"));
|
---|
7065 | end compare;
|
---|
7066 |
|
---|
7067 | function isEqual "Determine whether two strings are identical"
|
---|
7068 | extends Modelica.Icons.Function;
|
---|
7069 | input String string1;
|
---|
7070 | input String string2;
|
---|
7071 | input Boolean caseSensitive=true
|
---|
7072 | "= false, if lower and upper case are ignored for the comparison";
|
---|
7073 | output Boolean identical "True, if string1 is identical to string2";
|
---|
7074 | algorithm
|
---|
7075 | identical :=compare(string1, string2, caseSensitive) == Types.Compare.Equal;
|
---|
7076 | annotation (
|
---|
7077 | Documentation(info="<html>
|
---|
7078 | <h4>Syntax</h4>
|
---|
7079 | <blockquote><pre>
|
---|
7080 | Strings.<b>isEqual</b>(string1, string2);
|
---|
7081 | Strings.<b>isEqual</b>(string1, string2, caseSensitive=true);
|
---|
7082 | </pre></blockquote>
|
---|
7083 | <h4>Description</h4>
|
---|
7084 | <p>
|
---|
7085 | Compare whether two strings are identical,
|
---|
7086 | optionally ignoring case.
|
---|
7087 | </p>
|
---|
7088 | </html>"));
|
---|
7089 | end isEqual;
|
---|
7090 | annotation (
|
---|
7091 | Documentation(info="<HTML>
|
---|
7092 | <h4>Library content</h4>
|
---|
7093 | <p>
|
---|
7094 | Package <b>Strings</b> contains functions to manipulate strings.
|
---|
7095 | </p>
|
---|
7096 | <p>
|
---|
7097 | In the table below an example
|
---|
7098 | call to every function is given using the <b>default</b> options.
|
---|
7099 | </p>
|
---|
7100 | <table border=1 cellspacing=0 cellpadding=2>
|
---|
7101 | <tr><th><b><i>Function</i></b></th><th><b><i>Description</i></b></th></tr>
|
---|
7102 | <tr><td valign=\"top\">len = <a href=\"modelica://Modelica.Utilities.Strings.length\">length</a>(string)</td>
|
---|
7103 | <td valign=\"top\">Returns length of string</td></tr>
|
---|
7104 | <tr><td valign=\"top\">string2 = <a href=\"modelica://Modelica.Utilities.Strings.substring\">substring</a>(string1,startIndex,endIndex)
|
---|
7105 | </td>
|
---|
7106 | <td valign=\"top\">Returns a substring defined by start and end index</td></tr>
|
---|
7107 | <tr><td valign=\"top\">result = <a href=\"modelica://Modelica.Utilities.Strings.repeat\">repeat</a>(n)<br>
|
---|
7108 | result = <a href=\"modelica://Modelica.Utilities.Strings.repeat\">repeat</a>(n,string)</td>
|
---|
7109 | <td valign=\"top\">Repeat a blank or a string n times.</td></tr>
|
---|
7110 | <tr><td valign=\"top\">result = <a href=\"modelica://Modelica.Utilities.Strings.compare\">compare</a>(string1, string2)</td>
|
---|
7111 | <td valign=\"top\">Compares two substrings with regards to alphabetical order</td></tr>
|
---|
7112 | <tr><td valign=\"top\">identical =
|
---|
7113 | <a href=\"modelica://Modelica.Utilities.Strings.isEqual\">isEqual</a>(string1,string2)</td>
|
---|
7114 | <td valign=\"top\">Determine whether two strings are identical</td></tr>
|
---|
7115 | <tr><td valign=\"top\">result = <a href=\"modelica://Modelica.Utilities.Strings.count\">count</a>(string,searchString)</td>
|
---|
7116 | <td valign=\"top\">Count the number of occurrences of a string</td></tr>
|
---|
7117 | <tr>
|
---|
7118 | <td valign=\"top\">index = <a href=\"modelica://Modelica.Utilities.Strings.find\">find</a>(string,searchString)</td>
|
---|
7119 | <td valign=\"top\">Find first occurrence of a string in another string</td></tr>
|
---|
7120 | <tr>
|
---|
7121 | <td valign=\"top\">index = <a href=\"modelica://Modelica.Utilities.Strings.findLast\">findLast</a>(string,searchString)</td>
|
---|
7122 | <td valign=\"top\">Find last occurrence of a string in another string</td></tr>
|
---|
7123 | <tr><td valign=\"top\">string2 = <a href=\"modelica://Modelica.Utilities.Strings.replace\">replace</a>(string,searchString,replaceString)</td>
|
---|
7124 | <td valign=\"top\">Replace one or all occurrences of a string</td></tr>
|
---|
7125 | <tr><td valign=\"top\">stringVector2 = <a href=\"modelica://Modelica.Utilities.Strings.sort\">sort</a>(stringVector1)</td>
|
---|
7126 | <td valign=\"top\">Sort vector of strings in alphabetic order</td></tr>
|
---|
7127 | <tr><td valign=\"top\">(token, index) = <a href=\"modelica://Modelica.Utilities.Strings.scanToken\">scanToken</a>(string,startIndex)</td>
|
---|
7128 | <td valign=\"top\">Scan for a token (Real/Integer/Boolean/String/Identifier/Delimiter/NoToken)</td></tr>
|
---|
7129 | <tr><td valign=\"top\">(number, index) = <a href=\"modelica://Modelica.Utilities.Strings.scanReal\">scanReal</a>(string,startIndex)</td>
|
---|
7130 | <td valign=\"top\">Scan for a Real constant</td></tr>
|
---|
7131 | <tr><td valign=\"top\">(number, index) = <a href=\"modelica://Modelica.Utilities.Strings.scanInteger\">scanInteger</a>(string,startIndex)</td>
|
---|
7132 | <td valign=\"top\">Scan for an Integer constant</td></tr>
|
---|
7133 | <tr><td valign=\"top\">(boolean, index) = <a href=\"modelica://Modelica.Utilities.Strings.scanBoolean\">scanBoolean</a>(string,startIndex)</td>
|
---|
7134 | <td valign=\"top\">Scan for a Boolean constant</td></tr>
|
---|
7135 | <tr><td valign=\"top\">(string2, index) = <a href=\"modelica://Modelica.Utilities.Strings.scanString\">scanString</a>(string,startIndex)</td>
|
---|
7136 | <td valign=\"top\">Scan for a String constant</td></tr>
|
---|
7137 | <tr><td valign=\"top\">(identifier, index) = <a href=\"modelica://Modelica.Utilities.Strings.scanIdentifier\">scanIdentifier</a>(string,startIndex)</td>
|
---|
7138 | <td valign=\"top\">Scan for an identifier</td></tr>
|
---|
7139 | <tr><td valign=\"top\">(delimiter, index) = <a href=\"modelica://Modelica.Utilities.Strings.scanDelimiter\">scanDelimiter</a>(string,startIndex)</td>
|
---|
7140 | <td valign=\"top\">Scan for delimiters</td></tr>
|
---|
7141 | <tr><td valign=\"top\"><a href=\"modelica://Modelica.Utilities.Strings.scanNoToken\">scanNoToken</a>(string,startIndex)</td>
|
---|
7142 | <td valign=\"top\">Check that remaining part of string consists solely of <br>
|
---|
7143 | white space or line comments (\"// ...\\n\").</td></tr>
|
---|
7144 | <tr><td valign=\"top\"><a href=\"modelica://Modelica.Utilities.Strings.syntaxError\">syntaxError</a>(string,index,message)</td>
|
---|
7145 | <td valign=\"top\"> Print a \"syntax error message\" as well as a string and the <br>
|
---|
7146 | index at which scanning detected an error</td></tr>
|
---|
7147 | </table>
|
---|
7148 | <p>
|
---|
7149 | The functions \"compare\", \"isEqual\", \"count\", \"find\", \"findLast\", \"replace\", \"sort\"
|
---|
7150 | have the optional
|
---|
7151 | input argument <b>caseSensitive</b> with default <b>true</b>.
|
---|
7152 | If <b>false</b>, the operation is carried out without taking
|
---|
7153 | into account whether a character is upper or lower case.
|
---|
7154 | </p>
|
---|
7155 | </HTML>"));
|
---|
7156 | end Strings;
|
---|
7157 |
|
---|
7158 | package Types "Type definitions used in package Modelica.Utilities"
|
---|
7159 | extends Modelica.Icons.Package;
|
---|
7160 |
|
---|
7161 | type Compare = enumeration(
|
---|
7162 | Less "String 1 is lexicographically less than string 2",
|
---|
7163 | Equal "String 1 is identical to string 2",
|
---|
7164 | Greater "String 1 is lexicographically greater than string 2")
|
---|
7165 | "Enumeration defining comparision of two strings";
|
---|
7166 | annotation (Documentation(info="<html>
|
---|
7167 | <p>
|
---|
7168 | This package contains type definitions used in Modelica.Utilities.
|
---|
7169 | </p>
|
---|
7170 |
|
---|
7171 | </html>"));
|
---|
7172 | end Types;
|
---|
7173 | annotation (
|
---|
7174 | Documentation(info="<html>
|
---|
7175 | <p>
|
---|
7176 | This package contains Modelica <b>functions</b> that are
|
---|
7177 | especially suited for <b>scripting</b>. The functions might
|
---|
7178 | be used to work with strings, read data from file, write data
|
---|
7179 | to file or copy, move and remove files.
|
---|
7180 | </p>
|
---|
7181 | <p>
|
---|
7182 | For an introduction, have especially a look at:
|
---|
7183 | </p>
|
---|
7184 | <ul>
|
---|
7185 | <li> <a href=\"modelica://Modelica.Utilities.UsersGuide\">Modelica.Utilities.User's Guide</a>
|
---|
7186 | discusses the most important aspects of this library.</li>
|
---|
7187 | <li> <a href=\"modelica://Modelica.Utilities.Examples\">Modelica.Utilities.Examples</a>
|
---|
7188 | contains examples that demonstrate the usage of this library.</li>
|
---|
7189 | </ul>
|
---|
7190 | <p>
|
---|
7191 | The following main sublibraries are available:
|
---|
7192 | </p>
|
---|
7193 | <ul>
|
---|
7194 | <li> <a href=\"modelica://Modelica.Utilities.Files\">Files</a>
|
---|
7195 | provides functions to operate on files and directories, e.g.,
|
---|
7196 | to copy, move, remove files.</li>
|
---|
7197 | <li> <a href=\"modelica://Modelica.Utilities.Streams\">Streams</a>
|
---|
7198 | provides functions to read from files and write to files.</li>
|
---|
7199 | <li> <a href=\"modelica://Modelica.Utilities.Strings\">Strings</a>
|
---|
7200 | provides functions to operate on strings. E.g.
|
---|
7201 | substring, find, replace, sort, scanToken.</li>
|
---|
7202 | <li> <a href=\"modelica://Modelica.Utilities.System\">System</a>
|
---|
7203 | provides functions to interact with the environment.
|
---|
7204 | E.g., get or set the working directory or environment
|
---|
7205 | variables and to send a command to the default shell.</li>
|
---|
7206 | </ul>
|
---|
7207 |
|
---|
7208 | <p>
|
---|
7209 | Copyright © 1998-2010, Modelica Association, DLR, and Dassault Systèmes AB.
|
---|
7210 | </p>
|
---|
7211 |
|
---|
7212 | <p>
|
---|
7213 | <i>This Modelica package is <u>free</u> software and the use is completely at <u>your own risk</u>; it can be redistributed and/or modified under the terms of the Modelica License 2. For license conditions (including the disclaimer of warranty) see <a href=\"modelica://Modelica.UsersGuide.ModelicaLicense2\">Modelica.UsersGuide.ModelicaLicense2</a> or visit <a href=\"http://www.modelica.org/licenses/ModelicaLicense2\"> http://www.modelica.org/licenses/ModelicaLicense2</a>.</i>
|
---|
7214 | </p>
|
---|
7215 |
|
---|
7216 | </html>
|
---|
7217 | "));
|
---|
7218 | end Utilities;
|
---|
7219 |
|
---|
7220 | package Constants
|
---|
7221 | "Library of mathematical constants and constants of nature (e.g., pi, eps, R, sigma)"
|
---|
7222 | import SI = Modelica.SIunits;
|
---|
7223 | import NonSI = Modelica.SIunits.Conversions.NonSIunits;
|
---|
7224 | extends Modelica.Icons.Package;
|
---|
7225 |
|
---|
7226 | final constant Real pi=2*Modelica.Math.asin(1.0);
|
---|
7227 |
|
---|
7228 | final constant Real eps=1.e-15 "Biggest number such that 1.0 + eps = 1.0";
|
---|
7229 |
|
---|
7230 | final constant Real small=1.e-60
|
---|
7231 | "Smallest number such that small and -small are representable on the machine";
|
---|
7232 |
|
---|
7233 | final constant Real R(final unit="J/(mol.K)") = 8.314472
|
---|
7234 | "Molar gas constant";
|
---|
7235 |
|
---|
7236 | final constant Real sigma(final unit="W/(m2.K4)") = 5.670400e-8
|
---|
7237 | "Stefan-Boltzmann constant";
|
---|
7238 |
|
---|
7239 | final constant NonSI.Temperature_degC T_zero=-273.15
|
---|
7240 | "Absolute zero temperature";
|
---|
7241 | annotation (
|
---|
7242 | Documentation(info="<html>
|
---|
7243 | <p>
|
---|
7244 | This package provides often needed constants from mathematics, machine
|
---|
7245 | dependent constants and constants from nature. The latter constants
|
---|
7246 | (name, value, description) are from the following source:
|
---|
7247 | </p>
|
---|
7248 |
|
---|
7249 | <dl>
|
---|
7250 | <dt>Peter J. Mohr and Barry N. Taylor (1999):</dt>
|
---|
7251 | <dd><b>CODATA Recommended Values of the Fundamental Physical Constants: 1998</b>.
|
---|
7252 | Journal of Physical and Chemical Reference Data, Vol. 28, No. 6, 1999 and
|
---|
7253 | Reviews of Modern Physics, Vol. 72, No. 2, 2000. See also <a href=
|
---|
7254 | \"http://physics.nist.gov/cuu/Constants/\">http://physics.nist.gov/cuu/Constants/</a></dd>
|
---|
7255 | </dl>
|
---|
7256 |
|
---|
7257 | <p>CODATA is the Committee on Data for Science and Technology.</p>
|
---|
7258 |
|
---|
7259 | <dl>
|
---|
7260 | <dt><b>Main Author:</b></dt>
|
---|
7261 | <dd><a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a><br>
|
---|
7262 | Deutsches Zentrum für Luft und Raumfahrt e. V. (DLR)<br>
|
---|
7263 | Oberpfaffenhofen<br>
|
---|
7264 | Postfach 11 16<br>
|
---|
7265 | D-82230 Weßling<br>
|
---|
7266 | email: <a href=\"mailto:Martin.Otter@dlr.de\">Martin.Otter@dlr.de</a></dd>
|
---|
7267 | </dl>
|
---|
7268 |
|
---|
7269 | <p>
|
---|
7270 | Copyright © 1998-2010, Modelica Association and DLR.
|
---|
7271 | </p>
|
---|
7272 | <p>
|
---|
7273 | <i>This Modelica package is <u>free</u> software and the use is completely at <u>your own risk</u>; it can be redistributed and/or modified under the terms of the Modelica License 2. For license conditions (including the disclaimer of warranty) see <a href=\"modelica://Modelica.UsersGuide.ModelicaLicense2\">Modelica.UsersGuide.ModelicaLicense2</a> or visit <a href=\"http://www.modelica.org/licenses/ModelicaLicense2\"> http://www.modelica.org/licenses/ModelicaLicense2</a>.</i>
|
---|
7274 | </p>
|
---|
7275 | </html>
|
---|
7276 | ", revisions="<html>
|
---|
7277 | <ul>
|
---|
7278 | <li><i>Nov 8, 2004</i>
|
---|
7279 | by <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br>
|
---|
7280 | Constants updated according to 2002 CODATA values.</li>
|
---|
7281 | <li><i>Dec 9, 1999</i>
|
---|
7282 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
|
---|
7283 | Constants updated according to 1998 CODATA values. Using names, values
|
---|
7284 | and description text from this source. Included magnetic and
|
---|
7285 | electric constant.</li>
|
---|
7286 | <li><i>Sep 18, 1999</i>
|
---|
7287 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
|
---|
7288 | Constants eps, inf, small introduced.</li>
|
---|
7289 | <li><i>Nov 15, 1997</i>
|
---|
7290 | by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
|
---|
7291 | Realized.</li>
|
---|
7292 | </ul>
|
---|
7293 | </html>"),
|
---|
7294 | Invisible=true,
|
---|
7295 | Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
|
---|
7296 | 100}}), graphics={
|
---|
7297 | Line(
|
---|
7298 | points={{-34,-38},{12,-38}},
|
---|
7299 | color={0,0,0},
|
---|
7300 | thickness=0.5),
|
---|
7301 | Line(
|
---|
7302 | points={{-20,-38},{-24,-48},{-28,-56},{-34,-64}},
|
---|
7303 | color={0,0,0},
|
---|
7304 | thickness=0.5),
|
---|
7305 | Line(
|
---|
7306 | points={{-2,-38},{2,-46},{8,-56},{14,-64}},
|
---|
7307 | color={0,0,0},
|
---|
7308 | thickness=0.5)}),
|
---|
7309 | Diagram(graphics={
|
---|
7310 | Rectangle(
|
---|
7311 | extent={{200,162},{380,312}},
|
---|
7312 | fillColor={235,235,235},
|
---|
7313 | fillPattern=FillPattern.Solid,
|
---|
7314 | lineColor={0,0,255}),
|
---|
7315 | Polygon(
|
---|
7316 | points={{200,312},{220,332},{400,332},{380,312},{200,312}},
|
---|
7317 | fillColor={235,235,235},
|
---|
7318 | fillPattern=FillPattern.Solid,
|
---|
7319 | lineColor={0,0,255}),
|
---|
7320 | Polygon(
|
---|
7321 | points={{400,332},{400,182},{380,162},{380,312},{400,332}},
|
---|
7322 | fillColor={235,235,235},
|
---|
7323 | fillPattern=FillPattern.Solid,
|
---|
7324 | lineColor={0,0,255}),
|
---|
7325 | Text(
|
---|
7326 | extent={{210,302},{370,272}},
|
---|
7327 | lineColor={160,160,164},
|
---|
7328 | textString="Library"),
|
---|
7329 | Line(
|
---|
7330 | points={{266,224},{312,224}},
|
---|
7331 | color={0,0,0},
|
---|
7332 | thickness=1),
|
---|
7333 | Line(
|
---|
7334 | points={{280,224},{276,214},{272,206},{266,198}},
|
---|
7335 | color={0,0,0},
|
---|
7336 | thickness=1),
|
---|
7337 | Line(
|
---|
7338 | points={{298,224},{302,216},{308,206},{314,198}},
|
---|
7339 | color={0,0,0},
|
---|
7340 | thickness=1),
|
---|
7341 | Text(
|
---|
7342 | extent={{152,412},{458,334}},
|
---|
7343 | lineColor={255,0,0},
|
---|
7344 | textString="Modelica.Constants")}));
|
---|
7345 | end Constants;
|
---|
7346 |
|
---|
7347 | package Icons "Library of icons"
|
---|
7348 | extends Icons.Package;
|
---|
7349 |
|
---|
7350 | partial package Package "Icon for standard packages"
|
---|
7351 |
|
---|
7352 | annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
|
---|
7353 | -100},{100,100}}), graphics={Rectangle(
|
---|
7354 | extent={{-80,100},{100,-80}},
|
---|
7355 | lineColor={0,0,0},
|
---|
7356 | fillColor={215,230,240},
|
---|
7357 | fillPattern=FillPattern.Solid), Rectangle(
|
---|
7358 | extent={{-100,80},{80,-100}},
|
---|
7359 | lineColor={0,0,0},
|
---|
7360 | fillColor={240,240,240},
|
---|
7361 | fillPattern=FillPattern.Solid)}),
|
---|
7362 | Documentation(info="<html>
|
---|
7363 | <p>Standard package icon.</p>
|
---|
7364 | </html>"));
|
---|
7365 | end Package;
|
---|
7366 |
|
---|
7367 | partial package BasesPackage "Icon for packages containing base classes"
|
---|
7368 | //extends Modelica.Icons.Package;
|
---|
7369 | annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
|
---|
7370 | -100},{100,100}}), graphics={Rectangle(
|
---|
7371 | extent={{-80,100},{100,-80}},
|
---|
7372 | lineColor={0,0,0},
|
---|
7373 | fillColor={215,230,240},
|
---|
7374 | fillPattern=FillPattern.Solid), Rectangle(
|
---|
7375 | extent={{-100,80},{80,-100}},
|
---|
7376 | lineColor={0,0,0},
|
---|
7377 | fillColor={240,240,240},
|
---|
7378 | fillPattern=FillPattern.Solid),
|
---|
7379 | Ellipse(
|
---|
7380 | extent={{-30,10},{10,-30}},
|
---|
7381 | lineColor={0,0,0},
|
---|
7382 | fillColor={255,255,255},
|
---|
7383 | fillPattern=FillPattern.Solid)}),
|
---|
7384 | Documentation(info="<html>
|
---|
7385 | <p>This icon shall be used for a package/library that contains base models and classes, respectively.</p>
|
---|
7386 | </html>"));
|
---|
7387 | end BasesPackage;
|
---|
7388 |
|
---|
7389 | partial package InterfacesPackage "Icon for packages containing interfaces"
|
---|
7390 | //extends Modelica.Icons.Package;
|
---|
7391 | annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
|
---|
7392 | -100},{100,100}}), graphics={Rectangle(
|
---|
7393 | extent={{-80,100},{100,-80}},
|
---|
7394 | lineColor={0,0,0},
|
---|
7395 | fillColor={215,230,240},
|
---|
7396 | fillPattern=FillPattern.Solid), Rectangle(
|
---|
7397 | extent={{-100,80},{80,-100}},
|
---|
7398 | lineColor={0,0,0},
|
---|
7399 | fillColor={240,240,240},
|
---|
7400 | fillPattern=FillPattern.Solid),
|
---|
7401 | Polygon(
|
---|
7402 | points={{0,50},{20,50},{50,10},{80,10},{80,-30},{50,-30},{20,-70},{
|
---|
7403 | 0,-70},{0,50}},
|
---|
7404 | lineColor={0,0,0},
|
---|
7405 | smooth=Smooth.None,
|
---|
7406 | fillColor={215,215,215},
|
---|
7407 | fillPattern=FillPattern.Solid),
|
---|
7408 | Polygon(
|
---|
7409 | points={{-100,10},{-70,10},{-40,50},{-20,50},{-20,-70},{-40,-70},{
|
---|
7410 | -70,-30},{-100,-30},{-100,10}},
|
---|
7411 | lineColor={0,0,0},
|
---|
7412 | smooth=Smooth.None,
|
---|
7413 | fillColor={215,230,240},
|
---|
7414 | fillPattern=FillPattern.Solid)}),
|
---|
7415 | Documentation(info="<html>
|
---|
7416 | <p>This icon indicates packages containing interfaces.</p>
|
---|
7417 | </html>"));
|
---|
7418 | end InterfacesPackage;
|
---|
7419 |
|
---|
7420 | partial package SourcesPackage "Icon for packages containing sources"
|
---|
7421 | //extends Modelica.Icons.Package;
|
---|
7422 | annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
|
---|
7423 | -100},{100,100}}), graphics={Rectangle(
|
---|
7424 | extent={{-80,100},{100,-80}},
|
---|
7425 | lineColor={0,0,0},
|
---|
7426 | fillColor={215,230,240},
|
---|
7427 | fillPattern=FillPattern.Solid), Rectangle(
|
---|
7428 | extent={{-100,80},{80,-100}},
|
---|
7429 | lineColor={0,0,0},
|
---|
7430 | fillColor={240,240,240},
|
---|
7431 | fillPattern=FillPattern.Solid),
|
---|
7432 | Polygon(
|
---|
7433 | points={{-28,12},{-28,-40},{36,-14},{-28,12}},
|
---|
7434 | lineColor={0,0,0},
|
---|
7435 | smooth=Smooth.None,
|
---|
7436 | fillColor={255,255,255},
|
---|
7437 | fillPattern=FillPattern.Solid),
|
---|
7438 | Line(
|
---|
7439 | points={{-28,-14},{-68,-14}},
|
---|
7440 | color={0,0,0},
|
---|
7441 | smooth=Smooth.None)}),
|
---|
7442 | Documentation(info="<html>
|
---|
7443 | <p>This icon indicates a package which contains sources.</p>
|
---|
7444 | </html>"));
|
---|
7445 | end SourcesPackage;
|
---|
7446 |
|
---|
7447 | partial package MaterialPropertiesPackage
|
---|
7448 | "Icon for package containing property classes"
|
---|
7449 | //extends Modelica.Icons.Package;
|
---|
7450 | annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
|
---|
7451 | -100},{100,100}}), graphics={Rectangle(
|
---|
7452 | extent={{-80,100},{100,-80}},
|
---|
7453 | lineColor={0,0,0},
|
---|
7454 | fillColor={215,230,240},
|
---|
7455 | fillPattern=FillPattern.Solid), Rectangle(
|
---|
7456 | extent={{-100,80},{80,-100}},
|
---|
7457 | lineColor={0,0,0},
|
---|
7458 | fillColor={240,240,240},
|
---|
7459 | fillPattern=FillPattern.Solid),
|
---|
7460 | Ellipse(
|
---|
7461 | extent={{-68,50},{52,-70}},
|
---|
7462 | lineColor={0,0,0},
|
---|
7463 | fillPattern=FillPattern.Sphere,
|
---|
7464 | fillColor={215,230,240})}),
|
---|
7465 | Documentation(info="<html>
|
---|
7466 | <p>This icon indicates a package that contains properties</p>
|
---|
7467 | </html>"));
|
---|
7468 | end MaterialPropertiesPackage;
|
---|
7469 |
|
---|
7470 | partial class MaterialProperty "Icon for property classes"
|
---|
7471 |
|
---|
7472 | annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},
|
---|
7473 | {100,100}}), graphics={
|
---|
7474 | Ellipse(
|
---|
7475 | extent={{-100,100},{100,-100}},
|
---|
7476 | lineColor={0,0,0},
|
---|
7477 | fillPattern=FillPattern.Sphere,
|
---|
7478 | fillColor={215,230,240})}),
|
---|
7479 | Documentation(info="<html>
|
---|
7480 | <p>This icon indicates a property class.</p>
|
---|
7481 | </html>"));
|
---|
7482 | end MaterialProperty;
|
---|
7483 |
|
---|
7484 | partial function Function "Icon for functions"
|
---|
7485 |
|
---|
7486 | annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
|
---|
7487 | -100},{100,100}}), graphics={
|
---|
7488 | Text(extent={{-140,162},{136,102}}, textString=
|
---|
7489 | "%name"),
|
---|
7490 | Ellipse(
|
---|
7491 | extent={{-100,100},{100,-100}},
|
---|
7492 | lineColor={255,127,0},
|
---|
7493 | fillColor={255,255,255},
|
---|
7494 | fillPattern=FillPattern.Solid),
|
---|
7495 | Text(
|
---|
7496 | extent={{-100,100},{100,-100}},
|
---|
7497 | lineColor={255,127,0},
|
---|
7498 | textString=
|
---|
7499 | "f")}),Documentation(Error, info="<html>
|
---|
7500 | <p>This icon indicates Modelica functions.</p>
|
---|
7501 | </html>"));
|
---|
7502 | end Function;
|
---|
7503 |
|
---|
7504 | partial record Record "Icon for records"
|
---|
7505 |
|
---|
7506 | annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,
|
---|
7507 | -100},{100,100}}), graphics={
|
---|
7508 | Rectangle(
|
---|
7509 | extent={{-100,50},{100,-100}},
|
---|
7510 | fillColor={255,255,127},
|
---|
7511 | fillPattern=FillPattern.Solid,
|
---|
7512 | lineColor={0,0,255}),
|
---|
7513 | Text(
|
---|
7514 | extent={{-127,115},{127,55}},
|
---|
7515 | textString="%name",
|
---|
7516 | lineColor={0,0,255}),
|
---|
7517 | Line(points={{-100,-50},{100,-50}}, color={0,0,0}),
|
---|
7518 | Line(points={{-100,0},{100,0}}, color={0,0,0}),
|
---|
7519 | Line(points={{0,50},{0,-100}}, color={0,0,0})}),
|
---|
7520 | Documentation(info="<html>
|
---|
7521 | <p>
|
---|
7522 | This icon is indicates a record.
|
---|
7523 | </p>
|
---|
7524 | </html>"));
|
---|
7525 | end Record;
|
---|
7526 |
|
---|
7527 | partial package Library
|
---|
7528 | "This icon will be removed in future Modelica versions, use Package instead"
|
---|
7529 |
|
---|
7530 | annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
|
---|
7531 | -100},{100,100}}), graphics={Rectangle(
|
---|
7532 | extent={{-80,100},{100,-80}},
|
---|
7533 | lineColor={0,0,0},
|
---|
7534 | fillColor={215,230,240},
|
---|
7535 | fillPattern=FillPattern.Solid), Rectangle(
|
---|
7536 | extent={{-100,80},{80,-100}},
|
---|
7537 | lineColor={0,0,0},
|
---|
7538 | fillColor={240,240,240},
|
---|
7539 | fillPattern=FillPattern.Solid)}),
|
---|
7540 | Documentation(info="<html>
|
---|
7541 | <p>This icon of a package will be removed in future versions of the library.</p>
|
---|
7542 | <h5>Note</h5>
|
---|
7543 | <p>This icon will be removed in future versions of the Modelica Standard Library. Instead the icon <a href=\"modelica://Modelica.Icons.Package\">Package</a> shall be used.</p>
|
---|
7544 | </html>"));
|
---|
7545 | end Library;
|
---|
7546 | annotation(Documentation(__Dymola_DocumentationClass=true, info="<html>
|
---|
7547 | <p>This package contains definitions for the graphical layout of components which may be used in different libraries. The icons can be utilized by inheriting them in the desired class using "extends" or by directly copying the "icon" layer. </p>
|
---|
7548 | <dl>
|
---|
7549 | <dt><b>Main Authors:</b> </dt>
|
---|
7550 | <dd><a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a></dd><dd>Deutsches Zentrum fuer Luft und Raumfahrt e.V. (DLR)</dd><dd>Oberpfaffenhofen</dd><dd>Postfach 1116</dd><dd>D-82230 Wessling</dd><dd>email: <a href=\"mailto:Martin.Otter@dlr.de\">Martin.Otter@dlr.de</a></dd><br>
|
---|
7551 | <dd>Christian Kral</dd><dd><a href=\"http://www.ait.ac.at/\">Austrian Institute of Technology, AIT</a></dd><dd>Mobility Department</dd><dd>Giefinggasse 2</dd><dd>1210 Vienna, Austria</dd><dd>email: <a href=\"mailto:christian.kral@ait.ac.at\">christian.kral@ait.ac.at</a></dd><br>
|
---|
7552 | <dd align=\"justify\">Johan Andreasson</dd><dd align=\"justify\"><a href=\"http://www.modelon.se/\">Modelon AB</a></dd><dd align=\"justify\">Ideon Science Park</dd><dd align=\"justify\">22370 Lund, Sweden</dd><dd align=\"justify\">email: <a href=\"mailto:johan.andreasson@modelon.se\">johan.andreasson@modelon.se</a></dd>
|
---|
7553 | </dl>
|
---|
7554 | <p>Copyright © 1998-2010, Modelica Association, DLR, AIT, and Modelon AB. </p>
|
---|
7555 | <p><i>This Modelica package is <b>free</b> software; it can be redistributed and/or modified under the terms of the <b>Modelica license</b>, see the license conditions and the accompanying <b>disclaimer</b> in <a href=\"modelica://Modelica.UsersGuide.ModelicaLicense2\">Modelica.UsersGuide.ModelicaLicense2</a>.</i> </p>
|
---|
7556 | </html>"));
|
---|
7557 | end Icons;
|
---|
7558 |
|
---|
7559 | package SIunits
|
---|
7560 | "Library of type and unit definitions based on SI units according to ISO 31-1992"
|
---|
7561 | extends Modelica.Icons.Package;
|
---|
7562 |
|
---|
7563 | package Conversions
|
---|
7564 | "Conversion functions to/from non SI units and type definitions of non SI units"
|
---|
7565 | extends Modelica.Icons.Package;
|
---|
7566 |
|
---|
7567 | package NonSIunits "Type definitions of non SI units"
|
---|
7568 | extends Modelica.Icons.Package;
|
---|
7569 |
|
---|
7570 | type Temperature_degC = Real (final quantity="ThermodynamicTemperature",
|
---|
7571 | final unit="degC")
|
---|
7572 | "Absolute temperature in degree Celsius (for relative temperature use SIunits.TemperatureDifference)"
|
---|
7573 | annotation(__Dymola_absoluteValue=true);
|
---|
7574 |
|
---|
7575 | type Angle_deg = Real (final quantity="Angle", final unit="deg")
|
---|
7576 | "Angle in degree";
|
---|
7577 |
|
---|
7578 | type Pressure_bar = Real (final quantity="Pressure", final unit="bar")
|
---|
7579 | "Absolute pressure in bar";
|
---|
7580 | annotation (Documentation(info="<HTML>
|
---|
7581 | <p>
|
---|
7582 | This package provides predefined types, such as <b>Angle_deg</b> (angle in
|
---|
7583 | degree), <b>AngularVelocity_rpm</b> (angular velocity in revolutions per
|
---|
7584 | minute) or <b>Temperature_degF</b> (temperature in degree Fahrenheit),
|
---|
7585 | which are in common use but are not part of the international standard on
|
---|
7586 | units according to ISO 31-1992 \"General principles concerning quantities,
|
---|
7587 | units and symbols\" and ISO 1000-1992 \"SI units and recommendations for
|
---|
7588 | the use of their multiples and of certain other units\".</p>
|
---|
7589 | <p>If possible, the types in this package should not be used. Use instead
|
---|
7590 | types of package Modelica.SIunits. For more information on units, see also
|
---|
7591 | the book of Francois Cardarelli <b>Scientific Unit Conversion - A
|
---|
7592 | Practical Guide to Metrication</b> (Springer 1997).</p>
|
---|
7593 | <p>Some units, such as <b>Temperature_degC/Temp_C</b> are both defined in
|
---|
7594 | Modelica.SIunits and in Modelica.Conversions.NonSIunits. The reason is that these
|
---|
7595 | definitions have been placed erroneously in Modelica.SIunits although they
|
---|
7596 | are not SIunits. For backward compatibility, these type definitions are
|
---|
7597 | still kept in Modelica.SIunits.</p>
|
---|
7598 | </HTML>
|
---|
7599 | "), Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
|
---|
7600 | 100}}), graphics={Text(
|
---|
7601 | extent={{-66,-13},{52,-67}},
|
---|
7602 | lineColor={0,0,0},
|
---|
7603 | textString="[km/h]")}));
|
---|
7604 | end NonSIunits;
|
---|
7605 |
|
---|
7606 | function to_degC "Convert from Kelvin to degCelsius"
|
---|
7607 | extends ConversionIcon;
|
---|
7608 | input Temperature Kelvin "Kelvin value";
|
---|
7609 | output NonSIunits.Temperature_degC Celsius "Celsius value";
|
---|
7610 | algorithm
|
---|
7611 | Celsius := Kelvin + Modelica.Constants.T_zero;
|
---|
7612 | annotation (Inline=true,Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,
|
---|
7613 | -100},{100,100}}), graphics={Text(
|
---|
7614 | extent={{-20,100},{-100,20}},
|
---|
7615 | lineColor={0,0,0},
|
---|
7616 | textString="K"), Text(
|
---|
7617 | extent={{100,-20},{20,-100}},
|
---|
7618 | lineColor={0,0,0},
|
---|
7619 | textString="degC")}));
|
---|
7620 | end to_degC;
|
---|
7621 |
|
---|
7622 | function from_degC "Convert from degCelsius to Kelvin"
|
---|
7623 | extends ConversionIcon;
|
---|
7624 | input NonSIunits.Temperature_degC Celsius "Celsius value";
|
---|
7625 | output Temperature Kelvin "Kelvin value";
|
---|
7626 | algorithm
|
---|
7627 | Kelvin := Celsius - Modelica.Constants.T_zero;
|
---|
7628 | annotation (Inline=true,Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,
|
---|
7629 | -100},{100,100}}), graphics={Text(
|
---|
7630 | extent={{-20,100},{-100,20}},
|
---|
7631 | lineColor={0,0,0},
|
---|
7632 | textString="degC"), Text(
|
---|
7633 | extent={{100,-20},{20,-100}},
|
---|
7634 | lineColor={0,0,0},
|
---|
7635 | textString="K")}));
|
---|
7636 | end from_degC;
|
---|
7637 |
|
---|
7638 | function to_deg "Convert from radian to degree"
|
---|
7639 | extends ConversionIcon;
|
---|
7640 | input Angle radian "radian value";
|
---|
7641 | output NonSIunits.Angle_deg degree "degree value";
|
---|
7642 | algorithm
|
---|
7643 | degree := (180.0/Modelica.Constants.pi)*radian;
|
---|
7644 | annotation (Inline=true,Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,
|
---|
7645 | -100},{100,100}}), graphics={Text(
|
---|
7646 | extent={{10,100},{-100,46}},
|
---|
7647 | lineColor={0,0,0},
|
---|
7648 | textString="rad"), Text(
|
---|
7649 | extent={{100,-44},{-10,-100}},
|
---|
7650 | lineColor={0,0,0},
|
---|
7651 | textString="deg")}));
|
---|
7652 | end to_deg;
|
---|
7653 |
|
---|
7654 | function to_bar "Convert from Pascal to bar"
|
---|
7655 | extends ConversionIcon;
|
---|
7656 | input Pressure Pa "Pascal value";
|
---|
7657 | output NonSIunits.Pressure_bar bar "bar value";
|
---|
7658 | algorithm
|
---|
7659 | bar := Pa/1e5;
|
---|
7660 | annotation (Inline=true,Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,
|
---|
7661 | -100},{100,100}}), graphics={Text(
|
---|
7662 | extent={{-12,100},{-100,56}},
|
---|
7663 | lineColor={0,0,0},
|
---|
7664 | textString="Pa"), Text(
|
---|
7665 | extent={{98,-52},{-4,-100}},
|
---|
7666 | lineColor={0,0,0},
|
---|
7667 | textString="bar")}));
|
---|
7668 | end to_bar;
|
---|
7669 |
|
---|
7670 | partial function ConversionIcon "Base icon for conversion functions"
|
---|
7671 |
|
---|
7672 | annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,
|
---|
7673 | -100},{100,100}}), graphics={
|
---|
7674 | Rectangle(
|
---|
7675 | extent={{-100,100},{100,-100}},
|
---|
7676 | lineColor={191,0,0},
|
---|
7677 | fillColor={255,255,255},
|
---|
7678 | fillPattern=FillPattern.Solid),
|
---|
7679 | Line(points={{-90,0},{30,0}}, color={191,0,0}),
|
---|
7680 | Polygon(
|
---|
7681 | points={{90,0},{30,20},{30,-20},{90,0}},
|
---|
7682 | lineColor={191,0,0},
|
---|
7683 | fillColor={191,0,0},
|
---|
7684 | fillPattern=FillPattern.Solid),
|
---|
7685 | Text(
|
---|
7686 | extent={{-115,155},{115,105}},
|
---|
7687 | textString="%name",
|
---|
7688 | lineColor={0,0,255})}));
|
---|
7689 | end ConversionIcon;
|
---|
7690 | annotation (Icon(coordinateSystem(preserveAspectRatio=true,
|
---|
7691 | extent={{-100,-100},{100,100}}), graphics),
|
---|
7692 | Documentation(info="<HTML>
|
---|
7693 | <p>This package provides conversion functions from the non SI Units
|
---|
7694 | defined in package Modelica.SIunits.Conversions.NonSIunits to the
|
---|
7695 | corresponding SI Units defined in package Modelica.SIunits and vice
|
---|
7696 | versa. It is recommended to use these functions in the following
|
---|
7697 | way (note, that all functions have one Real input and one Real output
|
---|
7698 | argument):</p>
|
---|
7699 | <pre>
|
---|
7700 | <b>import</b> SI = Modelica.SIunits;
|
---|
7701 | <b>import</b> Modelica.SIunits.Conversions.*;
|
---|
7702 | ...
|
---|
7703 | <b>parameter</b> SI.Temperature T = from_degC(25); // convert 25 degree Celsius to Kelvin
|
---|
7704 | <b>parameter</b> SI.Angle phi = from_deg(180); // convert 180 degree to radian
|
---|
7705 | <b>parameter</b> SI.AngularVelocity w = from_rpm(3600); // convert 3600 revolutions per minutes
|
---|
7706 | // to radian per seconds
|
---|
7707 | </pre>
|
---|
7708 |
|
---|
7709 | </HTML>
|
---|
7710 | "));
|
---|
7711 | end Conversions;
|
---|
7712 |
|
---|
7713 | type Angle = Real (
|
---|
7714 | final quantity="Angle",
|
---|
7715 | final unit="rad",
|
---|
7716 | displayUnit="deg");
|
---|
7717 |
|
---|
7718 | type Length = Real (final quantity="Length", final unit="m");
|
---|
7719 |
|
---|
7720 | type Area = Real (final quantity="Area", final unit="m2");
|
---|
7721 |
|
---|
7722 | type Time = Real (final quantity="Time", final unit="s");
|
---|
7723 |
|
---|
7724 | type Velocity = Real (final quantity="Velocity", final unit="m/s");
|
---|
7725 |
|
---|
7726 | type Density = Real (
|
---|
7727 | final quantity="Density",
|
---|
7728 | final unit="kg/m3",
|
---|
7729 | displayUnit="g/cm3",
|
---|
7730 | min=0);
|
---|
7731 |
|
---|
7732 | type Pressure = Real (
|
---|
7733 | final quantity="Pressure",
|
---|
7734 | final unit="Pa",
|
---|
7735 | displayUnit="bar");
|
---|
7736 |
|
---|
7737 | type AbsolutePressure = Pressure (min=0);
|
---|
7738 |
|
---|
7739 | type DynamicViscosity = Real (
|
---|
7740 | final quantity="DynamicViscosity",
|
---|
7741 | final unit="Pa.s",
|
---|
7742 | min=0);
|
---|
7743 |
|
---|
7744 | type SurfaceTension = Real (final quantity="SurfaceTension", final unit="N/m");
|
---|
7745 |
|
---|
7746 | type Power = Real (final quantity="Power", final unit="W");
|
---|
7747 |
|
---|
7748 | type EnthalpyFlowRate = Real (final quantity="EnthalpyFlowRate", final unit=
|
---|
7749 | "W");
|
---|
7750 |
|
---|
7751 | type MassFlowRate = Real (quantity="MassFlowRate", final unit="kg/s");
|
---|
7752 |
|
---|
7753 | type ThermodynamicTemperature = Real (
|
---|
7754 | final quantity="ThermodynamicTemperature",
|
---|
7755 | final unit="K",
|
---|
7756 | min = 0,
|
---|
7757 | start = 288.15,
|
---|
7758 | displayUnit="degC")
|
---|
7759 | "Absolute temperature (use type TemperatureDifference for relative temperatures)"
|
---|
7760 | annotation(__Dymola_absoluteValue=true);
|
---|
7761 |
|
---|
7762 | type Temp_K = ThermodynamicTemperature;
|
---|
7763 |
|
---|
7764 | type Temperature = ThermodynamicTemperature;
|
---|
7765 |
|
---|
7766 | type TemperatureDifference = Real (
|
---|
7767 | final quantity="ThermodynamicTemperature",
|
---|
7768 | final unit="K") annotation(__Dymola_absoluteValue=false);
|
---|
7769 |
|
---|
7770 | type LinearTemperatureCoefficient = Real(final quantity = "LinearTemperatureCoefficient", final unit="1/K");
|
---|
7771 |
|
---|
7772 | type Compressibility = Real (final quantity="Compressibility", final unit=
|
---|
7773 | "1/Pa");
|
---|
7774 |
|
---|
7775 | type IsothermalCompressibility = Compressibility;
|
---|
7776 |
|
---|
7777 | type HeatFlowRate = Real (final quantity="Power", final unit="W");
|
---|
7778 |
|
---|
7779 | type ThermalConductivity = Real (final quantity="ThermalConductivity", final unit=
|
---|
7780 | "W/(m.K)");
|
---|
7781 |
|
---|
7782 | type ThermalConductance = Real (final quantity="ThermalConductance", final unit=
|
---|
7783 | "W/K");
|
---|
7784 |
|
---|
7785 | type ThermalDiffusivity = Real (final quantity="ThermalDiffusivity", final unit=
|
---|
7786 | "m2/s");
|
---|
7787 |
|
---|
7788 | type HeatCapacity = Real (final quantity="HeatCapacity", final unit="J/K");
|
---|
7789 |
|
---|
7790 | type SpecificHeatCapacity = Real (final quantity="SpecificHeatCapacity",
|
---|
7791 | final unit="J/(kg.K)");
|
---|
7792 |
|
---|
7793 | type RatioOfSpecificHeatCapacities = Real (final quantity=
|
---|
7794 | "RatioOfSpecificHeatCapacities", final unit="1");
|
---|
7795 |
|
---|
7796 | type SpecificEntropy = Real (final quantity="SpecificEntropy", final unit=
|
---|
7797 | "J/(kg.K)");
|
---|
7798 |
|
---|
7799 | type SpecificEnergy = Real (final quantity="SpecificEnergy", final unit=
|
---|
7800 | "J/kg");
|
---|
7801 |
|
---|
7802 | type SpecificInternalEnergy = SpecificEnergy;
|
---|
7803 |
|
---|
7804 | type SpecificEnthalpy = SpecificEnergy;
|
---|
7805 |
|
---|
7806 | type DerDensityByEnthalpy = Real (final unit="kg.s2/m5");
|
---|
7807 |
|
---|
7808 | type DerDensityByPressure = Real (final unit="s2/m2");
|
---|
7809 |
|
---|
7810 | type DerDensityByTemperature = Real (final unit="kg/(m3.K)");
|
---|
7811 |
|
---|
7812 | type DerEnthalpyByPressure = Real (final unit="J.m.s2/kg2");
|
---|
7813 |
|
---|
7814 | type Irradiance = Real (final quantity="Irradiance", final unit="W/m2");
|
---|
7815 |
|
---|
7816 | type Emissivity = Real (final quantity="Emissivity", final unit="1");
|
---|
7817 |
|
---|
7818 | type MolarMass = Real (final quantity="MolarMass", final unit="kg/mol",min=0);
|
---|
7819 |
|
---|
7820 | type MolarVolume = Real (final quantity="MolarVolume", final unit="m3/mol", min=0);
|
---|
7821 |
|
---|
7822 | type MassFraction = Real (final quantity="MassFraction", final unit="1");
|
---|
7823 |
|
---|
7824 | type MoleFraction = Real (final quantity="MoleFraction", final unit="1");
|
---|
7825 |
|
---|
7826 | type PrandtlNumber = Real (final quantity="PrandtlNumber", final unit="1");
|
---|
7827 | annotation (
|
---|
7828 | Invisible=true,
|
---|
7829 | Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
|
---|
7830 | 100}}), graphics={Text(
|
---|
7831 | extent={{-63,-13},{45,-67}},
|
---|
7832 | lineColor={0,0,0},
|
---|
7833 | textString="[kg.m2]")}),
|
---|
7834 | Documentation(info="<html>
|
---|
7835 | <p>This package provides predefined types, such as <i>Mass</i>,
|
---|
7836 | <i>Angle</i>, <i>Time</i>, based on the international standard
|
---|
7837 | on units, e.g.,
|
---|
7838 | </p>
|
---|
7839 |
|
---|
7840 | <pre> <b>type</b> Angle = Real(<b>final</b> quantity = \"Angle\",
|
---|
7841 | <b>final</b> unit = \"rad\",
|
---|
7842 | displayUnit = \"deg\");
|
---|
7843 | </pre>
|
---|
7844 |
|
---|
7845 | <p>
|
---|
7846 | as well as conversion functions from non SI-units to SI-units
|
---|
7847 | and vice versa in subpackage
|
---|
7848 | <a href=\"modelica://Modelica.SIunits.Conversions\">Conversions</a>.
|
---|
7849 | </p>
|
---|
7850 |
|
---|
7851 | <p>
|
---|
7852 | For an introduction how units are used in the Modelica standard library
|
---|
7853 | with package SIunits, have a look at:
|
---|
7854 | <a href=\"modelica://Modelica.SIunits.UsersGuide.HowToUseSIunits\">How to use SIunits</a>.
|
---|
7855 | </p>
|
---|
7856 |
|
---|
7857 | <p>
|
---|
7858 | Copyright © 1998-2010, Modelica Association and DLR.
|
---|
7859 | </p>
|
---|
7860 | <p>
|
---|
7861 | <i>This Modelica package is <u>free</u> software and the use is completely at <u>your own risk</u>; it can be redistributed and/or modified under the terms of the Modelica License 2. For license conditions (including the disclaimer of warranty) see <a href=\"modelica://Modelica.UsersGuide.ModelicaLicense2\">Modelica.UsersGuide.ModelicaLicense2</a> or visit <a href=\"http://www.modelica.org/licenses/ModelicaLicense2\"> http://www.modelica.org/licenses/ModelicaLicense2</a>.</i>
|
---|
7862 | </p>
|
---|
7863 | </html>", revisions="<html>
|
---|
7864 | <ul>
|
---|
7865 | <li><i>Jan. 27, 2010</i> by Christian Kral:<br/>Added complex units.</li>
|
---|
7866 | <li><i>Dec. 14, 2005</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br/>Add User';s Guide and removed "min" values for Resistance and Conductance.</li>
|
---|
7867 | <li><i>October 21, 2002</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a> and <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br/>Added new package <b>Conversions</b>. Corrected typo <i>Wavelenght</i>.</li>
|
---|
7868 | <li><i>June 6, 2000</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br/>Introduced the following new types<br/>type Temperature = ThermodynamicTemperature;<br/>types DerDensityByEnthalpy, DerDensityByPressure, DerDensityByTemperature, DerEnthalpyByPressure, DerEnergyByDensity, DerEnergyByPressure<br/>Attribute "final" removed from min and max values in order that these values can still be changed to narrow the allowed range of values.<br/>Quantity="Stress" removed from type "Stress", in order that a type "Stress" can be connected to a type "Pressure".</li>
|
---|
7869 | <li><i>Oct. 27, 1999</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br/>New types due to electrical library: Transconductance, InversePotential, Damping.</li>
|
---|
7870 | <li><i>Sept. 18, 1999</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br/>Renamed from SIunit to SIunits. Subpackages expanded, i.e., the SIunits package, does no longer contain subpackages.</li>
|
---|
7871 | <li><i>Aug 12, 1999</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br/>Type "Pressure" renamed to "AbsolutePressure" and introduced a new type "Pressure" which does not contain a minimum of zero in order to allow convenient handling of relative pressure. Redefined BulkModulus as an alias to AbsolutePressure instead of Stress, since needed in hydraulics.</li>
|
---|
7872 | <li><i>June 29, 1999</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br/>Bug-fix: Double definition of "Compressibility" removed and appropriate "extends Heat" clause introduced in package SolidStatePhysics to incorporate ThermodynamicTemperature.</li>
|
---|
7873 | <li><i>April 8, 1998</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a> and Astrid Jaschinski:<br/>Complete ISO 31 chapters realized.</li>
|
---|
7874 | <li><i>Nov. 15, 1997</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a> and <a href=\"http://www.control.lth.se/~hubertus/\">Hubertus Tummescheit</a>:<br/>Some chapters realized.</li>
|
---|
7875 | </ul>
|
---|
7876 | </html>"),
|
---|
7877 | Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
|
---|
7878 | 100}}), graphics={
|
---|
7879 | Rectangle(
|
---|
7880 | extent={{169,86},{349,236}},
|
---|
7881 | fillColor={235,235,235},
|
---|
7882 | fillPattern=FillPattern.Solid,
|
---|
7883 | lineColor={0,0,255}),
|
---|
7884 | Polygon(
|
---|
7885 | points={{169,236},{189,256},{369,256},{349,236},{169,236}},
|
---|
7886 | fillColor={235,235,235},
|
---|
7887 | fillPattern=FillPattern.Solid,
|
---|
7888 | lineColor={0,0,255}),
|
---|
7889 | Polygon(
|
---|
7890 | points={{369,256},{369,106},{349,86},{349,236},{369,256}},
|
---|
7891 | fillColor={235,235,235},
|
---|
7892 | fillPattern=FillPattern.Solid,
|
---|
7893 | lineColor={0,0,255}),
|
---|
7894 | Text(
|
---|
7895 | extent={{179,226},{339,196}},
|
---|
7896 | lineColor={160,160,164},
|
---|
7897 | textString="Library"),
|
---|
7898 | Text(
|
---|
7899 | extent={{206,173},{314,119}},
|
---|
7900 | lineColor={0,0,0},
|
---|
7901 | textString="[kg.m2]"),
|
---|
7902 | Text(
|
---|
7903 | extent={{163,320},{406,264}},
|
---|
7904 | lineColor={255,0,0},
|
---|
7905 | textString="Modelica.SIunits")}));
|
---|
7906 | end SIunits;
|
---|
7907 | annotation (
|
---|
7908 | preferredView="info",
|
---|
7909 | version="3.2",
|
---|
7910 | versionBuild=9,
|
---|
7911 | versionDate="2010-10-25",
|
---|
7912 | dateModified = "2012-02-09 11:32:00Z",
|
---|
7913 | revisionId="",
|
---|
7914 | uses(Complex(version="1.0"), ModelicaServices(version="1.2")),
|
---|
7915 | conversion(
|
---|
7916 | noneFromVersion="3.1",
|
---|
7917 | noneFromVersion="3.0.1",
|
---|
7918 | noneFromVersion="3.0",
|
---|
7919 | from(version="2.1", script="modelica://Modelica/Resources/Scripts/Dymola/ConvertModelica_from_2.2.2_to_3.0.mos"),
|
---|
7920 | from(version="2.2", script="modelica://Modelica/Resources/Scripts/Dymola/ConvertModelica_from_2.2.2_to_3.0.mos"),
|
---|
7921 | from(version="2.2.1", script="modelica://Modelica/Resources/Scripts/Dymola/ConvertModelica_from_2.2.2_to_3.0.mos"),
|
---|
7922 | from(version="2.2.2", script="modelica://Modelica/Resources/Scripts/Dymola/ConvertModelica_from_2.2.2_to_3.0.mos")),
|
---|
7923 | __Dymola_classOrder={"UsersGuide","Blocks","StateGraph","Electrical","Magnetic","Mechanics","Fluid","Media","Thermal",
|
---|
7924 | "Math","Utilities","Constants", "Icons", "SIunits"},
|
---|
7925 | Settings(NewStateSelection=true),
|
---|
7926 | Documentation(info="<HTML>
|
---|
7927 | <p>
|
---|
7928 | Package <b>Modelica®</b> is a <b>standardized</b> and <b>free</b> package
|
---|
7929 | that is developed together with the Modelica® language from the
|
---|
7930 | Modelica Association, see
|
---|
7931 | <a href=\"http://www.Modelica.org\">http://www.Modelica.org</a>.
|
---|
7932 | It is also called <b>Modelica Standard Library</b>.
|
---|
7933 | It provides model components in many domains that are based on
|
---|
7934 | standardized interface definitions. Some typical examples are shown
|
---|
7935 | in the next figure:
|
---|
7936 | </p>
|
---|
7937 |
|
---|
7938 | <img src=\"modelica://Modelica/Resources/Images/UsersGuide/ModelicaLibraries.png\">
|
---|
7939 |
|
---|
7940 | <p>
|
---|
7941 | For an introduction, have especially a look at:
|
---|
7942 | </p>
|
---|
7943 | <ul>
|
---|
7944 | <li> <a href=\"modelica://Modelica.UsersGuide.Overview\">Overview</a>
|
---|
7945 | provides an overview of the Modelica Standard Library
|
---|
7946 | inside the <a href=\"modelica://Modelica.UsersGuide\">User's Guide</a>.</li>
|
---|
7947 | <li><a href=\"modelica://Modelica.UsersGuide.ReleaseNotes\">Release Notes</a>
|
---|
7948 | summarizes the changes of new versions of this package.</li>
|
---|
7949 | <li> <a href=\"modelica://Modelica.UsersGuide.Contact\">Contact</a>
|
---|
7950 | lists the contributors of the Modelica Standard Library.</li>
|
---|
7951 | <li> The <b>Examples</b> packages in the various libraries, demonstrate
|
---|
7952 | how to use the components of the corresponding sublibrary.</li>
|
---|
7953 | </ul>
|
---|
7954 |
|
---|
7955 | <p>
|
---|
7956 | This version of the Modelica Standard Library consists of
|
---|
7957 | </p>
|
---|
7958 | <ul>
|
---|
7959 | <li> <b>1280</b> models and blocks, and</li>
|
---|
7960 | <li> <b>910</b> functions
|
---|
7961 | </ul>
|
---|
7962 | <p>
|
---|
7963 | that are directly usable (= number of public, non-partial classes).
|
---|
7964 | </p>
|
---|
7965 |
|
---|
7966 | <p>
|
---|
7967 | <b>Licensed by the Modelica Association under the Modelica License 2</b><br>
|
---|
7968 | Copyright © 1998-2010, ABB, AIT, T. Bödrich, DLR, Dassault Systèmes AB, Fraunhofer, A.Haumer, Modelon,
|
---|
7969 | TU Hamburg-Harburg, Politecnico di Milano.
|
---|
7970 | </p>
|
---|
7971 |
|
---|
7972 | <p>
|
---|
7973 | <i>This Modelica package is <u>free</u> software and the use is completely at <u>your own risk</u>; it can be redistributed and/or modified under the terms of the Modelica License 2. For license conditions (including the disclaimer of warranty) see <a href=\"modelica://Modelica.UsersGuide.ModelicaLicense2\">Modelica.UsersGuide.ModelicaLicense2</a> or visit <a href=\"http://www.modelica.org/licenses/ModelicaLicense2\"> http://www.modelica.org/licenses/ModelicaLicense2</a>.</i>
|
---|
7974 | </p>
|
---|
7975 | </HTML>
|
---|
7976 | "));
|
---|
7977 | end Modelica;
|
---|
7978 |
|
---|
7979 | package IDEAS "Integrated District Energy Assessment Simulation"
|
---|
7980 | extends Modelica.Icons.Library;
|
---|
7981 | import SI = Modelica.SIunits;
|
---|
7982 |
|
---|
7983 | model SimInfoManager
|
---|
7984 | "Simulation information manager for handling time and climate data required in each for simulation."
|
---|
7985 |
|
---|
7986 | replaceable parameter IDEAS.Climate.Meteo.Files.min60 detail constrainedby
|
---|
7987 | IDEAS.Climate.Meteo.Detail "Timeframe detail of the climate data"
|
---|
7988 | annotation (Dialog(group="Climate"));
|
---|
7989 | replaceable parameter IDEAS.Climate.Meteo.Locations.Uccle city constrainedby
|
---|
7990 | IDEAS.Climate.Meteo.Location "Location of the depicted climate data"
|
---|
7991 | annotation (Dialog(group="Climate"));
|
---|
7992 | parameter Boolean occBeh = false
|
---|
7993 | "put to true if user behaviour is to be read from files"
|
---|
7994 | annotation(Dialog(group="User behaviour"));
|
---|
7995 |
|
---|
7996 | parameter Boolean DHW = false
|
---|
7997 | "put to true if domestic how water (DHW) consumption is to be read from files"
|
---|
7998 | annotation(Dialog(group="User behaviour"));
|
---|
7999 | parameter Boolean PV = false
|
---|
8000 | "put to true if photovoltaics is to be read from files "
|
---|
8001 | annotation(Dialog(group="Photovoltaics"));
|
---|
8002 |
|
---|
8003 | replaceable parameter IDEAS.Occupants.Extern.Interfaces.Occ_Files occupants constrainedby
|
---|
8004 | IDEAS.Occupants.Extern.Interfaces.Occ_Files
|
---|
8005 | "Specifies the files with occupant behavior" annotation(Dialog(group="User behaviour"));
|
---|
8006 | parameter Integer nOcc = 33 "Number of occupant profiles to be read" annotation(Dialog(group="User behaviour"));
|
---|
8007 |
|
---|
8008 | parameter String fileNamePv = "onePVpanel10min"
|
---|
8009 | "Filename for photvoltaic profiles" annotation(Dialog(group="Photovoltaics"));
|
---|
8010 | parameter Integer nPV = 33 "Number of photovoltaic profiles" annotation(Dialog(group="Photovoltaics"));
|
---|
8011 | parameter Integer PNom = 1000
|
---|
8012 | "Nominal power (W) of the photovoltaic profiles" annotation(Dialog(group="Photovoltaics"));
|
---|
8013 |
|
---|
8014 | protected
|
---|
8015 | final parameter String filNamClim = "../Inputs/" + city.locNam + detail.filNam;
|
---|
8016 | final parameter Modelica.SIunits.Angle lat(displayUnit="deg") = city.lat
|
---|
8017 | "latitude of the locatioin";
|
---|
8018 | final parameter Modelica.SIunits.Angle lon(displayUnit="deg") = city.lon;
|
---|
8019 | final parameter Modelica.SIunits.Temperature Tdes = city.Tdes
|
---|
8020 | "design outdoor temperature";
|
---|
8021 | final parameter Modelica.SIunits.Temperature TdesGround = city.TdesGround
|
---|
8022 | "design ground temperature";
|
---|
8023 | final parameter Modelica.SIunits.Time timZonSta = city.timZonSta
|
---|
8024 | "standard time zone";
|
---|
8025 | final parameter Boolean DST = city.DST
|
---|
8026 | "boolean to take into account daylight saving time";
|
---|
8027 | final parameter Integer yr = city.yr "depcited year for DST only";
|
---|
8028 |
|
---|
8029 | final parameter Boolean BesTest = Modelica.Utilities.Strings.isEqual(city.locNam,"BesTest")
|
---|
8030 | "boolean to determine if this simulation is a BESTEST simulation";
|
---|
8031 |
|
---|
8032 | public
|
---|
8033 | Modelica.SIunits.Irradiance solDirPer = climate_solar.y[3]
|
---|
8034 | "direct irradiation on normal to solar zenith";
|
---|
8035 | Modelica.SIunits.Irradiance solDirHor = climate_solar.y[1]-climate_solar.y[2]
|
---|
8036 | "direct irradiation on horizontal surface";
|
---|
8037 | Modelica.SIunits.Irradiance solDifHor = climate_solar.y[2]
|
---|
8038 | "difuse irradiation on horizontal surface";
|
---|
8039 | Modelica.SIunits.Irradiance solGloHor = solDirHor + solDifHor
|
---|
8040 | "global irradiation on horizontal";
|
---|
8041 | Modelica.SIunits.Temperature Te = climate_nonSolar.y[1] + 273.15
|
---|
8042 | "ambient outdoor temperature for determination of sky radiation exchange";
|
---|
8043 | Modelica.SIunits.Temperature Tsky "effective overall sky temperature";
|
---|
8044 | Modelica.SIunits.Temperature TeAv = Te
|
---|
8045 | "running average of ambient outdoor temperature of the last 5 days, not yet implemented";
|
---|
8046 | Modelica.SIunits.Temperature Tground = TdesGround "ground temperature";
|
---|
8047 | Modelica.SIunits.Velocity Va "air velocity";
|
---|
8048 | Real Fc "cloud factor";
|
---|
8049 | Modelica.SIunits.Irradiance irr = climate_solar.y[1];
|
---|
8050 | Boolean summer = timMan.summer;
|
---|
8051 |
|
---|
8052 | Boolean day = true;
|
---|
8053 |
|
---|
8054 | Modelica.SIunits.Time timLoc = timMan.timLoc "Local time";
|
---|
8055 | Modelica.SIunits.Time timSol = timMan.timSol "Solar time";
|
---|
8056 | Modelica.SIunits.Time timCal = timMan.timCal "Calendar time";
|
---|
8057 |
|
---|
8058 | protected
|
---|
8059 | IDEAS.Climate.Time.SimTimes timMan(
|
---|
8060 | delay=detail.timestep/2,
|
---|
8061 | timZonSta=timZonSta,
|
---|
8062 | lon=lon,
|
---|
8063 | DST=false,
|
---|
8064 | ifSolCor=true)
|
---|
8065 | annotation (Placement(transformation(extent={{-80,60},{-60,80}})));
|
---|
8066 | Modelica.Blocks.Tables.CombiTable1Ds climate_nonSolar(final smoothness=Modelica.Blocks.Types.Smoothness.ContinuousDerivative,
|
---|
8067 | final tableOnFile=true, final tableName="data",final fileName=filNamClim, final columns = {15,16,12,10})
|
---|
8068 | annotation (Placement(transformation(extent={{-40,66},{-26,80}})));
|
---|
8069 | Modelica.Blocks.Tables.CombiTable1Ds climate_solar(
|
---|
8070 | final tableOnFile=true, final tableName="data",final fileName=filNamClim, final columns = {7,11,14},
|
---|
8071 | final smoothness=Modelica.Blocks.Types.Smoothness.LinearSegments)
|
---|
8072 | annotation (Placement(transformation(extent={{-40,46},{-26,60}})));
|
---|
8073 |
|
---|
8074 | public
|
---|
8075 | Modelica.Blocks.Tables.CombiTable1Ds tabQCon(
|
---|
8076 | final smoothness = Modelica.Blocks.Types.Smoothness.LinearSegments,
|
---|
8077 | tableOnFile = true,
|
---|
8078 | tableName = "data",
|
---|
8079 | fileName = "..\\Inputs\\" + occupants.filQCon,
|
---|
8080 | columns=2:nOcc+1) if occBeh annotation (Placement(transformation(extent={{-40,-34},
|
---|
8081 | {-26,-20}})));
|
---|
8082 | Modelica.Blocks.Tables.CombiTable1Ds tabQRad(
|
---|
8083 | final smoothness = Modelica.Blocks.Types.Smoothness.LinearSegments,
|
---|
8084 | tableOnFile = true,
|
---|
8085 | tableName = "data",
|
---|
8086 | fileName = "..\\Inputs\\" + occupants.filQRad,
|
---|
8087 | columns=2:nOcc+1) if occBeh annotation (Placement(transformation(extent={{-36,-38},
|
---|
8088 | {-22,-24}})));
|
---|
8089 | Modelica.Blocks.Sources.CombiTimeTable
|
---|
8090 | tabPre(
|
---|
8091 | final smoothness = Modelica.Blocks.Types.Smoothness.LinearSegments,
|
---|
8092 | tableOnFile = true,
|
---|
8093 | tableName = "data",
|
---|
8094 | fileName = "..\\Inputs\\" + occupants.filPres,
|
---|
8095 | columns=2:nOcc+1) if occBeh annotation (Placement(transformation(extent={{0,-34},
|
---|
8096 | {14,-20}})));
|
---|
8097 | Modelica.Blocks.Tables.CombiTable1Ds tabP(
|
---|
8098 | final smoothness = Modelica.Blocks.Types.Smoothness.LinearSegments,
|
---|
8099 | tableOnFile = true,
|
---|
8100 | tableName = "data",
|
---|
8101 | fileName = "..\\Inputs\\" + occupants.filP,
|
---|
8102 | columns=2:nOcc+1) if occBeh annotation (Placement(transformation(extent={{-40,-58},
|
---|
8103 | {-26,-44}})));
|
---|
8104 | Modelica.Blocks.Tables.CombiTable1Ds tabQ(
|
---|
8105 | final smoothness = Modelica.Blocks.Types.Smoothness.LinearSegments,
|
---|
8106 | tableOnFile = true,
|
---|
8107 | tableName = "data",
|
---|
8108 | fileName = "..\\Inputs\\" + occupants.filQ,
|
---|
8109 | columns=2:nOcc+1) if occBeh annotation (Placement(transformation(extent={{-36,-62},
|
---|
8110 | {-22,-48}})));
|
---|
8111 | Modelica.Blocks.Sources.CombiTimeTable
|
---|
8112 | tabDHW(
|
---|
8113 | final smoothness=Modelica.Blocks.Types.Smoothness.LinearSegments,
|
---|
8114 | tableOnFile=true,
|
---|
8115 | tableName="data",
|
---|
8116 | fileName="..\\Inputs\\" + occupants.filDHW,
|
---|
8117 | columns=2:nOcc+1) if DHW
|
---|
8118 | annotation (Placement(transformation(extent={{0,-58},
|
---|
8119 | {14,-44}})));
|
---|
8120 | Modelica.Blocks.Tables.CombiTable1Ds tabPPV(
|
---|
8121 | final smoothness=Modelica.Blocks.Types.Smoothness.LinearSegments,
|
---|
8122 | tableOnFile=true,
|
---|
8123 | tableName="data",
|
---|
8124 | fileName="..\\Inputs\\" + fileNamePv,
|
---|
8125 | columns=2:nPV + 1) if
|
---|
8126 | PV annotation (Placement(transformation(extent={{-36,2},
|
---|
8127 | {-22,16}})));
|
---|
8128 |
|
---|
8129 | equation
|
---|
8130 | if not BesTest then
|
---|
8131 | Tsky = Te - (23.8 - 0.2025 * (Te-273.15)*(1-0.87*Fc));
|
---|
8132 | Fc = 0.2;
|
---|
8133 | Va = 2.5;
|
---|
8134 | else
|
---|
8135 | Tsky = climate_nonSolar.y[2]+273.15;
|
---|
8136 | Fc = climate_nonSolar.y[3]*0.87;
|
---|
8137 | Va = climate_nonSolar.y[4];
|
---|
8138 | end if;
|
---|
8139 |
|
---|
8140 | connect(timMan.timCalSol, climate_solar.u) annotation (Line(
|
---|
8141 | points={{-60,62},{-52,62},{-52,53},{-41.4,53}},
|
---|
8142 | color={0,0,127},
|
---|
8143 | smooth=Smooth.None));
|
---|
8144 | connect(timMan.timSol, climate_nonSolar.u) annotation (Line(
|
---|
8145 | points={{-60,70},{-50,70},{-50,73},{-41.4,73}},
|
---|
8146 | color={0,0,127},
|
---|
8147 | smooth=Smooth.None));
|
---|
8148 | connect(timMan.timCal, tabQCon.u) annotation (Line(
|
---|
8149 | points={{-60,66},{-52,66},{-52,-27},{-41.4,-27}},
|
---|
8150 | color={0,0,127},
|
---|
8151 | smooth=Smooth.None));
|
---|
8152 | connect(timMan.timCal, tabQRad.u) annotation (Line(
|
---|
8153 | points={{-60,66},{-50,66},{-50,-31},{-37.4,-31}},
|
---|
8154 | color={0,0,127},
|
---|
8155 | smooth=Smooth.None));
|
---|
8156 | connect(timMan.timCal, tabP.u) annotation (Line(
|
---|
8157 | points={{-60,66},{-52,66},{-52,-51},{-41.4,-51}},
|
---|
8158 | color={0,0,127},
|
---|
8159 | smooth=Smooth.None));
|
---|
8160 | connect(timMan.timCal, tabQ.u) annotation (Line(
|
---|
8161 | points={{-60,66},{-50,66},{-50,-55},{-37.4,-55}},
|
---|
8162 | color={0,0,127},
|
---|
8163 | smooth=Smooth.None));
|
---|
8164 | connect(timMan.timCal, tabPPV.u) annotation (Line(
|
---|
8165 | points={{-60,66},{-48,66},{-48,9},{-37.4,9}},
|
---|
8166 | color={0,0,127},
|
---|
8167 | smooth=Smooth.None));
|
---|
8168 | annotation(defaultComponentName="sim", defaultComponentPrefixes="inner", missingInnerMessage="Your model is using an outer \"sim\" component. An inner \"sim\" component is not defined. For simulation drag IDEAS.SimInfoManager into your model.",
|
---|
8169 | Icon(graphics={
|
---|
8170 | Ellipse(
|
---|
8171 | extent={{-60,78},{74,-58}},
|
---|
8172 | lineColor={95,95,95},
|
---|
8173 | fillColor={135,135,135},
|
---|
8174 | fillPattern=FillPattern.Solid),
|
---|
8175 | Polygon(
|
---|
8176 | points={{18,52},{30,44},{36,44},{36,46},{34,48},{34,56},{22,60},{16,60},
|
---|
8177 | {10,58},{6,54},{8,52},{2,52},{-8,48},{-14,52},{-24,48},{-26,40},{-18,
|
---|
8178 | 40},{-14,32},{-14,28},{-12,24},{-16,10},{-8,2},{-8,-2},{-6,-6},{-4,
|
---|
8179 | -4},{0,-6},{2,-12},{10,-18},{18,-24},{22,-30},{26,-36},{32,-44},{34,
|
---|
8180 | -50},{36,-58},{60,-44},{72,-28},{72,-18},{64,-14},{58,-12},{48,-12},
|
---|
8181 | {44,-14},{40,-16},{34,-16},{26,-24},{20,-22},{20,-18},{24,-12},{16,
|
---|
8182 | -16},{8,-12},{8,-8},{10,-2},{16,0},{24,0},{28,-2},{30,-8},{32,-6},
|
---|
8183 | {28,2},{30,12},{34,18},{36,20},{38,24},{34,26},{36,32},{26,38},{18,
|
---|
8184 | 38},{20,32},{18,28},{12,32},{14,38},{16,42},{24,40},{22,46},{16,50},
|
---|
8185 | {18,52}},
|
---|
8186 | lineColor={255,255,255},
|
---|
8187 | smooth=Smooth.None,
|
---|
8188 | fillColor={255,255,255},
|
---|
8189 | fillPattern=FillPattern.Solid),
|
---|
8190 | Polygon(
|
---|
8191 | points={{-34,64},{-30,62},{-26,64},{-24,60},{-36,58},{-24,52},{-16,54},
|
---|
8192 | {-14,62},{-8,68},{6,74},{12,74},{22,70},{28,64},{30,64},{44,62},{46,
|
---|
8193 | 58},{42,56},{50,50},{66,34},{68,20},{74,12},{80,46},{70,78},{44,90},
|
---|
8194 | {2,90},{-32,80},{-34,64}},
|
---|
8195 | lineColor={255,255,255},
|
---|
8196 | smooth=Smooth.None,
|
---|
8197 | fillColor={255,255,255},
|
---|
8198 | fillPattern=FillPattern.Solid),
|
---|
8199 | Bitmap(extent={{22,-8},{20,-8}}, fileName=""),
|
---|
8200 | Ellipse(extent={{-60,78},{74,-58}}, lineColor={95,95,95}),
|
---|
8201 | Polygon(
|
---|
8202 | points={{-66,-20},{-70,-16},{-72,-20},{-68,-30},{-60,-42},{-60,-40},{-62,
|
---|
8203 | -32},{-66,-20}},
|
---|
8204 | lineColor={127,0,0},
|
---|
8205 | smooth=Smooth.None,
|
---|
8206 | fillColor={127,67,62},
|
---|
8207 | fillPattern=FillPattern.Solid),
|
---|
8208 | Polygon(
|
---|
8209 | points={{-62,-4},{-58,0},{-54,-2},{-54,-12},{-52,-20},{-48,-24},{-50,-28},
|
---|
8210 | {-50,-30},{-54,-28},{-56,-26},{-58,-12},{-62,-4}},
|
---|
8211 | lineColor={127,0,0},
|
---|
8212 | smooth=Smooth.None,
|
---|
8213 | fillColor={127,67,62},
|
---|
8214 | fillPattern=FillPattern.Solid),
|
---|
8215 | Polygon(
|
---|
8216 | points={{-48,0},{-46,4},{-42,4},{-40,0},{-40,-4},{-38,-16},{-38,-22},{
|
---|
8217 | -40,-24},{-44,-22},{-44,-16},{-48,0}},
|
---|
8218 | lineColor={127,0,0},
|
---|
8219 | smooth=Smooth.None,
|
---|
8220 | fillColor={127,67,62},
|
---|
8221 | fillPattern=FillPattern.Solid),
|
---|
8222 | Polygon(
|
---|
8223 | points={{-32,2},{-28,4},{-24,4},{-24,0},{-24,-12},{-24,-20},{-26,-24},
|
---|
8224 | {-30,-24},{-32,-6},{-32,2}},
|
---|
8225 | lineColor={127,0,0},
|
---|
8226 | smooth=Smooth.None,
|
---|
8227 | fillColor={127,67,62},
|
---|
8228 | fillPattern=FillPattern.Solid),
|
---|
8229 | Polygon(
|
---|
8230 | points={{-6,-36},{-12,-42},{-8,-42},{-4,-36},{0,-26},{-2,-22},{-6,-22},
|
---|
8231 | {-8,-26},{-10,-32},{-8,-36},{-6,-36}},
|
---|
8232 | lineColor={127,0,0},
|
---|
8233 | smooth=Smooth.None,
|
---|
8234 | fillColor={127,67,62},
|
---|
8235 | fillPattern=FillPattern.Solid),
|
---|
8236 | Polygon(
|
---|
8237 | points={{-60,-44},{-58,-40},{-54,-40},{-50,-36},{-42,-32},{-36,-32},{-32,
|
---|
8238 | -28},{-26,-28},{-24,-34},{-24,-36},{-26,-38},{-20,-42},{-16,-46},{
|
---|
8239 | -12,-46},{-8,-48},{-10,-52},{-12,-60},{-16,-66},{-20,-68},{-26,-70},
|
---|
8240 | {-30,-70},{-34,-70},{-36,-74},{-40,-76},{-42,-76},{-48,-72},{-54,-62},
|
---|
8241 | {-60,-44}},
|
---|
8242 | lineColor={127,0,0},
|
---|
8243 | smooth=Smooth.None,
|
---|
8244 | fillColor={127,67,62},
|
---|
8245 | fillPattern=FillPattern.Solid)}),
|
---|
8246 | Diagram(graphics),
|
---|
8247 | Documentation(info="<html>
|
---|
8248 | </html>"));
|
---|
8249 | end SimInfoManager;
|
---|
8250 |
|
---|
8251 | package Climate "Climate data"
|
---|
8252 | extends Modelica.Icons.Package;
|
---|
8253 |
|
---|
8254 | package Meteo
|
---|
8255 | extends Modelica.Icons.Package;
|
---|
8256 |
|
---|
8257 | partial model Detail
|
---|
8258 |
|
---|
8259 | parameter String filNam;
|
---|
8260 | parameter Modelica.SIunits.Time timestep;
|
---|
8261 |
|
---|
8262 | end Detail;
|
---|
8263 |
|
---|
8264 | partial model Location "Geogrphical location"
|
---|
8265 |
|
---|
8266 | parameter Modelica.SIunits.Angle lat(displayUnit="degree")
|
---|
8267 | "latitude of the locatioin";
|
---|
8268 | parameter Modelica.SIunits.Angle lon(displayUnit="degree")
|
---|
8269 | "longitude of the locatioin";
|
---|
8270 | parameter Modelica.SIunits.Temperature Tdes
|
---|
8271 | "Design outdoor temperature";
|
---|
8272 | parameter Modelica.SIunits.Temperature TdesGround
|
---|
8273 | "Design ground temperature";
|
---|
8274 | parameter Modelica.SIunits.Time timZonSta "Standard (winter) time zone";
|
---|
8275 | parameter Boolean DST "Take into account daylight saving time or not";
|
---|
8276 | parameter Integer yr "Ddepcited year for DST only";
|
---|
8277 | parameter String locNam;
|
---|
8278 |
|
---|
8279 | end Location;
|
---|
8280 |
|
---|
8281 | package Files
|
---|
8282 | extends Modelica.Icons.Package;
|
---|
8283 |
|
---|
8284 | model min60 "60-minute data"
|
---|
8285 | extends IDEAS.Climate.Meteo.Detail(filNam="_60.txt",
|
---|
8286 | timestep=3600);
|
---|
8287 | end min60;
|
---|
8288 | end Files;
|
---|
8289 |
|
---|
8290 | package Locations
|
---|
8291 | extends Modelica.Icons.Package;
|
---|
8292 |
|
---|
8293 | model Uccle "Uccle, Belgium"
|
---|
8294 | extends IDEAS.Climate.Meteo.Location(
|
---|
8295 | lat=50.800/180*Modelica.Constants.pi,
|
---|
8296 | lon=4.317/180*Modelica.Constants.pi,
|
---|
8297 | Tdes=265.15,
|
---|
8298 | TdesGround=284.15,
|
---|
8299 | timZonSta=3600,
|
---|
8300 | DST=true,
|
---|
8301 | yr=2010,
|
---|
8302 | locNam="climate");
|
---|
8303 | end Uccle;
|
---|
8304 | end Locations;
|
---|
8305 |
|
---|
8306 | package Solar
|
---|
8307 | extends Modelica.Icons.Package;
|
---|
8308 |
|
---|
8309 | package BaseClasses
|
---|
8310 | "Baseclass elements for solar incidence calculation"
|
---|
8311 | extends Modelica.Icons.BasesPackage;
|
---|
8312 |
|
---|
8313 | model AngleDay
|
---|
8314 |
|
---|
8315 | Real day;
|
---|
8316 | Real t;
|
---|
8317 | Real N "year";
|
---|
8318 |
|
---|
8319 | equation
|
---|
8320 | N=(time-365*24*60*30)/60/60/24/365;
|
---|
8321 | t=time-86400*N;
|
---|
8322 | day=t/60/60/24/365.25*2*Modelica.Constants.pi-0.048869;
|
---|
8323 |
|
---|
8324 | end AngleDay;
|
---|
8325 |
|
---|
8326 | block AngleHour
|
---|
8327 |
|
---|
8328 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8329 |
|
---|
8330 | outer IDEAS.SimInfoManager sim
|
---|
8331 | annotation (Placement(transformation(extent={{-92,74},{-72,94}})));
|
---|
8332 |
|
---|
8333 | Modelica.Blocks.Interfaces.RealOutput angHou(
|
---|
8334 | final quantity="Angle",
|
---|
8335 | final unit="rad",
|
---|
8336 | displayUnit="deg") "hour angle"
|
---|
8337 | annotation (Placement(transformation(extent={{90,50},{110,70}})));
|
---|
8338 |
|
---|
8339 | algorithm
|
---|
8340 | angHou :=(sim.timSol/3600 - 12)*2*Modelica.Constants.pi/24;
|
---|
8341 |
|
---|
8342 | annotation (Diagram(graphics));
|
---|
8343 | end AngleHour;
|
---|
8344 |
|
---|
8345 | model AngleSolar "solar angle to surface"
|
---|
8346 |
|
---|
8347 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8348 |
|
---|
8349 | parameter Modelica.SIunits.Angle inc(displayUnit="degree")
|
---|
8350 | "inclination";
|
---|
8351 | parameter Modelica.SIunits.Angle azi(displayUnit="degree") "azimuth";
|
---|
8352 | parameter Modelica.SIunits.Angle lat(displayUnit="degree");
|
---|
8353 |
|
---|
8354 | public
|
---|
8355 | Modelica.Blocks.Interfaces.RealInput angDec(final quantity="Angle", final unit="rad",displayUnit="deg")
|
---|
8356 | annotation (Placement(transformation(extent={{-120,40},{-80,80}})));
|
---|
8357 | Modelica.Blocks.Interfaces.RealInput angHou(final quantity="Angle", final unit="rad",displayUnit="deg")
|
---|
8358 | annotation (Placement(transformation(extent={{-120,0},{-80,40}})));
|
---|
8359 | Modelica.Blocks.Interfaces.RealOutput angInc(final quantity="Angle", final unit="rad",displayUnit="deg")
|
---|
8360 | "Incidence angle"
|
---|
8361 | annotation (Placement(transformation(extent={{90,50},{110,70}})));
|
---|
8362 |
|
---|
8363 | protected
|
---|
8364 | Real cosDec = Modelica.Math.cos(angDec);
|
---|
8365 | Real sinDec = Modelica.Math.sin(angDec);
|
---|
8366 | Real cosHou = Modelica.Math.cos(angHou);
|
---|
8367 | Real sinHou = Modelica.Math.sin(angHou);
|
---|
8368 | Real cosLat = Modelica.Math.cos(lat);
|
---|
8369 | Real sinLat = Modelica.Math.sin(lat);
|
---|
8370 |
|
---|
8371 | equation
|
---|
8372 | angInc = acos(cos(inc)*(cosDec*cosHou*cosLat + sinDec*sinLat) + sin(inc)*(sin(azi)*cosDec*sinHou + cos(azi)*(cosDec*cosHou*sinLat - sinDec*cosLat)));
|
---|
8373 |
|
---|
8374 | annotation (Icon(graphics={
|
---|
8375 | Ellipse(
|
---|
8376 | extent={{88,88},{40,42}},
|
---|
8377 | lineColor={255,255,0},
|
---|
8378 | fillColor={255,255,0},
|
---|
8379 | fillPattern=FillPattern.Solid),
|
---|
8380 | Polygon(
|
---|
8381 | points={{-90,-76},{-40,-36},{40,-36},{90,-76},{-90,-76}},
|
---|
8382 | lineColor={95,95,95},
|
---|
8383 | smooth=Smooth.None),
|
---|
8384 | Polygon(
|
---|
8385 | points={{16,-42},{22,-68},{-72,0},{-18,-18},{16,-42}},
|
---|
8386 | lineColor={0,0,0},
|
---|
8387 | smooth=Smooth.None,
|
---|
8388 | fillPattern=FillPattern.Solid,
|
---|
8389 | fillColor={175,175,175}),
|
---|
8390 | Line(
|
---|
8391 | points={{-6,-36},{84,40}},
|
---|
8392 | color={0,0,0},
|
---|
8393 | smooth=Smooth.None),
|
---|
8394 | Line(
|
---|
8395 | points={{-6,-36},{64,68}},
|
---|
8396 | color={0,0,0},
|
---|
8397 | smooth=Smooth.None)}), Diagram(graphics));
|
---|
8398 | end AngleSolar;
|
---|
8399 |
|
---|
8400 | model AngleZenith "solar angle to surface"
|
---|
8401 |
|
---|
8402 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8403 |
|
---|
8404 | parameter Modelica.SIunits.Angle lat(displayUnit="degree");
|
---|
8405 |
|
---|
8406 | public
|
---|
8407 | Modelica.Blocks.Interfaces.RealInput angDec(quantity="Angle", unit="rad")
|
---|
8408 | "declination"
|
---|
8409 | annotation (Placement(transformation(extent={{-120,40},{-80,80}})));
|
---|
8410 | Modelica.Blocks.Interfaces.RealInput angHou(quantity="Angle", unit="rad")
|
---|
8411 | "hour angle"
|
---|
8412 | annotation (Placement(transformation(extent={{-120,0},{-80,40}})));
|
---|
8413 | Modelica.Blocks.Interfaces.RealOutput angZen(
|
---|
8414 | final quantity="Angle",
|
---|
8415 | final unit="rad",
|
---|
8416 | displayUnit="deg") "Zenith Angle"
|
---|
8417 | annotation (Placement(transformation(extent={{90,50},{110,70}})));
|
---|
8418 |
|
---|
8419 | equation
|
---|
8420 | angZen = acos(cos(lat)*cos(angDec)*cos(angHou)+sin(lat)*sin(angDec));
|
---|
8421 |
|
---|
8422 | annotation (Diagram(graphics), Icon(graphics={
|
---|
8423 | Polygon(
|
---|
8424 | points={{-88,-78},{-38,-38},{42,-38},{92,-78},{-88,-78}},
|
---|
8425 | lineColor={95,95,95},
|
---|
8426 | smooth=Smooth.None,
|
---|
8427 | fillColor={175,175,175},
|
---|
8428 | fillPattern=FillPattern.Solid),
|
---|
8429 | Ellipse(
|
---|
8430 | extent={{90,90},{42,44}},
|
---|
8431 | lineColor={255,255,0},
|
---|
8432 | fillColor={255,255,0},
|
---|
8433 | fillPattern=FillPattern.Solid),
|
---|
8434 | Line(
|
---|
8435 | points={{66,68},{-2,-56}},
|
---|
8436 | color={0,0,0},
|
---|
8437 | smooth=Smooth.None),
|
---|
8438 | Line(
|
---|
8439 | points={{-2,-56},{-2,84}},
|
---|
8440 | color={0,0,0},
|
---|
8441 | smooth=Smooth.None)}));
|
---|
8442 | end AngleZenith;
|
---|
8443 |
|
---|
8444 | block Declination "solar declination"
|
---|
8445 |
|
---|
8446 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8447 |
|
---|
8448 | outer IDEAS.SimInfoManager sim
|
---|
8449 | annotation (Placement(transformation(extent={{-80,60},{-60,80}})));
|
---|
8450 | Modelica.Blocks.Interfaces.RealOutput delta(final quantity="Angle", final unit="rad",displayUnit="deg")
|
---|
8451 | "Declination angle"
|
---|
8452 | annotation (Placement(transformation(extent={{90,50},{110,70}})));
|
---|
8453 | equation
|
---|
8454 | delta = asin(-sin(23.45*2*Modelica.Constants.pi/360)*cos((sim.timLoc/86400+10)*2*Modelica.Constants.pi/365.25));
|
---|
8455 |
|
---|
8456 | annotation (Icon(graphics={
|
---|
8457 | Ellipse(
|
---|
8458 | extent={{-74,74},{78,-72}},
|
---|
8459 | lineColor={0,0,0},
|
---|
8460 | fillColor={85,170,255},
|
---|
8461 | fillPattern=FillPattern.Solid),
|
---|
8462 | Line(
|
---|
8463 | points={{0,90},{0,-88}},
|
---|
8464 | color={0,0,0},
|
---|
8465 | smooth=Smooth.None),
|
---|
8466 | Line(
|
---|
8467 | points={{-28,-86},{32,88}},
|
---|
8468 | color={0,0,0},
|
---|
8469 | smooth=Smooth.None)}));
|
---|
8470 | end Declination;
|
---|
8471 |
|
---|
8472 | model solDifTil
|
---|
8473 |
|
---|
8474 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8475 |
|
---|
8476 | parameter Modelica.SIunits.Area A;
|
---|
8477 | parameter Modelica.SIunits.Angle inc(displayUnit="degree")
|
---|
8478 | "inclination";
|
---|
8479 |
|
---|
8480 | Modelica.Blocks.Interfaces.RealOutput solDifTil
|
---|
8481 | annotation (Placement(transformation(extent={{90,50},{110,70}})));
|
---|
8482 | outer IDEAS.SimInfoManager sim
|
---|
8483 | annotation (Placement(transformation(extent={{60,72},{80,92}})));
|
---|
8484 |
|
---|
8485 | Modelica.Blocks.Interfaces.RealInput angZen
|
---|
8486 | annotation (Placement(transformation(extent={{-120,0},{-80,40}})));
|
---|
8487 | Modelica.Blocks.Interfaces.RealInput angInc
|
---|
8488 | annotation (Placement(transformation(extent={{-120,40},{-80,80}})));
|
---|
8489 |
|
---|
8490 | final parameter Modelica.SIunits.Angle i = inc/180*Modelica.Constants.pi;
|
---|
8491 |
|
---|
8492 | SkyClearness skyClearness
|
---|
8493 | annotation (Placement(transformation(extent={{-60,10},{-42,28}})));
|
---|
8494 | RelativeAirMass relativeAirMass
|
---|
8495 | annotation (Placement(transformation(extent={{-60,-18},{-42,0}})));
|
---|
8496 | SkyBrightness skyBrightness
|
---|
8497 | annotation (Placement(transformation(extent={{-34,-18},{-16,0}})));
|
---|
8498 | SkyBrightnessCoefficients skyBrightnessCoefficients
|
---|
8499 | annotation (Placement(transformation(extent={{0,22},{18,40}})));
|
---|
8500 | Perez perez(A=A, inc=inc) annotation (Placement(transformation(extent={{40,44},{60,64}})));
|
---|
8501 |
|
---|
8502 | equation
|
---|
8503 | connect(angZen, skyClearness.angZen) annotation (Line(
|
---|
8504 | points={{-100,20},{-70,20},{-70,24},{-66,24},{-60,24.4}},
|
---|
8505 | color={0,0,127},
|
---|
8506 | smooth=Smooth.None));
|
---|
8507 | connect(angZen, relativeAirMass.angZen) annotation (Line(
|
---|
8508 | points={{-100,20},{-70,20},{-70,-3.6},{-60,-3.6}},
|
---|
8509 | color={0,0,127},
|
---|
8510 | smooth=Smooth.None));
|
---|
8511 | connect(relativeAirMass.relAirMas, skyBrightness.relAirMas) annotation (
|
---|
8512 | Line(
|
---|
8513 | points={{-42,-3.6},{-40,-3.6},{-40,-3.6},{-38,-3.6},{-38,-3.6},{-34,-3.6}},
|
---|
8514 | color={0,0,127},
|
---|
8515 | smooth=Smooth.None));
|
---|
8516 | connect(angZen, skyBrightnessCoefficients.angZen) annotation (Line(
|
---|
8517 | points={{-100,20},{-70,20},{-70,36.4},{0,36.4}},
|
---|
8518 | color={0,0,127},
|
---|
8519 | smooth=Smooth.None));
|
---|
8520 | connect(skyClearness.skyCle, skyBrightnessCoefficients.skyCle) annotation (
|
---|
8521 | Line(
|
---|
8522 | points={{-42,24.4},{-22,24.4},{-22,32.8},{0,32.8}},
|
---|
8523 | color={0,0,127},
|
---|
8524 | smooth=Smooth.None));
|
---|
8525 | connect(skyBrightness.skyBri, skyBrightnessCoefficients.skyBri) annotation (
|
---|
8526 | Line(
|
---|
8527 | points={{-16,-3.6},{-8,-3.6},{-8,29.2},{0,29.2}},
|
---|
8528 | color={0,0,127},
|
---|
8529 | smooth=Smooth.None));
|
---|
8530 | connect(skyBrightnessCoefficients.F1, perez.F1) annotation (Line(
|
---|
8531 | points={{18,36.4},{22,36},{26,36},{26,52},{40,52}},
|
---|
8532 | color={0,0,127},
|
---|
8533 | smooth=Smooth.None));
|
---|
8534 | connect(skyBrightnessCoefficients.F2, perez.F2) annotation (Line(
|
---|
8535 | points={{18,32.8},{30,32.8},{30,48},{40,48}},
|
---|
8536 | color={0,0,127},
|
---|
8537 | smooth=Smooth.None));
|
---|
8538 | connect(angZen, perez.angZen) annotation (Line(
|
---|
8539 | points={{-100,20},{-70,20},{-70,56},{40,56}},
|
---|
8540 | color={0,0,127},
|
---|
8541 | smooth=Smooth.None));
|
---|
8542 | connect(angInc, perez.angInc) annotation (Line(
|
---|
8543 | points={{-100,60},{40,60}},
|
---|
8544 | color={0,0,127},
|
---|
8545 | smooth=Smooth.None));
|
---|
8546 | connect(perez.solDifTil, solDifTil) annotation (Line(
|
---|
8547 | points={{60,60},{100,60}},
|
---|
8548 | color={0,0,127},
|
---|
8549 | smooth=Smooth.None));
|
---|
8550 | annotation (Diagram(graphics));
|
---|
8551 | end solDifTil;
|
---|
8552 |
|
---|
8553 | model solDirTil
|
---|
8554 |
|
---|
8555 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8556 |
|
---|
8557 | parameter Modelica.SIunits.Area A;
|
---|
8558 | parameter Modelica.SIunits.Angle inc(displayUnit="degree")
|
---|
8559 | "inclination";
|
---|
8560 |
|
---|
8561 | Modelica.Blocks.Interfaces.RealInput angSol
|
---|
8562 | annotation (Placement(transformation(extent={{-120,40},{-80,80}})));
|
---|
8563 | Modelica.Blocks.Interfaces.RealOutput solDirTil
|
---|
8564 | annotation (Placement(transformation(extent={{90,50},{110,70}})));
|
---|
8565 | outer IDEAS.SimInfoManager sim
|
---|
8566 | annotation (Placement(transformation(extent={{-60,60},{-40,80}})));
|
---|
8567 |
|
---|
8568 | algorithm
|
---|
8569 | if inc <= Modelica.Constants.small then
|
---|
8570 | solDirTil := IDEAS.BaseClasses.Math.MaxSmooth(
|
---|
8571 | 0,
|
---|
8572 | A*sim.solDirHor,
|
---|
8573 | delta=0.01);
|
---|
8574 | else
|
---|
8575 | solDirTil := IDEAS.BaseClasses.Math.MaxSmooth(
|
---|
8576 | 0,
|
---|
8577 | cos(angSol)*sim.solDirPer*A,
|
---|
8578 | delta=0.01);
|
---|
8579 | end if;
|
---|
8580 | end solDirTil;
|
---|
8581 |
|
---|
8582 | model solradExtraTerra
|
---|
8583 |
|
---|
8584 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8585 |
|
---|
8586 | IDEAS.Climate.Meteo.Solar.BaseClasses.AngleDay angleDay;
|
---|
8587 |
|
---|
8588 | Modelica.Blocks.Interfaces.RealOutput sol
|
---|
8589 | annotation (Placement(transformation(extent={{90,50},{110,70}})));
|
---|
8590 | algorithm
|
---|
8591 | sol := 1366.1*(1+0.0033412*cos(angleDay.day));
|
---|
8592 |
|
---|
8593 | annotation (Icon(graphics));
|
---|
8594 | end solradExtraTerra;
|
---|
8595 |
|
---|
8596 | block RelativeAirMass
|
---|
8597 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8598 |
|
---|
8599 | Modelica.Blocks.Interfaces.RealInput angZen(
|
---|
8600 | quantity="Angle",
|
---|
8601 | unit="rad",
|
---|
8602 | displayUnit="degreeC") "zenith angle"
|
---|
8603 | annotation (Placement(transformation(extent={{-120,40},{-80,80}})));
|
---|
8604 | Modelica.Blocks.Interfaces.RealOutput relAirMas "relative air mass"
|
---|
8605 | annotation (Placement(transformation(extent={{90,50},{110,70}})));
|
---|
8606 |
|
---|
8607 | protected
|
---|
8608 | Real angZenLim "limited zenith angle";
|
---|
8609 | Real angZenDeg "limited zenith angle in degrees";
|
---|
8610 |
|
---|
8611 | algorithm
|
---|
8612 | angZenLim := IDEAS.BaseClasses.Math.MinSmooth(
|
---|
8613 | angZen,
|
---|
8614 | Modelica.Constants.pi/2,
|
---|
8615 | 0.01);
|
---|
8616 | angZenDeg := Modelica.SIunits.Conversions.to_deg(angZenLim);
|
---|
8617 | relAirMas := 1/(cos(angZenLim) + 0.50572*(96.07995-angZenDeg)^(-1.6364));
|
---|
8618 |
|
---|
8619 | end RelativeAirMass;
|
---|
8620 |
|
---|
8621 | block SkyClearness
|
---|
8622 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8623 | Modelica.Blocks.Interfaces.RealInput angZen(
|
---|
8624 | quantity="Angle",
|
---|
8625 | unit="rad",
|
---|
8626 | displayUnit="degreeC") "zenith angle"
|
---|
8627 | annotation (Placement(transformation(extent={{-120,40},{-80,80}})));
|
---|
8628 | Modelica.Blocks.Interfaces.RealOutput skyCle "sky clearness"
|
---|
8629 | annotation (Placement(transformation(extent={{90,50},{110,70}})));
|
---|
8630 | outer IDEAS.SimInfoManager sim
|
---|
8631 | annotation (Placement(transformation(extent={{-80,72},{-60,92}})));
|
---|
8632 |
|
---|
8633 | protected
|
---|
8634 | final parameter Real kappa = 1.041
|
---|
8635 | "original kappa of 1.014 but for degrees";
|
---|
8636 | Real solDifHor "smoothed horizontal difuse radiation";
|
---|
8637 |
|
---|
8638 | algorithm
|
---|
8639 | solDifHor := IDEAS.BaseClasses.Math.MaxSmooth(
|
---|
8640 | sim.solDifHor,
|
---|
8641 | 1e-4,
|
---|
8642 | 1e-5);
|
---|
8643 | skyCle := smooth(1, if noEvent(sim.solGloHor < 1) then 1 else ((sim.solGloHor)/solDifHor + kappa*angZen^3) / (1 + kappa*angZen^3));
|
---|
8644 |
|
---|
8645 | annotation (Diagram(graphics));
|
---|
8646 | end SkyClearness;
|
---|
8647 |
|
---|
8648 | block SkyBrightness
|
---|
8649 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8650 | outer IDEAS.SimInfoManager sim
|
---|
8651 | annotation (Placement(transformation(extent={{-80,72},{-60,92}})));
|
---|
8652 | Modelica.Blocks.Interfaces.RealInput relAirMas "relative air mass"
|
---|
8653 | annotation (Placement(transformation(extent={{-120,40},{-80,80}})));
|
---|
8654 | Modelica.Blocks.Interfaces.RealOutput skyBri "sky brightness"
|
---|
8655 | annotation (Placement(transformation(extent={{90,50},{110,70}})));
|
---|
8656 |
|
---|
8657 | algorithm
|
---|
8658 | skyBri := IDEAS.BaseClasses.Math.MinSmooth(
|
---|
8659 | sim.solDifHor*relAirMas/1367,
|
---|
8660 | 1,
|
---|
8661 | 0.025);
|
---|
8662 |
|
---|
8663 | annotation (Diagram(graphics));
|
---|
8664 | end SkyBrightness;
|
---|
8665 |
|
---|
8666 | block SkyBrightnessCoefficients
|
---|
8667 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8668 | Modelica.Blocks.Interfaces.RealInput skyCle
|
---|
8669 | annotation (Placement(transformation(extent={{-120,0},{-80,40}})));
|
---|
8670 | Modelica.Blocks.Interfaces.RealInput angZen
|
---|
8671 | annotation (Placement(transformation(extent={{-120,40},{-80,80}})));
|
---|
8672 | Modelica.Blocks.Interfaces.RealInput skyBri
|
---|
8673 | annotation (Placement(transformation(extent={{-120,-40},{-80,0}})));
|
---|
8674 | Modelica.Blocks.Interfaces.RealOutput F1
|
---|
8675 | "circumsolar brightening coefficient"
|
---|
8676 | annotation (Placement(transformation(extent={{90,50},{110,70}})));
|
---|
8677 |
|
---|
8678 | Modelica.Blocks.Interfaces.RealOutput F2
|
---|
8679 | "horizon brightening coefficient"
|
---|
8680 | annotation (Placement(transformation(extent={{90,10},{110,30}})));
|
---|
8681 |
|
---|
8682 | protected
|
---|
8683 | Real F11;
|
---|
8684 | Real F12;
|
---|
8685 | Real F13;
|
---|
8686 | Real F21;
|
---|
8687 | Real F22;
|
---|
8688 | Real F23;
|
---|
8689 | final parameter Real d = 0.01;
|
---|
8690 | Real[8] a;
|
---|
8691 | Real[8] b;
|
---|
8692 |
|
---|
8693 | algorithm
|
---|
8694 | //first we define the discrete sky clearness categories a[:]
|
---|
8695 | b[1] := Modelica.Media.Air.MoistAir.Utilities.spliceFunction(1,0,1.065 - skyCle,d);
|
---|
8696 | b[2] := Modelica.Media.Air.MoistAir.Utilities.spliceFunction(1,0,1.23 - skyCle,d);
|
---|
8697 | b[3] := Modelica.Media.Air.MoistAir.Utilities.spliceFunction(1,0,1.50 - skyCle,d);
|
---|
8698 | b[4] := Modelica.Media.Air.MoistAir.Utilities.spliceFunction(1,0,1.95 - skyCle,d);
|
---|
8699 | b[5] := Modelica.Media.Air.MoistAir.Utilities.spliceFunction(1,0,2.8 - skyCle,d);
|
---|
8700 | b[6] := Modelica.Media.Air.MoistAir.Utilities.spliceFunction(1,0,4.5 - skyCle,d);
|
---|
8701 | b[7] := Modelica.Media.Air.MoistAir.Utilities.spliceFunction(1,0,6.2 - skyCle,d);
|
---|
8702 | b[8] := Modelica.Media.Air.MoistAir.Utilities.spliceFunction(1,0,skyCle - 6.2,d);
|
---|
8703 | a[1] := b[1];
|
---|
8704 | a[1] := b[2] - b[1];
|
---|
8705 | a[2] := b[3] - b[2];
|
---|
8706 | a[3] := b[4] - b[3];
|
---|
8707 | a[4] := b[5] - b[4];
|
---|
8708 | a[5] := b[6] - b[5];
|
---|
8709 | a[6] := b[7] - b[6];
|
---|
8710 | a[7] := b[8];
|
---|
8711 |
|
---|
8712 | F11 := -0.008*a[1] + 0.130*a[2] + 0.330*a[3] + 0.568*a[4] + 0.873*a[5] + 1.132*a[6] + 1.060*a[7] + 0.678*a[8];
|
---|
8713 | F12 := 0.588*a[1] + 0.683*a[2] + 0.487*a[3] + 0.187*a[4] - 0.392*a[5] - 1.237*a[6] - 1.600*a[7] - 0.327*a[8];
|
---|
8714 | F13 := -0.062*a[1] - 0.151*a[2] - 0.221*a[3] - 0.295*a[4] - 0.362*a[5] - 0.412*a[6] - 0.359*a[7] - 0.250*a[8];
|
---|
8715 | F21 := -0.060*a[1] - 0.019*a[2] + 0.055*a[3] + 0.109*a[4] + 0.226*a[5] + 0.288*a[6] + 0.264*a[7] + 0.156*a[8];
|
---|
8716 | F22 := 0.072*a[1] + 0.066*a[2] - 0.064*a[3] - 0.152*a[4] - 0.462*a[5] - 0.823*a[6] - 1.127*a[7] - 1.377*a[8];
|
---|
8717 | F23 := -0.022*a[1] - 0.029*a[2] - 0.026*a[3] - 0.014*a[4] + 0.001*a[5] + 0.056*a[6] + 0.131*a[7] + 0.251*a[8];
|
---|
8718 | F1 := IDEAS.BaseClasses.Math.MaxSmooth(
|
---|
8719 | 0,
|
---|
8720 | F11 + F12*skyBri + F13*angZen,
|
---|
8721 | 0.01);
|
---|
8722 | F2 := F21 + F22*skyBri + F23*angZen;
|
---|
8723 |
|
---|
8724 | annotation (Diagram(graphics));
|
---|
8725 | end SkyBrightnessCoefficients;
|
---|
8726 |
|
---|
8727 | block Perez
|
---|
8728 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8729 | outer IDEAS.SimInfoManager sim
|
---|
8730 | annotation (Placement(transformation(extent={{-68,72},{-48,92}})));
|
---|
8731 | parameter Real rho = 0.2 "Ground reflectance";
|
---|
8732 | parameter Modelica.SIunits.Angle inc(displayUnit="degree")
|
---|
8733 | "surface inclination";
|
---|
8734 | parameter Modelica.SIunits.Area A "surface area";
|
---|
8735 |
|
---|
8736 | Modelica.Blocks.Interfaces.RealInput F1
|
---|
8737 | "Circomsolar brightening coefficient"
|
---|
8738 | annotation (Placement(transformation(extent={{-120,-40},{-80,0}})));
|
---|
8739 | Modelica.Blocks.Interfaces.RealInput F2
|
---|
8740 | "horizon brightening coefficient"
|
---|
8741 | annotation (Placement(transformation(extent={{-120,-80},{-80,-40}})));
|
---|
8742 | Modelica.Blocks.Interfaces.RealInput angZen(quantity="Angle", unit="rad", displayUnit="degree")
|
---|
8743 | "zenith angle"
|
---|
8744 | annotation (Placement(transformation(extent={{-120,0},{-80,40}})));
|
---|
8745 | Modelica.Blocks.Interfaces.RealInput angInc(quantity="Angle", unit="rad", displayUnit="degree")
|
---|
8746 | "incedence angle"
|
---|
8747 | annotation (Placement(transformation(extent={{-120,40},{-80,80}})));
|
---|
8748 | Modelica.Blocks.Interfaces.RealOutput solDifTil
|
---|
8749 | annotation (Placement(transformation(extent={{90,50},{110,70}})));
|
---|
8750 |
|
---|
8751 | protected
|
---|
8752 | Real a;
|
---|
8753 | Real b;
|
---|
8754 |
|
---|
8755 | algorithm
|
---|
8756 | a := IDEAS.BaseClasses.Math.MaxSmooth(
|
---|
8757 | 0,
|
---|
8758 | cos(angInc),
|
---|
8759 | 0.01);
|
---|
8760 | b := IDEAS.BaseClasses.Math.MaxSmooth(
|
---|
8761 | 0.087,
|
---|
8762 | cos(angZen),
|
---|
8763 | 0.01);
|
---|
8764 |
|
---|
8765 | if inc <= Modelica.Constants.small then
|
---|
8766 | solDifTil := A * sim.solDifHor;
|
---|
8767 | else
|
---|
8768 | solDifTil := A * sim.solDifHor * (0.5*(1-F1)*(1+cos(inc)) + F1*a/b + F2*sin(inc)) + A * sim.solGloHor * 0.5 * rho * (1-cos(inc));
|
---|
8769 | end if;
|
---|
8770 | end Perez;
|
---|
8771 | end BaseClasses;
|
---|
8772 |
|
---|
8773 | model RadSol "solar angle to surface"
|
---|
8774 |
|
---|
8775 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8776 |
|
---|
8777 | parameter Modelica.SIunits.Angle inc(displayUnit="degree")
|
---|
8778 | "inclination";
|
---|
8779 | parameter Modelica.SIunits.Angle azi(displayUnit="degree") "azimuth";
|
---|
8780 | parameter Modelica.SIunits.Angle lat(displayUnit="degree") = sim.city.lat
|
---|
8781 | "latitude";
|
---|
8782 | parameter Modelica.SIunits.Area A;
|
---|
8783 |
|
---|
8784 | outer IDEAS.SimInfoManager sim
|
---|
8785 | annotation (Placement(transformation(extent={{-80,60},{-60,80}})));
|
---|
8786 |
|
---|
8787 | BaseClasses.Declination
|
---|
8788 | declination
|
---|
8789 | annotation (Placement(transformation(extent={{-80,20},{-60,40}})));
|
---|
8790 | BaseClasses.AngleHour
|
---|
8791 | angleHour
|
---|
8792 | annotation (Placement(transformation(extent={{-80,-2},{-60,18}})));
|
---|
8793 | BaseClasses.AngleSolar
|
---|
8794 | angSolar(inc=inc, azi=azi,lat=lat)
|
---|
8795 | annotation (Placement(transformation(extent={{-40,20},{-20,40}})));
|
---|
8796 | BaseClasses.solDirTil
|
---|
8797 | solDirTil(A=A,inc=inc)
|
---|
8798 | annotation (Placement(transformation(extent={{0,20},{20,40}})));
|
---|
8799 | BaseClasses.solDifTil
|
---|
8800 | solDifTil(A=A,inc=inc)
|
---|
8801 | annotation (Placement(transformation(extent={{0,-2},{20,18}})));
|
---|
8802 | BaseClasses.solradExtraTerra
|
---|
8803 | extraTerra
|
---|
8804 | annotation (Placement(transformation(extent={{-80,-24},{-60,-4}})));
|
---|
8805 | Modelica.Blocks.Interfaces.RealOutput solDir
|
---|
8806 | annotation (Placement(transformation(extent={{90,50},{110,70}})));
|
---|
8807 | Modelica.Blocks.Interfaces.RealOutput solDif
|
---|
8808 | annotation (Placement(transformation(extent={{90,10},{110,30}})));
|
---|
8809 | BaseClasses.AngleZenith
|
---|
8810 | angleZenith(lat=lat)
|
---|
8811 | annotation (Placement(transformation(extent={{-40,-2},{-20,18}})));
|
---|
8812 | Modelica.Blocks.Interfaces.RealOutput angInc "Angle of incidence"
|
---|
8813 | annotation (Placement(transformation(extent={{90,-50},{110,-30}})));
|
---|
8814 | Modelica.Blocks.Interfaces.RealOutput angZen "Angle of incidence"
|
---|
8815 | annotation (Placement(transformation(extent={{90,-70},{110,-50}})));
|
---|
8816 | Modelica.Blocks.Interfaces.RealOutput angHou "Angle of incidence"
|
---|
8817 | annotation (Placement(transformation(extent={{90,-90},{110,-70}})));
|
---|
8818 | equation
|
---|
8819 | connect(declination.delta, angSolar.angDec) annotation (Line(
|
---|
8820 | points={{-60,36},{-40,36}},
|
---|
8821 | color={0,0,127},
|
---|
8822 | smooth=Smooth.None));
|
---|
8823 | connect(angleHour.angHou, angSolar.angHou) annotation (Line(
|
---|
8824 | points={{-60,14},{-48,14},{-48,32},{-40,32}},
|
---|
8825 | color={0,0,127},
|
---|
8826 | smooth=Smooth.None));
|
---|
8827 | connect(solDirTil.solDirTil, solDir) annotation (Line(
|
---|
8828 | points={{20,36},{56,36},{56,60},{100,60}},
|
---|
8829 | color={0,0,127},
|
---|
8830 | smooth=Smooth.None));
|
---|
8831 | connect(solDifTil.solDifTil, solDif) annotation (Line(
|
---|
8832 | points={{20,14},{56,14},{56,20},{100,20}},
|
---|
8833 | color={0,0,127},
|
---|
8834 | smooth=Smooth.None));
|
---|
8835 | connect(declination.delta, angleZenith.angDec) annotation (Line(
|
---|
8836 | points={{-60,36},{-50,36},{-50,14},{-40,14}},
|
---|
8837 | color={0,0,127},
|
---|
8838 | smooth=Smooth.None));
|
---|
8839 | connect(angleHour.angHou, angleZenith.angHou) annotation (Line(
|
---|
8840 | points={{-60,14},{-50,14},{-50,10},{-40,10}},
|
---|
8841 | color={0,0,127},
|
---|
8842 | smooth=Smooth.None));
|
---|
8843 | connect(angleZenith.angZen, solDifTil.angZen) annotation (Line(
|
---|
8844 | points={{-20,14},{-6,14},{-6,10},{0,10}},
|
---|
8845 | color={0,0,127},
|
---|
8846 | smooth=Smooth.None));
|
---|
8847 | connect(angSolar.angInc, solDifTil.angInc) annotation (Line(
|
---|
8848 | points={{-20,36},{-4,36},{-4,14},{0,14}},
|
---|
8849 | color={0,0,127},
|
---|
8850 | smooth=Smooth.None));
|
---|
8851 | connect(angSolar.angInc, solDirTil.angSol) annotation (Line(
|
---|
8852 | points={{-20,36},{0,36}},
|
---|
8853 | color={0,0,127},
|
---|
8854 | smooth=Smooth.None));
|
---|
8855 | connect(angSolar.angInc, angInc) annotation (Line(
|
---|
8856 | points={{-20,36},{-10,36},{-10,-40},{100,-40}},
|
---|
8857 | color={0,0,127},
|
---|
8858 | smooth=Smooth.None));
|
---|
8859 | connect(angleHour.angHou, angHou) annotation (Line(
|
---|
8860 | points={{-60,14},{-50,14},{-50,-80},{100,-80}},
|
---|
8861 | color={0,0,127},
|
---|
8862 | smooth=Smooth.None));
|
---|
8863 | connect(angleZenith.angZen, angZen) annotation (Line(
|
---|
8864 | points={{-20,14},{-14,14},{-14,-60},{100,-60}},
|
---|
8865 | color={0,0,127},
|
---|
8866 | smooth=Smooth.None));
|
---|
8867 | annotation (Diagram(graphics), Icon(graphics={
|
---|
8868 | Polygon(
|
---|
8869 | points={{-90,-80},{-40,-40},{40,-40},{90,-80},{-90,-80}},
|
---|
8870 | lineColor={95,95,95},
|
---|
8871 | smooth=Smooth.None),
|
---|
8872 | Polygon(
|
---|
8873 | points={{16,-46},{22,-72},{-72,-4},{-18,-22},{16,-46}},
|
---|
8874 | lineColor={0,0,0},
|
---|
8875 | smooth=Smooth.None,
|
---|
8876 | fillPattern=FillPattern.Solid,
|
---|
8877 | fillColor={175,175,175}),
|
---|
8878 | Ellipse(
|
---|
8879 | extent={{88,84},{40,38}},
|
---|
8880 | lineColor={255,255,0},
|
---|
8881 | fillColor={255,255,0},
|
---|
8882 | fillPattern=FillPattern.Solid)}));
|
---|
8883 | end RadSol;
|
---|
8884 | end Solar;
|
---|
8885 | end Meteo;
|
---|
8886 |
|
---|
8887 | package Time
|
---|
8888 | extends Modelica.Icons.Package;
|
---|
8889 |
|
---|
8890 | package BaseClasses
|
---|
8891 | extends Modelica.Icons.BasesPackage;
|
---|
8892 |
|
---|
8893 | model CalendarTime
|
---|
8894 |
|
---|
8895 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8896 |
|
---|
8897 | parameter Boolean ifSolCor;
|
---|
8898 |
|
---|
8899 | Modelica.Blocks.Interfaces.RealInput timSim
|
---|
8900 | annotation (Placement(transformation(extent={{-120,20},{-80,60}})));
|
---|
8901 | Modelica.Blocks.Interfaces.RealInput delay
|
---|
8902 | annotation (Placement(transformation(extent={{-120,-60},{-80,-20}})));
|
---|
8903 | Modelica.Blocks.Interfaces.RealOutput timCal
|
---|
8904 | annotation (Placement(transformation(extent={{90,30},{110,50}})));
|
---|
8905 | Modelica.Blocks.Interfaces.RealOutput timCalSol
|
---|
8906 | annotation (Placement(transformation(extent={{90,-50},{110,-30}})));
|
---|
8907 |
|
---|
8908 | equation
|
---|
8909 | timCal = timSim;// - integer(timSim/31536000)*31536000;
|
---|
8910 |
|
---|
8911 | if ifSolCor then
|
---|
8912 | timCalSol = timSim + delay;
|
---|
8913 | else
|
---|
8914 | timCalSol = timSim;
|
---|
8915 | end if;
|
---|
8916 |
|
---|
8917 | annotation (Diagram(graphics));
|
---|
8918 | end CalendarTime;
|
---|
8919 |
|
---|
8920 | model LocalTime
|
---|
8921 |
|
---|
8922 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8923 |
|
---|
8924 | parameter Modelica.SIunits.Angle lon(displayUnit="deg") "longitude";
|
---|
8925 |
|
---|
8926 | Modelica.Blocks.Interfaces.RealInput timZon "time zone"
|
---|
8927 | annotation (Placement(transformation(extent={{-120,20},{-80,60}})));
|
---|
8928 | Modelica.Blocks.Interfaces.RealInput timSim "simulation time"
|
---|
8929 | annotation (Placement(transformation(extent={{-120,-60},{-80,-20}})));
|
---|
8930 | Modelica.Blocks.Interfaces.RealOutput timLoc "local time"
|
---|
8931 | annotation (Placement(transformation(extent={{90,-10},{110,10}})));
|
---|
8932 |
|
---|
8933 | equation
|
---|
8934 | timLoc = timSim - timZon + lon * 43200 / Modelica.Constants.pi;
|
---|
8935 |
|
---|
8936 | annotation (Diagram(graphics));
|
---|
8937 | end LocalTime;
|
---|
8938 |
|
---|
8939 | model SimulationDelay
|
---|
8940 |
|
---|
8941 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8942 |
|
---|
8943 | parameter Modelica.SIunits.Time delay;
|
---|
8944 |
|
---|
8945 | Modelica.Blocks.Interfaces.RealOutput timSim
|
---|
8946 | annotation (Placement(transformation(extent={{90,-10},{110,10}})));
|
---|
8947 |
|
---|
8948 | equation
|
---|
8949 | timSim = delay;
|
---|
8950 |
|
---|
8951 | annotation (Diagram(graphics));
|
---|
8952 | end SimulationDelay;
|
---|
8953 |
|
---|
8954 | model SimulationTime
|
---|
8955 |
|
---|
8956 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8957 |
|
---|
8958 | Modelica.Blocks.Interfaces.RealOutput timSim
|
---|
8959 | annotation (Placement(transformation(extent={{90,-10},{110,10}})));
|
---|
8960 |
|
---|
8961 | equation
|
---|
8962 | timSim = rem(time,31536000);
|
---|
8963 |
|
---|
8964 | annotation (Diagram(graphics));
|
---|
8965 | end SimulationTime;
|
---|
8966 |
|
---|
8967 | model SolarTime
|
---|
8968 |
|
---|
8969 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8970 |
|
---|
8971 | Modelica.Blocks.Interfaces.RealInput timLoc(quantity="Time", unit="s")
|
---|
8972 | annotation (Placement(transformation(extent={{-120,20},{-80,60}})));
|
---|
8973 | Modelica.Blocks.Interfaces.RealInput timSim(quantity="Time", unit="s")
|
---|
8974 | annotation (Placement(transformation(extent={{-120,-60},{-80,-20}})));
|
---|
8975 | Modelica.Blocks.Interfaces.RealOutput timSol(quantity="Time", unit="s")
|
---|
8976 | annotation (Placement(transformation(extent={{90,-10},{110,10}})));
|
---|
8977 |
|
---|
8978 | protected
|
---|
8979 | Modelica.SIunits.Angle Bt;
|
---|
8980 | Modelica.SIunits.Time delta "difference of solar time to local time";
|
---|
8981 | Modelica.SIunits.Time nDay "Zero-based day number in seconds";
|
---|
8982 |
|
---|
8983 | algorithm
|
---|
8984 | nDay := timSim;
|
---|
8985 | Bt := Modelica.Constants.pi*((nDay + 86400)/86400 - 81)/182;
|
---|
8986 | delta := 60*(9.87*sin(2*Bt) - 7.53*cos(Bt) - 1.5*sin(Bt));
|
---|
8987 | timSol := timLoc + delta;
|
---|
8988 |
|
---|
8989 | annotation (Diagram(graphics));
|
---|
8990 | end SolarTime;
|
---|
8991 |
|
---|
8992 | block TimeZone
|
---|
8993 |
|
---|
8994 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
8995 |
|
---|
8996 | parameter Modelica.SIunits.Time timZonSta "standard time zone";
|
---|
8997 | parameter Boolean DST = true;
|
---|
8998 | parameter Integer yr "depcited year";
|
---|
8999 |
|
---|
9000 | Modelica.Blocks.Interfaces.RealInput timCal "time zone"
|
---|
9001 | annotation (Placement(transformation(extent={{-120,-20},{-80,20}})));
|
---|
9002 | Modelica.Blocks.Interfaces.RealOutput timZon "calendar time"
|
---|
9003 | annotation (Placement(transformation(extent={{90,-10},{110,10}})));
|
---|
9004 |
|
---|
9005 | parameter Modelica.SIunits.Time DSTstart = 86400*(31+28+31-rem(5*yr/4+4,7))+2*3600;
|
---|
9006 | parameter Modelica.SIunits.Time DSTend = 86400*(31+28+31+30+31+30+31+31+30+31-rem(5*yr/4+1,7))+2*3600;
|
---|
9007 | // Source : http://www.webexhibits.org/daylightsaving/i.html
|
---|
9008 |
|
---|
9009 | Modelica.Blocks.Interfaces.BooleanOutput summer annotation (Placement(
|
---|
9010 | transformation(
|
---|
9011 | extent={{10,-10},{-10,10}},
|
---|
9012 | rotation=-90,
|
---|
9013 | origin={0,100})));
|
---|
9014 |
|
---|
9015 | equation
|
---|
9016 | if timCal >= DSTstart and timCal <= DSTend then
|
---|
9017 | if DST then
|
---|
9018 | timZon = timZonSta + 3600;
|
---|
9019 | summer = true;
|
---|
9020 | else
|
---|
9021 | timZon = timZonSta;
|
---|
9022 | summer = false;
|
---|
9023 | end if;
|
---|
9024 | else
|
---|
9025 | timZon = timZonSta;
|
---|
9026 | summer = false;
|
---|
9027 | end if;
|
---|
9028 |
|
---|
9029 | end TimeZone;
|
---|
9030 | end BaseClasses;
|
---|
9031 |
|
---|
9032 | block SimTimes
|
---|
9033 |
|
---|
9034 | extends Modelica.Blocks.Interfaces.BlockIcon;
|
---|
9035 |
|
---|
9036 | parameter Modelica.SIunits.Angle lon(displayUnit="deg") = 4.317
|
---|
9037 | "longitude";
|
---|
9038 | parameter Modelica.SIunits.Time delay(displayUnit="s") = 0
|
---|
9039 | "delay for solar data";
|
---|
9040 | parameter Modelica.SIunits.Time timZonSta = 3600 "standard time zone";
|
---|
9041 | parameter Boolean DST = false "take into account daylight saving time";
|
---|
9042 | parameter Integer yr = 2010 "depcited year for DST only";
|
---|
9043 | parameter Boolean ifSolCor = true;
|
---|
9044 |
|
---|
9045 | Modelica.Blocks.Interfaces.RealOutput timSol "solar time"
|
---|
9046 | annotation (Placement(transformation(extent={{90,-10},{110,10}})));
|
---|
9047 | Modelica.Blocks.Interfaces.RealOutput timCal "calendar time"
|
---|
9048 | annotation (Placement(transformation(extent={{90,-50},{110,-30}})));
|
---|
9049 | Modelica.Blocks.Interfaces.RealOutput timCalSol
|
---|
9050 | "calendar time for solar data"
|
---|
9051 | annotation (Placement(transformation(extent={{90,-90},{110,-70}})));
|
---|
9052 | Modelica.Blocks.Interfaces.RealOutput timLoc
|
---|
9053 | annotation (Placement(transformation(extent={{90,30},{110,50}})));
|
---|
9054 | Modelica.Blocks.Interfaces.BooleanOutput summer
|
---|
9055 | annotation (Placement(transformation(extent={{90,70},{110,90}})));
|
---|
9056 |
|
---|
9057 | protected
|
---|
9058 | IDEAS.Climate.Time.BaseClasses.LocalTime
|
---|
9059 | localTime(lon=lon)
|
---|
9060 | annotation (Placement(transformation(extent={{-10,-6},{10,14}})));
|
---|
9061 | IDEAS.Climate.Time.BaseClasses.SolarTime
|
---|
9062 | solarTime
|
---|
9063 | annotation (Placement(transformation(extent={{30,-10},{50,10}})));
|
---|
9064 | IDEAS.Climate.Time.BaseClasses.CalendarTime
|
---|
9065 | calendarTime(ifSolCor=ifSolCor)
|
---|
9066 | annotation (Placement(transformation(extent={{30,-54},{50,-34}})));
|
---|
9067 | IDEAS.Climate.Time.BaseClasses.SimulationTime
|
---|
9068 | simulationTime
|
---|
9069 | annotation (Placement(transformation(extent={{-90,-30},{-70,-10}})));
|
---|
9070 | IDEAS.Climate.Time.BaseClasses.SimulationDelay
|
---|
9071 | simulationDelay(delay=delay)
|
---|
9072 | annotation (Placement(transformation(extent={{-90,-58},{-70,-38}})));
|
---|
9073 | IDEAS.Climate.Time.BaseClasses.TimeZone
|
---|
9074 | timeZone(timZonSta=timZonSta, DST=DST, yr=yr)
|
---|
9075 | annotation (Placement(transformation(extent={{-50,-6},{-30,14}})));
|
---|
9076 |
|
---|
9077 | equation
|
---|
9078 | connect(localTime.timLoc, solarTime.timLoc) annotation (Line(
|
---|
9079 | points={{10,4},{30,4}},
|
---|
9080 | color={0,0,127},
|
---|
9081 | smooth=Smooth.None));
|
---|
9082 | connect(solarTime.timSol, timSol) annotation (Line(
|
---|
9083 | points={{50,0},{100,0}},
|
---|
9084 | color={0,0,127},
|
---|
9085 | smooth=Smooth.None));
|
---|
9086 | connect(calendarTime.timCal, timCal) annotation (Line(
|
---|
9087 | points={{50,-40},{100,-40}},
|
---|
9088 | color={0,0,127},
|
---|
9089 | smooth=Smooth.None));
|
---|
9090 | connect(calendarTime.timCalSol, timCalSol) annotation (Line(
|
---|
9091 | points={{50,-48},{60,-48},{60,-80},{100,-80}},
|
---|
9092 | color={0,0,127},
|
---|
9093 | smooth=Smooth.None));
|
---|
9094 | connect(simulationDelay.timSim, calendarTime.delay) annotation (Line(
|
---|
9095 | points={{-70,-48},{30,-48}},
|
---|
9096 | color={0,0,127},
|
---|
9097 | smooth=Smooth.None));
|
---|
9098 | connect(simulationTime.timSim, calendarTime.timSim) annotation (Line(
|
---|
9099 | points={{-70,-20},{-22,-20},{-22,-40},{30,-40}},
|
---|
9100 | color={0,0,127},
|
---|
9101 | smooth=Smooth.None));
|
---|
9102 | connect(simulationTime.timSim, localTime.timSim) annotation (Line(
|
---|
9103 | points={{-70,-20},{-22,-20},{-22,0},{-10,0}},
|
---|
9104 | color={0,0,127},
|
---|
9105 | smooth=Smooth.None));
|
---|
9106 | connect(simulationTime.timSim, solarTime.timSim) annotation (Line(
|
---|
9107 | points={{-70,-20},{20,-20},{20,-4},{30,-4}},
|
---|
9108 | color={0,0,127},
|
---|
9109 | smooth=Smooth.None));
|
---|
9110 | connect(timeZone.timZon, localTime.timZon) annotation (Line(
|
---|
9111 | points={{-30,4},{-22,4},{-22,8},{-10,8}},
|
---|
9112 | color={0,0,127},
|
---|
9113 | smooth=Smooth.None));
|
---|
9114 | connect(calendarTime.timCal, timeZone.timCal) annotation (Line(
|
---|
9115 | points={{50,-40},{60,-40},{60,-26},{-56,-26},{-56,4},{-50,4}},
|
---|
9116 | color={0,0,127},
|
---|
9117 | smooth=Smooth.None));
|
---|
9118 | connect(localTime.timLoc, timLoc) annotation (Line(
|
---|
9119 | points={{10,4},{20,4},{20,40},{100,40}},
|
---|
9120 | color={0,0,127},
|
---|
9121 | smooth=Smooth.None));
|
---|
9122 | connect(timeZone.summer, summer) annotation (Line(
|
---|
9123 | points={{-40,14},{-40,80},{100,80}},
|
---|
9124 | color={255,0,255},
|
---|
9125 | smooth=Smooth.None));
|
---|
9126 | annotation (
|
---|
9127 | defaultComponentName="timMan",
|
---|
9128 | Documentation(info="<html>
|
---|
9129 | <p>
|
---|
9130 | This component defines all required types of time in the simulation.
|
---|
9131 | </p>
|
---|
9132 | </html>
|
---|
9133 | ", revisions="<html>
|
---|
9134 | <ul>
|
---|
9135 | <li>
|
---|
9136 | April 6, 2011, by Ruben Baetens:<br>
|
---|
9137 | First implementation.
|
---|
9138 | </li>
|
---|
9139 | </ul>
|
---|
9140 | </html>"),Diagram(coordinateSystem(preserveAspectRatio=true,extent={{-100,-100},{100,100}}),
|
---|
9141 | graphics),
|
---|
9142 | Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}),
|
---|
9143 | graphics={Text(
|
---|
9144 | extent={{-78,48},{74,-42}},
|
---|
9145 | lineColor={0,0,0},
|
---|
9146 | textString="time")}));
|
---|
9147 | end SimTimes;
|
---|
9148 | end Time;
|
---|
9149 | end Climate;
|
---|
9150 |
|
---|
9151 | package Buildings "Transient building models and model components"
|
---|
9152 | extends Modelica.Icons.Package;
|
---|
9153 |
|
---|
9154 | package Components
|
---|
9155 | "Building components for high-order building models or component analysis"
|
---|
9156 | extends Modelica.Icons.Package;
|
---|
9157 |
|
---|
9158 | model OuterWall "Opaque building envelope construction"
|
---|
9159 |
|
---|
9160 | extends IDEAS.Buildings.Components.Interfaces.StateWall;
|
---|
9161 |
|
---|
9162 | replaceable parameter Data.Constructions.CavityWall constructionType
|
---|
9163 | constrainedby
|
---|
9164 | Data.Interfaces.Construction(
|
---|
9165 | final insulationType = insulationType, final insulationTickness = insulationThickness)
|
---|
9166 | "Type of building construction" annotation (__Dymola_choicesAllMatching = true,
|
---|
9167 | Placement(transformation(extent={{-38,72},{-34,76}})),
|
---|
9168 | Dialog(group="Construction details"));
|
---|
9169 |
|
---|
9170 | replaceable parameter Data.Insulation.Rockwool insulationType constrainedby
|
---|
9171 | Data.Interfaces.Insulation( final d= insulationThickness)
|
---|
9172 | "Type of thermal insulation" annotation (__Dymola_choicesAllMatching = true,
|
---|
9173 | Placement(transformation(extent={{-38,84},{-34,88}})),
|
---|
9174 | Dialog(group="Construction details"));
|
---|
9175 | parameter Modelica.SIunits.Length insulationThickness = 0.05
|
---|
9176 | "Thermal insulation thickness"
|
---|
9177 | annotation (Dialog(group="Construction details"));
|
---|
9178 | parameter Modelica.SIunits.Area AWall "Total wall area";
|
---|
9179 | parameter Modelica.SIunits.Angle inc
|
---|
9180 | "Inclination of the wall, i.e. 90deg denotes vertical";
|
---|
9181 | parameter Modelica.SIunits.Angle azi
|
---|
9182 | "Azimuth of the wall, i.e. 0deg denotes South";
|
---|
9183 |
|
---|
9184 | final parameter Real U_value=1/(1/8 + sum(constructionType.mats.R) + 1/25)
|
---|
9185 | "Wall U-value";
|
---|
9186 | final parameter Modelica.SIunits.Power QNom=U_value*AWall*(273.15 + 21 - sim.city.Tdes)
|
---|
9187 | "Design heat losses at reference outdoor temperature";
|
---|
9188 |
|
---|
9189 | Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a port_emb
|
---|
9190 | "port for gains by embedded active layers"
|
---|
9191 | annotation (Placement(transformation(extent={{-10,-110},{10,-90}})));
|
---|
9192 |
|
---|
9193 | //protected
|
---|
9194 | IDEAS.Climate.Meteo.Solar.RadSol radSol(
|
---|
9195 | final inc=inc,
|
---|
9196 | final azi=azi,
|
---|
9197 | final A=AWall)
|
---|
9198 | "determination of incident solar radiation on wall based on inclination and azimuth"
|
---|
9199 | annotation (Placement(transformation(extent={{-70,-40},{-50,-20}})));
|
---|
9200 | IDEAS.Buildings.Components.BaseClasses.MultiLayerOpaque layMul(
|
---|
9201 | final A=AWall,
|
---|
9202 | final inc=inc,
|
---|
9203 | final nLay = constructionType.nLay,
|
---|
9204 | final mats = constructionType.mats,
|
---|
9205 | final locGain = constructionType.locGain)
|
---|
9206 | "declaration of array of resistances and capacitances for wall simulation"
|
---|
9207 | annotation (Placement(transformation(extent={{-10,-40},{10,-20}})));
|
---|
9208 | IDEAS.Buildings.Components.BaseClasses.ExteriorConvection extCon(final A=AWall)
|
---|
9209 | "convective surface heat transimission on the exterior side of the wall"
|
---|
9210 | annotation (Placement(transformation(extent={{-20,-60},{-40,-40}})));
|
---|
9211 | IDEAS.Buildings.Components.BaseClasses.InteriorConvection intCon(final A=AWall, final inc=
|
---|
9212 | inc)
|
---|
9213 | "convective surface heat transimission on the interior side of the wall"
|
---|
9214 | annotation (Placement(transformation(extent={{20,-40},{40,-20}})));
|
---|
9215 | IDEAS.Buildings.Components.BaseClasses.ExteriorSolarAbsorption solAbs(final A=AWall)
|
---|
9216 | "determination of absorbed solar radiation by wall based on incident radiation"
|
---|
9217 | annotation (Placement(transformation(extent={{-20,-40},{-40,-20}})));
|
---|
9218 | IDEAS.Buildings.Components.BaseClasses.ExteriorHeatRadidation extRad(final A=AWall,
|
---|
9219 | inc=inc)
|
---|
9220 | "determination of radiant heat exchange with the environment and sky"
|
---|
9221 | annotation (Placement(transformation(extent={{-20,-20},{-40,0}})));
|
---|
9222 |
|
---|
9223 | equation
|
---|
9224 | connect(radSol.solDir, solAbs.solDir) annotation (Line(
|
---|
9225 | points={{-50,-24},{-40,-24}},
|
---|
9226 | color={0,0,127},
|
---|
9227 | smooth=Smooth.None));
|
---|
9228 | connect(radSol.solDif, solAbs.solDif) annotation (Line(
|
---|
9229 | points={{-50,-28},{-40,-28}},
|
---|
9230 | color={0,0,127},
|
---|
9231 | smooth=Smooth.None));
|
---|
9232 | connect(extCon.port_a, layMul.port_a) annotation (Line(
|
---|
9233 | points={{-20,-50},{-16,-50},{-16,-30},{-10,-30}},
|
---|
9234 | color={191,0,0},
|
---|
9235 | smooth=Smooth.None));
|
---|
9236 | connect(solAbs.port_a, layMul.port_a) annotation (Line(
|
---|
9237 | points={{-20,-30},{-10,-30}},
|
---|
9238 | color={191,0,0},
|
---|
9239 | smooth=Smooth.None));
|
---|
9240 | connect(extRad.port_a, layMul.port_a) annotation (Line(
|
---|
9241 | points={{-20,-10},{-16,-10},{-16,-30},{-10,-30}},
|
---|
9242 | color={191,0,0},
|
---|
9243 | smooth=Smooth.None));
|
---|
9244 | connect(layMul.port_b, intCon.port_a) annotation (Line(
|
---|
9245 | points={{10,-30},{20,-30}},
|
---|
9246 | color={191,0,0},
|
---|
9247 | smooth=Smooth.None));
|
---|
9248 | connect(layMul.iEpsSw_a, solAbs.epsSw) annotation (Line(
|
---|
9249 | points={{-10,-26},{-14,-26},{-14,-24},{-20,-24}},
|
---|
9250 | color={0,0,127},
|
---|
9251 | smooth=Smooth.None));
|
---|
9252 | connect(layMul.iEpsLw_a, extRad.epsLw) annotation (Line(
|
---|
9253 | points={{-10,-22},{-14,-22},{-14,-4},{-20,-4}},
|
---|
9254 | color={0,0,127},
|
---|
9255 | smooth=Smooth.None));
|
---|
9256 |
|
---|
9257 | connect(port_emb, layMul.port_gain) annotation (Line(
|
---|
9258 | points={{0,-100},{0,-40}},
|
---|
9259 | color={191,0,0},
|
---|
9260 | smooth=Smooth.None));
|
---|
9261 | connect(intCon.port_b, surfCon_a) annotation (Line(
|
---|
9262 | points={{40,-30},{50,-30}},
|
---|
9263 | color={191,0,0},
|
---|
9264 | smooth=Smooth.None));
|
---|
9265 | connect(layMul.port_b, surfRad_a) annotation (Line(
|
---|
9266 | points={{10,-30},{16,-30},{16,-60},{50,-60}},
|
---|
9267 | color={191,0,0},
|
---|
9268 | smooth=Smooth.None));
|
---|
9269 | connect(layMul.iEpsLw_b, iEpsLw_a) annotation (Line(
|
---|
9270 | points={{10,-22},{14,-22},{14,30},{56,30}},
|
---|
9271 | color={0,0,127},
|
---|
9272 | smooth=Smooth.None));
|
---|
9273 | connect(layMul.iEpsSw_b, iEpsSw_a) annotation (Line(
|
---|
9274 | points={{10,-26},{16,-26},{16,0},{56,0}},
|
---|
9275 | color={0,0,127},
|
---|
9276 | smooth=Smooth.None));
|
---|
9277 | connect(layMul.area, area_a) annotation (Line(
|
---|
9278 | points={{0,-20},{0,60},{56,60}},
|
---|
9279 | color={0,0,127},
|
---|
9280 | smooth=Smooth.None));
|
---|
9281 | annotation (
|
---|
9282 | Icon(coordinateSystem(preserveAspectRatio=true, extent={{-50,-100},{50,100}}),
|
---|
9283 | graphics={
|
---|
9284 | Polygon(
|
---|
9285 | points={{-50,60},{-30,60},{-30,80},{50,80},{50,100},{-50,100},{-50,60}},
|
---|
9286 | pattern=LinePattern.None,
|
---|
9287 | lineThickness=0.5,
|
---|
9288 | smooth=Smooth.None,
|
---|
9289 | fillColor={175,175,175},
|
---|
9290 | fillPattern=FillPattern.Backward),
|
---|
9291 | Rectangle(
|
---|
9292 | extent={{-30,-70},{-50,-20}},
|
---|
9293 | lineThickness=0.5,
|
---|
9294 | fillColor={175,175,175},
|
---|
9295 | fillPattern=FillPattern.Backward,
|
---|
9296 | pattern=LinePattern.None),
|
---|
9297 | Line(
|
---|
9298 | points={{-50,60},{-50,66},{-50,100},{50,100}},
|
---|
9299 | color={175,175,175},
|
---|
9300 | smooth=Smooth.None),
|
---|
9301 | Line(
|
---|
9302 | points={{-50,60},{-30,60},{-30,80},{50,80}},
|
---|
9303 | color={175,175,175},
|
---|
9304 | smooth=Smooth.None),
|
---|
9305 | Line(
|
---|
9306 | points={{-50,-20},{-30,-20},{-30,-70},{-30,-70},{52,-70}},
|
---|
9307 | color={175,175,175},
|
---|
9308 | smooth=Smooth.None),
|
---|
9309 | Line(
|
---|
9310 | points={{-50,-20},{-50,-90},{50,-90}},
|
---|
9311 | color={175,175,175},
|
---|
9312 | smooth=Smooth.None),
|
---|
9313 | Line(
|
---|
9314 | points={{-44,60},{-30,60},{-30,80},{-28,80},{50,80}},
|
---|
9315 | pattern=LinePattern.None,
|
---|
9316 | thickness=0.5,
|
---|
9317 | smooth=Smooth.None),
|
---|
9318 | Line(
|
---|
9319 | points={{-44,-20},{-30,-20},{-30,-70}},
|
---|
9320 | pattern=LinePattern.None,
|
---|
9321 | thickness=0.5,
|
---|
9322 | smooth=Smooth.None),
|
---|
9323 | Line(
|
---|
9324 | points={{-44,60},{-44,-20}},
|
---|
9325 | smooth=Smooth.None,
|
---|
9326 | color={175,175,175})}),
|
---|
9327 | Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
|
---|
9328 | 100}}), graphics),
|
---|
9329 | Documentation(info="<html>
|
---|
9330 | <p><h4><font color=\"#008000\">General description</font></h4></p>
|
---|
9331 | <p><h5>Goal</h5></p>
|
---|
9332 | <p>The <code>OuterWall.mo</code> model describes the transient behaviour of opaque builiding enelope constructions. The description of the thermal response of a wall is structured as in the 3 different occurring processes, i.e. the heat balance of the exterior surface, heat conduction between both surfaces and the heat balance of the interior surface.</p>
|
---|
9333 | <p><h5>Description</h5></p>
|
---|
9334 | <p>For the purpose of dynamic building simulation, the partial differential equation of the continuous time and space model of heat transport through a solid is most often simplified into ordinary differential equations with a finite number of parameters representing only one-dimensional heat transport through a construction layer. Within this context, the wall is modeled with lumped elements, i.e. a model where temperatures and heat fluxes are determined from a system composed of a sequence of discrete resistances and capacitances R_{n+1}, C_{n}. The number of capacitive elements $n$ used in modeling the transient thermal response of the wall denotes the order of the lumped capacitance model.</p>
|
---|
9335 | <p>The heat balance of the exterior surface is determined as Q_{net} = Q_{c} + Q_{SW} + Q_{LW,e} + Q_{LW,sky} where Q_{net} denotes the heat flow into the wall, Q_{c} denotes heat transfer by convection, Q_{SW} denotes short-wave absorption of direct and diffuse solar light, Q_{LW,e} denotes long-wave heat exchange with the environment and Q_{nLW,sky} denotes long-wave heat exchange with the sky. The exterior convective heat flow is computed as Q_{c} = 5,01.A.v_{10}^{0.85}.(T_{db}-T{s}) where A is the surface area, T_{db} is the dry-bulb exterior air temperature, T_{s} is the surface temperature and v_{10} is the wind speed in the undisturbed flow at 10 meter above the ground and where the stated correlation is valid for a v_{10} range of [0.15,7.5] meter per second <a href=\"IDEAS.Buildings.UsersGuide.References\">[Defraeye 2011]</a>. The v_{10}-dependent term denoting the exterior convective heat transfer coefficient h_{ce} is determined as max(f(v_{10}), 5.6) in order to take into account buoyancy effects at low wind speeds <a href=\"IDEAS.Buildings.UsersGuide.References\">[Jurges 1924]</a>. Longwave radiation between the surface and environment Q_{LW,e} is determined as Q_{LW,e} = sigma.e.A.( T_{s}^4 - F_{sky}.T_{sky}^4 - (1-F_{sky})T_{db}^4 ) as derived from the Stefan-Boltzmann law wherefore sigma the Stefan-Boltzmann constant <a href=\"IDEAS.Buildings.UsersGuide.References\">[Mohr 2008]</a>, e the longwave emissivity of the exterior surface, F_{sky} the radiant-interchange configuration factor between the surface and sky <a href=\"IDEAS.Buildings.UsersGuide.References\">[Hamilton 1952]</a>, and the surface and the environment respectively and T_{s} and T_{sky} are the exterior surface and sky temperature respectively. Shortwave solar irradiation absorbed by the exterior surface is determined as Q_{SW} = e_{SW}.A.E_{SW} where e_{SW} is the shortwave absorption of the surface and E_{SW} the total irradiation on the depicted surface. </p>
|
---|
9336 | <p>The heat balance of the interior surface is determined as Q_{net} = Q_{c} + Sum(Q_{SW,i}) + Sum(Q_{LW,i}) where Q_{net} denotes the heat flow into the wall, Q_{c} denotes heat transfer by convection, Q_{SW,i} denotes short-wave absorption of direct and diffuse solar light netering the interior zone through windows and Q_{LW,i} denotes long-wave heat exchange with the surounding interior surfaces. </p>
|
---|
9337 | <p>The surface heat resistances <img src=\"modelica://IDEAS/Images/equations/equation-mp9YB9Y0.png\" alt=\"R_s\"/> for the exterior and interior surface respectively are determined as 1/R_{s} = A.h_{c} where A is the surface area and where h_ {c} is the exterior and interior convective heat transfer coefficient. The interior natural convective heat transfer coefficient h_{c,i} <img src=\"modelica://IDEAS/Images/equations/equation-eZGZlJrg.png\" alt=\"h_ci\"/> is computed for each interior surface as h_{c,i} = n1.D^{n2}.(T_{a}-T_{s})^{n3} where D is the characteristic length of the surface, T_{a} is the indoor air temperature and n are correlation coefficients. These parameters {n1, n2, n3} are identical to {1.823,-0.121,0.293} for vertical surfaces <a href=\"IDEAS.Buildings.UsersGuide.References\">[Khalifa 2001]</a>, {2.175,-0.076,0.308} for horizontal surfaces wherefore the heat flux is in the same direction as the buoyancy force <a href=\"IDEAS.Buildings.UsersGuide.References\">[Khalifa 2001]</a>, and {2.72,-,0.13} for horizontal surfaces wherefore the heat flux is in the opposite direction as the buoyancy force <a href=\"IDEAS.Buildings.UsersGuide.References\">[Awbi 1999]</a>. The interior natural convective heat transfer coefficient is only described as function of the temperature difference. </p>
|
---|
9338 | <p>Similar to the thermal model for heat transfer through a wall, a thermal circuit formulation for the direct radiant exchange between surfaces can be derived <a href=\"IDEAS.Buildings.UsersGuide.References\">[Buchberg 1955, Oppenheim 1956]</a>. The resulting heat exchange by longwave radiation between two surface s_{i} and s_{j} can be described as Q_{si,sj} = sigma.A_{si}.(T_{si}^{4}-T_{sj}^{4})/((1-e_{si})/e_{si} + 1/F_{si,sj} + A_{si}/sum(A_{si}) ) as derived from the Stefan-Boltzmann law wherefore e_{si} and e_{sj} are the emissivity of surfaces s_{i} and s_{j} respectively, F_{si,sj} is radiant-interchange configuration factor <a href=\"IDEAS.Buildings.UsersGuide.References\">[Hamilton 1952]</a> between surfaces s_{i} and s_{j} , A_{i} and A_{j} are the areas of surfaces s_{i} and s_{j} respectively, sigma is the Stefan-Boltzmann constant <a href=\"IDEAS.Buildings.UsersGuide.References\">[Mohr 2008]</a> and R_{i} and T_{j} are the surface temperature of surfaces s_{i} and s_{j} respectively. The above description of longwave radiation for a room or thermal zone results in the necessity of a very detailed input, i.e. the configuration between all surfaces needs to be described by their shape, position and orientation in order to define F_{si,sj}, and difficulties to introduce windows and internal gains in the zone of interest. Simplification is achieved by means of a delta-star transformation <a href=\"IDEAS.Buildings.UsersGuide.References\">[Kenelly 1899]</a> and by definition of a (fictive) radiant star node in the zone model. Literature <a href=\"IDEAS.Buildings.UsersGuide.References\">[Liesen 1997]</a> shows that the overall model is not significantly sensitive to this assumption. The heat exchange by longwave radiation between surface <img src=\"modelica://IDEAS/Images/equations/equation-Mjd7rCtc.png\" alt=\"s_i\"/> and the radiant star node in the zone model can be described as Q_{si,sj} = sigma.A_{si}.(T_{si}^{4}-T_{sr}^{4})/((1-e_{si})/e_{si} + A_{si}/sum(A_{si}) ) = sigma where e_{si} is the emissivity of surface s_{i}, A_{si} is the area of surface s_{i}, sum(A_{si}) is the sum of areas for all surfaces s_{i} of the thermal zone, sigma is the Stefan-Boltzmann constant <a href=\"IDEAS.Buildings.UsersGuide.References\">[Mohr 2008]</a> and T_{si} and T_{sr} are the temperatures of surfaces <img src=\"modelica://IDEAS/Images/equations/equation-olgnuMEg.png\" alt=\"s_i\"/> and the radiant star node respectively. Absorption of shortwave solar radiation on the interior surface is handled equally as for the outside surface. Determination of the receiving solar radiation on the interior surface after passing through windows is dealt with in the zone model.</p>
|
---|
9339 | <p><h4><font color=\"#008000\">Validation </font></h4></p>
|
---|
9340 | <p>By means of the <code>BESTEST.mo</code> examples in the <code>Validation.mo</code> package.</p>
|
---|
9341 | </html>"));
|
---|
9342 | end OuterWall;
|
---|
9343 |
|
---|
9344 | package Interfaces "Building component interfaces"
|
---|
9345 | extends Modelica.Icons.InterfacesPackage;
|
---|
9346 |
|
---|
9347 | partial model StateWall
|
---|
9348 | "Partial model for building envelope components"
|
---|
9349 |
|
---|
9350 | Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a surfCon_a
|
---|
9351 | "Convective surface node"
|
---|
9352 | annotation (Placement(transformation(extent={{40,-40},{60,-20}})));
|
---|
9353 | Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_b surfRad_a
|
---|
9354 | "Radiative surface node"
|
---|
9355 | annotation (Placement(transformation(extent={{40,-70},{60,-50}})));
|
---|
9356 | Modelica.Blocks.Interfaces.RealOutput iEpsLw_a
|
---|
9357 | "Longwave emissivity for radiative heat losses"
|
---|
9358 | annotation (Placement(transformation(extent={{46,20},{66,40}})));
|
---|
9359 | Modelica.Blocks.Interfaces.RealOutput iEpsSw_a
|
---|
9360 | "Shortwave emissivity for solar gain distribution"
|
---|
9361 | annotation (Placement(transformation(extent={{46,-10},{66,10}})));
|
---|
9362 | Modelica.Blocks.Interfaces.RealOutput area_a
|
---|
9363 | "Total interior surface area of the wall" annotation (Placement(
|
---|
9364 | transformation(
|
---|
9365 | extent={{-10,-10},{10,10}},
|
---|
9366 | rotation=0,
|
---|
9367 | origin={56,60})));
|
---|
9368 | inner outer IDEAS.SimInfoManager sim
|
---|
9369 | "Simulation information manager for climate data"
|
---|
9370 | annotation (Placement(transformation(extent={{30,-100},{50,-80}})));
|
---|
9371 | annotation (
|
---|
9372 | Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
|
---|
9373 | 100}}), graphics),
|
---|
9374 | Icon(coordinateSystem(preserveAspectRatio=true, extent={{-50,-100},{50,100}}),
|
---|
9375 | graphics));
|
---|
9376 |
|
---|
9377 | end StateWall;
|
---|
9378 | end Interfaces;
|
---|
9379 |
|
---|
9380 | package BaseClasses
|
---|
9381 | extends Modelica.Icons.BasesPackage;
|
---|
9382 |
|
---|
9383 | model MonoLayerOpaque "single material layer"
|
---|
9384 |
|
---|
9385 | parameter Modelica.SIunits.Area A "Layer area";
|
---|
9386 | parameter IDEAS.Buildings.Data.Interfaces.Material mat
|
---|
9387 | "Layer material";
|
---|
9388 | parameter Modelica.SIunits.Angle inc "Inclination";
|
---|
9389 |
|
---|
9390 | parameter Modelica.SIunits.Temperature TStart = 289.15
|
---|
9391 | "Start temperature for each of the states";
|
---|
9392 |
|
---|
9393 | final parameter Integer nSta = mat.nSta;
|
---|
9394 | final parameter Integer nFlo = mat.nSta + 1;
|
---|
9395 | final parameter Real R = mat.R "Total specific thermal resistance";
|
---|
9396 | final parameter Modelica.SIunits.ThermalConductance G=(A*mat.k*nSta)/mat.d;
|
---|
9397 | final parameter Modelica.SIunits.HeatCapacity C=(A*mat.rho*mat.c*mat.d)/nSta;
|
---|
9398 |
|
---|
9399 | public
|
---|
9400 | Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a port_a(T(start=TStart))
|
---|
9401 | annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
|
---|
9402 | Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_b port_b(T(start=TStart))
|
---|
9403 | annotation (Placement(transformation(extent={{90,-10},{110,10}})));
|
---|
9404 | Modelica.SIunits.Temperature[nSta] T(start=ones(nSta)*TStart)
|
---|
9405 | "Temperature at the states";
|
---|
9406 | Modelica.SIunits.HeatFlowRate[nFlo] Q_flow
|
---|
9407 | "Heat flow rate from state i to i+1";
|
---|
9408 |
|
---|
9409 | equation
|
---|
9410 | // connectors
|
---|
9411 | port_a.Q_flow = +Q_flow[1];
|
---|
9412 | port_b.Q_flow = -Q_flow[nFlo];
|
---|
9413 |
|
---|
9414 | // edge resistances
|
---|
9415 | port_a.T - T[1] = Q_flow[1]/(G*2);
|
---|
9416 | T[nSta] - port_b.T = Q_flow[nSta + 1]/(G*2);
|
---|
9417 |
|
---|
9418 | // Q_flow[i] is heat flowing from (i-1) to (i)
|
---|
9419 | for i in 2:nSta loop
|
---|
9420 | T[i - 1] - T[i] = Q_flow[i]/G;
|
---|
9421 | end for;
|
---|
9422 |
|
---|
9423 | // Heat storages in the masses
|
---|
9424 | for i in 1:nSta loop
|
---|
9425 | der(T[i]) = (Q_flow[i] - Q_flow[i + 1])/C;
|
---|
9426 | end for;
|
---|
9427 |
|
---|
9428 | annotation (
|
---|
9429 | Diagram(graphics),
|
---|
9430 | Icon(graphics={
|
---|
9431 | Rectangle(
|
---|
9432 | extent={{-90,80},{90,-80}},
|
---|
9433 | fillColor={192,192,192},
|
---|
9434 | fillPattern=FillPattern.Backward,
|
---|
9435 | pattern=LinePattern.None),
|
---|
9436 | Text(
|
---|
9437 | extent={{-150,113},{150,73}},
|
---|
9438 | textString="%name",
|
---|
9439 | lineColor={0,0,255}),
|
---|
9440 | Ellipse(
|
---|
9441 | extent={{-40,-42},{40,38}},
|
---|
9442 | lineColor={127,0,0},
|
---|
9443 | fillColor={255,255,255},
|
---|
9444 | fillPattern=FillPattern.Solid),
|
---|
9445 | Text(
|
---|
9446 | extent={{-39,40},{39,-40}},
|
---|
9447 | lineColor={127,0,0},
|
---|
9448 | fontName="Calibri",
|
---|
9449 | origin={0,-1},
|
---|
9450 | rotation=90,
|
---|
9451 | textString="S")}),
|
---|
9452 | Documentation(info="<html>
|
---|
9453 | <p>For the purpose of dynamic building simulation, the partial differential equation of the continuous time and space model of heat transport through a solid is most often simplified into ordinary differential equations with a finite number of parameters representing only one-dimensional heat transport through a construction layer. Within this context, the wall is modeled with lumped elements, i.e. a model where temperatures and heat fluxes are determined from a system composed of a sequence of discrete resistances and capacitances R_{n+1}, C_{n}. The number of capacitive elements $n$ used in modeling the transient thermal response of the wall denotes the order of the lumped capacitance model.</p>
|
---|
9454 | <p align=\"center\"><img src=\"modelica://IDEAS/Images/equations/equation-pqp0E04K.png\"/></p>
|
---|
9455 | <p>where <img src=\"modelica://IDEAS/Images/equations/equation-I7KXJhSH.png\"/> is the added energy to the lumped capacity, <img src=\"modelica://IDEAS/Images/equations/equation-B0HPmGTu.png\"/> is the temperature of the lumped capacity, <img src=\"modelica://IDEAS/Images/equations/equation-t7aqbnLB.png\"/> is the thermal capacity of the lumped capacity equal to<img src=\"modelica://IDEAS/Images/equations/equation-JieDs0oi.png\"/> for which rho denotes the density and <img src=\"modelica://IDEAS/Images/equations/equation-ml5CM4zK.png\"/> is the specific heat capacity of the material and <img src=\"modelica://IDEAS/Images/equations/equation-hOGNA6h5.png\"/> the equivalent thickness of the lumped element, where <img src=\"modelica://IDEAS/Images/equations/equation-1pDREAb7.png\"/> the heat flux through the lumped resistance and <img src=\"modelica://IDEAS/Images/equations/equation-XYf3O3hw.png\"/> is the total thermal resistance of the lumped resistance and where <img src=\"modelica://IDEAS/Images/equations/equation-dgS5sGAN.png\"/> are internal thermal source.</p>
|
---|
9456 | </html>"));
|
---|
9457 | end MonoLayerOpaque;
|
---|
9458 |
|
---|
9459 | model MultiLayerOpaque "multiple material layers in series"
|
---|
9460 |
|
---|
9461 | parameter Modelica.SIunits.Area A "total multilayer area";
|
---|
9462 | parameter Modelica.SIunits.Angle inc "inclination";
|
---|
9463 | parameter Integer nLay(min=1) "number of layers";
|
---|
9464 | parameter IDEAS.Buildings.Data.Interfaces.Material[nLay] mats
|
---|
9465 | "array of layer materials";
|
---|
9466 | parameter Integer locGain(min=1) "location of the internal gain";
|
---|
9467 |
|
---|
9468 | parameter Modelica.SIunits.Temperature[nLay] TStart = ones(nLay)*289.15
|
---|
9469 | "Start temperature for each of the layers";
|
---|
9470 |
|
---|
9471 | IDEAS.Buildings.Components.BaseClasses.MonoLayerOpaque[nLay] nMat(
|
---|
9472 | each final A=A,
|
---|
9473 | each final inc=inc,
|
---|
9474 | final TStart = TStart,
|
---|
9475 | final mat=mats) "layers";
|
---|
9476 |
|
---|
9477 | final parameter Real R=sum(nMat.R)
|
---|
9478 | "total specific thermal resistance";
|
---|
9479 |
|
---|
9480 | Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a port_gain
|
---|
9481 | "port for gains by embedded active layers"
|
---|
9482 | annotation (Placement(transformation(extent={{-10,-110},{10,-90}})));
|
---|
9483 | Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a port_a(T(start=289.15))
|
---|
9484 | annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
|
---|
9485 | Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_b port_b(T(start=289.15))
|
---|
9486 | annotation (Placement(transformation(extent={{90,-10},{110,10}})));
|
---|
9487 | Modelica.Blocks.Interfaces.RealOutput iEpsLw_b
|
---|
9488 | "output of the interior emissivity for radiative heat losses"
|
---|
9489 | annotation (Placement(transformation(extent={{90,70},{110,90}})));
|
---|
9490 | Modelica.Blocks.Interfaces.RealOutput iEpsSw_b
|
---|
9491 | "output of the interior emissivity for radiative heat losses"
|
---|
9492 | annotation (Placement(transformation(extent={{90,30},{110,50}})));
|
---|
9493 | Modelica.Blocks.Interfaces.RealOutput iEpsLw_a
|
---|
9494 | "output of the interior emissivity for radiative heat losses"
|
---|
9495 | annotation (Placement(transformation(extent={{-90,70},{-110,90}})));
|
---|
9496 | Modelica.Blocks.Interfaces.RealOutput iEpsSw_a
|
---|
9497 | "output of the interior emissivity for radiative heat losses"
|
---|
9498 | annotation (Placement(transformation(extent={{-90,30},{-110,50}})));
|
---|
9499 | Modelica.Blocks.Interfaces.RealOutput area=A
|
---|
9500 | "output of the interior emissivity for radiative heat losses" annotation (
|
---|
9501 | Placement(transformation(
|
---|
9502 | extent={{10,-10},{-10,10}},
|
---|
9503 | rotation=-90,
|
---|
9504 | origin={0,100})));
|
---|
9505 | equation
|
---|
9506 | connect(port_a, nMat[1].port_a);
|
---|
9507 |
|
---|
9508 | for j in 1:nLay - 1 loop
|
---|
9509 | connect(nMat[j].port_b, nMat[j + 1].port_a);
|
---|
9510 | end for;
|
---|
9511 |
|
---|
9512 | connect(nMat[locGain].port_b, port_gain);
|
---|
9513 | connect(port_b, nMat[nLay].port_b);
|
---|
9514 |
|
---|
9515 | iEpsLw_a = mats[1].epsLw;
|
---|
9516 | iEpsSw_a = mats[1].epsSw;
|
---|
9517 | iEpsLw_b = mats[nLay].epsLw;
|
---|
9518 | iEpsSw_b = mats[nLay].epsSw;
|
---|
9519 |
|
---|
9520 | annotation (
|
---|
9521 | Diagram(graphics),
|
---|
9522 | Icon(graphics={
|
---|
9523 | Rectangle(
|
---|
9524 | extent={{-90,80},{20,-80}},
|
---|
9525 | fillColor={192,192,192},
|
---|
9526 | fillPattern=FillPattern.Backward,
|
---|
9527 | pattern=LinePattern.None),
|
---|
9528 | Text(
|
---|
9529 | extent={{-150,113},{150,73}},
|
---|
9530 | textString="%name",
|
---|
9531 | lineColor={0,0,255}),
|
---|
9532 | Rectangle(
|
---|
9533 | extent={{20,80},{40,-80}},
|
---|
9534 | fillColor={192,192,192},
|
---|
9535 | fillPattern=FillPattern.Forward,
|
---|
9536 | pattern=LinePattern.None,
|
---|
9537 | lineColor={0,0,0}),
|
---|
9538 | Rectangle(
|
---|
9539 | extent={{40,80},{80,-80}},
|
---|
9540 | fillColor={192,192,192},
|
---|
9541 | fillPattern=FillPattern.Backward,
|
---|
9542 | pattern=LinePattern.None),
|
---|
9543 | Line(
|
---|
9544 | points={{20,80},{20,-80}},
|
---|
9545 | pattern=LinePattern.None,
|
---|
9546 | smooth=Smooth.None),
|
---|
9547 | Line(
|
---|
9548 | points={{40,80},{40,-80}},
|
---|
9549 | pattern=LinePattern.None,
|
---|
9550 | smooth=Smooth.None),
|
---|
9551 | Ellipse(
|
---|
9552 | extent={{-40,-42},{40,38}},
|
---|
9553 | lineColor={127,0,0},
|
---|
9554 | fillColor={255,255,255},
|
---|
9555 | fillPattern=FillPattern.Solid),
|
---|
9556 | Text(
|
---|
9557 | extent={{-39,40},{39,-40}},
|
---|
9558 | lineColor={127,0,0},
|
---|
9559 | fontName="Calibri",
|
---|
9560 | origin={0,-1},
|
---|
9561 | rotation=90,
|
---|
9562 | textString="S")}),
|
---|
9563 | Documentation(info="<html>
|
---|
9564 | <p>For the purpose of dynamic building simulation, the partial differential equation of the continuous time and space model of heat transport through a solid is most often simplified into ordinary differential equations with a finite number of parameters representing only one-dimensional heat transport through a construction layer. Within this context, the wall is modeled with lumped elements, i.e. a model where temperatures and heat fluxes are determined from a system composed of a sequence of discrete resistances and capacitances R_{n+1}, C_{n}. The number of capacitive elements $n$ used in modeling the transient thermal response of the wall denotes the order of the lumped capacitance model.</p>
|
---|
9565 | <p align=\"center\"><img src=\"modelica://IDEAS/Images/equations/equation-pqp0E04K.png\"/></p>
|
---|
9566 | <p>where <img src=\"modelica://IDEAS/Images/equations/equation-I7KXJhSH.png\"/> is the added energy to the lumped capacity, <img src=\"modelica://IDEAS/Images/equations/equation-B0HPmGTu.png\"/> is the temperature of the lumped capacity, <img src=\"modelica://IDEAS/Images/equations/equation-t7aqbnLB.png\"/> is the thermal capacity of the lumped capacity equal to<img src=\"modelica://IDEAS/Images/equations/equation-JieDs0oi.png\"/> for which rho denotes the density and <img src=\"modelica://IDEAS/Images/equations/equation-ml5CM4zK.png\"/> is the specific heat capacity of the material and <img src=\"modelica://IDEAS/Images/equations/equation-hOGNA6h5.png\"/> the equivalent thickness of the lumped element, where <img src=\"modelica://IDEAS/Images/equations/equation-1pDREAb7.png\"/> the heat flux through the lumped resistance and <img src=\"modelica://IDEAS/Images/equations/equation-XYf3O3hw.png\"/> is the total thermal resistance of the lumped resistance and where <img src=\"modelica://IDEAS/Images/equations/equation-dgS5sGAN.png\"/> are internal thermal source.</p>
|
---|
9567 | </html>"));
|
---|
9568 | end MultiLayerOpaque;
|
---|
9569 |
|
---|
9570 | model InteriorConvection "interior surface convection"
|
---|
9571 |
|
---|
9572 | parameter Modelica.SIunits.Area A "surface area";
|
---|
9573 | parameter Modelica.SIunits.Angle inc "inclination";
|
---|
9574 |
|
---|
9575 | Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a port_a(T(start=289.15))
|
---|
9576 | annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
|
---|
9577 | Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_b port_b(T(start=289.15))
|
---|
9578 | annotation (Placement(transformation(extent={{90,-10},{110,10}})));
|
---|
9579 | Real hcon;
|
---|
9580 |
|
---|
9581 | protected
|
---|
9582 | Modelica.SIunits.TemperatureDifference dT;
|
---|
9583 | final parameter Boolean Ceiling=abs(sin(inc)) < 10E-5 and cos(inc) > 0
|
---|
9584 | "true if ceiling";
|
---|
9585 | final parameter Boolean Floor=abs(sin(inc)) < 10E-5 and cos(inc) < 0
|
---|
9586 | "true if floor";
|
---|
9587 |
|
---|
9588 | equation
|
---|
9589 | if Ceiling then
|
---|
9590 | port_a.Q_flow = if noEvent(dT > 0) then A*2.72*abs(dT)^1.13 else -A*2.27*
|
---|
9591 | abs(dT)^1.24;
|
---|
9592 | elseif Floor then
|
---|
9593 | port_a.Q_flow = if noEvent(dT > 0) then A*2.27*abs(dT)^1.24 else -A*2.72*
|
---|
9594 | abs(dT)^1.13;
|
---|
9595 | else
|
---|
9596 | port_a.Q_flow = A*sign(dT)*2.07*abs(dT)^1.23;
|
---|
9597 | end if;
|
---|
9598 |
|
---|
9599 | port_a.Q_flow + port_b.Q_flow = 0 "no heat is stored";
|
---|
9600 | dT = port_a.T - port_b.T;
|
---|
9601 | hcon = port_a.Q_flow/dT;
|
---|
9602 |
|
---|
9603 | annotation (Icon(graphics={
|
---|
9604 | Rectangle(
|
---|
9605 | extent={{-90,80},{-60,-80}},
|
---|
9606 | fillColor={192,192,192},
|
---|
9607 | fillPattern=FillPattern.Backward,
|
---|
9608 | pattern=LinePattern.None),
|
---|
9609 | Line(points={{-60,20},{76,20}}, color={191,0,0}),
|
---|
9610 | Line(points={{-34,80},{-34,-80}}, color={0,127,255}),
|
---|
9611 | Line(points={{-60,-20},{76,-20}}, color={191,0,0}),
|
---|
9612 | Line(points={{56,30},{76,20}}, color={191,0,0}),
|
---|
9613 | Line(points={{56,10},{76,20}}, color={191,0,0}),
|
---|
9614 | Line(points={{56,-10},{76,-20}}, color={191,0,0}),
|
---|
9615 | Line(points={{56,-30},{76,-20}}, color={191,0,0}),
|
---|
9616 | Line(points={{6,80},{6,-80}}, color={0,127,255}),
|
---|
9617 | Line(points={{40,80},{40,-80}}, color={0,127,255}),
|
---|
9618 | Line(points={{76,80},{76,-80}}, color={0,127,255}),
|
---|
9619 | Line(points={{-34,-80},{-44,-60}}, color={0,127,255}),
|
---|
9620 | Line(points={{-34,-80},{-24,-60}}, color={0,127,255}),
|
---|
9621 | Line(points={{6,-80},{-4,-60}}, color={0,127,255}),
|
---|
9622 | Line(points={{6,-80},{16,-60}}, color={0,127,255}),
|
---|
9623 | Line(points={{40,-80},{30,-60}}, color={0,127,255}),
|
---|
9624 | Line(points={{40,-80},{50,-60}}, color={0,127,255}),
|
---|
9625 | Line(points={{76,-80},{66,-60}}, color={0,127,255}),
|
---|
9626 | Line(points={{76,-80},{86,-60}}, color={0,127,255}),
|
---|
9627 | Text(
|
---|
9628 | extent={{-150,-90},{150,-130}},
|
---|
9629 | textString="%name",
|
---|
9630 | lineColor={0,0,255}),
|
---|
9631 | Line(
|
---|
9632 | points={{-60,80},{-60,-80}},
|
---|
9633 | color={0,0,0},
|
---|
9634 | thickness=0.5)}), Documentation(info="<html>
|
---|
9635 | <p>The interior natural convective heat transfer coefficient <img src=\"modelica://IDEAS/Images/equations/equation-eZGZlJrg.png\"/> is computed for each interior surface as </p>
|
---|
9636 | <p align=\"center\"><img src=\"modelica://IDEAS/Images/equations/equation-KNBSKUDK.png\"/></p>
|
---|
9637 | <p>where <img src=\"modelica://IDEAS/Images/equations/equation-W5kvS3SS.png\"/> is the characteristic length of the surface, <img src=\"modelica://IDEAS/Images/equations/equation-jhC1rqax.png\"/> is the indoor air temperature and <img src=\"modelica://IDEAS/Images/equations/equation-sbXAgHuQ.png\"/> are correlation coefficients. These parameters {<img src=\"modelica://IDEAS/Images/equations/equation-nHmmePq5.png\"/>,<img src=\"modelica://IDEAS/Images/equations/equation-zJZmNUzp.png\"/>,<img src=\"modelica://IDEAS/Images/equations/equation-7nwXbcLp.png\"/>} are identical to {1.823,-0.121,0.293} for vertical surfaces <a href=\"IDEAS.Buildings.UsersGuide.References\">[Khalifa 2001]</a>, {2.175,-0.076,0.308} for horizontal surfaces wherefore the heat flux is in the same direction as the buoyancy force <a href=\"IDEAS.Buildings.UsersGuide.References\">[Khalifa 2001]</a>, and {2.72,-,0.13} for horizontal surfaces wherefore the heat flux is in the opposite direction as the buoyancy force <a href=\"IDEAS.Buildings.UsersGuide.References\">[Awbi 1999]</a>. The interior natural convective heat transfer coefficient is only described as function of the temperature difference. Similar to the thermal model for heat transfer through a wall, a thermal circuit formulation for the direct radiant exchange between surfaces can be derived <a href=\"IDEAS.Buildings.UsersGuide.References\">[ Buchberg 1955, Oppenheim 1956]</a>.</p>
|
---|
9638 | </html>"));
|
---|
9639 | end InteriorConvection;
|
---|
9640 |
|
---|
9641 | model ExteriorConvection "exterior surface convection"
|
---|
9642 |
|
---|
9643 | parameter Modelica.SIunits.Area A "surface area";
|
---|
9644 |
|
---|
9645 | Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a port_a(T(start=289.15))
|
---|
9646 | annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
|
---|
9647 | outer IDEAS.SimInfoManager sim "Simulation information manager"
|
---|
9648 | annotation (Placement(transformation(extent={{-100,80},{-80,100}})));
|
---|
9649 |
|
---|
9650 | Real hcon "equivalent surface conductance";
|
---|
9651 |
|
---|
9652 | equation
|
---|
9653 | if noEvent(sim.Va <= 5) then
|
---|
9654 | hcon = 4.0*sim.Va + 5.6;
|
---|
9655 | else
|
---|
9656 | hcon = 7.1*abs(sim.Va)^(0.78);
|
---|
9657 | end if;
|
---|
9658 |
|
---|
9659 | port_a.Q_flow = hcon*A*(port_a.T - sim.Te);
|
---|
9660 |
|
---|
9661 | annotation (Icon(graphics={
|
---|
9662 | Rectangle(
|
---|
9663 | extent={{-90,80},{-60,-80}},
|
---|
9664 | fillColor={192,192,192},
|
---|
9665 | fillPattern=FillPattern.Backward,
|
---|
9666 | pattern=LinePattern.None),
|
---|
9667 | Line(points={{-60,20},{76,20}}, color={191,0,0}),
|
---|
9668 | Line(points={{-34,80},{-34,-80}}, color={0,127,255}),
|
---|
9669 | Line(points={{-60,-20},{76,-20}}, color={191,0,0}),
|
---|
9670 | Line(points={{56,30},{76,20}}, color={191,0,0}),
|
---|
9671 | Line(points={{56,10},{76,20}}, color={191,0,0}),
|
---|
9672 | Line(points={{56,-10},{76,-20}}, color={191,0,0}),
|
---|
9673 | Line(points={{56,-30},{76,-20}}, color={191,0,0}),
|
---|
9674 | Line(points={{6,80},{6,-80}}, color={0,127,255}),
|
---|
9675 | Line(points={{40,80},{40,-80}}, color={0,127,255}),
|
---|
9676 | Line(points={{76,80},{76,-80}}, color={0,127,255}),
|
---|
9677 | Line(points={{-34,-80},{-44,-60}}, color={0,127,255}),
|
---|
9678 | Line(points={{-34,-80},{-24,-60}}, color={0,127,255}),
|
---|
9679 | Line(points={{6,-80},{-4,-60}}, color={0,127,255}),
|
---|
9680 | Line(points={{6,-80},{16,-60}}, color={0,127,255}),
|
---|
9681 | Line(points={{40,-80},{30,-60}}, color={0,127,255}),
|
---|
9682 | Line(points={{40,-80},{50,-60}}, color={0,127,255}),
|
---|
9683 | Line(points={{76,-80},{66,-60}}, color={0,127,255}),
|
---|
9684 | Line(points={{76,-80},{86,-60}}, color={0,127,255}),
|
---|
9685 | Text(
|
---|
9686 | extent={{-150,-90},{150,-130}},
|
---|
9687 | textString="%name",
|
---|
9688 | lineColor={0,0,255}),
|
---|
9689 | Line(
|
---|
9690 | points={{-60,80},{-60,-80}},
|
---|
9691 | color={0,0,0},
|
---|
9692 | thickness=0.5)}), Documentation(info="<html>
|
---|
9693 | <p>The exterior convective heat flow is computed as </p>
|
---|
9694 | <p align=\"center\"><img src=\"modelica://IDEAS/Images/equations/equation-dlroqBUD.png\"/></p>
|
---|
9695 | <p>where <img src=\"modelica://IDEAS/Images/equations/equation-pvb42RGk.png\"/> is the surface area, <img src=\"modelica://IDEAS/Images/equations/equation-EFr6uClx.png\"/> is the dry-bulb exterior air temperature, <img src=\"modelica://IDEAS/Images/equations/equation-9BU57cj4.png\"/> is the surface temperature and <img src=\"modelica://IDEAS/Images/equations/equation-HvwkeunV.png\"/> is the wind speed in the undisturbed flow at 10 meter above the ground and where the stated correlation is valid for a <img src=\"modelica://IDEAS/Images/equations/equation-HvwkeunV.png\"/> range of [0.15,7.5] meter per second <a href=\"IDEAS.Buildings.UsersGuide.References\">[Defraeye 2011]</a>. The <img src=\"modelica://IDEAS/Images/equations/equation-HvwkeunV.png\"/>-dependent term denoting the exterior convective heat transfer coefficient <img src=\"modelica://IDEAS/Images/equations/equation-W7Ft8vaa.png\"/> is determined as <img src=\"modelica://IDEAS/Images/equations/equation-aZcbMNkz.png\"/> in order to take into account buoyancy effects at low wind speeds <a href=\"IDEAS.Buildings.UsersGuide.References\">[Jurges 1924]</a>.</p>
|
---|
9696 | </html>"));
|
---|
9697 | end ExteriorConvection;
|
---|
9698 |
|
---|
9699 | model ExteriorSolarAbsorption
|
---|
9700 | "shortwave radiation absorption on an exterior surface"
|
---|
9701 |
|
---|
9702 | parameter Modelica.SIunits.Area A "surface area";
|
---|
9703 |
|
---|
9704 | Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a port_a(T(start=289.15))
|
---|
9705 | annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
|
---|
9706 | Modelica.Blocks.Interfaces.RealInput solDir
|
---|
9707 | "direct solar illuminance on surface se"
|
---|
9708 | annotation (Placement(transformation(extent={{120,40},{80,80}})));
|
---|
9709 | Modelica.Blocks.Interfaces.RealInput solDif
|
---|
9710 | "diffuse solar illuminance on surface s"
|
---|
9711 | annotation (Placement(transformation(extent={{120,0},{80,40}})));
|
---|
9712 | Modelica.Blocks.Interfaces.RealInput epsSw
|
---|
9713 | "shortwave emissivity of the surface"
|
---|
9714 | annotation (Placement(transformation(extent={{-120,40},{-80,80}})));
|
---|
9715 | equation
|
---|
9716 | port_a.Q_flow = -(solDir + solDif)*epsSw;
|
---|
9717 |
|
---|
9718 | annotation (Icon(graphics={
|
---|
9719 | Rectangle(
|
---|
9720 | extent={{-90,80},{-60,-80}},
|
---|
9721 | fillColor={192,192,192},
|
---|
9722 | fillPattern=FillPattern.Backward,
|
---|
9723 | pattern=LinePattern.None),
|
---|
9724 | Line(
|
---|
9725 | points={{-60,80},{-60,-80}},
|
---|
9726 | color={0,0,0},
|
---|
9727 | thickness=0.5),
|
---|
9728 | Line(points={{-40,10},{40,10}}, color={191,0,0}),
|
---|
9729 | Line(points={{-40,10},{-30,16}}, color={191,0,0}),
|
---|
9730 | Line(points={{-40,10},{-30,4}}, color={191,0,0}),
|
---|
9731 | Line(points={{-40,-10},{40,-10}}, color={191,0,0}),
|
---|
9732 | Line(points={{-40,-30},{40,-30}}, color={191,0,0}),
|
---|
9733 | Line(points={{-40,-30},{-30,-24}}, color={191,0,0}),
|
---|
9734 | Line(points={{-40,-30},{-30,-36}}, color={191,0,0}),
|
---|
9735 | Line(points={{-40,30},{40,30}}, color={191,0,0}),
|
---|
9736 | Line(points={{-40,30},{-30,36}}, color={191,0,0}),
|
---|
9737 | Line(points={{-40,30},{-30,24}},color={191,0,0}),
|
---|
9738 | Line(points={{-40,-10},{-30,-4}},color={191,0,0}),
|
---|
9739 | Line(points={{-40,-10},{-30,-16}}, color={191,0,0})}), Documentation(
|
---|
9740 | info="<html>
|
---|
9741 | <p>Transmitted shortwave solar radiation is distributed over all surfaces in the zone in a prescribed scale. This scale is an input value which may be dependent on the shape of the zone and the location of the windows, but literature <a href=\"IDEAS.Buildings.UsersGuide.References\">[Liesen 1997]</a> shows that the overall model is not significantly sensitive to this assumption.</p>
|
---|
9742 | </html>"));
|
---|
9743 | end ExteriorSolarAbsorption;
|
---|
9744 |
|
---|
9745 | model ExteriorHeatRadidation
|
---|
9746 | "longwave radiative heat exchange of an exterior surface with the environment"
|
---|
9747 |
|
---|
9748 | parameter Modelica.SIunits.Area A "surface area";
|
---|
9749 | parameter Modelica.SIunits.Angle inc "inclination";
|
---|
9750 |
|
---|
9751 | Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a port_a(T(start=289.15))
|
---|
9752 | annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
|
---|
9753 | outer IDEAS.SimInfoManager sim "Simulation information manager"
|
---|
9754 | annotation (Placement(transformation(extent={{-100,80},{-80,100}})));
|
---|
9755 |
|
---|
9756 | protected
|
---|
9757 | Real Fse=(1 - cos(inc))/2
|
---|
9758 | "radiant-interchange configuration factor between surface and environment";
|
---|
9759 | Real Fssky=(1 + cos(inc))/2
|
---|
9760 | "radiant-interchange configuration factor between surface and sky";
|
---|
9761 | Modelica.SIunits.Temperature Tenv
|
---|
9762 | "Radiative temperature of the total environment";
|
---|
9763 |
|
---|
9764 | public
|
---|
9765 | Modelica.Blocks.Interfaces.RealInput epsLw
|
---|
9766 | "shortwave emissivity of the surface"
|
---|
9767 | annotation (Placement(transformation(extent={{-120,40},{-80,80}})));
|
---|
9768 | equation
|
---|
9769 |
|
---|
9770 | Tenv = (Fssky*sim.Tsky^4 + (1 - Fssky)*sim.Te^4)^0.25;
|
---|
9771 | port_a.Q_flow = A*Modelica.Constants.sigma*epsLw*(port_a.T - Tenv)*(port_a.T
|
---|
9772 | + Tenv)*(port_a.T^2 + Tenv^2);
|
---|
9773 |
|
---|
9774 | annotation (Icon(graphics={
|
---|
9775 | Line(points={{-40,10},{40,10}}, color={191,0,0}),
|
---|
9776 | Line(points={{-40,10},{-30,16}}, color={191,0,0}),
|
---|
9777 | Line(points={{-40,10},{-30,4}}, color={191,0,0}),
|
---|
9778 | Line(points={{-40,-10},{40,-10}}, color={191,0,0}),
|
---|
9779 | Line(points={{30,-16},{40,-10}}, color={191,0,0}),
|
---|
9780 | Line(points={{30,-4},{40,-10}}, color={191,0,0}),
|
---|
9781 | Line(points={{-40,-30},{40,-30}}, color={191,0,0}),
|
---|
9782 | Line(points={{-40,-30},{-30,-24}}, color={191,0,0}),
|
---|
9783 | Line(points={{-40,-30},{-30,-36}}, color={191,0,0}),
|
---|
9784 | Line(points={{-40,30},{40,30}}, color={191,0,0}),
|
---|
9785 | Line(points={{30,24},{40,30}}, color={191,0,0}),
|
---|
9786 | Line(points={{30,36},{40,30}}, color={191,0,0}),
|
---|
9787 | Rectangle(
|
---|
9788 | extent={{-90,80},{-60,-80}},
|
---|
9789 | fillColor={192,192,192},
|
---|
9790 | fillPattern=FillPattern.Backward,
|
---|
9791 | pattern=LinePattern.None),
|
---|
9792 | Line(
|
---|
9793 | points={{-60,80},{-60,-80}},
|
---|
9794 | color={0,0,0},
|
---|
9795 | thickness=0.5),
|
---|
9796 | Rectangle(
|
---|
9797 | extent={{90,80},{60,-80}},
|
---|
9798 | fillColor={192,192,192},
|
---|
9799 | fillPattern=FillPattern.Backward,
|
---|
9800 | pattern=LinePattern.None),
|
---|
9801 | Line(
|
---|
9802 | points={{60,80},{60,-80}},
|
---|
9803 | color={0,0,0},
|
---|
9804 | thickness=0.5)}), Documentation(info="<html>
|
---|
9805 | <p>Longwave radiation between the surface and environment <img src=\"modelica://IDEAS/Images/equations/equation-AMjoTx5S.png\"/> is determined as</p>
|
---|
9806 | <p align=\"center\"><img src=\"modelica://IDEAS/Images/equations/equation-nt0agyic.png\"/></p>
|
---|
9807 | <p>as derived from the Stefan-Boltzmann law wherefore <img src=\"modelica://IDEAS/Images/equations/equation-C6ZFvd5P.png\"/> the Stefan-Boltzmann constant <a href=\"IDEAS.Buildings.UsersGuide.References\">[Mohr 2008]</a>, <img src=\"modelica://IDEAS/Images/equations/equation-sLNH0zgx.png\"/> the longwave emissivity of the exterior surface, <img src=\"modelica://IDEAS/Images/equations/equation-Q5X4Yht9.png\"/> the radiant-interchange configuration factor between the surface and sky <a href=\"IDEAS.Buildings.UsersGuide.References\">[Hamilton 1952]</a>, and the surface and the environment respectively and <img src=\"modelica://IDEAS/Images/equations/equation-k2V39u5g.png\"/> and <img src=\"modelica://IDEAS/Images/equations/equation-GuSnzLxW.png\"/> are the exterior surface and sky temperature respectively. Shortwave solar irradiation absorbed by the exterior surface is determined as </p>
|
---|
9808 | <p align=\"center\"><img src=\"modelica://IDEAS/Images/equations/equation-cISf3Itz.png\"/></p>
|
---|
9809 | <p>where <img src=\"modelica://IDEAS/Images/equations/equation-IKuIUMef.png\"/> is the shortwave absorption of the surface and <img src=\"modelica://IDEAS/Images/equations/equation-Vuo4fgcb.png\"/> the total irradiation on the depicted surface. </p>
|
---|
9810 | </html>"));
|
---|
9811 | end ExteriorHeatRadidation;
|
---|
9812 | end BaseClasses;
|
---|
9813 | end Components;
|
---|
9814 |
|
---|
9815 | package Data "Data for transient thermal building simulation"
|
---|
9816 | extends Modelica.Icons.MaterialPropertiesPackage;
|
---|
9817 |
|
---|
9818 | package Insulation "Library of thermal insulation materials"
|
---|
9819 | extends Modelica.Icons.MaterialPropertiesPackage;
|
---|
9820 |
|
---|
9821 | record Rockwool = IDEAS.Buildings.Data.Interfaces.Insulation (
|
---|
9822 | final k=0.036,
|
---|
9823 | final c=840,
|
---|
9824 | final rho=110,
|
---|
9825 | final epsLw=0.8,
|
---|
9826 | final epsSw=0.8) "Rockwool";
|
---|
9827 | end Insulation;
|
---|
9828 |
|
---|
9829 | package Materials "Library of construction materials"
|
---|
9830 | extends Modelica.Icons.MaterialPropertiesPackage;
|
---|
9831 |
|
---|
9832 | record BrickMe = IDEAS.Buildings.Data.Interfaces.Material (
|
---|
9833 | k=0.75,
|
---|
9834 | c=840,
|
---|
9835 | rho=1400,
|
---|
9836 | epsLw=0.88,
|
---|
9837 | epsSw=0.55) "Medium masonry for exterior applications ";
|
---|
9838 |
|
---|
9839 | record BrickMi = IDEAS.Buildings.Data.Interfaces.Material (
|
---|
9840 | k=0.54,
|
---|
9841 | c=840,
|
---|
9842 | rho=1400,
|
---|
9843 | epsLw=0.88,
|
---|
9844 | epsSw=0.55) "Medium masonry for interior applications ";
|
---|
9845 |
|
---|
9846 | record Gypsum = IDEAS.Buildings.Data.Interfaces.Material (
|
---|
9847 | k=0.6,
|
---|
9848 | c=840,
|
---|
9849 | rho=975,
|
---|
9850 | epsLw=0.85,
|
---|
9851 | epsSw=0.65) "Gypsum plaster for finishing";
|
---|
9852 | end Materials;
|
---|
9853 |
|
---|
9854 | package Constructions "Library of building envelope constructions"
|
---|
9855 | extends Modelica.Icons.MaterialPropertiesPackage;
|
---|
9856 |
|
---|
9857 | model CavityWall
|
---|
9858 | "Example - Classic cavity wall construction with fully-filled cavity"
|
---|
9859 |
|
---|
9860 | extends IDEAS.Buildings.Data.Interfaces.Construction(
|
---|
9861 | nLay=4,
|
---|
9862 | locGain=2,
|
---|
9863 | final mats={Materials.BrickMe(d=0.08),insulationType,Materials.BrickMi(d=0.14),Materials.Gypsum(d=0.015)});
|
---|
9864 |
|
---|
9865 | end CavityWall;
|
---|
9866 | end Constructions;
|
---|
9867 |
|
---|
9868 | package Interfaces "Building data interfaces"
|
---|
9869 | extends Modelica.Icons.InterfacesPackage;
|
---|
9870 |
|
---|
9871 | record Material "Properties of building materials"
|
---|
9872 |
|
---|
9873 | extends Modelica.Icons.MaterialProperty;
|
---|
9874 |
|
---|
9875 | parameter Modelica.SIunits.Length d = 0 "Layer thickness";
|
---|
9876 | parameter Modelica.SIunits.ThermalConductivity k
|
---|
9877 | "Thermal conductivity";
|
---|
9878 | parameter Modelica.SIunits.SpecificHeatCapacity c
|
---|
9879 | "Specific thermal capacity";
|
---|
9880 | parameter Modelica.SIunits.Density rho "Density";
|
---|
9881 | parameter Modelica.SIunits.Emissivity epsLw = 0.85
|
---|
9882 | "Longwave emisivity";
|
---|
9883 | parameter Modelica.SIunits.Emissivity epsSw = 0.85
|
---|
9884 | "Shortwave emissivity";
|
---|
9885 | parameter Boolean gas = false "Boolean wether the material is a gas";
|
---|
9886 | parameter Real mhu(unit="m2/s") = 0
|
---|
9887 | "Viscosity, i.e. if the material is a fluid";
|
---|
9888 | final parameter Real R = d/k;
|
---|
9889 |
|
---|
9890 | parameter Modelica.SIunits.Emissivity epsLw_a = 0.84
|
---|
9891 | "Longwave emisivity";
|
---|
9892 | parameter Modelica.SIunits.Emissivity epsLw_b = 0.84
|
---|
9893 | "Longwave emisivity";
|
---|
9894 |
|
---|
9895 | final parameter Modelica.SIunits.ThermalDiffusivity alpha = k/(c*rho)
|
---|
9896 | "Thermal diffusivity";
|
---|
9897 | final parameter Integer nStaRef = 3
|
---|
9898 | "Number of states of a reference case, ie. 20 cm dense concrete";
|
---|
9899 | final parameter Real piRef = 224
|
---|
9900 | "d/sqrt(mat.alpha) of a reference case, ie. 20 cm dense concrete";
|
---|
9901 | final parameter Real piLay = d/sqrt(alpha)
|
---|
9902 | "d/sqrt(mat.alpha) of the depicted layer";
|
---|
9903 | final parameter Integer nSta(min=1) = max(1, integer(ceil(nStaRef*piLay/piRef)))
|
---|
9904 | "Actual number of state variables in material";
|
---|
9905 |
|
---|
9906 | annotation (Documentation(info="<html>
|
---|
9907 | <p><h4><font color=\"#008000\">General description</font></h4></p>
|
---|
9908 | <p><h5>Goal</h5></p>
|
---|
9909 | <p>The <code>Material.mo</code> partial describes the material data required for building construction modelling.</p>
|
---|
9910 | <p><h5>Assumptions and limitations</h5></p>
|
---|
9911 | <p><ol>
|
---|
9912 | <li>Current number of states in the material layer is determined by a reference number of states in a 20cm concrete slab.</li>
|
---|
9913 | </ol></p>
|
---|
9914 | <p><h4><font color=\"#008000\">Validation </font></h4></p>
|
---|
9915 | <p>No validation required.</p>
|
---|
9916 | </html>"));
|
---|
9917 | end Material;
|
---|
9918 |
|
---|
9919 | record Insulation
|
---|
9920 |
|
---|
9921 | extends IDEAS.Buildings.Data.Interfaces.Material;
|
---|
9922 |
|
---|
9923 | end Insulation;
|
---|
9924 |
|
---|
9925 | model Construction
|
---|
9926 |
|
---|
9927 | extends Modelica.Icons.MaterialProperty;
|
---|
9928 |
|
---|
9929 | parameter Integer nLay(min=1)
|
---|
9930 | "Number of layers of the construction, including gaps";
|
---|
9931 | parameter Integer locGain(min=1) = 1
|
---|
9932 | "Location of possible embedded system";
|
---|
9933 | replaceable parameter IDEAS.Buildings.Data.Interfaces.Insulation insulationType(final d=insulationTickness) constrainedby
|
---|
9934 | IDEAS.Buildings.Data.Interfaces.Insulation
|
---|
9935 | "Type of thermal insulation";
|
---|
9936 | parameter IDEAS.Buildings.Data.Interfaces.Material[nLay] mats
|
---|
9937 | "Array of materials";
|
---|
9938 | parameter Modelica.SIunits.Length insulationTickness = 0
|
---|
9939 | "Thermal insulation thickness";
|
---|
9940 |
|
---|
9941 | annotation (Documentation(info="<html>
|
---|
9942 | <p><h4><font color=\"#008000\">General description</font></h4></p>
|
---|
9943 | <p><h5>Goal</h5></p>
|
---|
9944 | <p>The <code>Construction.mo</code> partial describes the material data required for building construction modelling.</p>
|
---|
9945 | <p><h4><font color=\"#008000\">Validation </font></h4></p>
|
---|
9946 | <p>No validation required.</p>
|
---|
9947 | </html>"));
|
---|
9948 | end Construction;
|
---|
9949 | end Interfaces;
|
---|
9950 | end Data;
|
---|
9951 | end Buildings;
|
---|
9952 |
|
---|
9953 | package Occupants "Building occupant models"
|
---|
9954 | extends Modelica.Icons.Package;
|
---|
9955 |
|
---|
9956 | package Extern
|
---|
9957 | extends Modelica.Icons.Package;
|
---|
9958 |
|
---|
9959 | package Interfaces
|
---|
9960 | extends Modelica.Icons.InterfacesPackage;
|
---|
9961 |
|
---|
9962 | model Occ_Files "Dummy file reader for occupant model"
|
---|
9963 | parameter Integer nOcc = 1 "Number of occupant data sets to be read" annotation(Dialog(group = "Building occupants"));
|
---|
9964 | parameter String filPres = "User_zeros.txt"
|
---|
9965 | "Filename for occupancy presence" annotation(Dialog(group = "Building occupants"));
|
---|
9966 | parameter String filQCon = "User_zeros.txt"
|
---|
9967 | "Filename for occupancy-driven convective gains" annotation(Dialog(group = "Building occupants"));
|
---|
9968 | parameter String filQRad = "User_zeros.txt"
|
---|
9969 | "Filename for occupancy-driven radiative gains" annotation(Dialog(group = "Building occupants"));
|
---|
9970 | parameter String filP = "User_zeros.txt"
|
---|
9971 | "Filename for occupancy-driven active power load" annotation(Dialog(group = "Building occupants"));
|
---|
9972 | parameter String filQ = "User_zeros.txt"
|
---|
9973 | "Filename for occupancy-driven reactive power load" annotation(Dialog(group = "Building occupants"));
|
---|
9974 | parameter String filDHW = "User_zeros.txt"
|
---|
9975 | "Filename for occupancy-driven domestic hot water redrawal" annotation(Dialog(group = "Building occupants"));
|
---|
9976 | end Occ_Files;
|
---|
9977 | end Interfaces;
|
---|
9978 | end Extern;
|
---|
9979 | end Occupants;
|
---|
9980 |
|
---|
9981 | package BaseClasses "Base classes for IDEAS"
|
---|
9982 | extends Modelica.Icons.BasesPackage;
|
---|
9983 |
|
---|
9984 | package Math "General mathematical stuff"
|
---|
9985 | extends Modelica.Icons.Package;
|
---|
9986 |
|
---|
9987 | function MaxSmooth
|
---|
9988 |
|
---|
9989 | input Real u1 "first argument for maximum";
|
---|
9990 | input Real u2 "second argument for maximum";
|
---|
9991 | input Real delta "width of the transition interval";
|
---|
9992 | output Real y "smooth maximum result";
|
---|
9993 |
|
---|
9994 | algorithm
|
---|
9995 | y := Modelica.Media.Air.MoistAir.Utilities.spliceFunction(pos= u1, neg= u2, x= u1-u2, deltax= delta);
|
---|
9996 |
|
---|
9997 | end MaxSmooth;
|
---|
9998 |
|
---|
9999 | function MinSmooth
|
---|
10000 |
|
---|
10001 | input Real u1 "first argument for maximum";
|
---|
10002 | input Real u2 "second argument for maximum";
|
---|
10003 | input Real delta "width of the transition interval";
|
---|
10004 | output Real y "smooth maximum result";
|
---|
10005 |
|
---|
10006 | algorithm
|
---|
10007 | y := Modelica.Media.Air.MoistAir.Utilities.spliceFunction(pos= u1, neg= u2, x= u2-u1, deltax= delta);
|
---|
10008 |
|
---|
10009 | end MinSmooth;
|
---|
10010 | end Math;
|
---|
10011 | end BaseClasses;
|
---|
10012 | annotation (uses(Modelica(version="3.2")), Icon(graphics),
|
---|
10013 | version="2",
|
---|
10014 | conversion(noneFromVersion="", noneFromVersion="1"),
|
---|
10015 | Documentation(info="<html>
|
---|
10016 | <p>Licensed by KU Leuven and 3E under the Modelica License 2 </p>
|
---|
10017 | <p>Copyright © 2013-2023, KU Leuven and 3E. </p>
|
---|
10018 | <p> </p>
|
---|
10019 | <p><i>This Modelica package is <u>free</u> software and the use is completely at <u>your own risk</u>;</i> <i>it can be redistributed and/or modified under the terms of the Modelica License 2. </i></p>
|
---|
10020 | <p><i>For license conditions (including the disclaimer of warranty) see <a href=\"UrlBlockedError.aspx\">Modelica.UsersGuide.ModelicaLicense2</a> or visit <a href=\"https://www.modelica.org/licenses/ModelicaLicense2\">https://www.modelica.org/licenses/ModelicaLicense2</a>.</i> </p>
|
---|
10021 | </html>"));
|
---|
10022 |
|
---|
10023 | model TEST
|
---|
10024 |
|
---|
10025 | inner SimInfoManager sim
|
---|
10026 | annotation (Placement(transformation(extent={{-100,80},{-80,100}})));
|
---|
10027 | Buildings.Components.OuterWall outerWall(
|
---|
10028 | redeclare final parameter IDEAS.Buildings.Data.Constructions.CavityWall constructionType,
|
---|
10029 | redeclare final parameter IDEAS.Buildings.Data.Insulation.Rockwool insulationType,
|
---|
10030 | final AWall=1,
|
---|
10031 | final insulationThickness=0.05,
|
---|
10032 | final inc=1.5707963267949,
|
---|
10033 | final azi=1.5707963267949)
|
---|
10034 | annotation (Placement(transformation(extent={{-76,40},{-66,60}})));
|
---|
10035 | Modelica.Thermal.HeatTransfer.Sources.FixedTemperature fixedTemperature(T=293.15)
|
---|
10036 | annotation (Placement(transformation(extent={{-18,38},{-38,58}})));
|
---|
10037 | Modelica.Thermal.HeatTransfer.Sources.FixedTemperature fixedTemperature1(T=294.15)
|
---|
10038 | annotation (Placement(transformation(extent={{-18,6},{-38,26}})));
|
---|
10039 | Modelica.Thermal.HeatTransfer.Sources.FixedHeatFlow fixedHeatFlow(Q_flow=0)
|
---|
10040 | annotation (Placement(transformation(
|
---|
10041 | extent={{-10,-10},{10,10}},
|
---|
10042 | rotation=90,
|
---|
10043 | origin={-74,8})));
|
---|
10044 | equation
|
---|
10045 | connect(outerWall.surfCon_a, fixedTemperature.port) annotation (Line(
|
---|
10046 | points={{-66,47},{-52,47},{-52,48},{-38,48}},
|
---|
10047 | color={191,0,0},
|
---|
10048 | smooth=Smooth.None));
|
---|
10049 | connect(outerWall.surfRad_a, fixedTemperature1.port) annotation (Line(
|
---|
10050 | points={{-66,44},{-52,44},{-52,16},{-38,16}},
|
---|
10051 | color={191,0,0},
|
---|
10052 | smooth=Smooth.None));
|
---|
10053 | connect(fixedHeatFlow.port, outerWall.port_emb) annotation (Line(
|
---|
10054 | points={{-74,18},{-72,18},{-72,40},{-71,40}},
|
---|
10055 | color={191,0,0},
|
---|
10056 | smooth=Smooth.None));
|
---|
10057 | annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
|
---|
10058 | -100},{100,100}}), graphics));
|
---|
10059 | end TEST;
|
---|
10060 | end IDEAS;
|
---|
10061 | model IDEAS_TEST
|
---|
10062 | extends IDEAS.TEST;
|
---|
10063 | annotation(experiment(
|
---|
10064 | StopTime=1,
|
---|
10065 | __Dymola_NumberOfIntervals=500,
|
---|
10066 | Tolerance=0.0001,
|
---|
10067 | __Dymola_Algorithm="dassl"),uses(IDEAS(version="2")));
|
---|
10068 | end IDEAS_TEST;
|
---|