root/branches/maintenance/3.0/Modelica/Blocks/Tables.mo

Revision 1041, 29.7 kB (checked in by otter, 10 months ago)

Added 'annotation(Library="ModelicaExternalC")' to all 'external "C"' functions, as decided at the last design meeting.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1within Modelica.Blocks;
2
3
4package Tables
5  "Library of blocks to interpolate in one and two-dimensional tables"
6  extends Modelica.Icons.Library;
7  model CombiTable1D
8    "Table look-up in one dimension (matrix/file) with n inputs and n outputs "
9    import Modelica.Blocks.Types;
10    parameter Boolean tableOnFile=false
11      "true, if table is defined on file or in function usertab" 
12      annotation(Dialog(group="table data definition"));
13    parameter Real table[:, :]=fill(0.0,0,2)
14      "table matrix (grid = first column; e.g., table=[0,2])" 
15         annotation(Dialog(group="table data definition", enable = not tableOnFile));
16    parameter String tableName="NoName"
17      "table name on file or in function usertab (see docu)" 
18         annotation(Dialog(group="table data definition", enable = tableOnFile));
19    parameter String fileName="NoName" "file where matrix is stored" 
20         annotation(Dialog(group="table data definition", enable = tableOnFile,
21                           __Dymola_loadSelector(filter="Text files (*.txt);;Matlab files (*.mat)",
22                           caption="Open file in which table is present")));
23    parameter Integer columns[:]=2:size(table, 2)
24      "columns of table to be interpolated" 
25    annotation(Dialog(group="table data interpretation"));
26    parameter Modelica.Blocks.Types.Smoothness smoothness=Types.Smoothness.LinearSegments
27      "smoothness of table interpolation" 
28    annotation(Dialog(group="table data interpretation"));
29    extends Modelica.Blocks.Interfaces.MIMOs(final n=size(columns, 1));
30    annotation (
31      Documentation(info="<html>
32<p>
33<b>Linear interpolation</b> in <b>one</b> dimension of a <b>table</b>.
34Via parameter <b>columns</b> it can be defined how many columns of the
35table are interpolated. If, e.g., columns={2,4}, it is assumed that 2 input
36and 2 output signals are present and that the first output interpolates
37the first input via column 2 and the second output interpolates the
38second input via column 4 of the table matrix.
39</p>
40<p>
41The grid points and function values are stored in a matrix \"table[i,j]\",
42where the first column \"table[:,1]\" contains the grid points and the
43other columns contain the data to be interpolated. Example:
44</p>
45<pre>
46   table = [0,  0;
47            1,  1;
48            2,  4;
49            4, 16]
50   If, e.g., the input u = 1.0, the output y =  1.0,
51       e.g., the input u = 1.5, the output y =  2.5,
52       e.g., the input u = 2.0, the output y =  4.0,
53       e.g., the input u =-1.0, the output y = -1.0 (i.e. extrapolation).
54</pre>
55<ul>
56<li> The interpolation is <b>efficient</b>, because a search for a new interpolation
57     starts at the interval used in the last call.</li>
58<li> If the table has only <b>one row</b>, the table value is returned,
59     independent of the value of the input signal.</li>
60<li> If the input signal <b>u[i]</b> is <b>outside</b> of the defined <b>interval</b>, i.e.,
61     u[i] &gt; table[size(table,1),i+1] or u[i] &lt; table[1,1], the corresponding
62     value is also determined by linear
63     interpolation through the last or first two points of the table.</li>
64<li> The grid values (first column) have to be <b>strict</b>
65     monotonically increasing.</li>
66</ul>
67<p>
68The table matrix can be defined in the following ways:
69</p>
70<ol>
71<li> Explicitly supplied as <b>parameter matrix</b> \"table\",
72     and the other parameters have the following values:
73<pre>
74   tableName is \"NoName\" or has only blanks,
75   fileName  is \"NoName\" or has only blanks.
76</pre></li>
77<li> <b>Read</b> from a <b>file</b> \"fileName\" where the matrix is stored as
78      \"tableName\". Both ASCII and binary file format is possible.
79      (the ASCII format is described below).
80      It is most convenient to generate the binary file from Matlab
81      (Matlab 4 storage format), e.g., by command
82<pre>
83   save tables.mat tab1 tab2 tab3 -V4
84</pre>
85      when the three tables tab1, tab2, tab3 should be
86      used from the model.</li>
87<li>  Statically stored in function \"usertab\" in file \"usertab.c\".
88      The matrix is identified by \"tableName\". Parameter
89      fileName = \"NoName\" or has only blanks.</li>
90</ol>
91<p>
92Table definition methods (1) and (3) do <b>not</b> allocate dynamic memory,
93and do not access files, whereas method (2) does. Therefore (1) and (3)
94are suited for hardware-in-the-loop simulation (e.g. with dSpace hardware).
95When the constant \"NO_FILE\" is defined in \"usertab.c\", all parts of the
96source code of method (2) are removed by the C-preprocessor, such that
97no dynamic memory allocation and no access to files takes place.
98</p>
99<p>
100If tables are read from an ASCII-file, the file need to have the
101following structure (\"-----\" is not part of the file content):
102</p>
103<pre>
104-----------------------------------------------------
105#1
106double tab1(5,2)   # comment line
107  0   0
108  1   1
109  2   4
110  3   9
111  4  16
112double tab2(5,2)   # another comment line
113  0   0
114  2   2
115  4   8
116  6  18
117  8  32
118-----------------------------------------------------
119</pre>
120<p>
121Note, that the first two characters in the file need to be
122\"#1\". Afterwards, the corresponding matrix has to be declared
123with type, name and actual dimensions. Finally, in successive
124rows of the file, the elements of the matrix have to be given.
125Several matrices may be defined one after another.
126</p>
127</HTML>
128"),   Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
129              100}}), graphics={
130          Line(points={{-60,40},{-60,-40},{60,-40},{60,40},{30,40},{30,-40},{-30,
131                -40},{-30,40},{-60,40},{-60,20},{60,20},{60,0},{-60,0},{-60,-20},
132                {60,-20},{60,-40},{-60,-40},{-60,40},{60,40},{60,-40}}, color={
133                0,0,0}),
134          Line(points={{0,40},{0,-40}}, color={0,0,0}),
135          Rectangle(
136            extent={{-60,40},{-30,20}},
137            lineColor={0,0,0},
138            fillColor={255,255,0},
139            fillPattern=FillPattern.Solid),
140          Rectangle(
141            extent={{-60,20},{-30,0}},
142            lineColor={0,0,0},
143            fillColor={255,255,0},
144            fillPattern=FillPattern.Solid),
145          Rectangle(
146            extent={{-60,0},{-30,-20}},
147            lineColor={0,0,0},
148            fillColor={255,255,0},
149            fillPattern=FillPattern.Solid),
150          Rectangle(
151            extent={{-60,-20},{-30,-40}},
152            lineColor={0,0,0},
153            fillColor={255,255,0},
154            fillPattern=FillPattern.Solid)}),
155      Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
156              100,100}}), graphics={
157          Rectangle(
158            extent={{-60,60},{60,-60}},
159            fillColor={235,235,235},
160            fillPattern=FillPattern.Solid,
161            lineColor={0,0,255}),
162          Line(points={{-100,0},{-58,0}}, color={0,0,255}),
163          Line(points={{60,0},{100,0}}, color={0,0,255}),
164          Text(
165            extent={{-100,100},{100,64}},
166            textString="1 dimensional linear table interpolation",
167            lineColor={0,0,255}),
168          Line(points={{-54,40},{-54,-40},{54,-40},{54,40},{28,40},{28,-40},{-28,
169                -40},{-28,40},{-54,40},{-54,20},{54,20},{54,0},{-54,0},{-54,-20},
170                {54,-20},{54,-40},{-54,-40},{-54,40},{54,40},{54,-40}}, color={
171                0,0,0}),
172          Line(points={{0,40},{0,-40}}, color={0,0,0}),
173          Rectangle(
174            extent={{-54,40},{-28,20}},
175            lineColor={0,0,0},
176            fillColor={255,255,0},
177            fillPattern=FillPattern.Solid),
178          Rectangle(
179            extent={{-54,20},{-28,0}},
180            lineColor={0,0,0},
181            fillColor={255,255,0},
182            fillPattern=FillPattern.Solid),
183          Rectangle(
184            extent={{-54,0},{-28,-20}},
185            lineColor={0,0,0},
186            fillColor={255,255,0},
187            fillPattern=FillPattern.Solid),
188          Rectangle(
189            extent={{-54,-20},{-28,-40}},
190            lineColor={0,0,0},
191            fillColor={255,255,0},
192            fillPattern=FillPattern.Solid),
193          Text(
194            extent={{-50,54},{-32,42}},
195            textString="u[1]/[2]",
196            lineColor={0,0,255}),
197          Text(
198            extent={{-24,54},{0,42}},
199            textString="y[1]",
200            lineColor={0,0,255}),
201          Text(
202            extent={{-2,-40},{30,-54}},
203            textString="columns",
204            lineColor={0,0,255}),
205          Text(
206            extent={{2,54},{26,42}},
207            textString="y[2]",
208            lineColor={0,0,255})}));
209
210  protected
211    Integer tableID;
212
213    function tableInit
214      input String tableName;
215      input String fileName;
216      input Real table[ :, :];
217      input Modelica.Blocks.Types.Smoothness smoothness;
218      output Integer tableID;
219    external "C" tableID = ModelicaTables_CombiTable1D_init(
220                   tableName, fileName, table, size(table, 1), size(table, 2),
221                   smoothness);
222      annotation(Library="ModelicaExternalC");
223    end tableInit;
224
225    function tableIpo
226      input Integer tableID;
227      input Integer icol;
228      input Real u;
229      output Real value;
230    external "C" value = 
231                       ModelicaTables_CombiTable1D_interpolate(tableID, icol, u);
232      annotation(Library="ModelicaExternalC");
233    end tableIpo;
234  equation
235    if tableOnFile then
236      assert(tableName<>"NoName", "tableOnFile = true and no table name given");
237    end if;
238    if not tableOnFile then
239      assert(size(table,1) > 0 and size(table,2) > 0, "tableOnFile = false and parameter table is an empty matrix");
240    end if;
241
242    for i in 1:n loop
243      y[i] = if not tableOnFile and size(table,1)==1 then 
244               table[1, columns[i]] else tableIpo(tableID, columns[i], u[i]);
245    end for;
246    when initial() then
247      tableID=tableInit(if tableOnFile then tableName else "NoName",
248                        if tableOnFile then fileName else "NoName", table, smoothness);
249    end when;
250  end CombiTable1D;
251
252  model CombiTable1Ds
253    "Table look-up in one dimension (matrix/file) with one input and n outputs"
254
255    import Modelica.Blocks.Types;
256    parameter Boolean tableOnFile=false
257      "true, if table is defined on file or in function usertab" 
258      annotation(Dialog(group="table data definition"));
259    parameter Real table[:, :]=fill(0.0,0,2)
260      "table matrix (grid = first column; e.g., table=[0,2])" 
261         annotation(Dialog(group="table data definition", enable = not tableOnFile));
262    parameter String tableName="NoName"
263      "table name on file or in function usertab (see docu)" 
264         annotation(Dialog(group="table data definition", enable = tableOnFile));
265    parameter String fileName="NoName" "file where matrix is stored" 
266         annotation(Dialog(group="table data definition", enable = tableOnFile,
267                           __Dymola_loadSelector(filter="Text files (*.txt);;Matlab files (*.mat)",
268                           caption="Open file in which table is present")));
269    parameter Integer columns[:]=2:size(table, 2)
270      "columns of table to be interpolated" 
271    annotation(Dialog(group="table data interpretation"));
272    parameter Modelica.Blocks.Types.Smoothness smoothness=Types.Smoothness.LinearSegments
273      "smoothness of table interpolation" 
274    annotation(Dialog(group="table data interpretation"));
275    extends Modelica.Blocks.Interfaces.SIMO(final nout=size(columns, 1));
276    annotation (
277      Documentation(info="<html>
278<p>
279<b>Linear interpolation</b> in <b>one</b> dimension of a <b>table</b>.
280Via parameter <b>columns</b> it can be defined how many columns of the
281table are interpolated. If, e.g., icol={2,4}, it is assumed that one input
282and 2 output signals are present and that the first output interpolates
283via column 2 and the second output interpolates via column 4 of the
284table matrix.
285</p>
286<p>
287The grid points and function values are stored in a matrix \"table[i,j]\",
288where the first column \"table[:,1]\" contains the grid points and the
289other columns contain the data to be interpolated. Example:
290</p>
291<pre>
292   table = [0,  0;
293            1,  1;
294            2,  4;
295            4, 16]
296   If, e.g., the input u = 1.0, the output y =  1.0,
297       e.g., the input u = 1.5, the output y =  2.5,
298       e.g., the input u = 2.0, the output y =  4.0,
299       e.g., the input u =-1.0, the output y = -1.0 (i.e. extrapolation).
300</pre>
301<ul>
302<li> The interpolation is <b>efficient</b>, because a search for a new interpolation
303     starts at the interval used in the last call.</li>
304<li> If the table has only <b>one row</b>, the table value is returned,
305     independent of the value of the input signal.</li>
306<li> If the input signal <b>u</b> is <b>outside</b> of the defined <b>interval</b>, i.e.,
307     u &gt; table[size(table,1),1] or u &lt; table[1,1], the corresponding
308     value is also determined by linear
309     interpolation through the last or first two points of the table.</li>
310<li> The grid values (first column) have to be <b>strict</b>
311     monotonically increasing.</li>
312</ul>
313<p>
314The table matrix can be defined in the following ways:
315</p>
316<ol>
317<li> Explicitly supplied as <b>parameter matrix</b> \"table\",
318     and the other parameters have the following values:
319<pre>
320   tableName is \"NoName\" or has only blanks,
321   fileName  is \"NoName\" or has only blanks.
322</pre></li>
323<li> <b>Read</b> from a <b>file</b> \"fileName\" where the matrix is stored as
324      \"tableName\". Both ASCII and binary file format is possible.
325      (the ASCII format is described below).
326      It is most convenient to generate the binary file from Matlab
327      (Matlab 4 storage format), e.g., by command
328<pre>
329   save tables.mat tab1 tab2 tab3 -V4
330</pre>
331      when the three tables tab1, tab2, tab3 should be
332      used from the model.</li>
333<li>  Statically stored in function \"usertab\" in file \"usertab.c\".
334      The matrix is identified by \"tableName\". Parameter
335      fileName = \"NoName\" or has only blanks.</li>
336</ol>
337<p>
338Table definition methods (1) and (3) do <b>not</b> allocate dynamic memory,
339and do not access files, whereas method (2) does. Therefore (1) and (3)
340are suited for hardware-in-the-loop simulation (e.g. with dSpace hardware).
341When the constant \"NO_FILE\" is defined, all parts of the
342source code of method (2) are removed by the C-preprocessor, such that
343no dynamic memory allocation and no access to files takes place.
344</p>
345<p>
346If tables are read from an ASCII-file, the file need to have the
347following structure (\"-----\" is not part of the file content):
348</p>
349<pre>
350-----------------------------------------------------
351#1
352double tab1(5,2)   # comment line
353  0   0
354  1   1
355  2   4
356  3   9
357  4  16
358double tab2(5,2)   # another comment line
359  0   0
360  2   2
361  4   8
362  6  18
363  8  32
364-----------------------------------------------------
365</pre>
366<p>
367Note, that the first two characters in the file need to be
368\"#1\". Afterwards, the corresponding matrix has to be declared
369with type, name and actual dimensions. Finally, in successive
370rows of the file, the elements of the matrix have to be given.
371Several matrices may be defined one after another.
372</p>
373</HTML>
374"),   Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
375              100}}), graphics={
376          Line(points={{-60,40},{-60,-40},{60,-40},{60,40},{30,40},{30,-40},{-30,
377                -40},{-30,40},{-60,40},{-60,20},{60,20},{60,0},{-60,0},{-60,-20},
378                {60,-20},{60,-40},{-60,-40},{-60,40},{60,40},{60,-40}}, color={
379                0,0,0}),
380          Line(points={{0,40},{0,-40}}, color={0,0,0}),
381          Rectangle(
382            extent={{-60,40},{-30,20}},
383            lineColor={0,0,0},
384            fillColor={255,255,0},
385            fillPattern=FillPattern.Solid),
386          Rectangle(
387            extent={{-60,20},{-30,0}},
388            lineColor={0,0,0},
389            fillColor={255,255,0},
390            fillPattern=FillPattern.Solid),
391          Rectangle(
392            extent={{-60,0},{-30,-20}},
393            lineColor={0,0,0},
394            fillColor={255,255,0},
395            fillPattern=FillPattern.Solid),
396          Rectangle(
397            extent={{-60,-20},{-30,-40}},
398            lineColor={0,0,0},
399            fillColor={255,255,0},
400            fillPattern=FillPattern.Solid)}),
401      Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
402              100,100}}), graphics={
403          Rectangle(
404            extent={{-60,60},{60,-60}},
405            fillColor={235,235,235},
406            fillPattern=FillPattern.Solid,
407            lineColor={0,0,255}),
408          Line(points={{-100,0},{-58,0}}, color={0,0,255}),
409          Line(points={{60,0},{100,0}}, color={0,0,255}),
410          Text(
411            extent={{-100,100},{100,64}},
412            textString="1 dimensional linear table interpolation",
413            lineColor={0,0,255}),
414          Line(points={{-54,40},{-54,-40},{54,-40},{54,40},{28,40},{28,-40},{-28,
415                -40},{-28,40},{-54,40},{-54,20},{54,20},{54,0},{-54,0},{-54,-20},
416                {54,-20},{54,-40},{-54,-40},{-54,40},{54,40},{54,-40}}, color={
417                0,0,0}),
418          Line(points={{0,40},{0,-40}}, color={0,0,0}),
419          Rectangle(
420            extent={{-54,40},{-28,20}},
421            lineColor={0,0,0},
422            fillColor={255,255,0},
423            fillPattern=FillPattern.Solid),
424          Rectangle(
425            extent={{-54,20},{-28,0}},
426            lineColor={0,0,0},
427            fillColor={255,255,0},
428            fillPattern=FillPattern.Solid),
429          Rectangle(
430            extent={{-54,0},{-28,-20}},
431            lineColor={0,0,0},
432            fillColor={255,255,0},
433            fillPattern=FillPattern.Solid),
434          Rectangle(
435            extent={{-54,-20},{-28,-40}},
436            lineColor={0,0,0},
437            fillColor={255,255,0},
438            fillPattern=FillPattern.Solid),
439          Text(
440            extent={{-52,56},{-34,44}},
441            textString="u",
442            lineColor={0,0,255}),
443          Text(
444            extent={{-22,54},{2,42}},
445            textString="y[1]",
446            lineColor={0,0,255}),
447          Text(
448            extent={{4,54},{28,42}},
449            textString="y[2]",
450            lineColor={0,0,255}),
451          Text(
452            extent={{0,-40},{32,-54}},
453            textString="columns",
454            lineColor={0,0,255})}));
455
456  protected
457    Integer tableID;
458
459    function tableInit
460      input String tableName;
461      input String fileName;
462      input Real table[ :, :];
463      input Modelica.Blocks.Types.Smoothness smoothness;
464      output Integer tableID;
465    external "C" tableID = ModelicaTables_CombiTable1D_init(
466                   tableName, fileName, table, size(table, 1), size(table, 2),
467                   smoothness);
468      annotation(Library="ModelicaExternalC");
469    end tableInit;
470
471    function tableIpo
472      input Integer tableID;
473      input Integer icol;
474      input Real u;
475      output Real value;
476    external "C" value = 
477                       ModelicaTables_CombiTable1D_interpolate(tableID, icol, u);
478      annotation(Library="ModelicaExternalC");
479    end tableIpo;
480
481  equation
482    if tableOnFile then
483      assert(tableName<>"NoName", "tableOnFile = true and no table name given");
484    end if;
485    if not tableOnFile then
486      assert(size(table,1) > 0 and size(table,2) > 0, "tableOnFile = false and parameter table is an empty matrix");
487    end if;
488
489    for i in 1:nout loop
490      y[i] = if not tableOnFile and size(table,1)==1 then 
491               table[1, columns[i]] else tableIpo(tableID, columns[i], u);
492    end for;
493    when initial() then
494      tableID=tableInit(if tableOnFile then tableName else "NoName",
495                        if tableOnFile then fileName else "NoName", table, smoothness);
496    end when;
497  end CombiTable1Ds;
498
499  model CombiTable2D "Table look-up in two dimensions (matrix/file) "
500
501    import Modelica.Blocks.Types;
502    extends Modelica.Blocks.Interfaces.SI2SO;
503
504    parameter Boolean tableOnFile=false
505      "true, if table is defined on file or in function usertab" 
506      annotation(Dialog(group="table data definition"));
507    parameter Real table[:, :]=fill(0.0,0,2)
508      "table matrix (grid u1 = first column, grid u2 = first row; e.g. table=[0,0;0,1])"
509         annotation(Dialog(group="table data definition", enable = not tableOnFile));
510    parameter String tableName="NoName"
511      "table name on file or in function usertab (see docu)" 
512         annotation(Dialog(group="table data definition", enable = tableOnFile));
513    parameter String fileName="NoName" "file where matrix is stored" 
514         annotation(Dialog(group="table data definition", enable = tableOnFile,
515                           __Dymola_loadSelector(filter="Text files (*.txt);;Matlab files (*.mat)",
516                           caption="Open file in which table is present")));
517    parameter Modelica.Blocks.Types.Smoothness smoothness=Types.Smoothness.LinearSegments
518      "smoothness of table interpolation" 
519    annotation(Dialog(group="table data interpretation"));
520    annotation (
521      Documentation(info="<html>
522<p>
523<b>Linear interpolation</b> in <b>two</b> dimensions of a <b>table</b>.
524The grid points and function values are stored in a matrix \"table[i,j]\",
525where:
526</p>
527<ul>
528<li> the first column \"table[2:,1]\" contains the u[1] grid points,</li>
529<li> the first row \"table[1,2:]\" contains the u[2] grid points,</li>
530<li> the other rows and columns contain the data to be interpolated.</li>
531</ul>
532<p>
533Example:
534</p>
535<pre>
536           |       |       |       |
537           |  1.0  |  2.0  |  3.0  |  // u2
538       ----*-------*-------*-------*
539       1.0 |  1.0  |  3.0  |  5.0  |
540       ----*-------*-------*-------*
541       2.0 |  2.0  |  4.0  |  6.0  |
542       ----*-------*-------*-------*
543     // u1
544   is defined as
545      table = [0.0,   1.0,   2.0,   3.0;
546               1.0,   1.0,   3.0,   5.0;
547               2.0,   2.0,   4.0,   6.0]
548   If, e.g. the input u is [1.0;1.0], the output y is 1.0,
549       e.g. the input u is [2.0;1.5], the output y is 3.0.
550</pre>
551<ul>
552<li> The interpolation is <b>efficient</b>, because a search for a new interpolation
553     starts at the interval used in the last call.</li>
554<li> If the table has only <b>one element</b>, the table value is returned,
555     independent of the value of the input signal.</li>
556<li> If the input signal <b>u1</b> or <b>u2</b> is <b>outside</b> of the defined <b>interval</b>,
557     the corresponding value is also determined by linear
558     interpolation through the last or first two points of the table.</li>
559<li> The grid values (first column and first row) have to be <b>strict</b>
560     monotonically increasing.</li>
561</ul>
562<p>
563The table matrix can be defined in the following ways:
564</p>
565<ol>
566<li> Explicitly supplied as <b>parameter matrix</b> \"table\",
567     and the other parameters have the following values:
568<pre>
569   tableName is \"NoName\" or has only blanks,
570   fileName  is \"NoName\" or has only blanks.
571</pre></li>
572<li> <b>Read</b> from a <b>file</b> \"fileName\" where the matrix is stored as
573      \"tableName\". Both ASCII and binary file format is possible.
574      (the ASCII format is described below).
575      It is most convenient to generate the binary file from Matlab
576      (Matlab 4 storage format), e.g., by command
577<pre>
578   save tables.mat tab1 tab2 tab3 -V4
579</pre>
580      when the three tables tab1, tab2, tab3 should be
581      used from the model.</li>
582<li>  Statically stored in function \"usertab\" in file \"usertab.c\".
583      The matrix is identified by \"tableName\". Parameter
584      fileName = \"NoName\" or has only blanks.</li>
585</ol>
586<p>
587Table definition methods (1) and (3) do <b>not</b> allocate dynamic memory,
588and do not access files, whereas method (2) does. Therefore (1) and (3)
589are suited for hardware-in-the-loop simulation (e.g. with dSpace hardware).
590When the constant \"NO_FILE\" is defined, all parts of the
591source code of method (2) are removed by the C-preprocessor, such that
592no dynamic memory allocation and no access to files takes place.
593</p>
594<p>
595If tables are read from an ASCII-file, the file need to have the
596following structure (\"-----\" is not part of the file content):
597</p>
598<pre>
599-----------------------------------------------------
600#1
601double table2D_1(3,4)   # comment line
6020.0  1.0  2.0  3.0  # u[2] grid points
6031.0  1.0  3.0  5.0
6042.0  2.0  4.0  6.0
605 
606double table2D_2(4,4)   # comment line
6070.0  1.0  2.0  3.0  # u[2] grid points
6081.0  1.0  3.0  5.0
6092.0  2.0  4.0  6.0
6103.0  3.0  5.0  7.0
611-----------------------------------------------------
612</pre>
613<p>
614Note, that the first two characters in the file need to be
615\"#1\". Afterwards, the corresponding matrix has to be declared
616with type, name and actual dimensions. Finally, in successive
617rows of the file, the elements of the matrix have to be given.
618Several matrices may be defined one after another.
619The matrix elements are interpreted in exactly the same way
620as if the matrix is given as a parameter. For example, the first
621column \"table2D_1[2:,1]\" contains the u[1] grid points,
622and the first row \"table2D_1[1,2:]\" contains the u[2] grid points.
623</p>
624 
625</html>
626"),   Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
627              100}}), graphics={
628          Line(points={{-60,40},{-60,-40},{60,-40},{60,40},{30,40},{30,-40},{-30,
629                -40},{-30,40},{-60,40},{-60,20},{60,20},{60,0},{-60,0},{-60,-20},
630        Â