LCOV - code coverage report
Current view: top level - EnergyPlus - IceThermalStorage.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 75.0 % 28 21
Test Date: 2025-05-22 16:09:37 Functions: 80.0 % 5 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 IceThermalStorage_hh_INCLUDED
      49              : #define IceThermalStorage_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/EPVector.hh>
      58              : #include <EnergyPlus/EnergyPlus.hh>
      59              : #include <EnergyPlus/Plant/Enums.hh>
      60              : #include <EnergyPlus/Plant/PlantLocation.hh>
      61              : #include <EnergyPlus/PlantComponent.hh>
      62              : #include <EnergyPlus/ScheduleManager.hh>
      63              : 
      64              : namespace EnergyPlus {
      65              : 
      66              : // Forward declarations
      67              : struct EnergyPlusData;
      68              : 
      69              : namespace IceThermalStorage {
      70              : 
      71              :     enum class CurveVars
      72              :     {
      73              :         Invalid = -1,
      74              :         FracChargedLMTD,
      75              :         FracDischargedLMTD,
      76              :         LMTDMassFlow,
      77              :         LMTDFracCharged,
      78              :         Num
      79              :     };
      80              : 
      81              :     enum class DetIce
      82              :     {
      83              :         Invalid = -1,
      84              :         InsideMelt,  // Inside melt system--charge starting with bare coil
      85              :         OutsideMelt, // Outside melt system--charge from existing ice layer on coil
      86              :         Num
      87              :     };
      88              : 
      89              :     enum class ITSType
      90              :     {
      91              :         Invalid = -1,
      92              :         IceOnCoilInternal,
      93              :         IceOnCoilExternal,
      94              :         Num
      95              :     };
      96              : 
      97              :     struct SimpleIceStorageData : PlantComponent
      98              :     {
      99              :         std::string Name;         // User identifier
     100              :         std::string ITSType;      // Ice Thermal Storage Type
     101              :         enum ITSType ITSType_Num; // Storage Type as number (IceOnCoilInternal,IceOnCoilExternal)
     102              :         int MapNum;               // Number to Map structure
     103              :         int UratePtr;             // Charging/Discharging SchedulePtr: u value schedule
     104              :         Real64 ITSNomCap;         // Design nominal capacity of Ice Thermal Storage [J] (user input in GJ)
     105              :         int PltInletNodeNum;      // Node number on the inlet side of the plant
     106              :         int PltOutletNodeNum;     // Node number on the outlet side of the plant
     107              :                                   // loop topology variables
     108              :         PlantLocation plantLoc;
     109              :         Real64 DesignMassFlowRate;
     110              :         Real64 FreezeTemp;
     111              :         bool ResetXForITSFlag;
     112              :         bool MyEnvrnFlag;
     113              :         Real64 UAIceCh;
     114              :         Real64 UAIceDisCh;
     115              :         Real64 HLoss;
     116              :         Real64 XCurIceFrac;
     117              :         Real64 ITSMassFlowRate;
     118              :         Real64 ITSInletTemp;
     119              :         Real64 ITSOutletTemp;
     120              :         Real64 ITSOutletSetPointTemp;
     121              :         Real64 ITSCoolingRate;
     122              :         Real64 ITSCoolingEnergy;
     123              :         bool CheckEquipName;
     124              : 
     125              :         Real64 MyLoad;            // load requested by plant [W]
     126              :         Real64 Urate;             // [fraction]
     127              :         Real64 IceFracRemain;     // Fraction of ice remaining in storage [fraction]
     128              :         Real64 ITSChargingRate;   // [W]
     129              :         Real64 ITSChargingEnergy; // [J]
     130              :         Real64 ITSmdot;           // [kg/s]
     131              : 
     132              :         // Duplicated reporting vars for now. Investigate diffs when time to remove.
     133              :         Real64 ITSCoolingRate_rep;   // [W]
     134              :         Real64 ITSCoolingEnergy_rep; // [J]
     135              : 
     136              :         bool MyPlantScanFlag;
     137              :         bool MyEnvrnFlag2;
     138              : 
     139              :         // Default Constructor
     140            0 :         SimpleIceStorageData()
     141            0 :             : MapNum(0), UratePtr(0), ITSNomCap(0.0), PltInletNodeNum(0), PltOutletNodeNum(0), plantLoc{}, DesignMassFlowRate(0.0), FreezeTemp(0.0),
     142            0 :               ResetXForITSFlag(false), MyEnvrnFlag(true), UAIceCh(0.0), UAIceDisCh(0.0), HLoss(0.0), XCurIceFrac(0.0), ITSMassFlowRate(0.0),
     143            0 :               ITSInletTemp(0.0), ITSOutletTemp(0.0), ITSOutletSetPointTemp(0.0), ITSCoolingRate(0.0), ITSCoolingEnergy(0.0), CheckEquipName(true),
     144            0 :               MyLoad(0.0), Urate(0.0), IceFracRemain(0.0), ITSChargingRate(0.0), ITSChargingEnergy(0.0), ITSmdot(0.0), ITSCoolingRate_rep(0.0),
     145            0 :               ITSCoolingEnergy_rep(0.0), MyPlantScanFlag(true), MyEnvrnFlag2(true)
     146              :         {
     147            0 :         }
     148              : 
     149              :         static PlantComponent *factory(EnergyPlusData &state, std::string const &objectName);
     150              : 
     151              :         void
     152              :         simulate(EnergyPlusData &state, const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override;
     153              : 
     154              :         void oneTimeInit(EnergyPlusData &state) override;
     155              : 
     156              :         void CalcIceStorageDormant(EnergyPlusData &state);
     157              : 
     158              :         void CalcIceStorageCapacity(EnergyPlusData &state, Real64 &MaxCap, Real64 &MinCap, Real64 &OptCap);
     159              : 
     160              :         void CalcIceStorageDischarge(EnergyPlusData &state, Real64 myLoad, bool RunFlag, Real64 MaxCap);
     161              : 
     162              :         void CalcQiceDischageMax(EnergyPlusData &state, Real64 &QiceMin);
     163              : 
     164              :         void CalcIceStorageCharge(EnergyPlusData &state);
     165              : 
     166              :         void CalcQiceChargeMaxByChiller(EnergyPlusData &state, Real64 &QiceMaxByChiller);
     167              : 
     168              :         void CalcQiceChargeMaxByITS(Real64 chillerOutletTemp, Real64 &QiceMaxByITS);
     169              : 
     170              :         void CalcUAIce(Real64 XCurIceFrac_loc, Real64 &UAIceCh_loc, Real64 &UAIceDisCh_loc, Real64 &HLoss_loc);
     171              : 
     172              :         void UpdateNode(EnergyPlusData &state, Real64 myLoad, bool RunFlag);
     173              : 
     174              :         void RecordOutput(Real64 myLoad, bool RunFlag);
     175              : 
     176              :         void setupOutputVars(EnergyPlusData &state);
     177              :     };
     178              : 
     179              :     struct DetailedIceStorageData : PlantComponent
     180              :     {
     181              :         std::string Name;            // User identifier // What kind of a comment is this?
     182              :         Sched::Schedule *availSched; // schedule (availability?)
     183              :         Real64 NomCapacity;          // Design storage capacity of Ice Thermal Storage system [W-hr]
     184              :         // (User input for this parameter in GJ--need to convert to W-hr)
     185              :         int PlantInNodeNum;  // Plant inlet node number for ice storage unit
     186              :         int PlantOutNodeNum; // Plant outlet node number for ice storage unit
     187              :         PlantLocation plantLoc;
     188              :         Real64 DesignMassFlowRate;
     189              :         int MapNum;                           // Number to Map structure
     190              :         std::string DischargeCurveName;       // Curve name for discharging (used to find the curve index)
     191              :         int DischargeCurveNum;                // Curve index for discharging
     192              :         enum CurveVars DischargeCurveTypeNum; // Integer version of discharging curve independent variables type
     193              :         std::string ChargeCurveName;          // Curve name for charging (used to find the curve index)
     194              :         int ChargeCurveNum;                   // Curve index for charging
     195              :         enum CurveVars ChargeCurveTypeNum;    // Integer version of charging curve independent variables type
     196              :         Real64 CurveFitTimeStep;              // Time step used to generate performance data [hours]
     197              :         Real64 DischargeParaElecLoad;         // Parasitic electric load duing discharging [dimensionless]
     198              :         // (This is multiplied by the tank capacity to obtain elec consump)
     199              :         Real64 ChargeParaElecLoad; // Parasitic electric load duing charging [dimensionless]
     200              :         // (This is multiplied by the tank capacity to obtain elec consump)
     201              :         Real64 TankLossCoeff; // Fraction of total storage capacity lost per hour [1/hours]
     202              :         Real64 FreezingTemp;  // Freezing/melting temperature of ice storage unit [C]
     203              :         // Reporting data
     204              :         Real64 CompLoad;                  // load requested by plant [W]
     205              :         Real64 IceFracChange;             // Change in fraction of ice stored during the time step [fraction]
     206              :         Real64 IceFracRemaining;          // Fraction of ice remaining in storage [fraction]
     207              :         std::string ThawProcessIndicator; // User input determining whether system is inside or outside melt
     208              :         enum DetIce ThawProcessIndex;     // Conversion of thaw process indicator to integer index
     209              :         Real64 IceFracOnCoil;             // Fraction of ice on the coil (affects charging) [fraction]
     210              :         Real64 DischargingRate;           // Rate at which energy is being added (thawing) to ice unit [W]
     211              :         Real64 DischargingEnergy;         // Total energy added to the ice storage unit [J]
     212              :         Real64 ChargingRate;              // Rate at which energy is removed (freezing) to ice unit [W]
     213              :         Real64 ChargingEnergy;            // Total energy removed from ice storage unit [J]
     214              :         Real64 MassFlowRate;              // Total mass flow rate to component [kg/s]
     215              :         Real64 BypassMassFlowRate;        // Mass flow rate that bypasses the ice unit locally [kg/s]
     216              :         Real64 TankMassFlowRate;          // Mass flow rate through the ice storage unit [kg/s]
     217              :         Real64 InletTemp;                 // Component inlet temperature (same as bypass temperature) [C]
     218              :         Real64 OutletTemp;                // Component outlet temperature (blended) [C]
     219              :         Real64 TankOutletTemp;            // Ice storage unit outlet temperature [C]
     220              :         Real64 ParasiticElecRate;         // Parasitic electrical energy rate consumed by ice storage [W]
     221              :         Real64 ParasiticElecEnergy;       // Total parasitic electrical energy consumed by ice storage [J]
     222              :         int DischargeIterErrors;          // Number of max iterations exceeded errors during discharging
     223              :         int DischargeErrorCount;          // Index for error counting routine
     224              :         int ChargeIterErrors;             // Number of max iterations exceeded errors during charging
     225              :         int ChargeErrorCount;             // Index for error counting routine
     226              :         bool ResetXForITSFlag;
     227              :         bool MyEnvrnFlag;
     228              :         bool CheckEquipName;
     229              :         bool MyPlantScanFlag;
     230              :         bool MyEnvrnFlag2;
     231              : 
     232              :         // Default Constructor
     233            5 :         DetailedIceStorageData()
     234            5 :             : NomCapacity(0.0), PlantInNodeNum(0), PlantOutNodeNum(0), plantLoc{}, DesignMassFlowRate(0.0), MapNum(0), DischargeCurveNum(0),
     235            5 :               ChargeCurveNum(0), CurveFitTimeStep(1.0), DischargeParaElecLoad(0.0), ChargeParaElecLoad(0.0), TankLossCoeff(0.0), FreezingTemp(0.0),
     236           10 :               CompLoad(0.0), IceFracChange(0.0), IceFracRemaining(1.0), IceFracOnCoil(1.0), DischargingRate(0.0), DischargingEnergy(0.0),
     237            5 :               ChargingRate(0.0), ChargingEnergy(0.0), MassFlowRate(0.0), BypassMassFlowRate(0.0), TankMassFlowRate(0.0), InletTemp(0.0),
     238            5 :               OutletTemp(0.0), TankOutletTemp(0.0), ParasiticElecRate(0.0), ParasiticElecEnergy(0.0), DischargeIterErrors(0), DischargeErrorCount(0),
     239            5 :               ChargeIterErrors(0), ChargeErrorCount(0), ResetXForITSFlag(false), MyEnvrnFlag(true), CheckEquipName(true), MyPlantScanFlag(true),
     240           10 :               MyEnvrnFlag2(true)
     241              :         {
     242            5 :         }
     243              : 
     244              :         static PlantComponent *factory(EnergyPlusData &state, std::string const &objectName);
     245              : 
     246              :         void simulate([[maybe_unused]] EnergyPlusData &state,
     247              :                       const PlantLocation &calledFromLocation,
     248              :                       bool FirstHVACIteration,
     249              :                       Real64 &CurLoad,
     250              :                       bool RunFlag) override;
     251              : 
     252              :         void oneTimeInit(EnergyPlusData &state) override;
     253              : 
     254              :         void SimDetailedIceStorage(EnergyPlusData &state);
     255              : 
     256              :         void UpdateDetailedIceStorage(EnergyPlusData &state);
     257              : 
     258              :         void ReportDetailedIceStorage(EnergyPlusData &state);
     259              : 
     260              :         void setupOutputVars(EnergyPlusData &state);
     261              :     };
     262              : 
     263              :     void GetIceStorageInput(EnergyPlusData &state);
     264              : 
     265              :     Real64 CalcDetIceStorLMTDstar(Real64 Tin,  // ice storage unit inlet temperature
     266              :                                   Real64 Tout, // ice storage unit outlet (setpoint) temperature
     267              :                                   Real64 Tfr   // freezing temperature
     268              :     );
     269              : 
     270              :     Real64 CalcQstar(EnergyPlusData &state,
     271              :                      int CurveIndex,                 // curve index
     272              :                      enum CurveVars CurveIndVarType, // independent variable type for ice storage
     273              :                      Real64 FracCharged,             // fraction charged for ice storage unit
     274              :                      Real64 LMTDstar,                // normalized log mean temperature difference across the ice storage unit
     275              :                      Real64 MassFlowstar             // normalized mass flow rate through the ice storage unit
     276              :     );
     277              : 
     278              :     Real64 TempSItoIP(Real64 Temp);
     279              : 
     280              :     Real64 TempIPtoSI(Real64 Temp);
     281              : 
     282              :     void UpdateIceFractions(EnergyPlusData const &state);
     283              : 
     284              : } // namespace IceThermalStorage
     285              : 
     286              : struct IceThermalStorageData : BaseGlobalStruct
     287              : {
     288              : 
     289              :     bool getITSInput = true;
     290              :     int NumSimpleIceStorage = 0;
     291              :     int NumDetailedIceStorage = 0;
     292              :     int TotalNumIceStorage = 0;
     293              :     EPVector<IceThermalStorage::SimpleIceStorageData> SimpleIceStorage;
     294              :     EPVector<IceThermalStorage::DetailedIceStorageData> DetailedIceStorage;
     295              : 
     296         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     297              :     {
     298         2126 :     }
     299              : 
     300         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     301              :     {
     302         1152 :     }
     303              : 
     304         2100 :     void clear_state() override
     305              :     {
     306         2100 :         this->getITSInput = true;
     307         2100 :         this->NumSimpleIceStorage = 0;
     308         2100 :         this->NumDetailedIceStorage = 0;
     309         2100 :         this->TotalNumIceStorage = 0;
     310         2100 :         this->SimpleIceStorage.deallocate();
     311         2100 :         this->DetailedIceStorage.deallocate();
     312         2100 :     }
     313              : };
     314              : 
     315              : } // namespace EnergyPlus
     316              : 
     317              : #endif
        

Generated by: LCOV version 2.0-1