LCOV - code coverage report
Current view: top level - EnergyPlus - ZoneEquipmentManager.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 100.0 % 7 7
Test Date: 2025-05-22 16:09:37 Functions: 100.0 % 3 3

            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 ZoneEquipmentManager_hh_INCLUDED
      49              : #define ZoneEquipmentManager_hh_INCLUDED
      50              : 
      51              : // ObjexxFCL Headers
      52              : #include <ObjexxFCL/Array1D.hh>
      53              : #include <ObjexxFCL/Optional.hh>
      54              : 
      55              : // EnergyPlus Headers
      56              : #include <EnergyPlus/Data/BaseData.hh>
      57              : #include <EnergyPlus/DataGlobalConstants.hh>
      58              : #include <EnergyPlus/DataGlobals.hh>
      59              : #include <EnergyPlus/DataHeatBalance.hh>
      60              : #include <EnergyPlus/DataSizing.hh>
      61              : #include <EnergyPlus/DataZoneEnergyDemands.hh>
      62              : #include <EnergyPlus/DataZoneEquipment.hh>
      63              : #include <EnergyPlus/EnergyPlus.hh>
      64              : 
      65              : namespace EnergyPlus {
      66              : 
      67              : // Forward declarations
      68              : struct EnergyPlusData;
      69              : 
      70              : namespace ZoneEquipmentManager {
      71              : 
      72              :     struct SimulationOrder
      73              :     {
      74              :         std::string EquipTypeName = "";
      75              :         DataZoneEquipment::ZoneEquipType equipType = DataZoneEquipment::ZoneEquipType::Invalid;
      76              :         std::string EquipName = "";
      77              :         int EquipPtr = 0;
      78              :         int CoolingPriority = 0;
      79              :         int HeatingPriority = 0;
      80              :     };
      81              : 
      82              :     void ManageZoneEquipment(EnergyPlusData &state,
      83              :                              bool FirstHVACIteration,
      84              :                              bool &SimZone, // Set to false at the end of the routine
      85              :                              bool &SimAir   // Eventually set to true via SimZoneEquipment if AirLoop must be resimulated
      86              :     );
      87              : 
      88              :     void GetZoneEquipment(EnergyPlusData &state);
      89              : 
      90              :     void InitZoneEquipment(EnergyPlusData &state, bool FirstHVACIteration); // unused 1208
      91              : 
      92              :     void sizeZoneSpaceEquipmentPart1(EnergyPlusData &state,
      93              :                                      DataZoneEquipment::EquipConfiguration &ZoneEquipConfig,
      94              :                                      DataSizing::ZoneSizingData &zsCalcSizing,
      95              :                                      DataZoneEnergyDemands::ZoneSystemSensibleDemand &zsEnergyDemand,
      96              :                                      DataZoneEnergyDemands::ZoneSystemMoistureDemand &zsMoistureDemand,
      97              :                                      DataHeatBalance::ZoneData const &zoneOrSpace,
      98              :                                      int zoneNum,
      99              :                                      int spaceNum = 0);
     100              : 
     101              :     void sizeZoneSpaceEquipmentPart2(EnergyPlusData &state,
     102              :                                      DataZoneEquipment::EquipConfiguration &zoneEquipConfig,
     103              :                                      DataSizing::ZoneSizingData &zsCalcSizing,
     104              :                                      int zoneNum,
     105              :                                      int spaceNum = 0);
     106              : 
     107              :     void SizeZoneEquipment(EnergyPlusData &state);
     108              : 
     109              :     void SetUpZoneSizingArrays(EnergyPlusData &state);
     110              : 
     111              :     void calcSizingOA(EnergyPlusData &state,
     112              :                       DataSizing::ZoneSizingData &zsFinalSizing,
     113              :                       DataSizing::ZoneSizingData &zsCalcFinalSizing,
     114              :                       bool &dsoaError,
     115              :                       bool &ErrorsFound,
     116              :                       int const zoneNum,
     117              :                       int const spaceNum = 0);
     118              : 
     119              :     void fillZoneSizingFromInput(EnergyPlusData &state,
     120              :                                  DataSizing::ZoneSizingInputData const &zoneSizingInput,
     121              :                                  Array2D<DataSizing::ZoneSizingData> &zsSizing,
     122              :                                  Array2D<DataSizing::ZoneSizingData> &zsCalcSizing,
     123              :                                  DataSizing::ZoneSizingData &zsFinalSizing,
     124              :                                  DataSizing::ZoneSizingData &zsCalcFinalSizing,
     125              :                                  std::string_view const zoneOrSpaceName,
     126              :                                  int const zoneOrSpaceNum);
     127              : 
     128              :     void RezeroZoneSizingArrays(EnergyPlusData &state);
     129              : 
     130              :     void UpdateZoneSizing(EnergyPlusData &state, Constant::CallIndicator CallIndicator);
     131              : 
     132              :     void updateZoneSizingBeginDay(EnergyPlusData const &state, DataSizing::ZoneSizingData &zsCalcSizing);
     133              : 
     134              :     void updateZoneSizingDuringDay(DataSizing::ZoneSizingData &zsSizing,
     135              :                                    DataSizing::ZoneSizingData &zsCalcSizing,
     136              :                                    Real64 const tstatHi,
     137              :                                    Real64 const tstatLo,
     138              :                                    Real64 &sizTstatHi,
     139              :                                    Real64 &sizTstatLo,
     140              :                                    int const timeStepInDay,
     141              :                                    Real64 const fracTimeStepZone);
     142              : 
     143              :     void updateZoneSizingEndDayMovingAvg(DataSizing::ZoneSizingData &zsCalcSizing, int const numTimeStepsInAvg);
     144              : 
     145              :     void updateZoneSizingEndDay(DataSizing::ZoneSizingData &zsCalcSizing,
     146              :                                 DataSizing::ZoneSizingData &zsCalcFinalSizing,
     147              :                                 int const numTimeStepInDay,
     148              :                                 DataSizing::DesDayWeathData const &desDayWeath,
     149              :                                 Real64 const stdRhoAir);
     150              : 
     151              :     void updateZoneSizingEndZoneSizingCalc1(EnergyPlusData &state, int const zoneNum);
     152              : 
     153              :     void updateZoneSizingEndZoneSizingCalc2(EnergyPlusData &state, DataSizing::ZoneSizingData &zsCalcSizing);
     154              : 
     155              :     void writeZszSpsz(EnergyPlusData &state,
     156              :                       EnergyPlus::InputOutputFile &outputFile,
     157              :                       int const numSpacesOrZones,
     158              :                       EPVector<DataSizing::ZoneSizingData> const &zsCalcFinalSizing,
     159              :                       Array2D<DataSizing::ZoneSizingData> const &zsCalcSizing,
     160              :                       bool const forSpaces);
     161              : 
     162              :     std::string sizingPeakTimeStamp(EnergyPlusData const &state, int timeStepIndex);
     163              : 
     164              :     void updateZoneSizingEndZoneSizingCalc3(DataSizing::ZoneSizingData &zsCalcFinalSizing,
     165              :                                             Array2D<DataSizing::ZoneSizingData> &zsCalcSizing,
     166              :                                             bool &anyLatentLoad,
     167              :                                             int const zoneOrSpaceNum);
     168              : 
     169              :     void updateZoneSizingEndZoneSizingCalc4(DataSizing::ZoneSizingData &zsSizing, DataSizing::ZoneSizingData const &zsCalcSizing);
     170              : 
     171              :     void updateZoneSizingEndZoneSizingCalc5(DataSizing::ZoneSizingData &zsFinalSizing, DataSizing::ZoneSizingData const &zsCalcFinalSizing);
     172              : 
     173              :     void updateZoneSizingEndZoneSizingCalc6(DataSizing::ZoneSizingData &zsSizing,
     174              :                                             DataSizing::ZoneSizingData const &zsCalcSizing,
     175              :                                             int const numTimeStepsInDay);
     176              : 
     177              :     void updateZoneSizingEndZoneSizingCalc7(EnergyPlusData &state,
     178              :                                             DataSizing::ZoneSizingData &zsFinalSizing,
     179              :                                             DataSizing::ZoneSizingData &zsCalcFinalSizing,
     180              :                                             Array2D<DataSizing::ZoneSizingData> &zsSizing,
     181              :                                             Array2D<DataSizing::ZoneSizingData> &zsCalcSizing,
     182              :                                             int const zoneOrSpaceNum);
     183              : 
     184              :     void SimZoneEquipment(EnergyPlusData &state, bool FirstHVACIteration, bool &SimAir);
     185              : 
     186              :     void SetZoneEquipSimOrder(EnergyPlusData &state, int ControlledZoneNum);
     187              : 
     188              :     void InitSystemOutputRequired(EnergyPlusData &state, int ZoneNum, bool FirstHVACIteration, bool ResetSimOrder = false);
     189              : 
     190              :     void initOutputRequired(EnergyPlusData &state,
     191              :                             int const ZoneNum,
     192              :                             DataZoneEnergyDemands::ZoneSystemSensibleDemand &energy,
     193              :                             DataZoneEnergyDemands::ZoneSystemMoistureDemand &moisture,
     194              :                             bool const FirstHVACIteration,
     195              :                             bool const ResetSimOrder,
     196              :                             int spaceNum = 0);
     197              : 
     198              :     void DistributeSystemOutputRequired(EnergyPlusData &state, int ZoneNum, bool FirstHVACIteration);
     199              : 
     200              :     void distributeOutputRequired(EnergyPlusData &state,
     201              :                                   int const ZoneNum,
     202              :                                   DataZoneEnergyDemands::ZoneSystemSensibleDemand &energy,
     203              :                                   DataZoneEnergyDemands::ZoneSystemMoistureDemand &moisture);
     204              : 
     205              :     void updateSystemOutputRequired(EnergyPlusData &state,
     206              :                                     int const ZoneNum,
     207              :                                     Real64 const SysOutputProvided, // sensible output provided by zone equipment (W)
     208              :                                     Real64 const LatOutputProvided, // latent output provided by zone equipment (kg/s)
     209              :                                     DataZoneEnergyDemands::ZoneSystemSensibleDemand &energy,
     210              :                                     DataZoneEnergyDemands::ZoneSystemMoistureDemand &moisture,
     211              :                                     int const EquipPriorityNum = -1 // optional index in PrioritySimOrder for this update
     212              :     );
     213              : 
     214              :     void adjustSystemOutputRequired(Real64 const sensibleRatio, // sensible load adjustment
     215              :                                     Real64 const latentRatio,   // latent load adjustment
     216              :                                     DataZoneEnergyDemands::ZoneSystemSensibleDemand &energy,
     217              :                                     DataZoneEnergyDemands::ZoneSystemMoistureDemand &moisture,
     218              :                                     int const equipPriorityNum // index in PrioritySimOrder
     219              :     );
     220              : 
     221              :     void CalcZoneMassBalance(EnergyPlusData &state, bool FirstHVACIteration);
     222              : 
     223              :     void CalcZoneInfiltrationFlows(EnergyPlusData &state,
     224              :                                    int const ZoneNum,                      // current zone index
     225              :                                    Real64 const &ZoneReturnAirMassFlowRate // zone total zone return air mass flow rate
     226              :     );
     227              : 
     228              :     void CalcAirFlowSimple(EnergyPlusData &state,
     229              :                            int SysTimestepLoop = 0,                    // System time step index
     230              :                            bool AdjustZoneMixingFlowFlag = false,      // flags to adjust zone mxing mass flow rate
     231              :                            bool AdjustZoneInfiltrationFlowFlag = false // flags to djust zone infiltration air flow rate
     232              :     );
     233              : 
     234              :     void GetStandAloneERVNodes(EnergyPlusData &state, DataHeatBalance::ZoneAirBalanceData &thisZoneAirBalance);
     235              : 
     236              :     void CalcZoneMixingFlowRateOfReceivingZone(EnergyPlusData &state, int ZoneNum, Real64 &ZoneMixingAirMassFlowRate);
     237              : 
     238              :     void CalcZoneMixingFlowRateOfSourceZone(EnergyPlusData &state, int ZoneNum);
     239              : 
     240              :     void CalcZoneLeavingConditions(EnergyPlusData &state, bool FirstHVACIteration);
     241              : 
     242              :     void UpdateZoneEquipment(EnergyPlusData &state, bool &SimAir);
     243              : 
     244              :     void CalcDOASSupCondsForSizing(EnergyPlusData &state,
     245              :                                    Real64 OutDB,                        // outside air temperature [C]
     246              :                                    Real64 OutHR,                        // outside humidity ratio [kg Water / kg Dry Air]
     247              :                                    DataSizing::DOASControl DOASControl, // dedicated outside air control strategy
     248              :                                    Real64 DOASLowTemp,                  // DOAS low setpoint [C]
     249              :                                    Real64 DOASHighTemp,                 // DOAS high setpoint [C]
     250              :                                    Real64 W90H, // humidity ratio at DOAS high setpoint temperature and 90% relative humidity [kg Water / kg Dry Air]
     251              :                                    Real64 W90L, // humidity ratio at DOAS low setpoint temperature and 90% relative humidity [kg Water / kg Dry Air]
     252              :                                    Real64 &DOASSupTemp, // DOAS supply temperature [C]
     253              :                                    Real64 &DOASSupHR    // DOAS Supply Humidity ratio [kg Water / kg Dry Air]
     254              :     );
     255              : 
     256              :     void AutoCalcDOASControlStrategy(EnergyPlusData &state);
     257              : 
     258              :     void ReportInfiltrations(EnergyPlusData &state);
     259              : 
     260              :     void ReportZoneSizingDOASInputs(EnergyPlusData &state,
     261              :                                     std::string const &ZoneName,         // the name of the zone
     262              :                                     std::string const &DOASCtrlStrategy, // DOAS control strategy
     263              :                                     Real64 DOASLowTemp,                  // DOAS design low setpoint temperature [C]
     264              :                                     Real64 DOASHighTemp,                 // DOAS design high setpoint temperature [C]
     265              :                                     bool &headerAlreadyPrinted);
     266              : 
     267              : } // namespace ZoneEquipmentManager
     268              : 
     269              : struct ZoneEquipmentManagerData : BaseGlobalStruct
     270              : {
     271              : 
     272              :     Array1D<Real64> AvgData;    // scratch array for storing averaged data -- keep on state to avoid it being recreated
     273              :     int NumOfTimeStepInDay = 0; // number of zone time steps in a day
     274              :     bool GetZoneEquipmentInputFlag = true;
     275              :     bool SizeZoneEquipmentOneTimeFlag = true;
     276              : 
     277              :     Array1D<ZoneEquipmentManager::SimulationOrder> PrioritySimOrder;
     278              : 
     279              :     bool InitZoneEquipmentOneTimeFlag = true;
     280              :     bool InitZoneEquipmentEnvrnFlag = true;
     281              :     bool FirstPassZoneEquipFlag = true; // indicates first pass through zone equipment, used to reset selected ZoneEqSizing variables
     282              : 
     283         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     284              :     {
     285         2126 :     }
     286              : 
     287         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     288              :     {
     289         1152 :     }
     290              : 
     291         2100 :     void clear_state() override
     292              :     {
     293         2100 :         new (this) ZoneEquipmentManagerData();
     294         2100 :     }
     295              : };
     296              : 
     297              : } // namespace EnergyPlus
     298              : 
     299              : #endif
        

Generated by: LCOV version 2.0-1