NANDRAD Data Model Library  Version 2.0
NANDRAD
NANDRAD_DailyCycle.h
1 /* The NANDRAD data model library.
2 
3  Copyright (c) 2012-today, Institut für Bauklimatik, TU Dresden, Germany
4 
5  Primary authors:
6  Andreas Nicolai <andreas.nicolai -[at]- tu-dresden.de>
7  Anne Paepcke <anne.paepcke -[at]- tu-dresden.de>
8 
9  This library is part of SIM-VICUS (https://github.com/ghorwin/SIM-VICUS)
10 
11  This library is free software: you can redistribute it and/or modify
12  it under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License for more details.
20 */
21 
22 #ifndef NANDRAD_DailyCycleH
23 #define NANDRAD_DailyCycleH
24 
25 #include <string>
26 #include <vector>
27 
28 #include <IBK_Parameter.h>
29 #include "NANDRAD_LinearSplineParameter.h"
30 #include "NANDRAD_DataTable.h"
31 #include "NANDRAD_CodeGenMacros.h"
32 
33 namespace NANDRAD {
34 
35 /*! Defines the daily course of one or more physical quantities/setpoints.
36 
37  The m_interpolation parameter defines how the tabulated data is interpreted.
38 
39  If m_interpolation == IT_CONSTANT, then the following rules apply:
40  - the time points in m_timePoints are interpreted as *start* of the next interval
41  - the first time point must be always 0, the last one must be < 24 h,
42  - the corresponding value is taken as constant during this interval
43 
44  For example, a time point vector "0 6 18" defines three intervals: 0-6, 6-18, 18-24 and
45  the data table must contain exactly 3 values.
46 
47  If m_interpolation == IT_LINEAR, then the following rules apply:
48  - the time points in m_timePoints are points in time where associated values are given
49  - the first time point must be always 0, the last one must be < 24 h,
50  because in cyclic usage, the time point at 24 h will be the same as for 0 h (and likewise
51  the scheduled values)
52  - between time points the values are linearly interpolated
53 */
54 class DailyCycle {
55 public:
56 
57  /*! Interpolation method for daily cycle data.
58  Note that for constant values some ramping may be used to smoothen out the steps.
59  If not set, IT_LINEAR is used.
60  */
62  /*! Constant values in defined intervals. */
63  IT_Constant, // Keyword: Constant 'Constant values in defined intervals.'
64  /*! Linear interpolation between values. */
65  IT_Linear, // Keyword: Linear 'Linear interpolation between values.'
66  NUM_IT
67  };
68 
69  /*! This structure holds the data for a single parameter stored in this DailyCycle.
70  It is used in vector m_valueData which is populated in prepareCalculation().
71  */
72  struct valueData_t {
73  /*! Default C'tor. */
75  /*! Initializing C'tor. */
76  valueData_t(const std::string & name, const IBK::Unit & unit, const std::vector<double> * valueVec) :
77  m_name(name), m_unit(unit), m_valueVec(valueVec) {}
78 
79  /*! Comparison operator. */
80  bool operator==(const std::string & name) const { return m_name == name; }
81 
82  /*! Parameter name. */
83  std::string m_name;
84  /*! Value input/output unit. */
85  IBK::Unit m_unit;
86  /*! Pointer to vector containing the actual data. */
87  const std::vector<double> *m_valueVec = nullptr;
88  };
89 
90  // *** PUBLIC MEMBER FUNCTIONS ***
91 
92  NANDRAD_READWRITE
93  NANDRAD_COMP(DailyCycle)
94 
95  /*! Checks for valid parametrization and generates m_valueNames, m_valueUnits and m_valueData. */
96  void prepareCalculation();
97 
98  // *** PUBLIC MEMBER VARIABLES ***
99 
100  /*! Value interpolation method. */
101  interpolation_t m_interpolation = NUM_IT; // XML:A
102 
103  /*! Time points in [h], must be strictly monotonically increasing, first must be 0, last must be less than 24. */
104  std::vector<double> m_timePoints; // XML:E
105 
106  /*! Actual values, key of m_values.m_values is physical quantity/setpoint/... scheduled quantity,
107  value is vector with values, same number of values as in m_timePoints.
108  */
109  DataTable m_values; // XML:E
110 
111  // *** solver runtime variables only (not written to file) ***
112 
113  /*! Extracted data of all variables. */
114  std::vector<valueData_t> m_valueData;
115 };
116 
117 } // namespace NANDRAD
118 
119 #endif // NANDRAD_DailyCycleH
A data member for a table with named columns.
std::vector< valueData_t > m_valueData
Extracted data of all variables.
std::vector< double > m_timePoints
Time points in [h], must be strictly monotonically increasing, first must be 0, last must be less tha...
IBK::Unit m_unit
Value input/output unit.
This structure holds the data for a single parameter stored in this DailyCycle.
Defines the daily course of one or more physical quantities/setpoints.
bool operator==(const std::string &name) const
Comparison operator.
const std::vector< double > * m_valueVec
Pointer to vector containing the actual data.
interpolation_t m_interpolation
Value interpolation method.
valueData_t(const std::string &name, const IBK::Unit &unit, const std::vector< double > *valueVec)
Initializing C&#39;tor.
DataTable m_values
Actual values, key of m_values.m_values is physical quantity/setpoint/...
Linear interpolation between values.
NANDRAD_READWRITE void prepareCalculation()
Checks for valid parametrization and generates m_valueNames, m_valueUnits and m_valueData.
Constant values in defined intervals.
interpolation_t
Interpolation method for daily cycle data.
The namespace NANDRAD contains the data model classes that make up the NANDRAD solver input data...
std::string m_name
Parameter name.