root/trunk/Modelica/C-Sources/ModelicaTables.h

Revision 1161, 6.1 kB (checked in by otter, 2 months ago)

Added a comment that the MSL tables use Akima Spline (algorithm 433 of ACM)

Line 
1#ifndef MODELICA_TABLES_H
2#define MODELICA_TABLES_H
3
4/* Definition of interface to external functions for table computation
5   in the Modelica Standard Library:
6
7       Modelica.Blocks.Sources.CombiTimeTable
8       Modelica.Blocks.Tables.CombiTable1D
9       Modelica.Blocks.Tables.CombiTable1Ds
10       Modelica.Blocks.Tables.CombiTable2D
11
12
13   Release Notes:
14      Jan. 27, 2008: by Martin Otter.
15                     Implemented a first version
16
17   Copyright (C) 2008, Modelica Association and DLR.
18
19   The content of this file is free software; it can be redistributed
20   and/or modified under the terms of the Modelica license, see the
21   license conditions and the accompanying disclaimer in file
22   ModelicaLicense.txt or in Modelica.UsersGuide.ModelicaLicense.
23*/
24
25
26/* A table can be defined in the following ways when initializing the table:
27
28     (1) Explicitly supplied in the argument list
29         (= table    is "NoName" or has only blanks AND
30            fileName is "NoName" or has only blanks).
31
32     (2) Read from a file (tableName, fileName have to be supplied).
33
34   Tables may be linearly interpolated or the first derivative may be continuous.
35   In the second case, Akima-Splines are used
36   (algorithm 433 of ACM, http://portal.acm.org/citation.cfm?id=355605)
37*/
38
39extern int ModelicaTables_CombiTimeTable_init(
40                      const char*   tableName,
41                      const char*   fileName, 
42                      double const* table, int nRow, int nColumn,
43                      double        startTime, 
44                      int           smoothness,
45                      int           extrapolation);
46  /* Initialize 1-dim. table where first column is time
47
48      -> tableName : Name of table.
49      -> fileName  : Name of file.
50      -> table     : If tableName="NoName" or has only blanks AND
51                        fileName ="NoName" or has only blanks, then
52                     this pointer points to a 2-dim. array (row-wise storage)
53                     in the Modelica environment that holds this matrix.
54      -> nRow      : Number of rows of table
55      -> nColumn   : Number of columns of table
56      -> startTime : Output = offset for time < startTime
57      -> smoothness: Interpolation type
58                     = 1: linear
59                     = 2: continuous first derivative
60      <- RETURN    : ID of internal memory of table.   
61  */
62
63extern void ModelicaTables_CombiTimeTable_close(int tableID);
64  /* Close table and free allocated memory */
65
66
67extern double ModelicaTables_CombiTimeTable_minimumTime(int tableID);
68  /* Return minimum time defined in table (= table[1,1]) */
69
70
71extern double ModelicaTables_CombiTimeTable_maximumTime(int tableID);
72  /* Return maximum time defined in table (= table[end,1]) */
73
74
75extern double ModelicaTables_CombiTimeTable_interpolate(int tableID, int icol, double u);
76  /* Interpolate in table
77   
78     -> tableID: Pointer to table defined with ModelicaTables_CombiTimeTable_init
79     -> icol   : Column to interpolate
80     -> u      : Abscissa value (time)
81     <- RETURN : Ordinate value
82 */
83
84
85
86extern int ModelicaTables_CombiTable1D_init(
87                  const  char*  tableName, 
88                  const  char*  fileName, 
89                  double const* table, int nRow, int nColumn,
90                  int smoothness);
91  /* Initialize 1-dim. table defined by matrix, where first column
92     is x-axis and further columns of matrix are interpolated
93
94      -> tableName : Name of table.
95      -> fileName  : Name of file.
96      -> table     : If tableName="NoName" or has only blanks AND
97                        fileName ="NoName" or has only blanks, then
98                     this pointer points to a 2-dim. array (row-wise storage)
99                     in the Modelica environment that holds this matrix.
100      -> nRow      : Number of rows of table
101      -> nColumn   : Number of columns of table
102      -> smoothness: Interpolation type
103                     = 1: linear
104                     = 2: continuous first derivative
105      <- RETURN    : ID of internal memory of table.   
106  */
107
108extern void ModelicaTables_CombiTable1D_close(int tableID);
109  /* Close table and free allocated memory */
110
111extern double ModelicaTables_CombiTable1D_interpolate(int tableID, int icol, double u);
112  /* Interpolate in table
113   
114     -> tableID: Pointer to table defined with ModelicaTables_CombiTable1D_init
115     -> icol   : Column to interpolate
116     -> u      : Abscissa value
117     <- RETURN : Ordinate value
118 */
119
120
121
122extern int ModelicaTables_CombiTable2D_init(
123                   const char*   tableName,
124                   const char*   fileName, 
125                   double const* table, int nRow, int nColumn, 
126                   int smoothness);
127  /* Initialize 2-dim. table defined by matrix, where first column
128     is x-axis, first row is y-axis and the matrix elements are the
129     z-values.
130       table[2:end,1    ]: Values of x-axis
131            [1    ,2:end]: Values of y-axis
132            [2:end,2:end]: Values of z-axis
133
134      -> tableName : Name of table.
135      -> fileName  : Name of file.
136      -> table     : If tableName="NoName" or has only blanks AND
137                        fileName ="NoName" or has only blanks, then
138                     this pointer points to a 2-dim. array (row-wise storage)
139                     in the Modelica environment that holds this matrix.
140      -> nRow      : Number of rows of table
141      -> nColumn   : Number of columns of table
142      -> smoothness: Interpolation type
143                     = 1: linear
144                     = 2: continuous first derivative
145      <- RETURN    : ID of internal memory of table.   
146  */
147
148extern void ModelicaTables_CombiTable2D_close(int tableID);
149  /* Close table and free allocated memory */
150
151extern double ModelicaTables_CombiTable2D_interpolate(int tableID, double u1, double u2);
152  /* Interpolate in table
153   
154     -> tableID: Pointer to table defined with ModelicaTables_CombiTable1D_init
155     -> u1     : x-axis value
156     -> u2     : y-axis value
157     <- RETURN : y-axis value
158 */
159
160
161#endif  /* MODELICA_TABLES */
Note: See TracBrowser for help on using the browser.