LCOV - code coverage report
Current view: top level - EnergyPlus - WaterThermalTanks.hh (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 91 94 96.8 %
Date: 2024-08-23 23:50:59 Functions: 8 11 72.7 %

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

Generated by: LCOV version 1.14