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

            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 Humidifiers_hh_INCLUDED
      49              : #define Humidifiers_hh_INCLUDED
      50              : 
      51              : // ObjexxFCL Headers
      52              : #include <ObjexxFCL/Array1D.hh>
      53              : 
      54              : // EnergyPlus Headers
      55              : #include <EnergyPlus/Data/BaseData.hh>
      56              : #include <EnergyPlus/DataGlobals.hh>
      57              : #include <EnergyPlus/EnergyPlus.hh>
      58              : 
      59              : namespace EnergyPlus {
      60              : 
      61              : // Forward declarations
      62              : struct EnergyPlusData;
      63              : 
      64              : namespace Humidifiers {
      65              : 
      66              :     static constexpr std::array<std::string_view, 2> HumidifierType = {"Humidifier:Steam:Electric", "Humidifier:Steam:Gas"};
      67              : 
      68              :     enum class HumidType
      69              :     {
      70              :         Invalid = -1,
      71              :         Electric,
      72              :         Gas,
      73              :         Num
      74              :     };
      75              : 
      76              :     enum class InletWaterTemp
      77              :     {
      78              :         Invalid = -1,
      79              :         Fixed,
      80              :         Variable,
      81              :         Num
      82              :     };
      83              :     static constexpr std::array<std::string_view, static_cast<int>(InletWaterTemp::Num)> inletWaterTempsUC = {"FIXEDINLETWATERTEMPERATURE",
      84              :                                                                                                               "VARIABLEINLETWATERTEMPERATURE"};
      85              : 
      86              :     class HumidifierData
      87              :     {
      88              :     private:
      89              :     public:
      90              :         // Members
      91              :         std::string Name;                      // unique name of component
      92              :         HumidType HumType;                     // Pointer to Humidifier in list of humidifiers
      93              :         int EquipIndex;                        // Pointer to Humidifier in list of humidifiers
      94              :         Sched::Schedule *availSched = nullptr; // availability schedule
      95              :         Real64 NomCapVol;                      // nominal capacity [m3/s of water]
      96              :         Real64 NomCap;                         // nominal capacity [kg/s of water]
      97              :         Real64 NomPower;                       // power consumption at full output [watts]
      98              :         Real64 ThermalEffRated;                // rated thermal efficiency of the gas fired humidifier [-]
      99              :         Real64 CurMakeupWaterTemp;             // makeup water temperature from main water [C]
     100              :         int EfficiencyCurvePtr;                // index to efficiency curve
     101              :         InletWaterTemp InletWaterTempOption;   // type inlet water temperature fixed or variable
     102              :         Real64 FanPower;                       // nominal fan power [watts]
     103              :         Real64 StandbyPower;                   // standby power consumption [watts]
     104              :         int AirInNode;                         // air inlet node of humidifier
     105              :         int AirOutNode;                        // air outlet node of humidifier
     106              :         Real64 AirInTemp;                      // inlet air temperature [C]
     107              :         Real64 AirInHumRat;                    // inlet air humidity ratio [kg water / kg air]
     108              :         Real64 AirInEnthalpy;                  // inlet air specific enthalpy [J/kg]
     109              :         Real64 AirInMassFlowRate;              // inlet air mass flow rate [kg/s]
     110              :         Real64 AirOutTemp;                     // outlet air temperature [C]
     111              :         Real64 AirOutHumRat;                   // outlet air humidity ratio [kg water / kg air]
     112              :         Real64 AirOutEnthalpy;                 // outlet air specific enthalpy [J/kg]
     113              :         Real64 AirOutMassFlowRate;             // outlet air mass flow rate [kg/s]
     114              :         Real64 HumRatSet;                      // humidity ratio setpoint [kg water / kg air]
     115              :         Real64 WaterAdd;                       // water output (and consumption) [kg/s]
     116              :         Real64 ElecUseEnergy;                  // electricity consumption [J]
     117              :         Real64 ElecUseRate;                    // electricity consumption [W]
     118              :         Real64 WaterCons;                      // water consumption in cubic meters
     119              :         Real64 WaterConsRate;                  // water consumption rate in m3/s
     120              :         bool SuppliedByWaterSystem;            // true means there is storage tank, otherwise mains
     121              :         int WaterTankID;                       // index pointer to water storage tank
     122              :         int WaterTankDemandARRID;              // index pointer to WaterStorage Demand arrays.
     123              :         Real64 TankSupplyVdot;
     124              :         Real64 TankSupplyVol;
     125              :         Real64 StarvedSupplyVdot;
     126              :         Real64 StarvedSupplyVol;
     127              :         int TankSupplyID; // index pointer to WaterStorage supply arrays.
     128              :         bool MySizeFlag;
     129              :         bool MyEnvrnFlag;
     130              :         bool MySetPointCheckFlag;
     131              :         // report variables for gas humidifier
     132              :         Real64 ThermalEff;       // current actual thermal efficiency gas humidifier [-]
     133              :         Real64 GasUseRate;       // gas consumption rate [W]
     134              :         Real64 GasUseEnergy;     // gas energy consumption [J]
     135              :         Real64 AuxElecUseRate;   // auxiliary electric power input [W]
     136              :         Real64 AuxElecUseEnergy; //  auxiliary electric energy consumption [J]'
     137              : 
     138              :         // Default Constructor
     139           11 :         HumidifierData()
     140           22 :             : HumType(HumidType::Invalid), EquipIndex(0), NomCapVol(0.0), NomCap(0.0), NomPower(0.0), ThermalEffRated(1.0), CurMakeupWaterTemp(0.0),
     141           11 :               EfficiencyCurvePtr(0), InletWaterTempOption(InletWaterTemp::Invalid), FanPower(0.0), StandbyPower(0.0), AirInNode(0), AirOutNode(0),
     142           11 :               AirInTemp(0.0), AirInHumRat(0.0), AirInEnthalpy(0.0), AirInMassFlowRate(0.0), AirOutTemp(0.0), AirOutHumRat(0.0), AirOutEnthalpy(0.0),
     143           11 :               AirOutMassFlowRate(0.0), HumRatSet(0.0), WaterAdd(0.0), ElecUseEnergy(0.0), ElecUseRate(0.0), WaterCons(0.0), WaterConsRate(0.0),
     144           11 :               SuppliedByWaterSystem(false), WaterTankID(0), WaterTankDemandARRID(0), TankSupplyVdot(0.0), TankSupplyVol(0.0), StarvedSupplyVdot(0.0),
     145           11 :               StarvedSupplyVol(0.0), TankSupplyID(0), MySizeFlag(true), MyEnvrnFlag(true), MySetPointCheckFlag(true), ThermalEff(0.0),
     146           11 :               GasUseRate(0.0), GasUseEnergy(0.0), AuxElecUseRate(0.0), AuxElecUseEnergy(0.0)
     147              :         {
     148           11 :         }
     149              : 
     150              :         void InitHumidifier(EnergyPlusData &state); // number of the current humidifier being simulated
     151              : 
     152              :         void SizeHumidifier(EnergyPlusData &state); // number of the current humidifier being sized
     153              : 
     154              :         void ControlHumidifier(EnergyPlusData &state,
     155              :                                Real64 &WaterAddNeeded // moisture addition rate needed to meet minimum humidity ratio setpoint [kg/s]
     156              :         );
     157              : 
     158              :         void CalcElecSteamHumidifier(EnergyPlusData &state, Real64 const WaterAddNeeded // moisture addition rate set by controller [kg/s]
     159              :         );
     160              : 
     161              :         void CalcGasSteamHumidifier(EnergyPlusData &state, Real64 const WaterAddNeeded // moisture addition rate set by controller [kg/s]
     162              :         );
     163              : 
     164              :         void UpdateReportWaterSystem(EnergyPlusData &state); // number of the current humidifier being simulated
     165              : 
     166              :         void UpdateHumidifier(EnergyPlusData &state); // number of the current humidifier being simulated
     167              : 
     168              :         void ReportHumidifier(EnergyPlusData &state); // number of the current humidifier being simulated
     169              :     };
     170              : 
     171              :     void SimHumidifier(EnergyPlusData &state,
     172              :                        std::string_view CompName,     // name of the humidifier unit
     173              :                        bool const FirstHVACIteration, // TRUE if 1st HVAC simulation of system timestep
     174              :                        int &CompIndex                 // Pointer to Humidifier Unit
     175              :     );
     176              : 
     177              :     void GetHumidifierInput(EnergyPlusData &state);
     178              : 
     179              :     int GetAirInletNodeNum(EnergyPlusData &state, std::string const &HumidifierName, bool &ErrorsFound);
     180              : 
     181              :     int GetAirOutletNodeNum(EnergyPlusData &state, std::string const &HumidifierName, bool &ErrorsFound);
     182              : 
     183              : } // namespace Humidifiers
     184              : 
     185              : struct HumidifiersData : BaseGlobalStruct
     186              : {
     187              :     int NumHumidifiers = 0;   // number of humidifiers of all types
     188              :     int NumElecSteamHums = 0; // number of electric steam humidifiers
     189              :     int NumGasSteamHums = 0;  // number of electric steam humidifiers
     190              :     Array1D_bool CheckEquipName;
     191              :     bool GetInputFlag = true; // moved up from a static function variable
     192              : 
     193              :     // Object Data
     194              :     Array1D<Humidifiers::HumidifierData> Humidifier;
     195              :     std::unordered_map<std::string, std::string> HumidifierUniqueNames;
     196              : 
     197         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     198              :     {
     199         2126 :     }
     200              : 
     201         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     202              :     {
     203         1152 :     }
     204              : 
     205         2100 :     void clear_state() override
     206              :     {
     207         2100 :         this->NumHumidifiers = 0;
     208         2100 :         this->NumElecSteamHums = 0;
     209         2100 :         this->NumGasSteamHums = 0;
     210         2100 :         this->CheckEquipName.clear();
     211         2100 :         this->GetInputFlag = true;
     212         2100 :         this->Humidifier.clear();
     213         2100 :         this->HumidifierUniqueNames.clear();
     214         2100 :     }
     215              : };
     216              : 
     217              : } // namespace EnergyPlus
     218              : 
     219              : #endif
        

Generated by: LCOV version 2.0-1