.ClaRa.Components.Utilities.Blocks.ReadMatrixFromFile

Information

Linear interpolation in two dimensions of a table. The grid points and function values are stored in a matrix "table[i,j]", where:

Example:

           |       |       |       |
           |  1.0  |  2.0  |  3.0  |  // u2
       ----*-------*-------*-------*
       1.0 |  1.0  |  3.0  |  5.0  |
       ----*-------*-------*-------*
       2.0 |  2.0  |  4.0  |  6.0  |
       ----*-------*-------*-------*
     // u1
   is defined as
      table = [0.0,   1.0,   2.0,   3.0;
               1.0,   1.0,   3.0,   5.0;
               2.0,   2.0,   4.0,   6.0]
   If, e.g. the input u is [1.0;1.0], the output y is 1.0,
       e.g. the input u is [2.0;1.5], the output y is 3.0.

The table matrix can be defined in the following ways:

  1. Explicitly supplied as parameter matrix "table", and the other parameters have the following values:
       tableName is "NoName" or has only blanks,
       fileName  is "NoName" or has only blanks.
    
  2. Read from a file "fileName" where the matrix is stored as "tableName". Both ASCII and binary file format is possible. (the ASCII format is described below). It is most convenient to generate the binary file from Matlab (Matlab 4 storage format), e.g., by command
       save tables.mat tab1 tab2 tab3 -V4
    
    when the three tables tab1, tab2, tab3 should be used from the model.
  3. Statically stored in function "usertab" in file "usertab.c". The matrix is identified by "tableName". Parameter fileName = "NoName" or has only blanks.

Table definition methods (1) and (3) do not allocate dynamic memory, and do not access files, whereas method (2) does. Therefore (1) and (3) are suited for hardware-in-the-loop simulation (e.g. with dSpace hardware). When the constant "NO_FILE" is defined, all parts of the source code of method (2) are removed by the C-preprocessor, such that no dynamic memory allocation and no access to files takes place.

If tables are read from an ASCII-file, the file need to have the following structure ("-----" is not part of the file content):

-----------------------------------------------------
#1
double table2D_1(3,4)   # comment line
0.0  1.0  2.0  3.0  # u[2] grid points
1.0  1.0  3.0  5.0
2.0  2.0  4.0  6.0

double table2D_2(4,4)   # comment line
0.0  1.0  2.0  3.0  # u[2] grid points
1.0  1.0  3.0  5.0
2.0  2.0  4.0  6.0
3.0  3.0  5.0  7.0
-----------------------------------------------------

Note, that the first two characters in the file need to be "#1". Afterwards, the corresponding matrix has to be declared with type, name and actual dimensions. Finally, in successive rows of the file, the elements of the matrix have to be given. Several matrices may be defined one after another. The matrix elements are interpreted in exactly the same way as if the matrix is given as a parameter. For example, the first column "table2D_1[2:,1]" contains the u[1] grid points, and the first row "table2D_1[1,2:]" contains the u[2] grid points.

For detailed model documentation please consult the html-documentation shipped with ClaRa.

 


Authorship and Copyright Statement for original (initial) Contribution

Author:

DYNCAP/DYNSTART development team, Copyright © 2011-2024.

References:

For references please consult the html-documentation shipped with ClaRa.

Remarks:

This component was developed by ClaRa development team under the 3-clause BSD License.

Acknowledgements:

ClaRa originated from the collaborative research projects DYNCAP and DYNSTART. Both research projects were supported by the German Federal Ministry for Economic Affairs and Energy (FKZ 03ET2009 and FKZ 03ET7060).

CLA:

The author(s) have agreed to ClaRa CLA, version 1.0. See https://claralib.com/pdf/CLA.pdf

By agreeing to ClaRa CLA, version 1.0 the author has granted the ClaRa development team a permanent right to use and modify his initial contribution as well as to publish it or its modified versions under the 3-clause BSD License.

The ClaRa development team consists of the following partners:

TLK-Thermo GmbH (Braunschweig, Germany)

XRG Simulation GmbH (Hamburg, Germany).

Revisions

For revisions please consult the html-documentation shipped with ClaRa.


Generated at 2024-11-21T19:25:40Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos