Line data Source code
1 : // EnergyPlus, Copyright (c) 1996-2025, The Board of Trustees of the University of Illinois,
2 : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
3 : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
4 : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
5 : // contributors. All rights reserved.
6 : //
7 : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
8 : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
9 : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
10 : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
11 : // derivative works, and perform publicly and display publicly, and to permit others to do so.
12 : //
13 : // Redistribution and use in source and binary forms, with or without modification, are permitted
14 : // provided that the following conditions are met:
15 : //
16 : // (1) Redistributions of source code must retain the above copyright notice, this list of
17 : // conditions and the following disclaimer.
18 : //
19 : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
20 : // conditions and the following disclaimer in the documentation and/or other materials
21 : // provided with the distribution.
22 : //
23 : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
24 : // the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
25 : // used to endorse or promote products derived from this software without specific prior
26 : // written permission.
27 : //
28 : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
29 : // without changes from the version obtained under this License, or (ii) Licensee makes a
30 : // reference solely to the software portion of its product, Licensee must refer to the
31 : // software as "EnergyPlus version X" software, where "X" is the version number Licensee
32 : // obtained under this License and may not use a different name for the software. Except as
33 : // specifically required in this Section (4), Licensee shall not use in a company name, a
34 : // product name, in advertising, publicity, or other promotional activities any name, trade
35 : // name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
36 : // similar designation, without the U.S. Department of Energy's prior written consent.
37 : //
38 : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
39 : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
40 : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
41 : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42 : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
43 : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
44 : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
45 : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
46 : // POSSIBILITY OF SUCH DAMAGE.
47 :
48 : #ifndef DemandManager_hh_INCLUDED
49 : #define DemandManager_hh_INCLUDED
50 :
51 : // C++ Headers
52 : #include <unordered_map>
53 :
54 : // ObjexxFCL Headers
55 : #include <ObjexxFCL/Array1D.hh>
56 :
57 : // EnergyPlus Headers
58 : #include <EnergyPlus/Data/BaseData.hh>
59 : #include <EnergyPlus/DataGlobals.hh>
60 : #include <EnergyPlus/EnergyPlus.hh>
61 : #include <EnergyPlus/ScheduleManager.hh>
62 :
63 : namespace EnergyPlus {
64 :
65 : // Forward declarations
66 : struct EnergyPlusData;
67 :
68 : namespace DemandManager {
69 :
70 : // MODULE PARAMETER DEFINITIONS:
71 : enum class ManagerType
72 : {
73 : Invalid = -1,
74 : ExtLights,
75 : Lights,
76 : ElecEquip,
77 : Thermostats,
78 : Ventilation,
79 : Num
80 : };
81 :
82 : enum class ManagePriorityType
83 : {
84 : Invalid = -1,
85 : Sequential,
86 : Optimal,
87 : All,
88 : Num
89 : };
90 :
91 : enum class ManagerLimit
92 : {
93 : Invalid = -1,
94 : Off,
95 : Fixed,
96 : Variable,
97 : ReductionRatio,
98 : Num
99 : };
100 :
101 : enum class ManagerSelection
102 : {
103 : Invalid = -1,
104 : All,
105 : Many,
106 : One,
107 : Num
108 : };
109 :
110 : enum class DemandAction
111 : {
112 : Invalid = -1,
113 : CheckCanReduce,
114 : SetLimit,
115 : ClearLimit,
116 : Num
117 : };
118 :
119 : // Types
120 : struct DemandManagerListData
121 : {
122 : // Members
123 : std::string Name; // Name of DEMAND MANAGER LIST
124 : int Meter; // Index to meter to demand limit
125 : Sched::Schedule *limitSched = nullptr; // Schedule for demand limit
126 : Real64 SafetyFraction; // Multiplier applied to demand limit schedule
127 : Sched::Schedule *billingSched = nullptr; // Schedule for billing month periods
128 : Real64 BillingPeriod; // Current billing period value
129 : Sched::Schedule *peakSched = nullptr; // Schedule index for billing month periods
130 : int AveragingWindow; // Number of timesteps for averaging demand window
131 : Array1D<Real64> History; // Demand window history
132 : ManagePriorityType ManagerPriority; // Indicator for priority (SEQUENTIAL, OPTIMAL, ALL)
133 : int NumOfManager = 0; // Number of DEMAND MANAGERs
134 : Array1D_int Manager; // Indexes for DEMAND MANAGERs
135 : Real64 MeterDemand; // Meter demand at this timestep
136 : Real64 AverageDemand; // Current demand over the demand window
137 : Real64 PeakDemand; // Peak demand in the billing month so far
138 : Real64 ScheduledLimit; // Scheduled demand limit
139 : Real64 DemandLimit; // Scheduled demand limit * Safety Fraction
140 : Real64 AvoidedDemand; // Demand avoided by active DEMAND MANAGERs
141 : Real64 OverLimit; // Amount that demand limit is exceeded
142 : Real64 OverLimitDuration; // Number of hours that demand limit is exceeded
143 :
144 : // Default Constructor
145 1 : DemandManagerListData()
146 4 : : Meter(0), SafetyFraction(1.0), BillingPeriod(0.0), AveragingWindow(1), ManagerPriority(ManagePriorityType::Invalid), MeterDemand(0.0),
147 1 : AverageDemand(0.0), PeakDemand(0.0), ScheduledLimit(0.0), DemandLimit(0.0), AvoidedDemand(0.0), OverLimit(0.0), OverLimitDuration(0.0)
148 : {
149 1 : }
150 : };
151 :
152 : struct DemandManagerData
153 : {
154 : // Members
155 : std::string Name; // Name of DEMAND MANAGER
156 : ManagerType Type; // Type of DEMAND MANAGER (:LIGHTS, :ELECTRICEQUIPMENT, etc.)
157 : int DemandManagerList; // Reference to parent DEMAND MANAGER LIST for error checking
158 : bool CanReduceDemand; // Flag to indicate whether manager can reduce demand
159 : Sched::Schedule *availSched = nullptr; // Availability Schedule
160 : bool Available; // Availability flag
161 : bool Activate; // Flag to activate the manager
162 : bool Active; // Flag to indicate that the manager is active
163 : ManagerLimit LimitControl;
164 : ManagerSelection SelectionControl;
165 : int LimitDuration; // Minimum duration of demand manager activity (min)
166 : int ElapsedTime; // Elapsed time for the demand manager activity (min)
167 : int RotationDuration; // Rotation duration (min)
168 : int ElapsedRotationTime; // Elapsed time for the current rotation (min)
169 : int RotatedLoadNum; // Index for rotated load
170 : Real64 LowerLimit; // Lowest demand limit as fraction of design level
171 : // Lowest heating setpoint for thermostats
172 : Real64 UpperLimit; // Not used for demand limit
173 : // Highest cooling setpoint for thermostats
174 : int NumOfLoads; // Number of load objects
175 : Array1D_int Load; // Pointers to load objects
176 :
177 : // Additional fields related to DemandManager:Ventilation
178 : Real64 FixedRate; // m3 per person
179 : Real64 ReductionRatio; // % of reduction
180 :
181 : // Default Constructor
182 2 : DemandManagerData()
183 4 : : Type(ManagerType::Invalid), DemandManagerList(0), CanReduceDemand(false), Available(false), Activate(false), Active(false),
184 2 : LimitControl(ManagerLimit::Invalid), SelectionControl(ManagerSelection::Invalid), LimitDuration(0), ElapsedTime(0), RotationDuration(0),
185 2 : ElapsedRotationTime(0), RotatedLoadNum(0), LowerLimit(0.0), UpperLimit(0.0), NumOfLoads(0), FixedRate(0.0), ReductionRatio(0.0)
186 : {
187 2 : }
188 : };
189 :
190 : void ManageDemand(EnergyPlusData &state);
191 :
192 : void SimulateDemandManagerList(EnergyPlusData &state,
193 : int ListNum,
194 : bool &ResimExt, // Flag to resimulate the exterior energy use simulation
195 : bool &ResimHB, // Flag to resimulate the heat balance simulation (including HVAC)
196 : bool &ResimHVAC // Flag to resimulate the HVAC simulation
197 : );
198 :
199 : void GetDemandManagerListInput(EnergyPlusData &state);
200 :
201 : void GetDemandManagerInput(EnergyPlusData &state);
202 :
203 : void SurveyDemandManagers(EnergyPlusData &state);
204 :
205 : void ActivateDemandManagers(EnergyPlusData &state);
206 :
207 : void UpdateDemandManagers(EnergyPlusData &state);
208 :
209 : void ReportDemandManagerList(EnergyPlusData &state, int ListNum);
210 :
211 : void LoadInterface(EnergyPlusData &state, DemandAction Action, int MgrNum, int LoadPtr, bool &CanReduceDemand);
212 :
213 : void InitDemandManagers(EnergyPlusData &state);
214 :
215 : } // namespace DemandManager
216 :
217 : struct DemandManagerData : BaseGlobalStruct
218 : {
219 : int NumDemandManagerList = 0;
220 : int NumDemandMgr = 0;
221 : int DemandManagerExtIterations = 0;
222 : int DemandManagerHBIterations = 0;
223 : int DemandManagerHVACIterations = 0;
224 : bool GetInput = true; // Flag to prevent input from being read multiple times
225 : Array1D<DemandManager::DemandManagerListData> DemandManagerList;
226 : Array1D<DemandManager::DemandManagerData> DemandMgr;
227 : std::unordered_map<std::string, std::string> UniqueDemandMgrNames;
228 : bool ClearHistory = true;
229 : bool BeginDemandSim = true;
230 : bool ResimHVAC = true;
231 : bool ResimHB = true;
232 : bool ResimExt = true;
233 : bool firstTime = true;
234 :
235 2126 : void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
236 : {
237 2126 : }
238 :
239 1152 : void init_state([[maybe_unused]] EnergyPlusData &state) override
240 : {
241 1152 : }
242 :
243 2100 : void clear_state() override
244 : {
245 2100 : NumDemandManagerList = 0;
246 2100 : NumDemandMgr = 0;
247 2100 : DemandManagerExtIterations = 0;
248 2100 : DemandManagerHBIterations = 0;
249 2100 : DemandManagerHVACIterations = 0;
250 2100 : GetInput = true;
251 2100 : DemandManagerList.deallocate();
252 2100 : DemandMgr.deallocate();
253 2100 : UniqueDemandMgrNames.clear();
254 2100 : ClearHistory = true;
255 2100 : BeginDemandSim = true;
256 2100 : ResimHVAC = true;
257 2100 : ResimHB = true;
258 2100 : ResimExt = true;
259 2100 : firstTime = true;
260 2100 : }
261 : };
262 :
263 : } // namespace EnergyPlus
264 :
265 : #endif
|