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

Generated by: LCOV version 1.13