LCOV - code coverage report
Current view: top level - EnergyPlus - DemandManager.hh (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 11 28 39.3 %
Date: 2023-01-17 19:17:23 Functions: 8 11 72.7 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2023, 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             : 
      62             : namespace EnergyPlus {
      63             : 
      64             : // Forward declarations
      65             : struct EnergyPlusData;
      66             : 
      67             : namespace DemandManager {
      68             : 
      69             :     // MODULE PARAMETER DEFINITIONS:
      70             :     enum class ManagerType
      71             :     {
      72             :         Invalid = -1,
      73             :         ExtLights,
      74             :         Lights,
      75             :         ElecEquip,
      76             :         Thermostats,
      77             :         Ventilation,
      78             :         Num
      79             :     };
      80             : 
      81             :     enum class ManagePriorityType
      82             :     {
      83             :         Invalid = -1,
      84             :         Sequential,
      85             :         Optimal,
      86             :         All,
      87             :         Num
      88             :     };
      89             : 
      90             :     enum class ManagerLimit
      91             :     {
      92             :         Invalid = -1,
      93             :         Off,
      94             :         Fixed,
      95             :         Variable,
      96             :         ReductionRatio,
      97             :         Num
      98             :     };
      99             : 
     100             :     enum class ManagerSelection
     101             :     {
     102             :         Invalid = -1,
     103             :         All,
     104             :         Many,
     105             :         One,
     106             :         Num
     107             :     };
     108             : 
     109             :     enum class DemandAction
     110             :     {
     111             :         Invalid = -1,
     112             :         CheckCanReduce,
     113             :         SetLimit,
     114             :         ClearLimit,
     115             :         Num
     116             :     };
     117             : 
     118             :     // Types
     119          18 :     struct DemandManagerListData
     120             :     {
     121             :         // Members
     122             :         std::string Name;                   // Name of DEMAND MANAGER LIST
     123             :         int Meter;                          // Index to meter to demand limit
     124             :         int LimitSchedule;                  // Schedule index for demand limit
     125             :         Real64 SafetyFraction;              // Multiplier applied to demand limit schedule
     126             :         int BillingSchedule;                // Schedule index for billing month periods
     127             :         Real64 BillingPeriod;               // Current billing period value
     128             :         int PeakSchedule;                   // Schedule index for billing month periods
     129             :         int AveragingWindow;                // Number of timesteps for averaging demand window
     130             :         Array1D<Real64> History;            // Demand window history
     131             :         ManagePriorityType ManagerPriority; // Indicator for priority (SEQUENTIAL, OPTIMAL, ALL)
     132             :         int NumOfManager = 0;               // Number of DEMAND MANAGERs
     133             :         Array1D_int Manager;                // Indexes for DEMAND MANAGERs
     134             :         Real64 MeterDemand;                 // Meter demand at this timestep
     135             :         Real64 AverageDemand;               // Current demand over the demand window
     136             :         Real64 PeakDemand;                  // Peak demand in the billing month so far
     137             :         Real64 ScheduledLimit;              // Scheduled demand limit
     138             :         Real64 DemandLimit;                 // Scheduled demand limit * Safety Fraction
     139             :         Real64 AvoidedDemand;               // Demand avoided by active DEMAND MANAGERs
     140             :         Real64 OverLimit;                   // Amount that demand limit is exceeded
     141             :         Real64 OverLimitDuration;           // Number of hours that demand limit is exceeded
     142             : 
     143             :         // Default Constructor
     144           6 :         DemandManagerListData()
     145           6 :             : Meter(0), LimitSchedule(0), SafetyFraction(1.0), BillingSchedule(0), BillingPeriod(0.0), PeakSchedule(0), AveragingWindow(1),
     146             :               ManagerPriority(ManagePriorityType::Invalid), MeterDemand(0.0), AverageDemand(0.0), PeakDemand(0.0), ScheduledLimit(0.0),
     147           6 :               DemandLimit(0.0), AvoidedDemand(0.0), OverLimit(0.0), OverLimitDuration(0.0)
     148             :         {
     149           6 :         }
     150             :     };
     151             : 
     152          78 :     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             :         int AvailSchedule;     // Schedule index pointer for 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           6 :         DemandManagerData()
     183           6 :             : Type(ManagerType::Invalid), DemandManagerList(0), CanReduceDemand(false), AvailSchedule(0), Available(false), Activate(false),
     184             :               Active(false), LimitControl(ManagerLimit::Invalid), SelectionControl(ManagerSelection::Invalid), LimitDuration(0), ElapsedTime(0),
     185             :               RotationDuration(0), ElapsedRotationTime(0), RotatedLoadNum(0), LowerLimit(0.0), UpperLimit(0.0), NumOfLoads(0), FixedRate(0.0),
     186           6 :               ReductionRatio(0.0)
     187             :         {
     188           6 :         }
     189             :     };
     190             : 
     191             :     void ManageDemand(EnergyPlusData &state);
     192             : 
     193             :     void SimulateDemandManagerList(EnergyPlusData &state,
     194             :                                    int ListNum,
     195             :                                    bool &ResimExt, // Flag to resimulate the exterior energy use simulation
     196             :                                    bool &ResimHB,  // Flag to resimulate the heat balance simulation (including HVAC)
     197             :                                    bool &ResimHVAC // Flag to resimulate the HVAC simulation
     198             :     );
     199             : 
     200             :     void GetDemandManagerListInput(EnergyPlusData &state);
     201             : 
     202             :     void GetDemandManagerInput(EnergyPlusData &state);
     203             : 
     204             :     void SurveyDemandManagers(EnergyPlusData &state);
     205             : 
     206             :     void ActivateDemandManagers(EnergyPlusData &state);
     207             : 
     208             :     void UpdateDemandManagers(EnergyPlusData &state);
     209             : 
     210             :     void ReportDemandManagerList(EnergyPlusData &state, int ListNum);
     211             : 
     212             :     void LoadInterface(EnergyPlusData &state, DemandAction Action, int MgrNum, int LoadPtr, bool &CanReduceDemand);
     213             : 
     214             :     void InitDemandManagers(EnergyPlusData &state);
     215             : 
     216             : } // namespace DemandManager
     217             : 
     218        1542 : struct DemandManagerData : BaseGlobalStruct
     219             : {
     220             :     int NumDemandManagerList = 0;
     221             :     int NumDemandMgr = 0;
     222             :     int DemandManagerExtIterations = 0;
     223             :     int DemandManagerHBIterations = 0;
     224             :     int DemandManagerHVACIterations = 0;
     225             :     bool GetInput = true; // Flag to prevent input from being read multiple times
     226             :     Array1D<DemandManager::DemandManagerListData> DemandManagerList;
     227             :     Array1D<DemandManager::DemandManagerData> DemandMgr;
     228             :     std::unordered_map<std::string, std::string> UniqueDemandMgrNames;
     229             :     bool ClearHistory = true;
     230             :     bool BeginDemandSim = true;
     231             :     bool ResimHVAC = true;
     232             :     bool ResimHB = true;
     233             :     bool ResimExt = true;
     234             :     bool firstTime = true;
     235             : 
     236           0 :     void clear_state() override
     237             :     {
     238           0 :         NumDemandManagerList = 0;
     239           0 :         NumDemandMgr = 0;
     240           0 :         DemandManagerExtIterations = 0;
     241           0 :         DemandManagerHBIterations = 0;
     242           0 :         DemandManagerHVACIterations = 0;
     243           0 :         GetInput = true;
     244           0 :         DemandManagerList.deallocate();
     245           0 :         DemandMgr.deallocate();
     246           0 :         UniqueDemandMgrNames.clear();
     247           0 :         ClearHistory = true;
     248           0 :         BeginDemandSim = true;
     249           0 :         ResimHVAC = true;
     250           0 :         ResimHB = true;
     251           0 :         ResimExt = true;
     252           0 :         firstTime = true;
     253           0 :     }
     254             : };
     255             : 
     256             : } // namespace EnergyPlus
     257             : 
     258             : #endif

Generated by: LCOV version 1.13