LCOV - code coverage report
Current view: top level - EnergyPlus - UnitVentilator.hh (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 12 33 36.4 %
Date: 2024-08-23 23:50:59 Functions: 7 8 87.5 %

          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 UnitVentilator_hh_INCLUDED
      49             : #define UnitVentilator_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/EPVector.hh>
      59             : #include <EnergyPlus/EnergyPlus.hh>
      60             : #include <EnergyPlus/Plant/Enums.hh>
      61             : #include <EnergyPlus/Plant/PlantLocation.hh>
      62             : #include <EnergyPlus/SystemAvailabilityManager.hh>
      63             : 
      64             : namespace EnergyPlus {
      65             : 
      66             : // Forward declarations
      67             : struct EnergyPlusData;
      68             : 
      69             : namespace UnitVentilator {
      70             : 
      71             :     enum class CoilsUsed
      72             :     {
      73             :         Invalid = -1,
      74             :         None,
      75             :         Both,
      76             :         Heating,
      77             :         Cooling,
      78             :         Num
      79             :     };
      80             :     enum class HeatCoilType
      81             :     {
      82             :         Invalid = -1,
      83             :         Electric,
      84             :         Gas,
      85             :         Water,
      86             :         Steam,
      87             :         Num
      88             :     };
      89             :     enum class CoolCoilType
      90             :     {
      91             :         Invalid = -1,
      92             :         Water,
      93             :         Detailed,
      94             :         HXAssisted,
      95             :         Num
      96             :     };
      97             :     enum class OAControl
      98             :     {
      99             :         Invalid = -1,
     100             :         VariablePercent,
     101             :         FixedTemperature,
     102             :         FixedAmount,
     103             :         Num
     104             :     };
     105             : 
     106             :     struct UnitVentilatorData
     107             :     {
     108             :         std::string Name;      // name of unit
     109             :         int SchedPtr = 0;      // index to schedule
     110             :         int AirInNode = 0;     // inlet air node number
     111             :         int AirOutNode = 0;    // outlet air node number
     112             :         int FanOutletNode = 0; // outlet node number for fan exit
     113             :         // (assumes fan is upstream of heating coil)
     114             :         HVAC::FanType fanType = HVAC::FanType::Invalid; // Fan type number (see DataHVACGlobals)
     115             :         std::string FanName;                            // name of fan
     116             :         int Fan_Index = 0;
     117             :         int FanSchedPtr = 0;                      // index to fan operating mode schedule
     118             :         int FanAvailSchedPtr = 0;                 // index to fan availability schedule
     119             :         HVAC::FanOp fanOp = HVAC::FanOp::Invalid; // mode of operation; 1=cycling fan, cycling coil, 2=continuous fan, cycling coil
     120             :         int ControlCompTypeNum = 0;
     121             :         int CompErrIndex = 0;
     122             :         Real64 MaxAirVolFlow = 0.0;                     // m3/s
     123             :         Real64 MaxAirMassFlow = 0.0;                    // kg/s
     124             :         OAControl OAControlType = OAControl::Invalid;   // type of control; options are VARIABLE PERCENT and FIXED TEMPERATURE
     125             :         int MinOASchedPtr = 0;                          // index to schedule
     126             :         int MaxOASchedPtr = 0;                          // index to schedule
     127             :         int TempSchedPtr = 0;                           // index to schedule
     128             :         int OutsideAirNode = 0;                         // outside air node number
     129             :         int AirReliefNode = 0;                          // relief air node number
     130             :         int OAMixerOutNode = 0;                         // outlet node after the outside air mixer (inlet to coils if present)
     131             :         Real64 OutAirVolFlow = 0.0;                     // m3/s
     132             :         Real64 OutAirMassFlow = 0.0;                    // kg/s
     133             :         Real64 MinOutAirVolFlow = 0.0;                  // m3/s
     134             :         Real64 MinOutAirMassFlow = 0.0;                 // kg/s
     135             :         CoilsUsed CoilOption = CoilsUsed::Invalid;      // type of coil option; options are BOTH, HEATING, COOLING, AND NONE
     136             :         bool HCoilPresent = false;                      // .TRUE. if unit ventilator has a heating coil
     137             :         HeatCoilType HCoilType = HeatCoilType::Invalid; // type of heating coil (water, gas, electric, etc.)
     138             :         std::string HCoilName;                          // name of heating coil
     139             :         std::string HCoilTypeCh;                        // type of heating coil character string (same as type on idf file).
     140             :         int HCoil_Index = 0;
     141             :         DataPlant::PlantEquipmentType HeatingCoilType = DataPlant::PlantEquipmentType::Invalid;
     142             :         int HCoil_FluidIndex = 0;
     143             :         int HCoilSchedPtr = 0; // index to schedule
     144             :         Real64 HCoilSchedValue = 0.0;
     145             :         Real64 MaxVolHotWaterFlow = 0.0; // m3/s
     146             :         Real64 MaxVolHotSteamFlow = 0.0; // m3/s
     147             :         Real64 MaxHotWaterFlow = 0.0;    // kg/s
     148             :         Real64 MaxHotSteamFlow = 0.0;
     149             :         Real64 MinHotSteamFlow = 0.0;
     150             :         Real64 MinVolHotWaterFlow = 0.0; // m3/s
     151             :         Real64 MinVolHotSteamFlow = 0.0; // m3/s
     152             :         Real64 MinHotWaterFlow = 0.0;    // kg/s
     153             :         int HotControlNode = 0;          // hot water control node
     154             :         int HotCoilOutNodeNum = 0;       // outlet of coil
     155             :         Real64 HotControlOffset = 0.0;   // control tolerance
     156             :         PlantLocation HWplantLoc;        // index for plant location for hot water coil
     157             :         bool CCoilPresent = false;       // .TRUE. if unit ventilator has a cooling coil
     158             :         std::string CCoilName;           // name of cooling coil
     159             :         std::string CCoilTypeCh;         // type of cooling coil as character string (same as on idf file)
     160             :         int CCoil_Index = 0;
     161             :         std::string CCoilPlantName; // name of cooling coil for plant
     162             :         std::string CCoilPlantType; // type of cooling coil for plant
     163             :         DataPlant::PlantEquipmentType CoolingCoilType = DataPlant::PlantEquipmentType::Invalid;
     164             :         CoolCoilType CCoilType = CoolCoilType::Invalid;
     165             :         int CCoilSchedPtr = 0; // index to schedule
     166             :         Real64 CCoilSchedValue = 0.0;
     167             :         Real64 MaxVolColdWaterFlow = 0.0; // m3/s
     168             :         Real64 MaxColdWaterFlow = 0.0;    // kg/s
     169             :         Real64 MinVolColdWaterFlow = 0.0; // m3/s
     170             :         Real64 MinColdWaterFlow = 0.0;    // kg/s
     171             :         int ColdControlNode = 0;          // chilled water control node
     172             :         int ColdCoilOutNodeNum = 0;       // chilled water coil out node
     173             :         Real64 ColdControlOffset = 0.0;   // control tolerance
     174             :         PlantLocation CWPlantLoc;         // index for plant component for chilled water coil
     175             :         // Report data
     176             :         Real64 HeatPower = 0.0;  // unit heating output in watts
     177             :         Real64 HeatEnergy = 0.0; // unit heating output in J
     178             :         Real64 TotCoolPower = 0.0;
     179             :         Real64 TotCoolEnergy = 0.0;
     180             :         Real64 SensCoolPower = 0.0;
     181             :         Real64 SensCoolEnergy = 0.0;
     182             :         Real64 ElecPower = 0.0;
     183             :         Real64 ElecEnergy = 0.0;
     184             :         std::string AvailManagerListName; // Name of an availability manager list object
     185             :         Avail::Status availStatus = Avail::Status::NoAction;
     186             :         Real64 FanPartLoadRatio = 0.0;                          // fan part-load ratio for time step
     187             :         Real64 PartLoadFrac = 0.0;                              // unit ventilator part-load ratio for time step
     188             :         int ZonePtr = 0;                                        // pointer to a zone served by a unit ventilator
     189             :         int HVACSizingIndex = 0;                                // index of a HVACSizing object for a unit ventilator
     190             :         bool ATMixerExists = false;                             // True if there is an ATMixer
     191             :         std::string ATMixerName;                                // name of air mixer
     192             :         int ATMixerIndex = 0;                                   // index to the air mixer
     193             :         HVAC::MixerType ATMixerType = HVAC::MixerType::Invalid; // 1 = inlet side mixer, 2 = supply side mixer
     194             :         int ATMixerPriNode = 0;                                 // primary inlet air node number for the mixer
     195             :         int ATMixerSecNode = 0;                                 // secondary air inlet node number for the mixer
     196             :         int ATMixerOutNode = 0;                                 // outlet air node number for the mixer
     197             :         bool FirstPass = true;                                  // detects first time through for resetting sizing data
     198             : 
     199          25 :         UnitVentilatorData() = default;
     200          30 :         ~UnitVentilatorData()
     201             :         {
     202          30 :         }
     203             :     };
     204             : 
     205             :     struct UnitVentNumericFieldData
     206             :     {
     207             :         // Members
     208             :         Array1D_string FieldNames;
     209             : 
     210          25 :         UnitVentNumericFieldData() = default;
     211          30 :         ~UnitVentNumericFieldData()
     212             :         {
     213          30 :         }
     214             :     };
     215             : 
     216             :     void SimUnitVentilator(EnergyPlusData &state,
     217             :                            std::string_view CompName,     // name of the fan coil unit
     218             :                            int const ZoneNum,             // number of zone being served
     219             :                            bool const FirstHVACIteration, // TRUE if 1st HVAC simulation of system timestep
     220             :                            Real64 &PowerMet,              // Sensible power supplied (W)
     221             :                            Real64 &LatOutputProvided,     // Latent add/removal supplied by window AC (kg/s), dehumid = negative
     222             :                            int &CompIndex);
     223             : 
     224             :     void GetUnitVentilatorInput(EnergyPlusData &state);
     225             : 
     226             :     void InitUnitVentilator(EnergyPlusData &state,
     227             :                             int const UnitVentNum,         // index for the current unit ventilator
     228             :                             bool const FirstHVACIteration, // TRUE if 1st HVAC simulation of system timestep
     229             :                             int const ZoneNum              // number of zone being served
     230             :     );
     231             : 
     232             :     void SizeUnitVentilator(EnergyPlusData &state, int const UnitVentNum);
     233             : 
     234             :     void CalcUnitVentilator(EnergyPlusData &state,
     235             :                             int &UnitVentNum,              // number of the current fan coil unit being simulated
     236             :                             int const ZoneNum,             // number of zone being served
     237             :                             bool const FirstHVACIteration, // TRUE if 1st HVAC simulation of system timestep
     238             :                             Real64 &PowerMet,              // Sensible power supplied (W)
     239             :                             Real64 &LatOutputProvided      // Latent power supplied (kg/s), negative = dehumidification
     240             :     );
     241             : 
     242             :     void CalcUnitVentilatorComponents(EnergyPlusData &state,
     243             :                                       int const UnitVentNum,         // Unit index in unit ventilator array
     244             :                                       bool const FirstHVACIteration, // flag for 1st HVAV iteration in the time step
     245             :                                       Real64 &LoadMet,               // load met by unit (watts)
     246             :                                       ObjexxFCL::Optional<HVAC::FanOp const> fanOp = HVAC::FanOp::Continuous, // Fan Type
     247             :                                       ObjexxFCL::Optional<Real64 const> PartLoadFrac = 1.0                    // Part Load Ratio of coil and fan
     248             :     );
     249             : 
     250             :     void SimUnitVentOAMixer(EnergyPlusData &state,
     251             :                             int const UnitVentNum,  // Unit index in unit ventilator array
     252             :                             HVAC::FanOp const fanOp // unit ventilator fan operating mode
     253             :     );
     254             : 
     255             :     void ReportUnitVentilator(EnergyPlusData &state, int const UnitVentNum); // Unit index in unit ventilator array
     256             : 
     257             :     int GetUnitVentilatorOutAirNode(EnergyPlusData &state, int const UnitVentNum);
     258             : 
     259             :     int GetUnitVentilatorZoneInletAirNode(EnergyPlusData &state, int const UnitVentNum);
     260             : 
     261             :     int GetUnitVentilatorMixedAirNode(EnergyPlusData &state, int const UnitVentNum);
     262             : 
     263             :     int GetUnitVentilatorReturnAirNode(EnergyPlusData &state, int const UnitVentNum);
     264             : 
     265             :     int getUnitVentilatorIndex(EnergyPlusData &state, std::string_view CompName);
     266             : 
     267             :     Real64 SetOAMassFlowRateForCoolingVariablePercent(EnergyPlusData &state,
     268             :                                                       int const UnitVentNum,     // Unit Ventilator index number
     269             :                                                       Real64 const MinOAFrac,    // Minimum Outside Air Fraction
     270             :                                                       Real64 const MassFlowRate, // Design Outside Air Mass Flow Rate
     271             :                                                       Real64 const MaxOAFrac,    // Maximum Outside Air Fraction
     272             :                                                       Real64 const Tinlet,       // Inlet Temperature to Unit or Zone Temperature
     273             :                                                       Real64 const Toutdoor      // Outdoor Air Temperature
     274             :     );
     275             : 
     276             :     void CalcMdotCCoilCycFan(EnergyPlusData &state,
     277             :                              Real64 &mdot,              // mass flow rate
     278             :                              Real64 &QCoilReq,          // Remaining cooling coil load
     279             :                              Real64 const QZnReq,       // Zone load to setpoint
     280             :                              int const UnitVentNum,     // Unit Ventilator index
     281             :                              Real64 const PartLoadRatio // Part load ratio for unit ventilator
     282             :     );
     283             : 
     284             : } // namespace UnitVentilator
     285             : 
     286             : struct UnitVentilatorsData : BaseGlobalStruct
     287             : {
     288             : 
     289             :     // Current Module Unit type
     290             :     std::string const cMO_UnitVentilator = "ZoneHVAC:UnitVentilator";
     291             : 
     292             :     bool HCoilOn = false;        // TRUE if the heating coil  = gas or electric especially) should be running
     293             :     int NumOfUnitVents = 0;      // Number of unit ventilators in the input file
     294             :     Real64 OAMassFlowRate = 0.0; // Outside air mass flow rate for the unit ventilator
     295             :     Real64 QZnReq = 0.0;         // heating or cooling needed by zone [watts]
     296             :     Array1D_bool MySizeFlag;
     297             :     bool GetUnitVentilatorInputFlag = true; // First time, input is "gotten"
     298             :     Array1D_bool CheckEquipName;
     299             : 
     300             :     EPVector<UnitVentilator::UnitVentilatorData> UnitVent;
     301             :     EPVector<UnitVentilator::UnitVentNumericFieldData> UnitVentNumericFields;
     302             : 
     303             :     bool MyOneTimeFlag = true;
     304             :     bool ZoneEquipmentListChecked = false; // True after the Zone Equipment List has been checked for items
     305             : 
     306             :     Array1D_bool MyEnvrnFlag;
     307             :     Array1D_bool MyPlantScanFlag;
     308             :     Array1D_bool MyZoneEqFlag;
     309             : 
     310             :     int RefrigIndex = 0;
     311             :     int DummyWaterIndex = 1;
     312             : 
     313             :     int ATMixOutNode = 0;   // outlet node of ATM Mixer
     314             :     int ATMixerPriNode = 0; // primary air node of ATM Mixer
     315             :     int ZoneNode = 0;       // zone node
     316             : 
     317         796 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     318             :     {
     319         796 :     }
     320             : 
     321           0 :     void clear_state() override
     322             :     {
     323           0 :         this->HCoilOn = false;
     324           0 :         this->NumOfUnitVents = 0;
     325           0 :         this->OAMassFlowRate = 0.0;
     326           0 :         this->QZnReq = 0.0;
     327           0 :         this->GetUnitVentilatorInputFlag = true;
     328           0 :         this->MySizeFlag.deallocate();
     329           0 :         this->CheckEquipName.deallocate();
     330           0 :         this->UnitVent.deallocate();
     331           0 :         this->UnitVentNumericFields.deallocate();
     332           0 :         this->MyOneTimeFlag = true;
     333           0 :         this->ZoneEquipmentListChecked = false;
     334           0 :         this->MyEnvrnFlag.deallocate();
     335           0 :         this->MyPlantScanFlag.deallocate();
     336           0 :         this->MyZoneEqFlag.deallocate();
     337           0 :         this->RefrigIndex = 0;
     338           0 :         this->DummyWaterIndex = 1;
     339           0 :         this->ATMixOutNode = 0;
     340           0 :         this->ATMixerPriNode = 0;
     341           0 :         this->ZoneNode = 0;
     342           0 :     }
     343             : 
     344             :     // Default Constructor
     345         796 :     UnitVentilatorsData() = default;
     346         796 :     ~UnitVentilatorsData()
     347        1592 :     {
     348         796 :     }
     349             : };
     350             : } // namespace EnergyPlus
     351             : 
     352             : #endif

Generated by: LCOV version 1.14