NANDRAD Data Model Library  Version 2.0
NANDRAD
NANDRAD_Schedules.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_SchedulesH
23 #define NANDRAD_SchedulesH
24 
25 #include <string>
26 #include <vector>
27 
28 #include <IBK_Flag.h>
29 
30 #include "NANDRAD_Schedule.h"
31 #include "NANDRAD_CodeGenMacros.h"
32 
33 namespace NANDRAD {
34 
35 /*! Schedules define purely time-dependent properties.
36 
37  Scheduled quantities are associated with models via object lists. The object list
38  names are the keys to the maps m_scheduleGroups and m_annualSchedules.
39 */
40 class Schedules {
41 public:
42 
43  /*! Day ids, also used to define "a weekend definition". */
44  enum day_t {
45  SD_MONDAY, // Keyword: Mon 'Monday.'
46  SD_TUESDAY, // Keyword: Tue 'Tuesday.'
47  SD_WEDNESDAY, // Keyword: Wed 'Wednesday.'
48  SD_THURSDAY, // Keyword: Thu 'Thursday.'
49  SD_FRIDAY, // Keyword: Fri 'Friday.'
50  SD_SATURDAY, // Keyword: Sat 'Saturday.'
51  SD_SUNDAY, // Keyword: Sun 'Sunday.'
52  NUM_SD
53  };
54 
55  /*! Flags controlling schedule evaluation. */
56  enum flag_t {
57  /*! If enabled, schedules are treated as annually repeating schedules. */
58  F_EnableCyclicSchedules, // Keyword: EnableCyclicSchedules 'If enabled, schedules are treated as annually repeating schedules.'
59  NUM_F
60  };
61 
62  // *** PUBLIC MEMBER FUNCTIONS ***
63 
64  /*! Init default values (called before readXML()).
65  \note These values will be overwritten in readXML() when the respective property is set
66  in the project file.
67  */
68  void initDefaults();
69 
70  NANDRAD_READWRITE
71  NANDRAD_COMP(Schedules)
72 
73 
74  /*! Checks given parameters and initializes all linear splines given as tsv-files. */
75  void checkParameters(const std::map<std::string, IBK::Path> &placeholders);
76 
77  /*! This function does all the work in the actual schedule-by-daily-cycle implementation.
78  It constructs a linear spline for cyclic annual use by processing all days of the year,
79  looking up the respective parameter and combining day cycle values.
80 
81  \param objectListName Name of schedule group (i.e. name of corresponding object list)
82  \param parameterName Name of scheduled parameter
83  \param spline Here the spline data will be stored, values are already converted to the base SI unit.
84  \param interpolationType Here the interpolation type set for the daily cycle will be set.
85  */
86  void generateLinearSpline(const std::string & objectListName, const std::string & parameterName,
87  IBK::LinearSpline & spline,
88  DailyCycle::interpolation_t & interpolationType
89  ) const;
90 
91 
92  /*! Compares two schedule groups by schedule content, hereby ignoring the name of the schedule group. */
93  static bool equalSchedules(const std::vector<Schedule> & first, const std::vector<Schedule> & second);
94 
95 
96  // *** PUBLIC MEMBER VARIABLES ***
97 
98  /*! List of holiday days, stored in "day of the year", not including leap days. */
99  std::set< unsigned int> m_holidays;
100 
101  /*! Weekend days. */
102  std::set< day_t > m_weekEndDays;
103 
104  /*! The daytype of January 1st (offset of day of the week (0-Mon, ...6-Sun)) of the start year,
105  defaults to Monday.
106  */
107  day_t m_firstDayOfYear = SD_MONDAY;
108 
109  /*! List of flags. */
110  IBK::Flag m_flags[NUM_F];
111 
112  /*! Key is object list name, value is vector of schedules. */
113  std::map<std::string, std::vector<Schedule> > m_scheduleGroups;
114  /*! Key is object list name, value is vector of LinearSplineParameter.
115  The LinearSplineParameter has a name, which corresponds to the
116  quantity that this scheduled parameter is for.
117  */
118  std::map<std::string, std::vector<NANDRAD::LinearSplineParameter> > m_annualSchedules;
119 };
120 
121 } // namespace NANDRAD
122 
123 #endif // NANDRAD_SchedulesH
void generateLinearSpline(const std::string &objectListName, const std::string &parameterName, IBK::LinearSpline &spline, DailyCycle::interpolation_t &interpolationType) const
This function does all the work in the actual schedule-by-daily-cycle implementation.
std::map< std::string, std::vector< Schedule > > m_scheduleGroups
Key is object list name, value is vector of schedules.
std::set< day_t > m_weekEndDays
Weekend days.
std::map< std::string, std::vector< NANDRAD::LinearSplineParameter > > m_annualSchedules
Key is object list name, value is vector of LinearSplineParameter.
Schedules define purely time-dependent properties.
static bool equalSchedules(const std::vector< Schedule > &first, const std::vector< Schedule > &second)
Compares two schedule groups by schedule content, hereby ignoring the name of the schedule group...
If enabled, schedules are treated as annually repeating schedules.
IBK::Flag m_flags[NUM_F]
List of flags.
std::set< unsigned int > m_holidays
List of holiday days, stored in "day of the year", not including leap days.
day_t m_firstDayOfYear
The daytype of January 1st (offset of day of the week (0-Mon, ...6-Sun)) of the start year...
interpolation_t
Interpolation method for daily cycle data.
The namespace NANDRAD contains the data model classes that make up the NANDRAD solver input data...
NANDRAD_READWRITE void checkParameters(const std::map< std::string, IBK::Path > &placeholders)
Checks given parameters and initializes all linear splines given as tsv-files.
day_t
Day ids, also used to define "a weekend definition".
flag_t
Flags controlling schedule evaluation.
void initDefaults()
Init default values (called before readXML()).