usertab.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #ifndef USERTAB_H
  2. #define USERTAB_H
  3. /*
  4. * Copyright (C) 1997-2001 Dynasim AB.
  5. * All rights reserved.
  6. *
  7. */
  8. #if defined(DYMOLA_DSPACE)
  9. #include <dsdefs.h>
  10. #else
  11. #include <stdio.h>
  12. #endif
  13. #include <string.h>
  14. #include "dymutil.h"
  15. #include "dymtable.h"
  16. typedef struct {
  17. char *name; /* Name of table */
  18. double *value; /* Pointer to value matrix */
  19. int nipo; /* = 0: 1D-table with time as abszissa */
  20. /* = 1: 1D-table */
  21. /* = 2: 2D-table */
  22. int dim[2]; /* Actual number of dimensions */
  23. } UsertabTableElement;
  24. /* ------------------------------------------------------------------------- */
  25. /* Static definitions of all tables. Adapt to your needs. */
  26. /* ------------------------------------------------------------------------- */
  27. /* Use at most 28 characters for the names of table vectors,
  28. since this limit is imposed by Dymola for character strings
  29. A 1D-table is defined as a matrix where
  30. - the first column is the abszissa data
  31. - the other columns are the ordinate data to
  32. be interpolated with respect to the first column.
  33. A 1D-table with time as abszissa may have discontinuities, i.e.,
  34. the abszissa data needs to be only monotonically increasing.
  35. In all other cases, the abszissa data needs to be strict
  36. monotonically increasing.
  37. A 2D-table is defined as a matrix where
  38. - the first column (without first element), i.e., table(2:,1),
  39. is the first abscissa (u(1)),
  40. - the first row (without first element), i.e., table(1,2:),
  41. is the second abscissa (u(2)),
  42. - the other elements, i.e., table(i,j) with i>=2,j>=2,
  43. are the corresponding ordinate values.
  44. */
  45. /* ------------------------------------------------------------------------ */
  46. /* Definition of all value vectors */
  47. static double TestTable_1[] = {0.0, 0.0, /* 1D-table */
  48. 1.0, 1.0,
  49. 2.0, 4.0,
  50. 3.0, 9.0,
  51. 4.0, 16.0,
  52. 5.0, 25.0};
  53. static double TestTable_2[] = {0.0, 0.0, 0.0, /* 1D-table */
  54. 1.0, 2.0, 0.5,
  55. 2.0, 4.0, 1.0,
  56. 3.0, 6.0, 1.5};
  57. static double TestTable_3[] = {0.0, 0.0, 2.0, 4.0, /* 2D-table */
  58. 0.0, 0.0, 5.0, 15.0,
  59. 1.0, 3.0, 10.0, 20.0,
  60. 2.0, 6.0, 15.0, 25.0};
  61. /* Definition of the tables
  62. N_TABLEDEF: Number of tables.
  63. name : Name of table.
  64. nipo : = 0: time-table (first axis is time; discontinuous points
  65. are allowed).
  66. = 1: 1D-table.
  67. = 2: 2D-table.
  68. dim1 : Number of rows.
  69. dim2 : Number of columns.
  70. */
  71. #define N_TABLEDEF 3
  72. static UsertabTableElement tableDef[N_TABLEDEF] = {
  73. /* name pointer to value nipo, dim1, dim2 */
  74. {"TestTable_1", TestTable_1, 1, {6, 2} }
  75. ,{"TestTable_2", TestTable_2, 1, {4, 3} }
  76. ,{"TestTable_3", TestTable_3, 2, {4, 4} }
  77. };
  78. #endif