NANDRAD Data Model Library  Version 2.0
NANDRAD
NANDRAD_Schedule.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_ScheduleH
23 #define NANDRAD_ScheduleH
24 
25 #include <string>
26 #include <vector>
27 
28 #include <IBK_Time.h>
29 #include <IBK_Unit.h>
30 
31 #include "NANDRAD_DailyCycle.h"
32 #include "NANDRAD_CodeGenMacros.h"
33 
34 namespace NANDRAD {
35 
36 /*! Class Schedule defines scheduled parameters in sets of daily cycles.
37 
38  Schedules are defined for a specific day type: week day,
39  week end, holiday or all days. They contain one or more daily cycles
40  that specify the distribution for different scheduled quantities over
41  a period of one day.
42  Holidays and week end days are defined in Schedules.
43 */
44 class Schedule {
45 public:
46 
47  /*! Different day types a schedule can be defined for.
48  \warning Do not change order of schedule definitions, since they mark
49  also the lookup priority - for example, a holiday schedule takes precedence before
50  a specific day schedule.
51  */
53  ST_ALLDAYS, // Keyword: AllDays 'All days (Weekend days and Weekdays).'
54  ST_WEEKDAY, // Keyword: WeekDay 'Weekday schedule.'
55  ST_WEEKEND, // Keyword: WeekEnd 'Weekend schedule.'
56  ST_MONDAY, // Keyword: Monday 'Special Weekday schedule: Monday.'
57  ST_TUESDAY, // Keyword: Tuesday 'Special Weekday schedule: Tuesday.'
58  ST_WEDNESDAY, // Keyword: Wednesday 'Special Weekday schedule: Wednesday.'
59  ST_THURSDAY, // Keyword: Thursday 'Special Weekday schedule: Thursday.'
60  ST_FRIDAY, // Keyword: Friday 'Special Weekday schedule: Friday.'
61  ST_SATURDAY, // Keyword: Saturday 'Special Weekday schedule: Saturday.'
62  ST_SUNDAY, // Keyword: Sunday 'Special Weekday schedule: Sunday.'
63  ST_HOLIDAY, // Keyword: Holiday 'Holiday schedule.'
64  NUM_ST
65  };
66 
67  // *** PUBLIC MEMBER FUNCTIONS ***
68 
69  NANDRAD_READWRITE
70  NANDRAD_COMP(Schedule)
71 
72  /*! Prepares calculation by initializing daily cycles and by collecting names of all scheduled parameters.
73  \warning In this function persistent pointers to memory locations are stored. Hence, you must
74  not modify the memory location of this object or any of the vectors afterwards!
75  */
76  void prepareCalculation();
77 
78  /*! Returns true, if given day is inside the start and end date of the schedule. */
79  bool containsDay(unsigned int dayOfYear) const {return dayOfYear >= m_startDayOfTheYear && dayOfYear <= m_endDayOfTheYear; }
80 
81  /*! Returns true if schedule is a whole year schedule (startDay = 0 and endDay = 364). */
82  bool isWholeYearSchedule() const {return m_startDayOfTheYear == 0 && m_endDayOfTheYear == 364; }
83 
84  // *** PUBLIC MEMBER VARIABLES ***
85 
86  /*! Type of day this schedule is defined for. */
87  ScheduledDayType m_type = NUM_ST; // XML:A:required
88 
89  /*! Start day of the year for the schedule, if not given, defaults to 0 = 1.1. */
90  unsigned int m_startDayOfTheYear = 0; // XML:E
91 
92  /*! End day for the schedule (includes the entire day), if not given, defaults 364 = 31.12. */
93  unsigned int m_endDayOfTheYear = 364; // XML:E
94 
95  /*! List of daily cycles that are used on day type specified above.
96  These cycles define different quantities/control parameters etc.
97  */
98  std::vector<DailyCycle> m_dailyCycles; // XML:E
99 
100 
101  // *** solver runtime variables only (not written to file) ***
102 
103  /*! All value names provided by all of the daily cycles.
104  This map is composed during prepareCalculation() and primarily used to quickly check
105  if this schedule provides a required parameter at all. Also, it identifies the actual
106  schedule that defines this parameter.
107  \note with this map we also ensure, that the user does not specify multiple daily cycles for
108  the same parameter.
109  */
110  std::map<std::string, DailyCycle *> m_parameters;
111 };
112 
113 } // namespace NANDRAD
114 
115 #endif // NANDRAD_ScheduleH
ScheduledDayType m_type
Type of day this schedule is defined for.
bool containsDay(unsigned int dayOfYear) const
Returns true, if given day is inside the start and end date of the schedule.
bool isWholeYearSchedule() const
Returns true if schedule is a whole year schedule (startDay = 0 and endDay = 364).
NANDRAD_READWRITE void prepareCalculation()
Prepares calculation by initializing daily cycles and by collecting names of all scheduled parameters...
ScheduledDayType
Different day types a schedule can be defined for.
Class Schedule defines scheduled parameters in sets of daily cycles.
std::map< std::string, DailyCycle * > m_parameters
All value names provided by all of the daily cycles.
unsigned int m_endDayOfTheYear
End day for the schedule (includes the entire day), if not given, defaults 364 = 31.12.
std::vector< DailyCycle > m_dailyCycles
List of daily cycles that are used on day type specified above.
The namespace NANDRAD contains the data model classes that make up the NANDRAD solver input data...
unsigned int m_startDayOfTheYear
Start day of the year for the schedule, if not given, defaults to 0 = 1.1.