LCOV - code coverage report
Current view: top level - EnergyPlus - WaterThermalTanks.hh (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 24 27 88.9 %
Date: 2023-01-17 19:17:23 Functions: 13 18 72.2 %

          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 WaterThermalTanks_hh_INCLUDED
      49             : #define WaterThermalTanks_hh_INCLUDED
      50             : 
      51             : // ObjexxFCL Headers
      52             : #include <ObjexxFCL/Array1D.fwd.hh>
      53             : #include <ObjexxFCL/Optional.fwd.hh>
      54             : 
      55             : // EnergyPlus Headers
      56             : #include <EnergyPlus/Data/BaseData.hh>
      57             : #include <EnergyPlus/DataBranchAirLoopPlant.hh>
      58             : #include <EnergyPlus/DataGlobalConstants.hh>
      59             : #include <EnergyPlus/EnergyPlus.hh>
      60             : #include <EnergyPlus/Plant/Enums.hh>
      61             : #include <EnergyPlus/Plant/PlantLocation.hh>
      62             : #include <EnergyPlus/PlantComponent.hh>
      63             : #include <EnergyPlus/VariableSpeedCoils.hh>
      64             : 
      65             : namespace EnergyPlus {
      66             : 
      67             : // Forward declarations
      68             : struct EnergyPlusData;
      69             : 
      70             : namespace WaterThermalTanks {
      71             : 
      72             :     enum class WTTAmbientTemp
      73             :     {
      74             :         Invalid = -1,
      75             :         Schedule,   // ambient temperature around tank (or HPWH inlet air) is scheduled
      76             :         TempZone,   // tank is located in a zone or HPWH inlet air is zone air only
      77             :         OutsideAir, // tank is located outdoors or HPWH inlet air is outdoor air only
      78             :         ZoneAndOA,  // applicable to HPWH only, inlet air is mixture of OA and zone air
      79             :         Num,
      80             :     };
      81             : 
      82             :     constexpr std::array<std::string_view, static_cast<int>(WTTAmbientTemp::Num)> HPWHAmbientTempNamesUC{
      83             :         "SCHEDULE", "ZONEAIRONLY", "OUTDOORAIRONLY", "ZONEANDOUTDOORAIR"};
      84             : 
      85             :     constexpr std::array<std::string_view, static_cast<int>(WTTAmbientTemp::Num) - 1> TankAmbientTempNamesUC{
      86             :         "SCHEDULE",
      87             :         "ZONE",
      88             :         "OUTDOORS",
      89             :     };
      90             : 
      91             :     enum class CrankcaseHeaterControlTemp
      92             :     {
      93             :         Invalid = -1,
      94             :         Schedule, // temperature controlling compressor crankcase heater is scheduled
      95             :         Zone,     // temperature controlling compressor crankcase heater is zone air
      96             :         Outdoors, // temperature controlling compressor crankcase heater is outdoor air
      97             :         Num
      98             :     };
      99             : 
     100             :     constexpr std::array<std::string_view, static_cast<int>(CrankcaseHeaterControlTemp::Num)> CrankcaseHeaterControlTempNamesUC{
     101             :         "SCHEDULE",
     102             :         "ZONE",
     103             :         "OUTDOORS",
     104             :     };
     105             : 
     106             :     enum class TankShape
     107             :     {
     108             :         Invalid = -1,
     109             :         VertCylinder,  // tank shape is a vertical cylinder
     110             :         HorizCylinder, // tank shape is a horizontal cylinder
     111             :         Other,         // tank shape has an arbitrary perimeter shape
     112             :         Num
     113             :     };
     114             : 
     115             :     constexpr std::array<std::string_view, static_cast<int>(TankShape::Num)> TankShapeNamesUC{
     116             :         "VERTICALCYLINDER",
     117             :         "HORIZONTALCYLINDER",
     118             :         "OTHER",
     119             :     };
     120             : 
     121             :     enum class HeaterControlMode
     122             :     {
     123             :         Invalid = -1,
     124             :         Cycle,
     125             :         Modulate,
     126             :         Num
     127             :     };
     128             : 
     129             :     constexpr std::array<std::string_view, static_cast<int>(HeaterControlMode::Num)> HeaterControlModeNamesUC{"CYCLE", "MODULATE"};
     130             : 
     131             :     enum class PriorityControlMode // For Stratified Water Heaters, this controls how the two heating elements work together
     132             :     {
     133             :         Invalid = -1,
     134             :         MasterSlave,  // water heater only, master-slave priority control of heater elements
     135             :         Simultaneous, // water heater only, simultaneous control of heater elements
     136             :         Num
     137             :     };
     138             : 
     139             :     constexpr std::array<std::string_view, static_cast<int>(PriorityControlMode::Num)> PriorityControlModeNamesUC{"MASTERSLAVE", "SIMULTANEOUS"};
     140             : 
     141             :     enum class InletPositionMode
     142             :     {
     143             :         Invalid = -1,
     144             :         Fixed,   // water heater only, inlet water always enters at the user-specified height
     145             :         Seeking, // water heater only, inlet water seeks out the node with the closest temperature
     146             :         Num
     147             :     };
     148             : 
     149             :     constexpr std::array<std::string_view, static_cast<int>(InletPositionMode::Num)> InletPositionModeNamesUC{"FIXED", "SEEKING"};
     150             : 
     151             :     // reclaim heat object types for Coil:WaterHeating:Desuperheater object
     152             :     enum class ReclaimHeatObjectType
     153             :     {
     154             :         Invalid = -1,
     155             :         CoilCoolingDX,                  // reclaim heating source is new DX Cooling coil
     156             :         CompressorRackRefrigeratedCase, // reclaim heating source is refrigerated case compressor rack
     157             :         DXCooling,                      // reclaim heating source is DX cooling coil
     158             :         DXMultiSpeed,                   // reclaim heating source is DX multispeed coil
     159             :         DXMultiMode,                    // reclaim heating source is DX multimode coil
     160             :         CondenserRefrigeration,         // reclaim heating source is detailed refrigeration system condenser
     161             :         DXVariableCooling,              // reclaim heating source is Variable Speed DX cooling coil
     162             :         AirWaterHeatPumpEQ,             // reclaim heating source is Water to air heat pump cooling coil
     163             :         Num
     164             :     };
     165             : 
     166             :     enum class WaterHeaterSide
     167             :     {
     168             :         Invalid = -1,
     169             :         Use,    // Indicates Use side of water heater
     170             :         Source, // Indicates Source side of water heater
     171             :         Num
     172             :     };
     173             : 
     174             :     enum class SizingMode
     175             :     {
     176             :         Invalid = -1,
     177             :         PeakDraw,
     178             :         ResidentialMin,
     179             :         PerPerson,
     180             :         PerFloorArea,
     181             :         PerUnit,
     182             :         PerSolarColArea,
     183             :         Num
     184             :     };
     185             : 
     186             :     enum class SourceSideControl
     187             :     {
     188             :         Invalid = -1,
     189             :         StorageTank,
     190             :         IndirectHeatPrimarySetpoint,
     191             :         IndirectHeatAltSetpoint,
     192             :         Num
     193             :     };
     194             : 
     195             :     constexpr std::array<std::string_view, static_cast<int>(SourceSideControl::Num)> SourceSideControlNamesUC{
     196             :         "STORAGETANK", "INDIRECTHEATPRIMARYSETPOINT", "INDIRECTHEATALTERNATESETPOINT"};
     197             : 
     198             :     enum class FlowMode
     199             :     {
     200             :         Invalid = -1,
     201             :         PassingFlowThru,
     202             :         MaybeRequestingFlow,
     203             :         ThrottlingFlow,
     204             :         Num
     205             :     };
     206             : 
     207             :     enum class Fuel
     208             :     {
     209             :         Invalid = -1,
     210             :         Electricity,
     211             :         NaturalGas,
     212             :         Diesel,
     213             :         Gasoline,
     214             :         Coal,
     215             :         FuelOilNo1,
     216             :         FuelOilNo2,
     217             :         Propane,
     218             :         Steam,
     219             :         OtherFuel1,
     220             :         OtherFuel2,
     221             :         DistrictHeating,
     222             :         Num
     223             :     };
     224             : 
     225             :     constexpr std::array<std::string_view, static_cast<int>(Fuel::Num)> FuelTypeNames{"Electricity",
     226             :                                                                                       "NaturalGas",
     227             :                                                                                       "Diesel",
     228             :                                                                                       "Gasoline",
     229             :                                                                                       "Coal",
     230             :                                                                                       "FuelOilNo1",
     231             :                                                                                       "FuelOilNo2",
     232             :                                                                                       "Propane",
     233             :                                                                                       "Steam",
     234             :                                                                                       "OtherFuel1",
     235             :                                                                                       "OtherFuel2",
     236             :                                                                                       "DistrictHeating"};
     237             : 
     238             :     constexpr std::array<std::string_view, static_cast<int>(Fuel::Num)> FuelTypeNamesUC{"ELECTRICITY",
     239             :                                                                                         "NATURALGAS",
     240             :                                                                                         "DIESEL",
     241             :                                                                                         "GASOLINE",
     242             :                                                                                         "COAL",
     243             :                                                                                         "FUELOILNO1",
     244             :                                                                                         "FUELOILNO2",
     245             :                                                                                         "PROPANE",
     246             :                                                                                         "STEAM",
     247             :                                                                                         "OTHERFUEL1",
     248             :                                                                                         "OTHERFUEL2",
     249             :                                                                                         "DISTRICTHEATING"};
     250             : 
     251             :     enum class TankOperatingMode
     252             :     {
     253             :         Invalid = -1,
     254             :         Heating,  // heating source is on, source will not turn off until setpoint temp is reached
     255             :         Floating, // heating source is off, source will not turn on until cut-in temp is reached
     256             :         Venting,  // tank temp is above maximum temperature and water is venting
     257             :         Cooling,  // cooling source is on, source will not turn off until setpoint temp is reached
     258             :         Num
     259             :     };
     260             : 
     261             :     struct StratifiedNodeData
     262             :     {
     263             :         // Members
     264             :         Real64 Mass; // All nodes have the same mass (kg)
     265             :         Real64 OnCycLossCoeff;
     266             :         Real64 OffCycLossCoeff;
     267             :         Real64 Temp;
     268             :         Real64 SavedTemp;
     269             :         Real64 NewTemp;
     270             :         Real64 TempSum;
     271             :         Real64 TempAvg; // Average node temperature over the time step (C)
     272             :         Real64 CondCoeffUp;
     273             :         Real64 CondCoeffDn;
     274             :         Real64 OffCycParaLoad; // Heat delivered to the tank from off-cycle parasitic sources
     275             :         Real64 OnCycParaLoad;
     276             :         Real64 UseMassFlowRate;
     277             :         Real64 SourceMassFlowRate;
     278             :         Real64 MassFlowFromUpper; // Mass flow rate into this node from node above
     279             :         Real64 MassFlowFromLower; // Mass flow rate into this node from node below
     280             :         Real64 MassFlowToUpper;   // Mass flow rate from this node to node above
     281             :         Real64 MassFlowToLower;   // Mass flow rate from this node to node below
     282             :         // Report Variables
     283             :         Real64 Volume;
     284             :         Real64 Height;      // Node height from top to bottom (like a thickness)
     285             :         Real64 MaxCapacity; // For reporting
     286             :         int Inlets;
     287             :         int Outlets;
     288             :         Real64 HPWHWrappedCondenserHeatingFrac; // fraction of the heat from a wrapped condenser that enters into this node, should add up to 1.
     289             : 
     290             :         // Default Constructor
     291          18 :         StratifiedNodeData()
     292          18 :             : Mass(0.0), OnCycLossCoeff(0.0), OffCycLossCoeff(0.0), Temp(0.0), SavedTemp(0.0), NewTemp(0.0), TempSum(0.0), TempAvg(0.0),
     293             :               CondCoeffUp(0.0), CondCoeffDn(0.0), OffCycParaLoad(0.0), OnCycParaLoad(0.0), UseMassFlowRate(0.0), SourceMassFlowRate(0.0),
     294             :               MassFlowFromUpper(0.0), MassFlowFromLower(0.0), MassFlowToUpper(0.0), MassFlowToLower(0.0), Volume(0.0), Height(0.0), MaxCapacity(0.0),
     295          18 :               Inlets(0), Outlets(0), HPWHWrappedCondenserHeatingFrac(0.0)
     296             :         {
     297          18 :         }
     298             :     };
     299             : 
     300             :     struct WaterHeaterSizingData
     301             :     {
     302             :         // Members
     303             :         // input data
     304             :         SizingMode DesignMode;                    // what sizing method to use
     305             :         Real64 TankDrawTime;                      // in hours, time storage can meet peak demand
     306             :         Real64 RecoveryTime;                      // time for tank to recover
     307             :         Real64 NominalVolForSizingDemandSideFlow; // nominal tank size to use in sizing demand side connections
     308             :         int NumberOfBedrooms;
     309             :         Real64 NumberOfBathrooms;
     310             :         Real64 TankCapacityPerPerson;
     311             :         Real64 RecoveryCapacityPerPerson;
     312             :         Real64 TankCapacityPerArea;
     313             :         Real64 RecoveryCapacityPerArea;
     314             :         Real64 NumberOfUnits;
     315             :         Real64 TankCapacityPerUnit;
     316             :         Real64 RecoveryCapacityPerUnit;
     317             :         Real64 TankCapacityPerCollectorArea;
     318             :         Real64 HeightAspectRatio;
     319             :         // data from elsewhere in E+
     320             :         Real64 PeakDemand;
     321             :         Real64 PeakNumberOfPeople;
     322             :         Real64 TotalFloorArea;
     323             :         Real64 TotalSolarCollectorArea;
     324             : 
     325             :         // Default Constructor
     326         128 :         WaterHeaterSizingData()
     327         128 :             : DesignMode(SizingMode::Invalid), TankDrawTime(0.0), RecoveryTime(0.0), NominalVolForSizingDemandSideFlow(0.0), NumberOfBedrooms(0),
     328             :               NumberOfBathrooms(0.0), TankCapacityPerPerson(0.0), RecoveryCapacityPerPerson(0.0), TankCapacityPerArea(0.0),
     329             :               RecoveryCapacityPerArea(0.0), NumberOfUnits(0.0), TankCapacityPerUnit(0.0), RecoveryCapacityPerUnit(0.0),
     330             :               TankCapacityPerCollectorArea(0.0), HeightAspectRatio(0.0), PeakDemand(0.0), PeakNumberOfPeople(0.0), TotalFloorArea(0.0),
     331         128 :               TotalSolarCollectorArea(0.0)
     332             :         {
     333         128 :         }
     334             :     };
     335             : 
     336          55 :     struct HeatPumpWaterHeaterData : PlantComponent
     337             :     {
     338             :         // Members
     339             :         std::string Name;                                           // Name of heat pump water heater
     340             :         std::string Type;                                           // Type of water heater (HEAT PUMP:WATER HEATER)
     341             :         DataPlant::PlantEquipmentType HPWHType;                     // integer parameter for heat pump water heater
     342             :         std::string TankName;                                       // Name of tank associated with heat pump water heater
     343             :         std::string TankType;                                       // Type of water heater (MIXED or STRATIFIED) used with heat pump
     344             :         DataPlant::PlantEquipmentType HPWHTankType;                 // Parameter for tank type (MIXED or STRATIFIED)
     345             :         bool StandAlone;                                            // Flag for operation with no plant connections (no use nodes)
     346             :         int AvailSchedPtr;                                          // Index to Availability Schedule curve index
     347             :         int SetPointTempSchedule;                                   // Index to Setpoint Temperature Schedule curve
     348             :         Real64 DeadBandTempDiff;                                    // Dead band temperature difference (cut-in temperature)
     349             :         Real64 Capacity;                                            // Heat Pump rated capacity (W)
     350             :         Real64 BackupElementCapacity;                               // Tank backup element capacity (W)
     351             :         Real64 BackupElementEfficiency;                             // Tank backup element efficiency
     352             :         Real64 WHOnCycParaLoad;                                     // tank's on-cycle parasitic load (W), disable for rating
     353             :         Real64 WHOffCycParaLoad;                                    // tank's off-cycle parasitic load (W), disable for rating
     354             :         Real64 WHOnCycParaFracToTank;                               // tank's on-cycle parasitic frac to tank, disable for rating
     355             :         Real64 WHOffCycParaFracToTank;                              // tank's off-cycle parasitic frac to tank, disable for rating
     356             :         int WHPLFCurve;                                             // tank part-load fraction curve index, used for rating procedure
     357             :         Real64 OperatingAirFlowRate;                                // Operating volumetric air flow rate (m3/s)
     358             :         Real64 OperatingAirMassFlowRate;                            // Operating air mass flow rate (kg/s)
     359             :         Real64 OperatingWaterFlowRate;                              // Operating volumetric water flow rate (m3/s)
     360             :         Real64 COP;                                                 // Heat Pump coefficient of performance (W/W)
     361             :         Real64 SHR;                                                 // Heat Pump air-side coil sensible heat ratio
     362             :         Real64 RatedInletDBTemp;                                    // Rated evaporator inlet air dry-bulb temperature (C)
     363             :         Real64 RatedInletWBTemp;                                    // Rated evaporator inlet air wet-bulb temperature (C)
     364             :         Real64 RatedInletWaterTemp;                                 // Rated condenser inlet water temperature (C)
     365             :         bool FoundTank;                                             // Found storage tank flag associated with HP water heater
     366             :         int HeatPumpAirInletNode;                                   // HP air inlet node (for zone, zone/outdoor or scheduled)
     367             :         int HeatPumpAirOutletNode;                                  // HP air outlet node (for zone, zone/outdoor or scheduled)
     368             :         int OutsideAirNode;                                         // outdoor air node (for outdoor or zone/outdoor air unit only)
     369             :         int ExhaustAirNode;                                         // Exhaust air node (for outdoor or zone/outdoor air unit only)
     370             :         int CondWaterInletNode;                                     // Condenser water inlet node
     371             :         int CondWaterOutletNode;                                    // Condenser water outlet node
     372             :         int WHUseInletNode;                                         // Water heater tank use side inlet node
     373             :         int WHUseOutletNode;                                        // Water heater tank use side outlet node
     374             :         int WHUseSidePlantLoopNum;                                  // if not zero, then this water heater is on plant loop #
     375             :         std::string DXCoilType;                                     // Type of DX coil (Coil:DX:HeatPumpWaterHeater)
     376             :         std::string DXCoilName;                                     // Name of DX coil
     377             :         int DXCoilNum;                                              // Index of DX coil
     378             :         int DXCoilTypeNum;                                          // Type Number of DX coil
     379             :         int DXCoilAirInletNode;                                     // Inlet air node number of DX coil
     380             :         int DXCoilPLFFPLR;                                          // Index to HPWH's DX Coil PLF as a function of PLR curve
     381             :         std::string FanType;                                        // Type of Fan (Fan:OnOff)
     382             :         int FanType_Num;                                            // Integer type of fan (3 = Fan:OnOff)
     383             :         std::string FanName;                                        // Name of Fan
     384             :         std::string FanInletNode_str;                               // Fan inlet node name
     385             :         std::string FanOutletNode_str;                              // Fan outlet node name
     386             :         int FanNum;                                                 // Index of Fan
     387             :         int FanPlacement;                                           // Location of Fan
     388             :         int FanOutletNode;                                          // Outlet node of heat pump water heater fan
     389             :         int WaterHeaterTankNum;                                     // Index of Water Heater Tank
     390             :         int OutletAirSplitterSchPtr;                                // Index to air-side outlet air splitter schedule
     391             :         int InletAirMixerSchPtr;                                    // Index to air-side inlet air mixer schedule
     392             :         TankOperatingMode Mode = TankOperatingMode::Floating;       // HP mode (0 = float, 1 = heating [-1 = venting na for HP])
     393             :         TankOperatingMode SaveMode = TankOperatingMode::Floating;   // HP mode on first iteration
     394             :         TankOperatingMode SaveWHMode = TankOperatingMode::Floating; // mode of water heater tank element (backup element)
     395             :         Real64 Power;                                               // HP power used for reporting
     396             :         Real64 Energy;                                              // HP energy used for reporting
     397             :         Real64 HeatingPLR;                                          // HP PLR used for reporting
     398             :         Real64 SetPointTemp;                                        // set point or cut-out temperature [C]
     399             :         Real64 MinAirTempForHPOperation;                            // HP does not operate below this ambient temperature
     400             :         Real64 MaxAirTempForHPOperation;                            // HP does not operate above this ambient temperature
     401             :         int InletAirMixerNode;                                      // Inlet air mixer node number of HP water heater
     402             :         int OutletAirSplitterNode;                                  // Outlet air splitter node number of HP water heater
     403             :         Real64 SourceMassFlowRate;                                  // Maximum mass flow rate on the source side (kg/s)
     404             :         WTTAmbientTemp InletAirConfiguration;                       // Identifies source of HPWH inlet air
     405             :         int AmbientTempSchedule;                                    // Schedule index pointer for ambient air temp at HPWH inlet
     406             :         int AmbientRHSchedule;                                      // Schedule index pointer for ambient air RH at HPWH inlet
     407             :         int AmbientTempZone;                                        // Index of ambient zone for ambient air at HPWH inlet
     408             :         CrankcaseHeaterControlTemp CrankcaseTempIndicator;          // Indicator for HPWH compressor/crankcase heater location
     409             :         int CrankcaseTempSchedule;                                  // Schedule index pointer where crankcase heater is located
     410             :         int CrankcaseTempZone;                                      // Index of zone where compressor/crankcase heater is located
     411             :         Real64 OffCycParaLoad;                                      // Rate for off-cycle parasitic load (W)
     412             :         Real64 OnCycParaLoad;                                       // Rate for on-cycle parasitic load (W)
     413             :         WTTAmbientTemp ParasiticTempIndicator;                      // Indicator for HPWH parasitic heat rejection location
     414             :         Real64 OffCycParaFuelRate;                                  // Electric consumption rate for off-cycle parasitic load (W)
     415             :         Real64 OnCycParaFuelRate;                                   // Electric consumption rate for on-cycle parasitic load (W)
     416             :         Real64 OffCycParaFuelEnergy;                                // Electric energy consumption for off-cycle parasitic load (J)
     417             :         Real64 OnCycParaFuelEnergy;                                 // Electric energy consumption for on-cycle parasitic load (J)
     418             :         bool AirFlowRateAutoSized;                                  // Used to report air flow autosize info in Init
     419             :         bool WaterFlowRateAutoSized;                                // Used to report water flow autosize info in Init
     420             :         int HPSetPointError;                                        // Used when temperature SP's in tank and HP are reversed
     421             :         int HPSetPointErrIndex1;                                    // Index to recurring error for tank/HP set point temp
     422             :         int IterLimitErrIndex1;                                     // Index for recurring iteration limit warning messages
     423             :         int IterLimitExceededNum1;                                  // Counter for recurring iteration limit warning messages
     424             :         int RegulaFalsiFailedIndex1;                                // Index for recurring RegulaFalsi failed warning messages
     425             :         int RegulaFalsiFailedNum1;                                  // Counter for recurring RegulaFalsi failed warning messages
     426             :         int IterLimitErrIndex2;                                     // Index for recurring iteration limit warning messages
     427             :         int IterLimitExceededNum2;                                  // Counter for recurring iteration limit warning messages
     428             :         int RegulaFalsiFailedIndex2;                                // Index for recurring RegulaFalsi failed warning messages
     429             :         int RegulaFalsiFailedNum2;                                  // Counter for recurring RegulaFalsi failed warning messages
     430             :         bool FirstTimeThroughFlag;                                  // Flag for saving water heater status
     431             :         bool ShowSetPointWarning;                                   // Warn when set point is greater than max tank temp limit
     432             :         Real64 HPWaterHeaterSensibleCapacity;                       // sensible capacity delivered when HPWH is attached to a zone (W)
     433             :         Real64 HPWaterHeaterLatentCapacity;                         // latent capacity delivered when HPWH is attached to a zone (kg/s)
     434             :         Real64 WrappedCondenserBottomLocation;                      // Location of the bottom of the wrapped condenser.
     435             :         Real64 WrappedCondenserTopLocation;                         // Location of the top of the wrapped condenser.
     436             :         Real64 ControlSensor1Height;                                // location from bottom of tank of control sensor 1
     437             :         int ControlSensor1Node;                                     // Node number of control sensor 1
     438             :         Real64 ControlSensor1Weight;                                // weight of control sensor 1
     439             :         Real64 ControlSensor2Height;                                // location from bottom of tank of control sensor 2
     440             :         int ControlSensor2Node;                                     // Node number of control sensor 2
     441             :         Real64 ControlSensor2Weight;                                // weight of control sensor 2
     442             :         Real64 ControlTempAvg;                              // Measured control temperature for the heat pump, average over timestep, for reporting
     443             :         Real64 ControlTempFinal;                            // Measured control temperature at the end of the timestep, for reporting
     444             :         bool AllowHeatingElementAndHeatPumpToRunAtSameTime; // if false, if the heating element kicks on, it will recover with that before turning the
     445             :         // heat pump back on.
     446             :         // variables for variable-speed HPWH
     447             :         int NumofSpeed;                        // number of speeds for VS HPWH
     448             :         Array1D<Real64> HPWHAirVolFlowRate;    // air volume flow rate during heating operation
     449             :         Array1D<Real64> HPWHAirMassFlowRate;   // air mass flow rate during heating operation
     450             :         Array1D<Real64> HPWHWaterVolFlowRate;  // water volume flow rate during heating operation
     451             :         Array1D<Real64> HPWHWaterMassFlowRate; // water mass flow rate during heating operation
     452             :         Array1D<Real64> MSAirSpeedRatio;       // air speed ratio in heating mode
     453             :         Array1D<Real64> MSWaterSpeedRatio;     // water speed ratio in heating mode
     454             :         bool bIsIHP;                           // whether the HP is a part of Integrated Heat Pump
     455             :         bool MyOneTimeFlagHP;                  // first pass log
     456             :         bool MyTwoTimeFlagHP;                  // second pass do input check
     457             :         std::string CoilInletNode_str;         // Used to set up comp set
     458             :         std::string CoilOutletNode_str;        // Used to set up comp set
     459             :         bool CheckHPWHEquipName;
     460             : 
     461             :         std::string InletNodeName1;
     462             :         std::string OutletNodeName1;
     463             :         std::string InletNodeName2;
     464             :         std::string OutletNodeName2;
     465             : 
     466             :         bool myOneTimeInitFlag;
     467             : 
     468             :         // end of variables for variable-speed HPWH
     469             : 
     470             :         // Default Constructor
     471           9 :         HeatPumpWaterHeaterData()
     472           9 :             : HPWHType(DataPlant::PlantEquipmentType::Invalid), HPWHTankType(DataPlant::PlantEquipmentType::Invalid), StandAlone(false),
     473             :               AvailSchedPtr(0), SetPointTempSchedule(0), DeadBandTempDiff(0.0), Capacity(0.0), BackupElementCapacity(0.0),
     474             :               BackupElementEfficiency(0.0), WHOnCycParaLoad(0.0), WHOffCycParaLoad(0.0), WHOnCycParaFracToTank(0.0), WHOffCycParaFracToTank(0.0),
     475             :               WHPLFCurve(0), OperatingAirFlowRate(0.0), OperatingAirMassFlowRate(0.0), OperatingWaterFlowRate(0.0), COP(0.0), SHR(0.0),
     476             :               RatedInletDBTemp(0.0), RatedInletWBTemp(0.0), RatedInletWaterTemp(0.0), FoundTank(false), HeatPumpAirInletNode(0),
     477             :               HeatPumpAirOutletNode(0), OutsideAirNode(0), ExhaustAirNode(0), CondWaterInletNode(0), CondWaterOutletNode(0), WHUseInletNode(0),
     478             :               WHUseOutletNode(0), WHUseSidePlantLoopNum(0), DXCoilNum(0), DXCoilTypeNum(0), DXCoilAirInletNode(0), DXCoilPLFFPLR(0), FanType_Num(0),
     479             :               FanNum(0), FanPlacement(0), FanOutletNode(0), WaterHeaterTankNum(0), OutletAirSplitterSchPtr(0), InletAirMixerSchPtr(0), Power(0.0),
     480             :               Energy(0.0), HeatingPLR(0.0), SetPointTemp(0.0), MinAirTempForHPOperation(5.0), MaxAirTempForHPOperation(48.8888888889),
     481             :               InletAirMixerNode(0), OutletAirSplitterNode(0), SourceMassFlowRate(0.0), InletAirConfiguration(WTTAmbientTemp::OutsideAir),
     482             :               AmbientTempSchedule(0), AmbientRHSchedule(0), AmbientTempZone(0), CrankcaseTempIndicator(CrankcaseHeaterControlTemp::Schedule),
     483             :               CrankcaseTempSchedule(0), CrankcaseTempZone(0), OffCycParaLoad(0.0), OnCycParaLoad(0.0),
     484             :               ParasiticTempIndicator(WTTAmbientTemp::OutsideAir), OffCycParaFuelRate(0.0), OnCycParaFuelRate(0.0), OffCycParaFuelEnergy(0.0),
     485             :               OnCycParaFuelEnergy(0.0), AirFlowRateAutoSized(false), WaterFlowRateAutoSized(false), HPSetPointError(0), HPSetPointErrIndex1(0),
     486             :               IterLimitErrIndex1(0), IterLimitExceededNum1(0), RegulaFalsiFailedIndex1(0), RegulaFalsiFailedNum1(0), IterLimitErrIndex2(0),
     487             :               IterLimitExceededNum2(0), RegulaFalsiFailedIndex2(0), RegulaFalsiFailedNum2(0), FirstTimeThroughFlag(true), ShowSetPointWarning(true),
     488             :               HPWaterHeaterSensibleCapacity(0.0), HPWaterHeaterLatentCapacity(0.0), WrappedCondenserBottomLocation(0.0),
     489             :               WrappedCondenserTopLocation(0.0), ControlSensor1Height(-1.0), ControlSensor1Node(1), ControlSensor1Weight(1.0),
     490             :               ControlSensor2Height(-1.0), ControlSensor2Node(2), ControlSensor2Weight(0.0), ControlTempAvg(0.0), ControlTempFinal(0.0),
     491             :               AllowHeatingElementAndHeatPumpToRunAtSameTime(true), NumofSpeed(0), HPWHAirVolFlowRate(DataGlobalConstants::MaxSpeedLevels, 0.0),
     492             :               HPWHAirMassFlowRate(DataGlobalConstants::MaxSpeedLevels, 0.0), HPWHWaterVolFlowRate(DataGlobalConstants::MaxSpeedLevels, 0.0),
     493             :               HPWHWaterMassFlowRate(DataGlobalConstants::MaxSpeedLevels, 0.0), MSAirSpeedRatio(DataGlobalConstants::MaxSpeedLevels, 0.0),
     494             :               MSWaterSpeedRatio(DataGlobalConstants::MaxSpeedLevels, 0.0), bIsIHP(false), MyOneTimeFlagHP(true), MyTwoTimeFlagHP(true),
     495           9 :               CheckHPWHEquipName(true), myOneTimeInitFlag(true)
     496             :         {
     497           9 :         }
     498             : 
     499             :         static PlantComponent *factory(EnergyPlusData &state, std::string const &objectName);
     500             : 
     501             :         void
     502             :         simulate(EnergyPlusData &state, const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override;
     503             : 
     504             :         void onInitLoopEquip([[maybe_unused]] EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation) override;
     505             : 
     506             :         void getDesignCapacities(EnergyPlusData &state,
     507             :                                  [[maybe_unused]] const PlantLocation &calledFromLocation,
     508             :                                  Real64 &MaxLoad,
     509             :                                  Real64 &MinLoad,
     510             :                                  Real64 &OptLoad) override;
     511             : 
     512             :         void oneTimeInit(EnergyPlusData &state) override;
     513             :     };
     514             : 
     515         514 :     struct WaterThermalTankData : PlantComponent
     516             :     {
     517             :         // Members
     518             :         std::string Name;                                   // Name of water heater
     519             :         std::string Type;                                   // Type of water heater (MIXED or STRATIFIED)
     520             :         DataPlant::PlantEquipmentType WaterThermalTankType; // integer parameter for water heater(if part of an HPWH,then=HPWH)
     521             :         bool IsChilledWaterTank;                            // logical flag, true if for chilled water, false if for hot water
     522             :         std::string EndUseSubcategoryName;                  // User-defined end-use subcategory name
     523             :         bool Init;                                          // Flag for initialization:  TRUE means do the init
     524             :         bool StandAlone;                                    // Flag for operation with no plant connections (no source or use)
     525             :         Real64 Volume;                                      // Tank volume (m3)
     526             :         bool VolumeWasAutoSized;                            // true if tank volume was autosize on input
     527             :         Real64 Mass;                                        // Total mass of fluid in the tank (kg)
     528             :         Real64 TimeElapsed;                                 // Fraction of the current hour that has elapsed (h)
     529             :         // Saved in order to identify the beginning of a new system time
     530             :         WTTAmbientTemp AmbientTempIndicator;                       // Indicator for ambient tank losses (SCHEDULE, ZONE, EXTERIOR)
     531             :         int AmbientTempSchedule;                                   // Schedule index pointer
     532             :         int AmbientTempZone;                                       // Number of ambient zone around tank
     533             :         int AmbientTempOutsideAirNode;                             // Number of outside air node
     534             :         Real64 AmbientTemp;                                        // Ambient temperature around tank (C)
     535             :         Real64 AmbientZoneGain;                                    // Internal gain to zone from tank losses (W)
     536             :         Real64 LossCoeff;                                          // Overall tank heat loss coefficient, UA (W/K)
     537             :         Real64 OffCycLossCoeff;                                    // Off-cycle overall tank heat loss coefficient, UA (W/K)
     538             :         Real64 OffCycLossFracToZone;                               // Fraction of off-cycle losses added to zone
     539             :         Real64 OnCycLossCoeff;                                     // On-cycle overall tank heat loss coefficient, UA (W/K)
     540             :         Real64 OnCycLossFracToZone;                                // Fraction of on-cycle losses added to zone
     541             :         TankOperatingMode Mode = TankOperatingMode::Floating;      // Indicator for current operating mode
     542             :         TankOperatingMode SavedMode = TankOperatingMode::Floating; // Mode indicator saved from previous time step
     543             :         HeaterControlMode ControlType;                             // Indicator for Heater Control type
     544             :         PriorityControlMode StratifiedControlMode;                 // Indicator for Stratified Water Heaters Priority Control Type
     545             :         Fuel FuelType;                                             // Fuel type
     546             :         Real64 MaxCapacity;                                        // Maximum capacity of auxiliary heater 1 (W)
     547             :         bool MaxCapacityWasAutoSized;                              // true if heater 1 capacity was autosized on input
     548             :         Real64 MinCapacity;                                        // Minimum capacity of auxiliary heater 1 (W)
     549             :         Real64 Efficiency;                                         // Thermal efficiency of auxiliary heater 1 ()
     550             :         int PLFCurve;                                              // Part load factor curve as a function of part load ratio
     551             :         int SetPointTempSchedule;                                  // Schedule index pointer
     552             :         Real64 SetPointTemp;                                       // Setpoint temperature of auxiliary heater 1 (C)
     553             :         Real64 DeadBandDeltaTemp;                                  // Deadband temperature difference of auxiliary heater 1 (deltaC)
     554             :         Real64 TankTempLimit;                                      // Maximum tank temperature limit before venting (C)
     555             :         Real64 IgnitionDelay;                                      // Time delay before heater is allowed to turn on (s)
     556             :         Real64 OffCycParaLoad;                                     // Rate for off-cycle parasitic load (W)
     557             :         Fuel OffCycParaFuelType;                                   // Fuel type for off-cycle parasitic load
     558             :         Real64 OffCycParaFracToTank;                               // Fraction of off-cycle parasitic energy ending up in tank (W)
     559             :         Real64 OnCycParaLoad;                                      // Rate for on-cycle parasitic load (W)
     560             :         Fuel OnCycParaFuelType;                                    // Fuel type for on-cycle parasitic load
     561             :         Real64 OnCycParaFracToTank;                                // Fraction of on-cycle parasitic energy ending up in tank (W)
     562             :         DataPlant::FlowLock UseCurrentFlowLock;                    // current flow lock setting on use side
     563             :         int UseInletNode;                                          // Inlet node on the use side; colder water returning to a hottank
     564             :         Real64 UseInletTemp;                                       // Use side inlet temperature (C)
     565             :         int UseOutletNode;                                         // Outlet node on the use side; hot tank water
     566             :         Real64 UseOutletTemp;                                      // Use side outlet temperature (C)
     567             :         Real64 UseMassFlowRate;                                    // Mass flow rate on the use side (kg/s)
     568             :         Real64 UseEffectiveness;                                   // Heat transfer effectiveness on use side ()
     569             :         Real64 PlantUseMassFlowRateMax;                            // Plant demand-side max flow request on use side (kg/s)
     570             :         Real64 SavedUseOutletTemp;                                 // Use side outlet temp saved for demand-side flow control (C)
     571             :         Real64 UseDesignVolFlowRate;                               // Use side plant volume flow rate (input data, autosizable) m3/s
     572             :         bool UseDesignVolFlowRateWasAutoSized;                     // true if use flow rate was autosize on input
     573             :         DataBranchAirLoopPlant::ControlType UseBranchControlType;  // Use side plant branch control type e.g active, passive, bypass
     574             :         int UseSidePlantSizNum;                                    // index in plant sizing that the use side is on
     575             :         bool UseSideSeries;
     576             :         int UseSideAvailSchedNum;    // use side availability schedule
     577             :         Real64 UseSideLoadRequested; // hold MyLoad request from plant management.
     578             :         PlantLocation UseSidePlantLoc;
     579             :         int SourceInletNode;                                         // Inlet node for the source side; hot water from supply
     580             :         Real64 SourceInletTemp;                                      // Source side inlet temperature (C)
     581             :         int SourceOutletNode;                                        // Outlet node for the source side; colder tank water
     582             :         Real64 SourceOutletTemp;                                     // Source side outlet temperature (C)
     583             :         Real64 SourceMassFlowRate;                                   // Mass flow rate on the source side (kg/s)
     584             :         Real64 SourceEffectiveness;                                  // Heat transfer effectiveness on source side ()
     585             :         Real64 PlantSourceMassFlowRateMax;                           // Plant demand-side max flow request on source side (kg/s)
     586             :         Real64 SavedSourceOutletTemp;                                // Source side outlet temp saved for demand-side flow control (C)
     587             :         Real64 SourceDesignVolFlowRate;                              // Source side plant volume flow rate (input, autosizable) m3/s
     588             :         bool SourceDesignVolFlowRateWasAutoSized;                    // true if source flow rate was autosize on input
     589             :         DataBranchAirLoopPlant::ControlType SourceBranchControlType; // source side plant branch control type e.g active, passive, bypass
     590             :         int SourceSidePlantSizNum;                                   // index in plant sizing that the source side is on
     591             :         bool SourceSideSeries;
     592             :         int SourceSideAvailSchedNum; // source side availability schedule.
     593             :         PlantLocation SrcSidePlantLoc;
     594             :         SourceSideControl SourceSideControlMode; // flag for how source side flow is controlled
     595             :         int SourceSideAltSetpointSchedNum;       // schedule of alternate temperature setpoint values
     596             :         Real64 SizingRecoveryTime;               // sizing parameter for autosizing indirect water heaters (hr)
     597             :         Real64 MassFlowRateMax;                  // Maximum flow rate for scheduled DHW (kg/s)
     598             :         Real64 VolFlowRateMin;                   // Minimum flow rate for heater ignition (kg/s)
     599             :         Real64 MassFlowRateMin;                  // Minimum mass flow rate for heater ignition (kg/s)
     600             :         int FlowRateSchedule;                    // Schedule index pointer
     601             :         int UseInletTempSchedule;                // Cold water supply temperature schedule index pointer
     602             :         Real64 TankTemp;                         // Temperature of tank fluid (average, if stratified) (C)
     603             :         Real64 SavedTankTemp;                    // Tank temp that is carried from time step to time step (C)
     604             :         Real64 TankTempAvg;                      // Average tank temperature over the time step (C)
     605             :         // Stratified variables (in addition to the above)
     606             :         Real64 Height;           // Height of tank (m)
     607             :         bool HeightWasAutoSized; // true if the height of tank was autosize on input
     608             :         Real64 Perimeter;        // Perimeter of tank (m), only used for OTHER shape
     609             :         TankShape Shape;         // Tank shape:  VERTICAL CYLINDER, HORIZONTAL CYLINDER, or OTHER
     610             :         Real64 HeaterHeight1;
     611             :         int HeaterNode1;
     612             :         bool HeaterOn1;
     613             :         bool SavedHeaterOn1;
     614             :         Real64 HeaterHeight2;
     615             :         int HeaterNode2;
     616             :         bool HeaterOn2;
     617             :         bool SavedHeaterOn2;
     618             :         Real64 AdditionalCond; // Additional destratification conductivity (W/m K)
     619             :         Real64 SetPointTemp2;  // Setpoint temperature of auxiliary heater 2 (C)
     620             :         int SetPointTempSchedule2;
     621             :         Real64 DeadBandDeltaTemp2;
     622             :         Real64 MaxCapacity2;
     623             :         Real64 OffCycParaHeight;
     624             :         Real64 OnCycParaHeight;
     625             :         Real64 SkinLossCoeff;
     626             :         Real64 SkinLossFracToZone;
     627             :         Real64 OffCycFlueLossCoeff;
     628             :         Real64 OffCycFlueLossFracToZone;
     629             :         Real64 UseInletHeight;              // Height of use side inlet (m)
     630             :         Real64 UseOutletHeight;             // Height of use side outlet (m)
     631             :         bool UseOutletHeightWasAutoSized;   // true if use outlet height was autosize on input
     632             :         Real64 SourceInletHeight;           // Height of source side inlet (m)
     633             :         bool SourceInletHeightWasAutoSized; // true if source inlet height was autosize on input
     634             :         Real64 SourceOutletHeight;          // Height of source side outlet (m)
     635             :         int UseInletStratNode;              // Use-side inlet node number
     636             :         int UseOutletStratNode;             // Use-side outlet node number
     637             :         int SourceInletStratNode;           // Source-side inlet node number
     638             :         int SourceOutletStratNode;          // Source-side outlet node number
     639             :         InletPositionMode InletMode;        // Inlet position mode:  1 = FIXED; 2 = SEEKING
     640             :         Real64 InversionMixingRate;
     641             :         Array1D<Real64> AdditionalLossCoeff; // Loss coefficient added to the skin loss coefficient (W/m2-K)
     642             :         int Nodes;                           // Number of nodes
     643             :         Array1D<StratifiedNodeData> Node;    // Array of node data
     644             :         // Report variables
     645             :         Real64 VolFlowRate;            // Scheduled DHW demand (m3/s)
     646             :         Real64 VolumeConsumed;         // Volume of DHW consumed (m3)
     647             :         Real64 UnmetRate;              // Energy demand to heat tank water to setpoint (W)
     648             :         Real64 LossRate;               // Energy demand to support heat losses due to ambient temp (W)
     649             :         Real64 FlueLossRate;           // Heat loss rate to flue (W)
     650             :         Real64 UseRate;                // Energy demand to heat the Use Side water to tank temp (W)
     651             :         Real64 TotalDemandRate;        // Total demand rate (sum of all above rates) (W)
     652             :         Real64 SourceRate;             // Energy supplied by the source side to help heat the tank (W)
     653             :         Real64 HeaterRate;             // The energy the water heater burner puts into the water (W)
     654             :         Real64 HeaterRate1;            // The energy heater 1 puts into the water (W)
     655             :         Real64 HeaterRate2;            // The energy heater 2 puts into the water (W)
     656             :         Real64 FuelRate;               // The fuel consumption rate for the water heater burner (W)
     657             :         Real64 FuelRate1;              // The fuel consumption rate for heater 1 (W)
     658             :         Real64 FuelRate2;              // The fuel consumption rate for heater 2 (W)
     659             :         Real64 VentRate;               // Heat recovery energy lost due to setpoint temp (W)
     660             :         Real64 OffCycParaFuelRate;     // Fuel consumption rate for off-cycle parasitic load (W)
     661             :         Real64 OffCycParaRateToTank;   // Heat rate to tank for off-cycle parasitic load (W)
     662             :         Real64 OnCycParaFuelRate;      // Fuel consumption rate for on-cycle parasitic load (W)
     663             :         Real64 OnCycParaRateToTank;    // Heat rate to tank for on-cycle parasitic load (W)
     664             :         Real64 NetHeatTransferRate;    // Net heat transfer rate to/from tank (W)
     665             :         int CycleOnCount;              // Number of times heater cycles on in the current time step
     666             :         int CycleOnCount1;             // Number of times heater 1 cycles on in the current time step
     667             :         int CycleOnCount2;             // Number of times heater 2 cycles on in the current time step
     668             :         Real64 RuntimeFraction;        // Runtime fraction, fraction of timestep that any  heater is running
     669             :         Real64 RuntimeFraction1;       // Runtime fraction, fraction of timestep that heater 1 is running
     670             :         Real64 RuntimeFraction2;       // Runtime fraction, fraction of timestep that heater 2 is running
     671             :         Real64 PartLoadRatio;          // Part load ratio, fraction of maximum heater capacity
     672             :         Real64 UnmetEnergy;            // Energy to heat tank water to setpoint (J)
     673             :         Real64 LossEnergy;             // Energy to support heat losses due to ambient temp (J)
     674             :         Real64 FlueLossEnergy;         // Energy to support heat losses to the flue (J)
     675             :         Real64 UseEnergy;              // Energy to heat the use side water to tank temp (J)
     676             :         Real64 TotalDemandEnergy;      // Total energy demand (sum of all above energies) (J)
     677             :         Real64 SourceEnergy;           // Energy supplied by the source side to help heat the tank (J)
     678             :         Real64 HeaterEnergy;           // The energy the water heater burner puts into the water (J)
     679             :         Real64 HeaterEnergy1;          // The energy heater 1 puts into the water (J)
     680             :         Real64 HeaterEnergy2;          // The energy heater 2 puts into the water (J)
     681             :         Real64 FuelEnergy;             // The fuel consumption energy for the water heater burner (J)
     682             :         Real64 FuelEnergy1;            // The fuel consumption energy for heater 1 (J)
     683             :         Real64 FuelEnergy2;            // The fuel consumption energy for heater 2 (J)
     684             :         Real64 VentEnergy;             // Heat recovery energy lost due to setpoint temp (J)
     685             :         Real64 OffCycParaFuelEnergy;   // Fuel consumption energy for off-cycle parasitic load (J)
     686             :         Real64 OffCycParaEnergyToTank; // Energy to tank for off-cycle parasitic load (J)
     687             :         Real64 OnCycParaFuelEnergy;    // Fuel consumption energy for on-cycle parasitic load (J)
     688             :         Real64 OnCycParaEnergyToTank;  // Energy to tank for on-cycle parasitic load (J)
     689             :         Real64 NetHeatTransferEnergy;  // Net heat transfer energy to/from tank (J)
     690             :         bool FirstRecoveryDone;        // Flag to indicate when first recovery to the setpoint is done
     691             :         Real64 FirstRecoveryFuel;      // Fuel energy needed for first recovery to the setpoint (J)
     692             :         int HeatPumpNum;               // Index to heat pump water heater
     693             :         int DesuperheaterNum;          // Index to desuperheating coil
     694             :         bool ShowSetPointWarning;      // Warn when set point is greater than max tank temp limit
     695             :         int MaxCycleErrorIndex;        // recurring error index
     696             :         int FreezingErrorIndex;        // recurring error index for freeze conditions
     697             :         WaterHeaterSizingData Sizing;  // ancillary data for autosizing
     698             :         int FluidIndex;                // fluid properties index
     699             :         bool MyOneTimeFlagWH;          // first pass log
     700             :         bool MyTwoTimeFlagWH;          // second pass do input check
     701             :         bool MyEnvrnFlag;
     702             :         bool WarmupFlag;
     703             :         bool SetLoopIndexFlag;
     704             :         bool AlreadyReported;
     705             :         bool AlreadyRated;
     706             :         bool MyHPSizeFlag;
     707             :         bool CheckWTTEquipName;
     708             : 
     709             :         std::string InletNodeName1;
     710             :         std::string OutletNodeName1;
     711             :         std::string InletNodeName2;
     712             :         std::string OutletNodeName2;
     713             : 
     714             :         bool myOneTimeInitFlag;
     715             :         bool scanPlantLoopsFlag;
     716             : 
     717             :         int callerLoopNum;
     718             :         int waterIndex;
     719             : 
     720             :         // Default Constructor
     721         128 :         WaterThermalTankData()
     722         128 :             : WaterThermalTankType(DataPlant::PlantEquipmentType::Invalid), IsChilledWaterTank(false), Init(true), StandAlone(false), Volume(0.0),
     723             :               VolumeWasAutoSized(false), Mass(0.0), TimeElapsed(0.0), AmbientTempIndicator(WTTAmbientTemp::OutsideAir), AmbientTempSchedule(0),
     724             :               AmbientTempZone(0), AmbientTempOutsideAirNode(0), AmbientTemp(0.0), AmbientZoneGain(0.0), LossCoeff(0.0), OffCycLossCoeff(0.0),
     725             :               OffCycLossFracToZone(0.0), OnCycLossCoeff(0.0), OnCycLossFracToZone(0.0), ControlType(HeaterControlMode::Cycle),
     726             :               StratifiedControlMode(PriorityControlMode::Invalid), MaxCapacity(0.0), MaxCapacityWasAutoSized(false), MinCapacity(0.0),
     727             :               Efficiency(0.0), PLFCurve(0), SetPointTempSchedule(0), SetPointTemp(0.0), DeadBandDeltaTemp(0.0), TankTempLimit(0.0),
     728             :               IgnitionDelay(0.0), OffCycParaLoad(0.0), OffCycParaFracToTank(0.0), OnCycParaLoad(0.0), OnCycParaFracToTank(0.0),
     729             :               UseCurrentFlowLock(DataPlant::FlowLock::Unlocked), UseInletNode(0), UseInletTemp(0.0), UseOutletNode(0), UseOutletTemp(0.0),
     730             :               UseMassFlowRate(0.0), UseEffectiveness(0.0), PlantUseMassFlowRateMax(0.0), SavedUseOutletTemp(0.0), UseDesignVolFlowRate(0.0),
     731             :               UseDesignVolFlowRateWasAutoSized(false), UseBranchControlType(DataBranchAirLoopPlant::ControlType::Passive), UseSidePlantSizNum(0),
     732             :               UseSideSeries(true), UseSideAvailSchedNum(0), UseSideLoadRequested(0.0), UseSidePlantLoc{}, SourceInletNode(0), SourceInletTemp(0.0),
     733             :               SourceOutletNode(0), SourceOutletTemp(0.0), SourceMassFlowRate(0.0), SourceEffectiveness(0.0), PlantSourceMassFlowRateMax(0.0),
     734             :               SavedSourceOutletTemp(0.0), SourceDesignVolFlowRate(0.0), SourceDesignVolFlowRateWasAutoSized(false),
     735             :               SourceBranchControlType(DataBranchAirLoopPlant::ControlType::Passive), SourceSidePlantSizNum(0), SourceSideSeries(true),
     736             :               SourceSideAvailSchedNum(0), SrcSidePlantLoc{}, SourceSideControlMode(SourceSideControl::IndirectHeatAltSetpoint),
     737             :               SourceSideAltSetpointSchedNum(0), SizingRecoveryTime(0.0), MassFlowRateMax(0.0), VolFlowRateMin(0.0), MassFlowRateMin(0.0),
     738             :               FlowRateSchedule(0), UseInletTempSchedule(0), TankTemp(0.0), SavedTankTemp(0.0), TankTempAvg(0.0), Height(0.0),
     739             :               HeightWasAutoSized(false), Perimeter(0.0), Shape(TankShape::VertCylinder), HeaterHeight1(0.0), HeaterNode1(0), HeaterOn1(false),
     740             :               SavedHeaterOn1(false), HeaterHeight2(0.0), HeaterNode2(0), HeaterOn2(false), SavedHeaterOn2(false), AdditionalCond(0.0),
     741             :               SetPointTemp2(0.0), SetPointTempSchedule2(0), DeadBandDeltaTemp2(0.0), MaxCapacity2(0.0), OffCycParaHeight(0.0), OnCycParaHeight(0.0),
     742             :               SkinLossCoeff(0.0), SkinLossFracToZone(0.0), OffCycFlueLossCoeff(0.0), OffCycFlueLossFracToZone(0.0), UseInletHeight(0.0),
     743             :               UseOutletHeight(0.0), UseOutletHeightWasAutoSized(false), SourceInletHeight(0.0), SourceInletHeightWasAutoSized(false),
     744             :               SourceOutletHeight(0.0), UseInletStratNode(0), UseOutletStratNode(0), SourceInletStratNode(0), SourceOutletStratNode(0),
     745             :               InletMode(InletPositionMode::Fixed), InversionMixingRate(0.0), Nodes(0), VolFlowRate(0.0), VolumeConsumed(0.0), UnmetRate(0.0),
     746             :               LossRate(0.0), FlueLossRate(0.0), UseRate(0.0), TotalDemandRate(0.0), SourceRate(0.0), HeaterRate(0.0), HeaterRate1(0.0),
     747             :               HeaterRate2(0.0), FuelRate(0.0), FuelRate1(0.0), FuelRate2(0.0), VentRate(0.0), OffCycParaFuelRate(0.0), OffCycParaRateToTank(0.0),
     748             :               OnCycParaFuelRate(0.0), OnCycParaRateToTank(0.0), NetHeatTransferRate(0.0), CycleOnCount(0), CycleOnCount1(0), CycleOnCount2(0),
     749             :               RuntimeFraction(0.0), RuntimeFraction1(0.0), RuntimeFraction2(0.0), PartLoadRatio(0.0), UnmetEnergy(0.0), LossEnergy(0.0),
     750             :               FlueLossEnergy(0.0), UseEnergy(0.0), TotalDemandEnergy(0.0), SourceEnergy(0.0), HeaterEnergy(0.0), HeaterEnergy1(0.0),
     751             :               HeaterEnergy2(0.0), FuelEnergy(0.0), FuelEnergy1(0.0), FuelEnergy2(0.0), VentEnergy(0.0), OffCycParaFuelEnergy(0.0),
     752             :               OffCycParaEnergyToTank(0.0), OnCycParaFuelEnergy(0.0), OnCycParaEnergyToTank(0.0), NetHeatTransferEnergy(0.0), FirstRecoveryDone(false),
     753             :               FirstRecoveryFuel(0.0), HeatPumpNum(0), DesuperheaterNum(0), ShowSetPointWarning(true), MaxCycleErrorIndex(0), FreezingErrorIndex(0),
     754             :               FluidIndex(0), MyOneTimeFlagWH(true), MyTwoTimeFlagWH(true), MyEnvrnFlag(true), WarmupFlag(false), SetLoopIndexFlag(true),
     755             :               AlreadyReported(false), AlreadyRated(false), MyHPSizeFlag(true), CheckWTTEquipName(true), myOneTimeInitFlag(true),
     756         128 :               scanPlantLoopsFlag(true), callerLoopNum(0), waterIndex(1)
     757             :         {
     758         128 :         }
     759             : 
     760             :         static PlantComponent *factory(EnergyPlusData &state, std::string const &objectName);
     761             : 
     762             :         void setupOutputVars(EnergyPlusData &state);
     763             : 
     764             :         void setupZoneInternalGains(EnergyPlusData &state);
     765             : 
     766             :         void setupChilledWaterTankOutputVars(EnergyPlusData &state);
     767             : 
     768             :         void setupWaterHeaterOutputVars(EnergyPlusData &state);
     769             : 
     770             :         void
     771             :         simulate(EnergyPlusData &state, const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override;
     772             : 
     773             :         Real64 PartLoadFactor(EnergyPlusData &state, Real64 PartLoadRatio_loc);
     774             : 
     775             :         void CalcNodeMassFlows(InletPositionMode inletMode);
     776             : 
     777             :         void SetupStratifiedNodes(EnergyPlusData &state);
     778             : 
     779             :         void initialize(EnergyPlusData &state, bool FirstHVACIteration);
     780             : 
     781             :         bool SourceHeatNeed(EnergyPlusData &state, Real64 OutletTemp, Real64 DeadBandTemp, Real64 SetPointTemp_loc);
     782             : 
     783             :         void SizeDemandSidePlantConnections(EnergyPlusData &state);
     784             : 
     785             :         void SizeTankForSupplySide(EnergyPlusData &state);
     786             : 
     787             :         void SizeTankForDemandSide(EnergyPlusData &state);
     788             : 
     789             :         void MinePlantStructForInfo(EnergyPlusData &state);
     790             : 
     791             :         void SizeSupplySidePlantConnections(EnergyPlusData &state, Optional_int_const LoopNum = _);
     792             : 
     793             :         void CalcWaterThermalTank(EnergyPlusData &state);
     794             : 
     795             :         void SizeStandAloneWaterHeater(EnergyPlusData &state);
     796             : 
     797             :         void UpdateWaterThermalTank(EnergyPlusData &state);
     798             : 
     799             :         void ReportWaterThermalTank(EnergyPlusData &state);
     800             : 
     801             :         void CalcWaterThermalTankStratified(EnergyPlusData &state); // Water Heater being simulated
     802             : 
     803             :         void CalcWaterThermalTankMixed(EnergyPlusData &state); // Water Heater being simulated
     804             : 
     805             :         void CalcStandardRatings(EnergyPlusData &state);
     806             : 
     807             :         void ReportCWTankInits(EnergyPlusData &state);
     808             : 
     809             :         Real64 GetHPWHSensedTankTemp(EnergyPlusData &state);
     810             : 
     811             :         Real64 FindStratifiedTankSensedTemp(EnergyPlusData &state, bool UseAverage = false);
     812             : 
     813             :         Real64 getDeadBandTemp();
     814             : 
     815             :         Real64 PlantMassFlowRatesFunc(EnergyPlusData &state,
     816             :                                       int InNodeNum,
     817             :                                       bool FirstHVACIteration,
     818             :                                       WaterHeaterSide WaterThermalTankSide,
     819             :                                       DataPlant::LoopSideLocation PlantLoopSide,
     820             :                                       bool PlumbedInSeries, // !unused1208
     821             :                                       DataBranchAirLoopPlant::ControlType BranchControlType,
     822             :                                       Real64 OutletTemp,
     823             :                                       Real64 DeadBandTemp,
     824             :                                       Real64 SetPointTemp_loc);
     825             : 
     826             :         static Real64 CalcTimeNeeded(Real64 Ti, // Initial tank temperature (C)
     827             :                                      Real64 Tf, // Final tank temperature (C)
     828             :                                      Real64 Ta, // Ambient environment temperature (C)
     829             :                                      Real64 T1, // Temperature of flow 1 (C)
     830             :                                      Real64 T2, // Temperature of flow 2 (C)
     831             :                                      Real64 m,  // Mass of tank fluid (kg)
     832             :                                      Real64 Cp, // Specific heat of fluid (J/kg deltaC)
     833             :                                      Real64 m1, // Mass flow rate 1 (kg/s)
     834             :                                      Real64 m2, // Mass flow rate 2 (kg/s)
     835             :                                      Real64 UA, // Heat loss coefficient to ambient environment (W/deltaC)
     836             :                                      Real64 Q   // Net heating rate for non-temp dependent sources, i.e. heater and parasitics (W)
     837             :         );
     838             : 
     839             :         static Real64 CalcTankTemp(Real64 Ti, // Initial tank temperature (C)
     840             :                                    Real64 Ta, // Ambient environment temperature (C)
     841             :                                    Real64 T1, // Temperature of flow 1 (C)
     842             :                                    Real64 T2, // Temperature of flow 2 (C)
     843             :                                    Real64 m,  // Mass of tank fluid (kg)
     844             :                                    Real64 Cp, // Specific heat of fluid (J/kg deltaC)
     845             :                                    Real64 m1, // Mass flow rate 1 (kg/s)
     846             :                                    Real64 m2, // Mass flow rate 2 (kg/s)
     847             :                                    Real64 UA, // Heat loss coefficient to ambient environment (W/deltaC)
     848             :                                    Real64 Q,  // Net heating rate for non-temp dependent sources, i.e. heater and parasitics (W)
     849             :                                    Real64 t   // Time elapsed from Ti to Tf (s)
     850             :         );
     851             : 
     852             :         static Real64 CalcTempIntegral(Real64 Ti, // Initial tank temperature (C)
     853             :                                        Real64 Tf, // Final tank temperature (C)
     854             :                                        Real64 Ta, // Ambient environment temperature (C)
     855             :                                        Real64 T1, // Temperature of flow 1 (C)
     856             :                                        Real64 T2, // Temperature of flow 2 (C)
     857             :                                        Real64 m,  // Mass of tank fluid (kg)
     858             :                                        Real64 Cp, // Specific heat of fluid (J/kg deltaC)
     859             :                                        Real64 m1, // Mass flow rate 1 (kg/s)
     860             :                                        Real64 m2, // Mass flow rate 2 (kg/s)
     861             :                                        Real64 UA, // Heat loss coefficient to ambient environment (W/deltaC)
     862             :                                        Real64 Q,  // Net heating rate for non-temp dependent sources, i.e. heater and parasitics (W)
     863             :                                        Real64 t   // Time elapsed from Ti to Tf (s)
     864             :         );
     865             : 
     866             :         static void CalcMixedTankSourceSideHeatTransferRate(Real64 HPWHCondenserDeltaT, // input, The temperature difference (C) across the heat pump,
     867             :                                                                                         // zero if there is no heat pump or if the heat pump is off
     868             :                                                             Real64 SourceInletTemp,     // input, Source inlet temperature (C)
     869             :                                                             Real64 Cp,                  // Specific heat of fluid (J/kg deltaC)
     870             :                                                             Real64 SetPointTemp,        // input, Mixed tank set point temperature
     871             :                                                             Real64 &SourceMassFlowRate, // source mass flow rate (kg/s)
     872             :                                                             Real64 &Qheatpump,          // heat transfer rate from heat pump
     873             :                                                             Real64 &Qsource // steady state heat transfer rate from a constant source side flow
     874             :         );
     875             : 
     876             :         void CalcDesuperheaterWaterHeater(EnergyPlusData &state, bool FirstHVACIteration);
     877             : 
     878             :         Real64 PLRResidualWaterThermalTank(EnergyPlusData &state,
     879             :                                            Real64 HPPartLoadRatio,    // compressor cycling ratio (1.0 is continuous, 0.0 is off)
     880             :                                            Array1D<Real64> const &Par // par(1) = HP set point temperature [C]
     881             :         );
     882             : 
     883             :         void CalcHeatPumpWaterHeater(EnergyPlusData &state, bool FirstHVACIteration);
     884             : 
     885             :         void ConvergeSingleSpeedHPWHCoilAndTank(EnergyPlusData &state, Real64 partLoadRatio);
     886             : 
     887             :         void SetVSHPWHFlowRates(EnergyPlusData &state,
     888             :                                 HeatPumpWaterHeaterData &HPWH,
     889             :                                 int SpeedNum,
     890             :                                 Real64 SpeedRatio,
     891             :                                 Real64 WaterDens,
     892             :                                 Real64 &MdotWater,      // water flow rate
     893             :                                 bool FirstHVACIteration // TRUE if First iteration of simulation
     894             :         );
     895             : 
     896             :         Real64 PLRResidualHPWH(EnergyPlusData &state, Real64 HPPartLoadRatio, Real64 desTankTemp, TankOperatingMode mode, Real64 mDotWater);
     897             : 
     898             :         Real64 PLRResidualIterSpeed(EnergyPlusData &state,
     899             :                                     Real64 SpeedRatio, // speed ratio between two speed levels
     900             :                                     int HPNum,
     901             :                                     int SpeedNum,
     902             :                                     int HPWaterInletNode,
     903             :                                     int HPWaterOutletNode,
     904             :                                     Real64 RhoWater,
     905             :                                     Real64 desTankTemp,
     906             :                                     TankOperatingMode mode,
     907             :                                     bool FirstHVACIteration);
     908             : 
     909             :         static void ValidatePLFCurve(EnergyPlusData &state, int CurveIndex, bool &IsValid);
     910             : 
     911             :         void onInitLoopEquip(EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation) override;
     912             : 
     913             :         void getDesignCapacities(EnergyPlusData &state,
     914             :                                  [[maybe_unused]] const PlantLocation &calledFromLocation,
     915             :                                  Real64 &MaxLoad,
     916             :                                  Real64 &MinLoad,
     917             :                                  Real64 &OptLoad) override;
     918             : 
     919             :         void oneTimeInit(EnergyPlusData &state) override;
     920             : 
     921             :         void setBackupElementCapacity(EnergyPlusData &state);
     922             :     };
     923             : 
     924          18 :     struct WaterHeaterDesuperheaterData
     925             :     {
     926             :         // Members
     927             :         std::string Name;                          // Name of heat pump water heater desuperheater
     928             :         std::string Type;                          // Type of water heater desuperheating coil
     929             :         int InsuffTemperatureWarn;                 // Used for recurring error count on low source temperature
     930             :         int AvailSchedPtr;                         // Index to Availability Schedule curve index
     931             :         int SetPointTempSchedule;                  // Index to Setpoint Temperature Schedule curve
     932             :         Real64 DeadBandTempDiff;                   // Dead band temperature difference (cut-in temperature)
     933             :         Real64 HeatReclaimRecoveryEff;             // recovery efficiency of desuperheater (0.3 max)
     934             :         int WaterInletNode;                        // Desuperheater water inlet node
     935             :         int WaterOutletNode;                       // Desuperheater water outlet node
     936             :         Real64 RatedInletWaterTemp;                // Inlet water temp at rated heat reclaim recovery eff (C)
     937             :         Real64 RatedOutdoorAirTemp;                // Outdoor air temp at rated heat reclaim recovery eff (C)
     938             :         Real64 MaxInletWaterTemp;                  // Max water temp for heat reclaim recovery (C)
     939             :         std::string TankType;                      // Type of water heater (MIXED or STRATIFIED)
     940             :         DataPlant::PlantEquipmentType TankTypeNum; // Parameter for tank type (MIXED or STRATIFIED)
     941             :         std::string TankName;                      // Name of tank associated with desuperheater
     942             :         int TankNum;
     943             :         bool StandAlone;                                            // Flag for operation with no plant connections (no use nodes)
     944             :         std::string HeatingSourceType;                              // Type of heating source (DX coil or refrigerated rack)
     945             :         std::string HeatingSourceName;                              // Name of heating source
     946             :         Real64 HeaterRate;                                          // Report variable for desuperheater heating rate [W]
     947             :         Real64 HeaterEnergy;                                        // Report variable for desuperheater heating energy [J]
     948             :         Real64 PumpPower;                                           // Report variable for water circulation pump power [W]
     949             :         Real64 PumpEnergy;                                          // Report variable for water circulation pump energy [J]
     950             :         Real64 PumpElecPower;                                       // Nominal power input to the water circulation pump [W]
     951             :         Real64 PumpFracToWater;                                     // Nominal power fraction to water for the water circulation pump
     952             :         Real64 OperatingWaterFlowRate;                              // Operating volumetric water flow rate (m3/s)
     953             :         int HEffFTemp;                                              // Heating capacity as a function of temperature curve index
     954             :         Real64 HEffFTempOutput;                                     // report variable for HEffFTemp curve
     955             :         Real64 SetPointTemp;                                        // set point or cut-out temperature [C]
     956             :         int WaterHeaterTankNum;                                     // Index of Water Heater Tank
     957             :         Real64 DesuperheaterPLR;                                    // part load ratio of desuperheater
     958             :         Real64 OnCycParaLoad;                                       // Rate for on-cycle parasitic load (W)
     959             :         Real64 OffCycParaLoad;                                      // Rate for off-cycle parasitic load (W)
     960             :         Real64 OnCycParaFuelEnergy;                                 // Electric energy consumption for on-cycle parasitic load (J)
     961             :         Real64 OnCycParaFuelRate;                                   // Electric consumption rate for on-cycle parasitic load (W)
     962             :         Real64 OffCycParaFuelEnergy;                                // Electric energy consumption for off-cycle parasitic load (J)
     963             :         Real64 OffCycParaFuelRate;                                  // Electric consumption rate for off-cycle parasitic load (W)
     964             :         TankOperatingMode Mode = TankOperatingMode::Floating;       // mode
     965             :         TankOperatingMode SaveMode = TankOperatingMode::Floating;   // desuperheater mode on first iteration
     966             :         TankOperatingMode SaveWHMode = TankOperatingMode::Floating; // mode of water heater tank element (backup element)
     967             :         Real64 BackupElementCapacity;                               // Tank backup element capacity (W)
     968             :         Real64 DXSysPLR;                                            // runtime fraction of desuperheater heating coil
     969             :         int ReclaimHeatingSourceIndexNum;                           // Index to reclaim heating source (condenser) of a specific type
     970             :         ReclaimHeatObjectType ReclaimHeatingSource;                 // The source for the Desuperheater Heating Coil
     971             :         int SetPointError;                                          // Used when temp SP in tank and desuperheater are reversed
     972             :         int SetPointErrIndex1;                                      // Index to recurring error for tank/desuperheater set point temp
     973             :         int IterLimitErrIndex1;                                     // Index for recurring iteration limit warning messages
     974             :         int IterLimitExceededNum1;                                  // Counter for recurring iteration limit warning messages
     975             :         int RegulaFalsiFailedIndex1;                                // Index for recurring RegulaFalsi failed warning messages
     976             :         int RegulaFalsiFailedNum1;                                  // Counter for recurring RegulaFalsi failed warning messages
     977             :         int IterLimitErrIndex2;                                     // Index for recurring iteration limit warning messages
     978             :         int IterLimitExceededNum2;                                  // Counter for recurring iteration limit warning messages
     979             :         int RegulaFalsiFailedIndex2;                                // Index for recurring RegulaFalsi failed warning messages
     980             :         int RegulaFalsiFailedNum2;                                  // Counter for recurring RegulaFalsi failed warning messages
     981             :         bool FirstTimeThroughFlag;                                  // Flag for saving water heater status
     982             :         bool ValidSourceType;
     983             : 
     984             :         std::string InletNodeName1;
     985             :         std::string OutletNodeName1;
     986             :         std::string InletNodeName2;
     987             :         std::string OutletNodeName2;
     988             : 
     989             :         // Default Constructor
     990           6 :         WaterHeaterDesuperheaterData()
     991           6 :             : InsuffTemperatureWarn(0), AvailSchedPtr(0), SetPointTempSchedule(0), DeadBandTempDiff(0.0), HeatReclaimRecoveryEff(0.0),
     992             :               WaterInletNode(0), WaterOutletNode(0), RatedInletWaterTemp(0.0), RatedOutdoorAirTemp(0.0), MaxInletWaterTemp(0.0),
     993             :               TankTypeNum(DataPlant::PlantEquipmentType::Invalid), TankNum(0), StandAlone(false), HeaterRate(0.0), HeaterEnergy(0.0), PumpPower(0.0),
     994             :               PumpEnergy(0.0), PumpElecPower(0.0), PumpFracToWater(0.0), OperatingWaterFlowRate(0.0), HEffFTemp(0), HEffFTempOutput(0.0),
     995             :               SetPointTemp(0.0), WaterHeaterTankNum(0), DesuperheaterPLR(0.0), OnCycParaLoad(0.0), OffCycParaLoad(0.0), OnCycParaFuelEnergy(0.0),
     996             :               OnCycParaFuelRate(0.0), OffCycParaFuelEnergy(0.0), OffCycParaFuelRate(0.0), BackupElementCapacity(0.0), DXSysPLR(0.0),
     997             :               ReclaimHeatingSourceIndexNum(0), ReclaimHeatingSource(ReclaimHeatObjectType::DXCooling), SetPointError(0), SetPointErrIndex1(0),
     998             :               IterLimitErrIndex1(0), IterLimitExceededNum1(0), RegulaFalsiFailedIndex1(0), RegulaFalsiFailedNum1(0), IterLimitErrIndex2(0),
     999           6 :               IterLimitExceededNum2(0), RegulaFalsiFailedIndex2(0), RegulaFalsiFailedNum2(0), FirstTimeThroughFlag(true), ValidSourceType(false)
    1000             :         {
    1001           6 :         }
    1002             :     };
    1003             : 
    1004             :     // Functions
    1005             : 
    1006             :     void SimulateWaterHeaterStandAlone(EnergyPlusData &state, int WaterHeaterNum, bool FirstHVACIteration);
    1007             : 
    1008             :     void SimHeatPumpWaterHeater(EnergyPlusData &state,
    1009             :                                 std::string_view CompName,
    1010             :                                 bool FirstHVACIteration,
    1011             :                                 Real64 &SensLoadMet, // sensible load met by this equipment and sent to zone, W
    1012             :                                 Real64 &LatLoadMet,  // net latent load met and sent to zone (kg/s), dehumid = negative
    1013             :                                 int &CompIndex);
    1014             : 
    1015             :     bool getDesuperHtrInput(EnergyPlusData &state);
    1016             : 
    1017             :     bool getHPWaterHeaterInput(EnergyPlusData &state);
    1018             : 
    1019             :     bool getWaterHeaterMixedInputs(EnergyPlusData &state);
    1020             : 
    1021             :     bool getWaterHeaterStratifiedInput(EnergyPlusData &state);
    1022             : 
    1023             :     bool getWaterTankMixedInput(EnergyPlusData &state);
    1024             : 
    1025             :     bool getWaterTankStratifiedInput(EnergyPlusData &state);
    1026             : 
    1027             :     bool GetWaterThermalTankInput(EnergyPlusData &state);
    1028             : 
    1029             :     void CalcWaterThermalTankZoneGains(EnergyPlusData &state);
    1030             : 
    1031             :     int getTankIDX(EnergyPlusData &state, std::string_view CompName, int &CompIndex);
    1032             : 
    1033             :     int getHPTankIDX(EnergyPlusData &state, std::string_view CompName, int &CompIndex);
    1034             : 
    1035             :     bool GetHeatPumpWaterHeaterNodeNumber(EnergyPlusData &state, int NodeNumber);
    1036             : 
    1037             : } // namespace WaterThermalTanks
    1038             : 
    1039        1542 : struct WaterThermalTanksData : BaseGlobalStruct
    1040             : {
    1041             :     int numChilledWaterMixed = 0;        // number of mixed chilled water tanks
    1042             :     int numChilledWaterStratified = 0;   // number of stratified chilled water tanks
    1043             :     int numWaterHeaterMixed = 0;         // number of mixed water heaters
    1044             :     int numWaterHeaterStratified = 0;    // number of stratified water heaters
    1045             :     int numWaterThermalTank = 0;         // total number of water thermal tanks, hot and cold (MIXED + STRATIFIED)
    1046             :     int numWaterHeaterDesuperheater = 0; // number of desuperheater heating coils
    1047             :     int numHeatPumpWaterHeater = 0;      // number of heat pump water heaters
    1048             :     int numWaterHeaterSizing = 0;        // Number of sizing/design objects for water heaters.
    1049             : 
    1050             :     Real64 hpPartLoadRatio = 0.0;       // part load ratio of HPWH
    1051             :     Real64 mixerInletAirSchedule = 0.0; // output of inlet air mixer node schedule
    1052             :     Real64 mdotAir = 0.0;               // mass flow rate of evaporator air, kg/s
    1053             : 
    1054             :     Array1D<WaterThermalTanks::WaterThermalTankData> WaterThermalTank;
    1055             :     Array1D<WaterThermalTanks::HeatPumpWaterHeaterData> HPWaterHeater;
    1056             :     Array1D<WaterThermalTanks::WaterHeaterDesuperheaterData> WaterHeaterDesuperheater;
    1057             :     std::unordered_map<std::string, std::string> UniqueWaterThermalTankNames;
    1058             : 
    1059             :     bool getWaterThermalTankInputFlag = true; // Calls to Water Heater from multiple places in code
    1060             :     bool calcWaterThermalTankZoneGainsMyEnvrnFlag = true;
    1061             : 
    1062           0 :     void clear_state() override
    1063             :     {
    1064           0 :         *this = WaterThermalTanksData();
    1065           0 :     }
    1066             : };
    1067             : 
    1068             : } // namespace EnergyPlus
    1069             : 
    1070             : #endif

Generated by: LCOV version 1.13