LCOV - code coverage report
Current view: top level - EnergyPlus - IceThermalStorage.hh (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 11 19 57.9 %
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 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             : 
      63             : namespace EnergyPlus {
      64             : 
      65             : // Forward declarations
      66             : struct EnergyPlusData;
      67             : 
      68             : namespace IceThermalStorage {
      69             : 
      70             :     enum class CurveVars
      71             :     {
      72             :         Invalid = -1,
      73             :         FracChargedLMTD,
      74             :         FracDischargedLMTD,
      75             :         LMTDMassFlow,
      76             :         LMTDFracCharged,
      77             :         Num
      78             :     };
      79             : 
      80             :     enum class DetIce
      81             :     {
      82             :         Invalid = -1,
      83             :         InsideMelt,  // Inside melt system--charge starting with bare coil
      84             :         OutsideMelt, // Outside melt system--charge from existing ice layer on coil
      85             :         Num
      86             :     };
      87             : 
      88             :     enum class ITSType
      89             :     {
      90             :         Invalid = -1,
      91             :         IceOnCoilInternal,
      92             :         IceOnCoilExternal,
      93             :         Num
      94             :     };
      95             : 
      96          13 :     struct SimpleIceStorageData : PlantComponent
      97             :     {
      98             :         std::string Name;         // User identifier
      99             :         std::string ITSType;      // Ice Thermal Storage Type
     100             :         enum ITSType ITSType_Num; // Storage Type as number (IceOnCoilInternal,IceOnCoilExternal)
     101             :         int MapNum;               // Number to Map structure
     102             :         int UratePtr;             // Charging/Discharging SchedulePtr: u value schedule
     103             :         Real64 ITSNomCap;         // Design nominal capacity of Ice Thermal Storage [J] (user input in GJ)
     104             :         int PltInletNodeNum;      // Node number on the inlet side of the plant
     105             :         int PltOutletNodeNum;     // Node number on the outlet side of the plant
     106             :                                   // loop topology variables
     107             :         PlantLocation plantLoc;
     108             :         Real64 DesignMassFlowRate;
     109             :         Real64 FreezeTemp;
     110             :         bool ResetXForITSFlag;
     111             :         bool MyEnvrnFlag;
     112             :         Real64 UAIceCh;
     113             :         Real64 UAIceDisCh;
     114             :         Real64 HLoss;
     115             :         Real64 XCurIceFrac;
     116             :         Real64 ITSMassFlowRate;
     117             :         Real64 ITSInletTemp;
     118             :         Real64 ITSOutletTemp;
     119             :         Real64 ITSOutletSetPointTemp;
     120             :         Real64 ITSCoolingRate;
     121             :         Real64 ITSCoolingEnergy;
     122             :         bool CheckEquipName;
     123             : 
     124             :         Real64 MyLoad;            // load requested by plant [W]
     125             :         Real64 Urate;             // [fraction]
     126             :         Real64 IceFracRemain;     // Fraction of ice remaining in storage [fraction]
     127             :         Real64 ITSChargingRate;   // [W]
     128             :         Real64 ITSChargingEnergy; // [J]
     129             :         Real64 ITSmdot;           // [kg/s]
     130             : 
     131             :         // Duplicated reporting vars for now. Investigate diffs when time to remove.
     132             :         Real64 ITSCoolingRate_rep;   // [W]
     133             :         Real64 ITSCoolingEnergy_rep; // [J]
     134             : 
     135             :         bool MyPlantScanFlag;
     136             :         bool MyEnvrnFlag2;
     137             : 
     138             :         // Default Constructor
     139          11 :         SimpleIceStorageData()
     140          11 :             : MapNum(0), UratePtr(0), ITSNomCap(0.0), PltInletNodeNum(0), PltOutletNodeNum(0), plantLoc{}, DesignMassFlowRate(0.0), FreezeTemp(0.0),
     141             :               ResetXForITSFlag(false), MyEnvrnFlag(true), UAIceCh(0.0), UAIceDisCh(0.0), HLoss(0.0), XCurIceFrac(0.0), ITSMassFlowRate(0.0),
     142             :               ITSInletTemp(0.0), ITSOutletTemp(0.0), ITSOutletSetPointTemp(0.0), ITSCoolingRate(0.0), ITSCoolingEnergy(0.0), CheckEquipName(true),
     143             :               MyLoad(0.0), Urate(0.0), IceFracRemain(0.0), ITSChargingRate(0.0), ITSChargingEnergy(0.0), ITSmdot(0.0), ITSCoolingRate_rep(0.0),
     144          11 :               ITSCoolingEnergy_rep(0.0), MyPlantScanFlag(true), MyEnvrnFlag2(true)
     145             :         {
     146          11 :         }
     147             : 
     148             :         static PlantComponent *factory(EnergyPlusData &state, std::string const &objectName);
     149             : 
     150             :         void
     151             :         simulate(EnergyPlusData &state, const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override;
     152             : 
     153             :         void oneTimeInit(EnergyPlusData &state) override;
     154             : 
     155             :         void CalcIceStorageDormant(EnergyPlusData &state);
     156             : 
     157             :         void CalcIceStorageCapacity(EnergyPlusData &state, Real64 &MaxCap, Real64 &MinCap, Real64 &OptCap);
     158             : 
     159             :         void CalcIceStorageDischarge(EnergyPlusData &state, Real64 myLoad, bool RunFlag, Real64 MaxCap);
     160             : 
     161             :         void CalcQiceDischageMax(EnergyPlusData &state, Real64 &QiceMin);
     162             : 
     163             :         void CalcIceStorageCharge(EnergyPlusData &state);
     164             : 
     165             :         void CalcQiceChargeMaxByChiller(EnergyPlusData &state, Real64 &QiceMaxByChiller);
     166             : 
     167             :         void CalcQiceChargeMaxByITS(Real64 chillerOutletTemp, Real64 &QiceMaxByITS);
     168             : 
     169             :         void CalcUAIce(Real64 XCurIceFrac_loc, Real64 &UAIceCh_loc, Real64 &UAIceDisCh_loc, Real64 &HLoss_loc);
     170             : 
     171             :         void UpdateNode(EnergyPlusData &state, Real64 myLoad, bool RunFlag);
     172             : 
     173             :         void RecordOutput(Real64 myLoad, bool RunFlag);
     174             : 
     175             :         void setupOutputVars(EnergyPlusData &state);
     176             :     };
     177             : 
     178          23 :     struct DetailedIceStorageData : PlantComponent
     179             :     {
     180             :         std::string Name;         // User identifier
     181             :         std::string ScheduleName; // User identifier
     182             :         int ScheduleIndex;        // Plant inlet node number for ice storage unit
     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          16 :         DetailedIceStorageData()
     234          16 :             : ScheduleIndex(0), NomCapacity(0.0), PlantInNodeNum(0), PlantOutNodeNum(0), plantLoc{}, DesignMassFlowRate(0.0), MapNum(0),
     235             :               DischargeCurveNum(0), ChargeCurveNum(0), CurveFitTimeStep(1.0), DischargeParaElecLoad(0.0), ChargeParaElecLoad(0.0), TankLossCoeff(0.0),
     236             :               FreezingTemp(0.0), CompLoad(0.0), IceFracChange(0.0), IceFracRemaining(1.0), IceFracOnCoil(1.0), DischargingRate(0.0),
     237             :               DischargingEnergy(0.0), ChargingRate(0.0), ChargingEnergy(0.0), MassFlowRate(0.0), BypassMassFlowRate(0.0), TankMassFlowRate(0.0),
     238             :               InletTemp(0.0), OutletTemp(0.0), TankOutletTemp(0.0), ParasiticElecRate(0.0), ParasiticElecEnergy(0.0), DischargeIterErrors(0),
     239             :               DischargeErrorCount(0), ChargeIterErrors(0), ChargeErrorCount(0), ResetXForITSFlag(false), MyEnvrnFlag(true), CheckEquipName(true),
     240          16 :               MyPlantScanFlag(true), MyEnvrnFlag2(true)
     241             :         {
     242          16 :         }
     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 &state);
     283             : 
     284             : } // namespace IceThermalStorage
     285             : 
     286        1542 : 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           0 :     void clear_state() override
     297             :     {
     298           0 :         this->getITSInput = true;
     299           0 :         this->NumSimpleIceStorage = 0;
     300           0 :         this->NumDetailedIceStorage = 0;
     301           0 :         this->TotalNumIceStorage = 0;
     302           0 :         this->SimpleIceStorage.deallocate();
     303           0 :         this->DetailedIceStorage.deallocate();
     304           0 :     }
     305             : };
     306             : 
     307             : } // namespace EnergyPlus
     308             : 
     309             : #endif

Generated by: LCOV version 1.13