LCOV - code coverage report
Current view: top level - EnergyPlus - UnitHeater.hh (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 15 32 46.9 %
Date: 2024-08-23 23:50:59 Functions: 4 5 80.0 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2024, 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 UnitHeater_hh_INCLUDED
      49             : #define UnitHeater_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/DataGlobals.hh>
      58             : #include <EnergyPlus/EnergyPlus.hh>
      59             : 
      60             : namespace EnergyPlus {
      61             : 
      62             : // Forward declarations
      63             : struct EnergyPlusData;
      64             : 
      65             : namespace UnitHeater {
      66             : 
      67             :     enum class HCoilType
      68             :     {
      69             :         Invalid = -1,
      70             :         Electric,
      71             :         Gas,
      72             :         WaterHeatingCoil,
      73             :         SteamCoil,
      74             :         Num
      75             :     };
      76             : 
      77             :     static constexpr std::array<std::string_view, static_cast<int>(HCoilType::Num)> HCoilTypeNamesUC{
      78             :         "COIL:HEATING:ELECTRIC",
      79             :         "COIL:HEATING:FUEL",
      80             :         "COIL:HEATING:WATER",
      81             :         "COIL:HEATING:STEAM",
      82             :     };
      83             : 
      84             :     struct UnitHeaterData
      85             :     {
      86             :         // Members
      87             :         // Input data
      88             :         std::string Name;      // name of unit
      89             :         std::string SchedName; // availability schedule
      90             :         int SchedPtr;          // index to schedule
      91             :         int AirInNode;         // inlet air node number
      92             :         int AirOutNode;        // outlet air node number
      93             :         HVAC::FanType fanType; // Fan type number (see DataHVACGlobals)
      94             :         std::string FanName;   // name of fan
      95             :         int Fan_Index;
      96             :         int FanSchedPtr;      // index to fan operating mode schedule
      97             :         int FanAvailSchedPtr; // index to fan availability schedule
      98             :         int ControlCompTypeNum;
      99             :         int CompErrIndex;
     100             :         Real64 MaxAirVolFlow;                   // m3/s
     101             :         Real64 MaxAirMassFlow;                  // kg/s
     102             :         std::string FanOperatesDuringNoHeating; // Indicates whether fan operates or not during no heating
     103             :         int FanOutletNode;                      // outlet node number for fan exit
     104             :         // (assumes fan is upstream of heating coil)
     105             :         HVAC::FanOp fanOp = HVAC::FanOp::Invalid; // mode of operation; 1=cycling fan, cycling coil, 2=continuous fan, cycling coil
     106             :         HCoilType Type;                           // type of heating coil (water, gas, electric, etc.)
     107             :         std::string HCoilTypeCh;                  // actual object name
     108             :         std::string HCoilName;                    // name of heating coil
     109             :         int HCoil_Index;
     110             :         DataPlant::PlantEquipmentType HeatingCoilType;
     111             :         int HCoil_FluidIndex;
     112             :         Real64 MaxVolHotWaterFlow; // m3/s
     113             :         Real64 MaxVolHotSteamFlow; // m3/s
     114             :         Real64 MaxHotWaterFlow;    // kg/s
     115             :         Real64 MaxHotSteamFlow;    // m3/s
     116             :         Real64 MinVolHotWaterFlow; // m3/s
     117             :         Real64 MinVolHotSteamFlow; // m3/s
     118             :         Real64 MinHotWaterFlow;    // kg/s
     119             :         Real64 MinHotSteamFlow;    // kg/s
     120             :         int HotControlNode;        // hot water control node, inlet of coil
     121             :         Real64 HotControlOffset;   // control tolerance
     122             :         int HotCoilOutNodeNum;     // outlet of coil
     123             :         PlantLocation HWplantLoc;  // Location of plant component for hot plant coil
     124             :         Real64 PartLoadFrac;       // part load fraction for the unit
     125             :         // Report data
     126             :         Real64 HeatPower;  // unit heating output in watts
     127             :         Real64 HeatEnergy; // unit heating output in J
     128             :         Real64 ElecPower;
     129             :         Real64 ElecEnergy;
     130             :         std::string AvailManagerListName; // Name of an availability manager list object
     131             :         Avail::Status availStatus = Avail::Status::NoAction;
     132             :         bool FanOffNoHeating;    // True when fan is on during no heating load
     133             :         Real64 FanPartLoadRatio; // fan part-load ratio for time step
     134             :         int ZonePtr;             // pointer to a zone served by a unit heater
     135             :         int HVACSizingIndex;     // index of a HVACSizing object for a unit heater
     136             :         bool FirstPass;          // detects first time through for resetting sizing data
     137             : 
     138             :         // Default Constructor
     139          77 :         UnitHeaterData()
     140         231 :             : SchedPtr(0), AirInNode(0), AirOutNode(0), fanType(HVAC::FanType::Invalid), Fan_Index(0), FanSchedPtr(0), FanAvailSchedPtr(0),
     141         231 :               ControlCompTypeNum(0), CompErrIndex(0), MaxAirVolFlow(0.0), MaxAirMassFlow(0.0), FanOutletNode(0), HCoil_Index(0),
     142          77 :               HeatingCoilType(DataPlant::PlantEquipmentType::Invalid), HCoil_FluidIndex(0), MaxVolHotWaterFlow(0.0), MaxVolHotSteamFlow(0.0),
     143          77 :               MaxHotWaterFlow(0.0), MaxHotSteamFlow(0.0), MinVolHotWaterFlow(0.0), MinVolHotSteamFlow(0.0), MinHotWaterFlow(0.0),
     144          77 :               MinHotSteamFlow(0.0), HotControlNode(0), HotControlOffset(0.0), HotCoilOutNodeNum(0), HWplantLoc{}, PartLoadFrac(0.0), HeatPower(0.0),
     145         154 :               HeatEnergy(0.0), ElecPower(0.0), ElecEnergy(0.0), FanOffNoHeating(false), FanPartLoadRatio(0.0), ZonePtr(0), HVACSizingIndex(0),
     146         154 :               FirstPass(true)
     147             :         {
     148          77 :         }
     149             :     };
     150             : 
     151             :     struct UnitHeatNumericFieldData
     152             :     {
     153             :         // Members
     154             :         Array1D_string FieldNames;
     155             : 
     156             :         // Default Constructor
     157          77 :         UnitHeatNumericFieldData()
     158          77 :         {
     159          77 :         }
     160             :     };
     161             : 
     162             :     void SimUnitHeater(EnergyPlusData &state,
     163             :                        std::string_view CompName,     // name of the fan coil unit
     164             :                        int const ZoneNum,             // number of zone being served
     165             :                        bool const FirstHVACIteration, // TRUE if 1st HVAC simulation of system timestep
     166             :                        Real64 &PowerMet,              // Sensible power supplied (W)
     167             :                        Real64 &LatOutputProvided,     // Latent add/removal supplied by window AC (kg/s), dehumid = negative
     168             :                        int &CompIndex);
     169             : 
     170             :     void GetUnitHeaterInput(EnergyPlusData &state);
     171             : 
     172             :     void InitUnitHeater(EnergyPlusData &state,
     173             :                         int const UnitHeatNum,        // index for the current unit heater
     174             :                         int const ZoneNum,            // number of zone being served
     175             :                         bool const FirstHVACIteration // TRUE if 1st HVAC simulation of system timestep
     176             :     );
     177             : 
     178             :     void SizeUnitHeater(EnergyPlusData &state, int const UnitHeatNum);
     179             : 
     180             :     void CalcUnitHeater(EnergyPlusData &state,
     181             :                         int &UnitHeatNum,              // number of the current fan coil unit being simulated
     182             :                         int const ZoneNum,             // number of zone being served
     183             :                         bool const FirstHVACIteration, // TRUE if 1st HVAC simulation of system timestep
     184             :                         Real64 &PowerMet,              // Sensible power supplied (W)
     185             :                         Real64 &LatOutputProvided      // Latent power supplied (kg/s), negative = dehumidification
     186             :     );
     187             : 
     188             :     void CalcUnitHeaterComponents(EnergyPlusData &state,
     189             :                                   int const UnitHeatNum,                             // Unit index in unit heater array
     190             :                                   bool const FirstHVACIteration,                     // flag for 1st HVAV iteration in the time step
     191             :                                   Real64 &LoadMet,                                   // load met by unit (watts)
     192             :                                   HVAC::FanOp const fanOp = HVAC::FanOp::Continuous, // fan operating mode
     193             :                                   Real64 const PartLoadRatio = 1.0                   // part-load ratio
     194             :     );
     195             : 
     196             :     // SUBROUTINE UpdateUnitHeater
     197             : 
     198             :     // No update routine needed in this module since all of the updates happen on
     199             :     // the Node derived type directly and these updates are done by other routines.
     200             : 
     201             :     // END SUBROUTINE UpdateUnitHeater
     202             : 
     203             :     void ReportUnitHeater(EnergyPlusData &state, int const UnitHeatNum); // Unit index in unit heater array
     204             : 
     205             :     int getUnitHeaterIndex(EnergyPlusData &state, std::string_view CompName);
     206             : } // namespace UnitHeater
     207             : 
     208             : struct UnitHeatersData : BaseGlobalStruct
     209             : {
     210             : 
     211             :     // MODULE PARAMETER DEFINITIONS
     212             :     std::string const cMO_UnitHeater = "ZoneHVAC:UnitHeater";
     213             : 
     214             :     // Character parameters for outside air control types:
     215             : 
     216             :     bool HCoilOn;       // TRUE if the heating coil (gas or electric especially) should be running
     217             :     int NumOfUnitHeats; // Number of unit heaters in the input file
     218             :     Real64 QZnReq;      // heating or cooling needed by zone [watts]
     219             :     Array1D_bool MySizeFlag;
     220             :     Array1D_bool CheckEquipName;
     221             : 
     222             :     bool InitUnitHeaterOneTimeFlag = true;
     223             :     bool GetUnitHeaterInputFlag = true;
     224             :     bool ZoneEquipmentListChecked = false; // True after the Zone Equipment List has been checked for items
     225             :     bool SetMassFlowRateToZero = false;    // TRUE when mass flow rates need to be set to zero
     226             : 
     227             :     // Object Data
     228             :     EPVector<UnitHeater::UnitHeaterData> UnitHeat;
     229             :     EPVector<UnitHeater::UnitHeatNumericFieldData> UnitHeatNumericFields;
     230             : 
     231             :     Array1D_bool MyEnvrnFlag;
     232             :     Array1D_bool MyPlantScanFlag;
     233             :     Array1D_bool MyZoneEqFlag; // used to set up zone equipment availability managers
     234             : 
     235             :     int RefrigIndex = 0;
     236             : 
     237         796 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     238             :     {
     239         796 :     }
     240             : 
     241           0 :     void clear_state() override
     242             :     {
     243           0 :         this->HCoilOn = false;
     244           0 :         this->NumOfUnitHeats = 0;
     245           0 :         this->QZnReq = 0.0;
     246           0 :         this->MySizeFlag.deallocate();
     247           0 :         this->CheckEquipName.deallocate();
     248           0 :         this->UnitHeat.deallocate();
     249           0 :         this->UnitHeatNumericFields.deallocate();
     250           0 :         this->InitUnitHeaterOneTimeFlag = true;
     251           0 :         this->GetUnitHeaterInputFlag = true;
     252           0 :         this->ZoneEquipmentListChecked = false;
     253           0 :         this->SetMassFlowRateToZero = false;
     254           0 :         this->MyEnvrnFlag.deallocate();
     255           0 :         this->MyPlantScanFlag.deallocate();
     256           0 :         this->MyZoneEqFlag.deallocate();
     257           0 :         this->RefrigIndex = 0;
     258           0 :     }
     259             : 
     260             :     // Default Constructor
     261         796 :     UnitHeatersData() = default;
     262             : };
     263             : 
     264             : } // namespace EnergyPlus
     265             : 
     266             : #endif

Generated by: LCOV version 1.14