.WaterHub.Blocks.Sources.hydrographFromFile

Information

This block was modified from Modelica.Blocks.Sources.CombiTimeTable to fit the needs of the WaterHub model. When connecting this block to an end-use model, remember to connect it to y[1] (and not y[:], as the default). This is a bug that will be addressed in the future. The block accepts .txt and .csv files containing a table that has the following format

  #1
  float FlowTable(86400, 4)
  0, 0.0, 0.0, 0.0
  1, 0.0, 0.0, 0.0
  2, 0.0, 0.0, 0.0
  ...
  

where the first column is the time (86400 rows for one day simulation at second resolution, which can be tuned as required), the second column the probability for an end-use event to happen, the third column the cumulative frequency and the fourth column the water flow generated by a random event. This kind of table is generated by a python script named HydroGen, for 'Hydrograph Generator'. See specific documentation for use.

The following information is copied from the TimeCombiTable Block information:

This block generates an output signal y[:] by constant, linear or cubic Hermite spline interpolation in a table. The time points and function values are stored in a matrix table[i,j], where the first column table[:,1] contains the time points and the other columns contain the data to be interpolated.

CombiTimeTable.png

Via parameter columns it can be defined which columns of the table are interpolated. If, e.g., columns={2,4}, it is assumed that 2 output signals are present and that the first output is computed by interpolation of column 2 and the second output is computed by interpolation of column 4 of the table matrix. The table interpolation has the following properties:

Example:

   table = [0, 0;
            1, 0;
            1, 1;
            2, 4;
            3, 9;
            4, 16];
   extrapolation = 2 (default)
  If, e.g., time = 1.0, the output y =  0.0 (before event), 1.0 (after event)
    e.g., time = 1.5, the output y =  2.5,
    e.g., time = 2.0, the output y =  4.0,
    e.g., time = 5.0, the output y = 23.0 (i.e., extrapolation via last 2 points).
  

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 MAT-file format is possible. (The ASCII format is described below). The MAT-file format comes in four different versions: v4, v6, v7 and v7.3. The library supports at least v4, v6 and v7 whereas v7.3 is optional. It is most convenient to generate the MAT-file from FreeMat or MATLAB® by command
       save tables.mat tab1 tab2 tab3
      
    or Scilab by command
       savematfile tables.mat tab1 tab2 tab3
      
    when the three tables tab1, tab2, tab3 should be used from the model.
    Note, a fileName can be defined as URI by using the helper function loadResource.
  3. Statically stored in function "usertab" in file "usertab.c". The matrix is identified by "tableName". Parameter fileName = "NoName" or has only blanks. Row-wise storage is always to be preferred as otherwise the table is reallocated and transposed.

When the constant "NO_FILE_SYSTEM" is defined, all file I/O related parts of the source code are removed by the C-preprocessor, such that no access to files takes place.

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

  -----------------------------------------------------
  #1
  double tab1(6,2)   # comment line
  0   0
  1   0
  1   1
  2   4
  3   9
  4  16
  double tab2(6,2)   # another comment line
  0   0
  2   0
  2   2
  4   8
  6  18
  8  32
  -----------------------------------------------------
  

Note, that the first two characters in the file need to be "#1" (a line comment defining the version number of the file format). Afterwards, the corresponding matrix has to be declared with type (= "double" or "float"), name and actual dimensions. Finally, in successive rows of the file, the elements of the matrix have to be given. The elements have to be provided as a sequence of numbers in row-wise order (therefore a matrix row can span several lines in the file and need not start at the beginning of a line). Numbers have to be given according to C syntax (such as 2.3, -2, +2.e4). Number separators are spaces, tab (\t), comma (,), or semicolon (;). Several matrices may be defined one after another. Line comments start with the hash symbol (#) and can appear everywhere. Other characters, like trailing non comments, are not allowed in the file.

MATLAB is a registered trademark of The MathWorks, Inc.

Revisions

Release Notes:


Generated at 2024-12-17T19:26:02Z by OpenModelicaOpenModelica 1.24.3 using GenerateDoc.mos