LCOV - code coverage report
Current view: top level - EnergyPlus - IntegratedHeatPump.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 854 1169 73.1 %
Date: 2023-01-17 19:17:23 Functions: 22 22 100.0 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2023, The Board of Trustees of the University of Illinois,
       2             : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3             : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4             : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5             : // contributors. All rights reserved.
       6             : //
       7             : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8             : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9             : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10             : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11             : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12             : //
      13             : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14             : // provided that the following conditions are met:
      15             : //
      16             : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17             : //     conditions and the following disclaimer.
      18             : //
      19             : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20             : //     conditions and the following disclaimer in the documentation and/or other materials
      21             : //     provided with the distribution.
      22             : //
      23             : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24             : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25             : //     used to endorse or promote products derived from this software without specific prior
      26             : //     written permission.
      27             : //
      28             : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29             : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30             : //     reference solely to the software portion of its product, Licensee must refer to the
      31             : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32             : //     obtained under this License and may not use a different name for the software. Except as
      33             : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34             : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35             : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36             : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37             : //
      38             : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39             : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40             : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41             : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42             : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43             : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44             : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45             : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46             : // POSSIBILITY OF SUCH DAMAGE.
      47             : 
      48             : // ObjexxFCL Headers
      49             : #include <ObjexxFCL/Array1D.hh>
      50             : #include <ObjexxFCL/Optional.hh>
      51             : 
      52             : // EnergyPlus Headers
      53             : #include <EnergyPlus/BranchNodeConnections.hh>
      54             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      55             : #include <EnergyPlus/DataEnvironment.hh>
      56             : #include <EnergyPlus/DataHVACGlobals.hh>
      57             : #include <EnergyPlus/DataSizing.hh>
      58             : #include <EnergyPlus/GeneralRoutines.hh>
      59             : #include <EnergyPlus/GlobalNames.hh>
      60             : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
      61             : #include <EnergyPlus/IntegratedHeatPump.hh>
      62             : #include <EnergyPlus/NodeInputManager.hh>
      63             : #include <EnergyPlus/OutputProcessor.hh>
      64             : #include <EnergyPlus/Plant/DataPlant.hh>
      65             : #include <EnergyPlus/UtilityRoutines.hh>
      66             : #include <EnergyPlus/VariableSpeedCoils.hh>
      67             : #include <EnergyPlus/WaterThermalTanks.hh>
      68             : 
      69             : namespace EnergyPlus::IntegratedHeatPump {
      70             : 
      71             : // Using/Aliasing
      72             : using namespace DataLoopNode;
      73             : 
      74             : Real64 constexpr WaterDensity(986.0); // standard water density at 60 C
      75             : 
      76      264111 : void SimIHP(EnergyPlusData &state,
      77             :             std::string_view CompName,                               // Coil Name
      78             :             int &CompIndex,                                          // Index for Component name
      79             :             int const CyclingScheme,                                 // Continuous fan OR cycling compressor
      80             :             Real64 &MaxONOFFCyclesperHour,                           // Maximum cycling rate of heat pump [cycles/hr]
      81             :             Real64 &HPTimeConstant,                                  // Heat pump time constant [s]
      82             :             Real64 &FanDelayTime,                                    // Fan delay time, time delay for the HP's fan to
      83             :             DataHVACGlobals::CompressorOperation const CompressorOp, // compressor on/off. 0 = off; 1= on
      84             :             Real64 const PartLoadFrac,                               // part load fraction
      85             :             int const SpeedNum,                                      // compressor speed number
      86             :             Real64 const SpeedRatio,                                 // compressor speed ratio
      87             :             Real64 const SensLoad,                                   // Sensible demand load [W]
      88             :             Real64 const LatentLoad,                                 // Latent demand load [W]
      89             :             bool const IsCallbyWH, // whether the call from the water heating loop or air loop, true = from water heating loop
      90             :             [[maybe_unused]] bool const FirstHVACIteration, // TRUE if First iteration of simulation
      91             :             Optional<Real64 const> OnOffAirFlowRat          // ratio of comp on to comp off air flow rate
      92             : )
      93             : {
      94             : 
      95             :     //       AUTHOR         Bo Shen, ORNL
      96             :     //       DATE WRITTEN   March 2016
      97             :     //       RE-ENGINEERED  na
      98             : 
      99             :     // PURPOSE OF THIS SUBROUTINE:
     100             :     // This subroutine manages variable-speed integrated Air source heat pump simulation.
     101             : 
     102             :     // Using/Aliasing
     103             :     using VariableSpeedCoils::InitVarSpeedCoil;
     104             :     using VariableSpeedCoils::SimVariableSpeedCoils;
     105             :     using VariableSpeedCoils::UpdateVarSpeedCoil;
     106             : 
     107             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     108      264111 :     int DXCoilNum(0); // The IHP No that you are currently dealing with
     109             : 
     110             :     // Obtains and Allocates ASIHP related parameters from input file
     111      264111 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
     112           0 :         GetIHPInput(state);
     113           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
     114             :     }
     115             : 
     116      264111 :     if (CompIndex == 0) {
     117           0 :         DXCoilNum = UtilityRoutines::FindItemInList(CompName, state.dataIntegratedHP->IntegratedHeatPumps);
     118           0 :         if (DXCoilNum == 0) {
     119           0 :             ShowFatalError(state, format("Integrated Heat Pump not found={}", CompName));
     120             :         }
     121           0 :         CompIndex = DXCoilNum;
     122             :     } else {
     123      264111 :         DXCoilNum = CompIndex;
     124      264111 :         if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
     125           0 :             ShowFatalError(state,
     126           0 :                            format("SimIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name={}",
     127             :                                   DXCoilNum,
     128           0 :                                   state.dataIntegratedHP->IntegratedHeatPumps.size(),
     129           0 :                                   CompName));
     130             :         }
     131      264111 :         if (!CompName.empty() && CompName != state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum).Name) {
     132           0 :             ShowFatalError(state,
     133           0 :                            format("SimIHP: Invalid CompIndex passed={}, Integrated HP name={}, stored Integrated HP Name for that index={}",
     134             :                                   DXCoilNum,
     135             :                                   CompName,
     136           0 :                                   state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum).Name));
     137             :         }
     138             :     };
     139             : 
     140      264111 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
     141             : 
     142      264111 :     if (!ihp.IHPCoilsSized) SizeIHP(state, DXCoilNum);
     143             : 
     144      264111 :     InitializeIHP(state, DXCoilNum);
     145             : 
     146      264111 :     Real64 airMassFlowRate = state.dataLoopNodes->Node(ihp.AirCoolInletNodeNum).MassFlowRate;
     147      264111 :     ihp.AirLoopFlowRate = airMassFlowRate;
     148             : 
     149      264111 :     switch (ihp.CurMode) {
     150       68344 :     case IHPOperationMode::SpaceClg:
     151       68344 :         if (!IsCallbyWH) // process when called from air loop
     152             :         {
     153      195696 :             SimVariableSpeedCoils(state,
     154      130464 :                                   std::string(),
     155             :                                   ihp.SCDWHCoolCoilIndex,
     156             :                                   CyclingScheme,
     157             :                                   MaxONOFFCyclesperHour,
     158             :                                   HPTimeConstant,
     159             :                                   FanDelayTime,
     160             :                                   CompressorOp,
     161             :                                   0.0,
     162             :                                   1,
     163             :                                   0.0,
     164             :                                   0.0,
     165             :                                   0.0,
     166             :                                   OnOffAirFlowRat);
     167      195696 :             SimVariableSpeedCoils(state,
     168      130464 :                                   std::string(),
     169             :                                   ihp.SCDWHWHCoilIndex,
     170             :                                   CyclingScheme,
     171             :                                   MaxONOFFCyclesperHour,
     172             :                                   HPTimeConstant,
     173             :                                   FanDelayTime,
     174             :                                   CompressorOp,
     175             :                                   0.0,
     176             :                                   1,
     177             :                                   0.0,
     178             :                                   0.0,
     179             :                                   0.0,
     180             :                                   OnOffAirFlowRat);
     181      195696 :             SimVariableSpeedCoils(state,
     182      130464 :                                   std::string(),
     183             :                                   ihp.SHDWHHeatCoilIndex,
     184             :                                   CyclingScheme,
     185             :                                   MaxONOFFCyclesperHour,
     186             :                                   HPTimeConstant,
     187             :                                   FanDelayTime,
     188             :                                   CompressorOp,
     189             :                                   0.0,
     190             :                                   1,
     191             :                                   0.0,
     192             :                                   0.0,
     193             :                                   0.0,
     194             :                                   OnOffAirFlowRat);
     195      195696 :             SimVariableSpeedCoils(state,
     196      130464 :                                   std::string(),
     197             :                                   ihp.SHDWHWHCoilIndex,
     198             :                                   CyclingScheme,
     199             :                                   MaxONOFFCyclesperHour,
     200             :                                   HPTimeConstant,
     201             :                                   FanDelayTime,
     202             :                                   CompressorOp,
     203             :                                   0.0,
     204             :                                   1,
     205             :                                   0.0,
     206             :                                   0.0,
     207             :                                   0.0,
     208             :                                   OnOffAirFlowRat);
     209      195696 :             SimVariableSpeedCoils(state,
     210      130464 :                                   std::string(),
     211             :                                   ihp.SCWHCoilIndex,
     212             :                                   CyclingScheme,
     213             :                                   MaxONOFFCyclesperHour,
     214             :                                   HPTimeConstant,
     215             :                                   FanDelayTime,
     216             :                                   CompressorOp,
     217             :                                   0.0,
     218             :                                   1,
     219             :                                   0.0,
     220             :                                   0.0,
     221             :                                   0.0,
     222             :                                   OnOffAirFlowRat);
     223      195696 :             SimVariableSpeedCoils(state,
     224      130464 :                                   std::string(),
     225             :                                   ihp.DWHCoilIndex,
     226             :                                   CyclingScheme,
     227             :                                   MaxONOFFCyclesperHour,
     228             :                                   HPTimeConstant,
     229             :                                   FanDelayTime,
     230             :                                   CompressorOp,
     231             :                                   0.0,
     232             :                                   1,
     233             :                                   0.0,
     234             :                                   0.0,
     235             :                                   0.0,
     236             :                                   OnOffAirFlowRat);
     237             : 
     238      195696 :             SimVariableSpeedCoils(state,
     239      130464 :                                   std::string(),
     240             :                                   ihp.SCCoilIndex,
     241             :                                   CyclingScheme,
     242             :                                   MaxONOFFCyclesperHour,
     243             :                                   HPTimeConstant,
     244             :                                   FanDelayTime,
     245             :                                   CompressorOp,
     246             :                                   PartLoadFrac,
     247             :                                   SpeedNum,
     248             :                                   SpeedRatio,
     249             :                                   SensLoad,
     250             :                                   LatentLoad,
     251             :                                   OnOffAirFlowRat);
     252             : 
     253      195696 :             SimVariableSpeedCoils(state,
     254      130464 :                                   std::string(),
     255             :                                   ihp.SHCoilIndex,
     256             :                                   CyclingScheme,
     257             :                                   MaxONOFFCyclesperHour,
     258             :                                   HPTimeConstant,
     259             :                                   FanDelayTime,
     260             :                                   CompressorOp,
     261             :                                   0.0,
     262             :                                   1,
     263             :                                   0.0,
     264             :                                   0.0,
     265             :                                   0.0,
     266             :                                   OnOffAirFlowRat);
     267             : 
     268       65232 :             ihp.AirFlowSavInAirLoop = airMassFlowRate;
     269             :         }
     270             : 
     271       68344 :         ihp.TankSourceWaterMassFlowRate = 0.0;
     272       68344 :         break;
     273       75114 :     case IHPOperationMode::SpaceHtg:
     274       75114 :         if (!IsCallbyWH) // process when called from air loop
     275             :         {
     276      225336 :             SimVariableSpeedCoils(state,
     277      150224 :                                   std::string(),
     278             :                                   ihp.SCDWHCoolCoilIndex,
     279             :                                   CyclingScheme,
     280             :                                   MaxONOFFCyclesperHour,
     281             :                                   HPTimeConstant,
     282             :                                   FanDelayTime,
     283             :                                   CompressorOp,
     284             :                                   0.0,
     285             :                                   1,
     286             :                                   0.0,
     287             :                                   0.0,
     288             :                                   0.0,
     289             :                                   OnOffAirFlowRat);
     290      225336 :             SimVariableSpeedCoils(state,
     291      150224 :                                   std::string(),
     292             :                                   ihp.SCDWHWHCoilIndex,
     293             :                                   CyclingScheme,
     294             :                                   MaxONOFFCyclesperHour,
     295             :                                   HPTimeConstant,
     296             :                                   FanDelayTime,
     297             :                                   CompressorOp,
     298             :                                   0.0,
     299             :                                   1,
     300             :                                   0.0,
     301             :                                   0.0,
     302             :                                   0.0,
     303             :                                   OnOffAirFlowRat);
     304      225336 :             SimVariableSpeedCoils(state,
     305      150224 :                                   std::string(),
     306             :                                   ihp.SHDWHHeatCoilIndex,
     307             :                                   CyclingScheme,
     308             :                                   MaxONOFFCyclesperHour,
     309             :                                   HPTimeConstant,
     310             :                                   FanDelayTime,
     311             :                                   CompressorOp,
     312             :                                   0.0,
     313             :                                   1,
     314             :                                   0.0,
     315             :                                   0.0,
     316             :                                   0.0,
     317             :                                   OnOffAirFlowRat);
     318      225336 :             SimVariableSpeedCoils(state,
     319      150224 :                                   std::string(),
     320             :                                   ihp.SHDWHWHCoilIndex,
     321             :                                   CyclingScheme,
     322             :                                   MaxONOFFCyclesperHour,
     323             :                                   HPTimeConstant,
     324             :                                   FanDelayTime,
     325             :                                   CompressorOp,
     326             :                                   0.0,
     327             :                                   1,
     328             :                                   0.0,
     329             :                                   0.0,
     330             :                                   0.0,
     331             :                                   OnOffAirFlowRat);
     332      225336 :             SimVariableSpeedCoils(state,
     333      150224 :                                   std::string(),
     334             :                                   ihp.SCWHCoilIndex,
     335             :                                   CyclingScheme,
     336             :                                   MaxONOFFCyclesperHour,
     337             :                                   HPTimeConstant,
     338             :                                   FanDelayTime,
     339             :                                   CompressorOp,
     340             :                                   0.0,
     341             :                                   1,
     342             :                                   0.0,
     343             :                                   0.0,
     344             :                                   0.0,
     345             :                                   OnOffAirFlowRat);
     346      225336 :             SimVariableSpeedCoils(state,
     347      150224 :                                   std::string(),
     348             :                                   ihp.SCCoilIndex,
     349             :                                   CyclingScheme,
     350             :                                   MaxONOFFCyclesperHour,
     351             :                                   HPTimeConstant,
     352             :                                   FanDelayTime,
     353             :                                   CompressorOp,
     354             :                                   0.0,
     355             :                                   1,
     356             :                                   0.0,
     357             :                                   0.0,
     358             :                                   0.0,
     359             :                                   OnOffAirFlowRat);
     360      225336 :             SimVariableSpeedCoils(state,
     361      150224 :                                   std::string(),
     362             :                                   ihp.DWHCoilIndex,
     363             :                                   CyclingScheme,
     364             :                                   MaxONOFFCyclesperHour,
     365             :                                   HPTimeConstant,
     366             :                                   FanDelayTime,
     367             :                                   CompressorOp,
     368             :                                   0.0,
     369             :                                   1,
     370             :                                   0.0,
     371             :                                   0.0,
     372             :                                   0.0,
     373             :                                   OnOffAirFlowRat);
     374             : 
     375      225336 :             SimVariableSpeedCoils(state,
     376      150224 :                                   std::string(),
     377             :                                   ihp.SHCoilIndex,
     378             :                                   CyclingScheme,
     379             :                                   MaxONOFFCyclesperHour,
     380             :                                   HPTimeConstant,
     381             :                                   FanDelayTime,
     382             :                                   CompressorOp,
     383             :                                   PartLoadFrac,
     384             :                                   SpeedNum,
     385             :                                   SpeedRatio,
     386             :                                   SensLoad,
     387             :                                   LatentLoad,
     388             :                                   OnOffAirFlowRat);
     389             : 
     390       75112 :             ihp.AirFlowSavInAirLoop = airMassFlowRate;
     391             :         }
     392       75114 :         ihp.TankSourceWaterMassFlowRate = 0.0;
     393       75114 :         break;
     394        2336 :     case IHPOperationMode::DedicatedWaterHtg:
     395        2336 :         if (IsCallbyWH) // process when called from water loop
     396             :         {
     397        4320 :             SimVariableSpeedCoils(state,
     398        2880 :                                   std::string(),
     399             :                                   ihp.SCDWHCoolCoilIndex,
     400             :                                   CyclingScheme,
     401             :                                   MaxONOFFCyclesperHour,
     402             :                                   HPTimeConstant,
     403             :                                   FanDelayTime,
     404             :                                   CompressorOp,
     405             :                                   0.0,
     406             :                                   1,
     407             :                                   0.0,
     408             :                                   0.0,
     409             :                                   0.0,
     410             :                                   OnOffAirFlowRat);
     411        4320 :             SimVariableSpeedCoils(state,
     412        2880 :                                   std::string(),
     413             :                                   ihp.SCDWHWHCoilIndex,
     414             :                                   CyclingScheme,
     415             :                                   MaxONOFFCyclesperHour,
     416             :                                   HPTimeConstant,
     417             :                                   FanDelayTime,
     418             :                                   CompressorOp,
     419             :                                   0.0,
     420             :                                   1,
     421             :                                   0.0,
     422             :                                   0.0,
     423             :                                   0.0,
     424             :                                   OnOffAirFlowRat);
     425        4320 :             SimVariableSpeedCoils(state,
     426        2880 :                                   std::string(),
     427             :                                   ihp.SHDWHHeatCoilIndex,
     428             :                                   CyclingScheme,
     429             :                                   MaxONOFFCyclesperHour,
     430             :                                   HPTimeConstant,
     431             :                                   FanDelayTime,
     432             :                                   CompressorOp,
     433             :                                   0.0,
     434             :                                   1,
     435             :                                   0.0,
     436             :                                   0.0,
     437             :                                   0.0,
     438             :                                   OnOffAirFlowRat);
     439        4320 :             SimVariableSpeedCoils(state,
     440        2880 :                                   std::string(),
     441             :                                   ihp.SHDWHWHCoilIndex,
     442             :                                   CyclingScheme,
     443             :                                   MaxONOFFCyclesperHour,
     444             :                                   HPTimeConstant,
     445             :                                   FanDelayTime,
     446             :                                   CompressorOp,
     447             :                                   0.0,
     448             :                                   1,
     449             :                                   0.0,
     450             :                                   0.0,
     451             :                                   0.0,
     452             :                                   OnOffAirFlowRat);
     453        4320 :             SimVariableSpeedCoils(state,
     454        2880 :                                   std::string(),
     455             :                                   ihp.SCWHCoilIndex,
     456             :                                   CyclingScheme,
     457             :                                   MaxONOFFCyclesperHour,
     458             :                                   HPTimeConstant,
     459             :                                   FanDelayTime,
     460             :                                   CompressorOp,
     461             :                                   0.0,
     462             :                                   1,
     463             :                                   0.0,
     464             :                                   0.0,
     465             :                                   0.0,
     466             :                                   OnOffAirFlowRat);
     467        4320 :             SimVariableSpeedCoils(state,
     468        2880 :                                   std::string(),
     469             :                                   ihp.SCCoilIndex,
     470             :                                   CyclingScheme,
     471             :                                   MaxONOFFCyclesperHour,
     472             :                                   HPTimeConstant,
     473             :                                   FanDelayTime,
     474             :                                   CompressorOp,
     475             :                                   0.0,
     476             :                                   1,
     477             :                                   0.0,
     478             :                                   0.0,
     479             :                                   0.0,
     480             :                                   OnOffAirFlowRat);
     481        4320 :             SimVariableSpeedCoils(state,
     482        2880 :                                   std::string(),
     483             :                                   ihp.SHCoilIndex,
     484             :                                   CyclingScheme,
     485             :                                   MaxONOFFCyclesperHour,
     486             :                                   HPTimeConstant,
     487             :                                   FanDelayTime,
     488             :                                   CompressorOp,
     489             :                                   0.0,
     490             :                                   1,
     491             :                                   0.0,
     492             :                                   0.0,
     493             :                                   0.0,
     494             :                                   OnOffAirFlowRat);
     495             : 
     496        4320 :             SimVariableSpeedCoils(state,
     497        2880 :                                   std::string(),
     498             :                                   ihp.DWHCoilIndex,
     499             :                                   CyclingScheme,
     500             :                                   MaxONOFFCyclesperHour,
     501             :                                   HPTimeConstant,
     502             :                                   FanDelayTime,
     503             :                                   CompressorOp,
     504             :                                   PartLoadFrac,
     505             :                                   SpeedNum,
     506             :                                   SpeedRatio,
     507             :                                   SensLoad,
     508             :                                   LatentLoad,
     509             :                                   OnOffAirFlowRat);
     510             :             // IntegratedHeatPumps(DXCoilNum).TotalHeatingEnergyRate =
     511             :             // VarSpeedCoil(IntegratedHeatPumps(DXCoilNum).DWHCoilIndex).TotalHeatingEnergyRate;
     512             :         }
     513             : 
     514        2336 :         ihp.TankSourceWaterMassFlowRate = state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate;
     515        2336 :         break;
     516           0 :     case IHPOperationMode::SCWHMatchSC:
     517           0 :         if (!IsCallbyWH) // process when called from air loop
     518             :         {
     519           0 :             SimVariableSpeedCoils(state,
     520           0 :                                   std::string(),
     521             :                                   ihp.SCDWHCoolCoilIndex,
     522             :                                   CyclingScheme,
     523             :                                   MaxONOFFCyclesperHour,
     524             :                                   HPTimeConstant,
     525             :                                   FanDelayTime,
     526             :                                   CompressorOp,
     527             :                                   0.0,
     528             :                                   1,
     529             :                                   0.0,
     530             :                                   0.0,
     531             :                                   0.0,
     532             :                                   OnOffAirFlowRat);
     533           0 :             SimVariableSpeedCoils(state,
     534           0 :                                   std::string(),
     535             :                                   ihp.SCDWHWHCoilIndex,
     536             :                                   CyclingScheme,
     537             :                                   MaxONOFFCyclesperHour,
     538             :                                   HPTimeConstant,
     539             :                                   FanDelayTime,
     540             :                                   CompressorOp,
     541             :                                   0.0,
     542             :                                   1,
     543             :                                   0.0,
     544             :                                   0.0,
     545             :                                   0.0,
     546             :                                   OnOffAirFlowRat);
     547           0 :             SimVariableSpeedCoils(state,
     548           0 :                                   std::string(),
     549             :                                   ihp.SHDWHHeatCoilIndex,
     550             :                                   CyclingScheme,
     551             :                                   MaxONOFFCyclesperHour,
     552             :                                   HPTimeConstant,
     553             :                                   FanDelayTime,
     554             :                                   CompressorOp,
     555             :                                   0.0,
     556             :                                   1,
     557             :                                   0.0,
     558             :                                   0.0,
     559             :                                   0.0,
     560             :                                   OnOffAirFlowRat);
     561           0 :             SimVariableSpeedCoils(state,
     562           0 :                                   std::string(),
     563             :                                   ihp.SHDWHWHCoilIndex,
     564             :                                   CyclingScheme,
     565             :                                   MaxONOFFCyclesperHour,
     566             :                                   HPTimeConstant,
     567             :                                   FanDelayTime,
     568             :                                   CompressorOp,
     569             :                                   0.0,
     570             :                                   1,
     571             :                                   0.0,
     572             :                                   0.0,
     573             :                                   0.0,
     574             :                                   OnOffAirFlowRat);
     575           0 :             SimVariableSpeedCoils(state,
     576           0 :                                   std::string(),
     577             :                                   ihp.SCCoilIndex,
     578             :                                   CyclingScheme,
     579             :                                   MaxONOFFCyclesperHour,
     580             :                                   HPTimeConstant,
     581             :                                   FanDelayTime,
     582             :                                   CompressorOp,
     583             :                                   0.0,
     584             :                                   1,
     585             :                                   0.0,
     586             :                                   0.0,
     587             :                                   0.0,
     588             :                                   OnOffAirFlowRat);
     589           0 :             SimVariableSpeedCoils(state,
     590           0 :                                   std::string(),
     591             :                                   ihp.DWHCoilIndex,
     592             :                                   CyclingScheme,
     593             :                                   MaxONOFFCyclesperHour,
     594             :                                   HPTimeConstant,
     595             :                                   FanDelayTime,
     596             :                                   CompressorOp,
     597             :                                   0.0,
     598             :                                   1,
     599             :                                   0.0,
     600             :                                   0.0,
     601             :                                   0.0,
     602             :                                   OnOffAirFlowRat);
     603             : 
     604           0 :             SimVariableSpeedCoils(state,
     605           0 :                                   std::string(),
     606             :                                   ihp.SCWHCoilIndex,
     607             :                                   CyclingScheme,
     608             :                                   MaxONOFFCyclesperHour,
     609             :                                   HPTimeConstant,
     610             :                                   FanDelayTime,
     611             :                                   CompressorOp,
     612             :                                   PartLoadFrac,
     613             :                                   SpeedNum,
     614             :                                   SpeedRatio,
     615             :                                   SensLoad,
     616             :                                   LatentLoad,
     617             :                                   OnOffAirFlowRat);
     618             : 
     619           0 :             SimVariableSpeedCoils(state,
     620           0 :                                   std::string(),
     621             :                                   ihp.SHCoilIndex,
     622             :                                   CyclingScheme,
     623             :                                   MaxONOFFCyclesperHour,
     624             :                                   HPTimeConstant,
     625             :                                   FanDelayTime,
     626             :                                   CompressorOp,
     627             :                                   0.0,
     628             :                                   1,
     629             :                                   0.0,
     630             :                                   0.0,
     631             :                                   0.0,
     632             :                                   OnOffAirFlowRat);
     633             : 
     634           0 :             ihp.AirFlowSavInAirLoop = airMassFlowRate;
     635             :         }
     636             : 
     637           0 :         ihp.TankSourceWaterMassFlowRate = state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate;
     638             : 
     639           0 :         break;
     640        3472 :     case IHPOperationMode::SCWHMatchWH:
     641        3472 :         if (IsCallbyWH) // process when called from water loop
     642             :         {
     643        6384 :             SimVariableSpeedCoils(state,
     644        4256 :                                   std::string(),
     645             :                                   ihp.SCDWHCoolCoilIndex,
     646             :                                   CyclingScheme,
     647             :                                   MaxONOFFCyclesperHour,
     648             :                                   HPTimeConstant,
     649             :                                   FanDelayTime,
     650             :                                   CompressorOp,
     651             :                                   0.0,
     652             :                                   1,
     653             :                                   0.0,
     654             :                                   0.0,
     655             :                                   0.0,
     656             :                                   OnOffAirFlowRat);
     657        6384 :             SimVariableSpeedCoils(state,
     658        4256 :                                   std::string(),
     659             :                                   ihp.SCDWHWHCoilIndex,
     660             :                                   CyclingScheme,
     661             :                                   MaxONOFFCyclesperHour,
     662             :                                   HPTimeConstant,
     663             :                                   FanDelayTime,
     664             :                                   CompressorOp,
     665             :                                   0.0,
     666             :                                   1,
     667             :                                   0.0,
     668             :                                   0.0,
     669             :                                   0.0,
     670             :                                   OnOffAirFlowRat);
     671        6384 :             SimVariableSpeedCoils(state,
     672        4256 :                                   std::string(),
     673             :                                   ihp.SHDWHHeatCoilIndex,
     674             :                                   CyclingScheme,
     675             :                                   MaxONOFFCyclesperHour,
     676             :                                   HPTimeConstant,
     677             :                                   FanDelayTime,
     678             :                                   CompressorOp,
     679             :                                   0.0,
     680             :                                   1,
     681             :                                   0.0,
     682             :                                   0.0,
     683             :                                   0.0,
     684             :                                   OnOffAirFlowRat);
     685        6384 :             SimVariableSpeedCoils(state,
     686        4256 :                                   std::string(),
     687             :                                   ihp.SHDWHWHCoilIndex,
     688             :                                   CyclingScheme,
     689             :                                   MaxONOFFCyclesperHour,
     690             :                                   HPTimeConstant,
     691             :                                   FanDelayTime,
     692             :                                   CompressorOp,
     693             :                                   0.0,
     694             :                                   1,
     695             :                                   0.0,
     696             :                                   0.0,
     697             :                                   0.0,
     698             :                                   OnOffAirFlowRat);
     699        6384 :             SimVariableSpeedCoils(state,
     700        4256 :                                   std::string(),
     701             :                                   ihp.SCCoilIndex,
     702             :                                   CyclingScheme,
     703             :                                   MaxONOFFCyclesperHour,
     704             :                                   HPTimeConstant,
     705             :                                   FanDelayTime,
     706             :                                   CompressorOp,
     707             :                                   0.0,
     708             :                                   1,
     709             :                                   0.0,
     710             :                                   0.0,
     711             :                                   0.0,
     712             :                                   OnOffAirFlowRat);
     713        6384 :             SimVariableSpeedCoils(state,
     714        4256 :                                   std::string(),
     715             :                                   ihp.DWHCoilIndex,
     716             :                                   CyclingScheme,
     717             :                                   MaxONOFFCyclesperHour,
     718             :                                   HPTimeConstant,
     719             :                                   FanDelayTime,
     720             :                                   CompressorOp,
     721             :                                   0.0,
     722             :                                   1,
     723             :                                   0.0,
     724             :                                   0.0,
     725             :                                   0.0,
     726             :                                   OnOffAirFlowRat);
     727             : 
     728        6384 :             SimVariableSpeedCoils(state,
     729        4256 :                                   std::string(),
     730             :                                   ihp.SCWHCoilIndex,
     731             :                                   CyclingScheme,
     732             :                                   MaxONOFFCyclesperHour,
     733             :                                   HPTimeConstant,
     734             :                                   FanDelayTime,
     735             :                                   CompressorOp,
     736             :                                   PartLoadFrac,
     737             :                                   SpeedNum,
     738             :                                   SpeedRatio,
     739             :                                   SensLoad,
     740             :                                   LatentLoad,
     741             :                                   OnOffAirFlowRat);
     742             : 
     743        6384 :             SimVariableSpeedCoils(state,
     744        4256 :                                   std::string(),
     745             :                                   ihp.SHCoilIndex,
     746             :                                   CyclingScheme,
     747             :                                   MaxONOFFCyclesperHour,
     748             :                                   HPTimeConstant,
     749             :                                   FanDelayTime,
     750             :                                   CompressorOp,
     751             :                                   0.0,
     752             :                                   1,
     753             :                                   0.0,
     754             :                                   0.0,
     755             :                                   0.0,
     756             :                                   OnOffAirFlowRat);
     757             : 
     758        2128 :             ihp.AirFlowSavInWaterLoop = airMassFlowRate;
     759             :         }
     760             : 
     761        3472 :         ihp.TankSourceWaterMassFlowRate = state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate;
     762        3472 :         break;
     763      102184 :     case IHPOperationMode::SpaceClgDedicatedWaterHtg:
     764      102184 :         if (!IsCallbyWH) // process when called from air loop
     765             :         {
     766      289368 :             SimVariableSpeedCoils(state,
     767      192912 :                                   std::string(),
     768             :                                   ihp.SHDWHHeatCoilIndex,
     769             :                                   CyclingScheme,
     770             :                                   MaxONOFFCyclesperHour,
     771             :                                   HPTimeConstant,
     772             :                                   FanDelayTime,
     773             :                                   CompressorOp,
     774             :                                   0.0,
     775             :                                   1,
     776             :                                   0.0,
     777             :                                   0.0,
     778             :                                   0.0,
     779             :                                   OnOffAirFlowRat);
     780      289368 :             SimVariableSpeedCoils(state,
     781      192912 :                                   std::string(),
     782             :                                   ihp.SHDWHWHCoilIndex,
     783             :                                   CyclingScheme,
     784             :                                   MaxONOFFCyclesperHour,
     785             :                                   HPTimeConstant,
     786             :                                   FanDelayTime,
     787             :                                   CompressorOp,
     788             :                                   0.0,
     789             :                                   1,
     790             :                                   0.0,
     791             :                                   0.0,
     792             :                                   0.0,
     793             :                                   OnOffAirFlowRat);
     794      289368 :             SimVariableSpeedCoils(state,
     795      192912 :                                   std::string(),
     796             :                                   ihp.SCWHCoilIndex,
     797             :                                   CyclingScheme,
     798             :                                   MaxONOFFCyclesperHour,
     799             :                                   HPTimeConstant,
     800             :                                   FanDelayTime,
     801             :                                   CompressorOp,
     802             :                                   0.0,
     803             :                                   1,
     804             :                                   0.0,
     805             :                                   0.0,
     806             :                                   0.0,
     807             :                                   OnOffAirFlowRat);
     808      289368 :             SimVariableSpeedCoils(state,
     809      192912 :                                   std::string(),
     810             :                                   ihp.SCCoilIndex,
     811             :                                   CyclingScheme,
     812             :                                   MaxONOFFCyclesperHour,
     813             :                                   HPTimeConstant,
     814             :                                   FanDelayTime,
     815             :                                   CompressorOp,
     816             :                                   0.0,
     817             :                                   1,
     818             :                                   0.0,
     819             :                                   0.0,
     820             :                                   0.0,
     821             :                                   OnOffAirFlowRat);
     822      289368 :             SimVariableSpeedCoils(state,
     823      192912 :                                   std::string(),
     824             :                                   ihp.DWHCoilIndex,
     825             :                                   CyclingScheme,
     826             :                                   MaxONOFFCyclesperHour,
     827             :                                   HPTimeConstant,
     828             :                                   FanDelayTime,
     829             :                                   CompressorOp,
     830             :                                   0.0,
     831             :                                   1,
     832             :                                   0.0,
     833             :                                   0.0,
     834             :                                   0.0,
     835             :                                   OnOffAirFlowRat);
     836             : 
     837      289368 :             SimVariableSpeedCoils(state,
     838      192912 :                                   std::string(),
     839             :                                   ihp.SCDWHWHCoilIndex,
     840             :                                   CyclingScheme,
     841             :                                   MaxONOFFCyclesperHour,
     842             :                                   HPTimeConstant,
     843             :                                   FanDelayTime,
     844             :                                   CompressorOp,
     845             :                                   PartLoadFrac,
     846             :                                   SpeedNum,
     847             :                                   SpeedRatio,
     848             :                                   SensLoad,
     849             :                                   LatentLoad,
     850             :                                   OnOffAirFlowRat);
     851      289368 :             SimVariableSpeedCoils(state,
     852      192912 :                                   std::string(),
     853             :                                   ihp.SCDWHCoolCoilIndex,
     854             :                                   CyclingScheme,
     855             :                                   MaxONOFFCyclesperHour,
     856             :                                   HPTimeConstant,
     857             :                                   FanDelayTime,
     858             :                                   CompressorOp,
     859             :                                   PartLoadFrac,
     860             :                                   SpeedNum,
     861             :                                   SpeedRatio,
     862             :                                   SensLoad,
     863             :                                   LatentLoad,
     864             :                                   OnOffAirFlowRat);
     865             : 
     866      289368 :             SimVariableSpeedCoils(state,
     867      192912 :                                   std::string(),
     868             :                                   ihp.SHCoilIndex,
     869             :                                   CyclingScheme,
     870             :                                   MaxONOFFCyclesperHour,
     871             :                                   HPTimeConstant,
     872             :                                   FanDelayTime,
     873             :                                   CompressorOp,
     874             :                                   0.0,
     875             :                                   1,
     876             :                                   0.0,
     877             :                                   0.0,
     878             :                                   0.0,
     879             :                                   OnOffAirFlowRat);
     880             : 
     881       96456 :             ihp.AirFlowSavInAirLoop = airMassFlowRate;
     882             :         }
     883             : 
     884      102184 :         ihp.TankSourceWaterMassFlowRate = state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate;
     885      102184 :         break;
     886           0 :     case IHPOperationMode::SHDWHElecHeatOff:
     887             :     case IHPOperationMode::SHDWHElecHeatOn:
     888           0 :         if (!IsCallbyWH) // process when called from air loop
     889             :         {
     890           0 :             SimVariableSpeedCoils(state,
     891           0 :                                   std::string(),
     892             :                                   ihp.SCDWHCoolCoilIndex,
     893             :                                   CyclingScheme,
     894             :                                   MaxONOFFCyclesperHour,
     895             :                                   HPTimeConstant,
     896             :                                   FanDelayTime,
     897             :                                   CompressorOp,
     898             :                                   0.0,
     899             :                                   1,
     900             :                                   0.0,
     901             :                                   0.0,
     902             :                                   0.0,
     903             :                                   OnOffAirFlowRat);
     904           0 :             SimVariableSpeedCoils(state,
     905           0 :                                   std::string(),
     906             :                                   ihp.SCDWHWHCoilIndex,
     907             :                                   CyclingScheme,
     908             :                                   MaxONOFFCyclesperHour,
     909             :                                   HPTimeConstant,
     910             :                                   FanDelayTime,
     911             :                                   CompressorOp,
     912             :                                   0.0,
     913             :                                   1,
     914             :                                   0.0,
     915             :                                   0.0,
     916             :                                   0.0,
     917             :                                   OnOffAirFlowRat);
     918           0 :             SimVariableSpeedCoils(state,
     919           0 :                                   std::string(),
     920             :                                   ihp.SCWHCoilIndex,
     921             :                                   CyclingScheme,
     922             :                                   MaxONOFFCyclesperHour,
     923             :                                   HPTimeConstant,
     924             :                                   FanDelayTime,
     925             :                                   CompressorOp,
     926             :                                   0.0,
     927             :                                   1,
     928             :                                   0.0,
     929             :                                   0.0,
     930             :                                   0.0,
     931             :                                   OnOffAirFlowRat);
     932           0 :             SimVariableSpeedCoils(state,
     933           0 :                                   std::string(),
     934             :                                   ihp.SCCoilIndex,
     935             :                                   CyclingScheme,
     936             :                                   MaxONOFFCyclesperHour,
     937             :                                   HPTimeConstant,
     938             :                                   FanDelayTime,
     939             :                                   CompressorOp,
     940             :                                   0.0,
     941             :                                   1,
     942             :                                   0.0,
     943             :                                   0.0,
     944             :                                   0.0,
     945             :                                   OnOffAirFlowRat);
     946           0 :             SimVariableSpeedCoils(state,
     947           0 :                                   std::string(),
     948             :                                   ihp.SHCoilIndex,
     949             :                                   CyclingScheme,
     950             :                                   MaxONOFFCyclesperHour,
     951             :                                   HPTimeConstant,
     952             :                                   FanDelayTime,
     953             :                                   CompressorOp,
     954             :                                   0.0,
     955             :                                   1,
     956             :                                   0.0,
     957             :                                   0.0,
     958             :                                   0.0,
     959             :                                   OnOffAirFlowRat);
     960           0 :             SimVariableSpeedCoils(state,
     961           0 :                                   std::string(),
     962             :                                   ihp.DWHCoilIndex,
     963             :                                   CyclingScheme,
     964             :                                   MaxONOFFCyclesperHour,
     965             :                                   HPTimeConstant,
     966             :                                   FanDelayTime,
     967             :                                   CompressorOp,
     968             :                                   0.0,
     969             :                                   1,
     970             :                                   0.0,
     971             :                                   0.0,
     972             :                                   0.0,
     973             :                                   OnOffAirFlowRat);
     974             : 
     975           0 :             SimVariableSpeedCoils(state,
     976           0 :                                   std::string(),
     977             :                                   ihp.SHDWHWHCoilIndex,
     978             :                                   CyclingScheme,
     979             :                                   MaxONOFFCyclesperHour,
     980             :                                   HPTimeConstant,
     981             :                                   FanDelayTime,
     982             :                                   CompressorOp,
     983             :                                   PartLoadFrac,
     984             :                                   SpeedNum,
     985             :                                   SpeedRatio,
     986             :                                   SensLoad,
     987             :                                   LatentLoad,
     988             :                                   OnOffAirFlowRat);
     989           0 :             SimVariableSpeedCoils(state,
     990           0 :                                   std::string(),
     991             :                                   ihp.SHDWHHeatCoilIndex,
     992             :                                   CyclingScheme,
     993             :                                   MaxONOFFCyclesperHour,
     994             :                                   HPTimeConstant,
     995             :                                   FanDelayTime,
     996             :                                   CompressorOp,
     997             :                                   PartLoadFrac,
     998             :                                   SpeedNum,
     999             :                                   SpeedRatio,
    1000             :                                   SensLoad,
    1001             :                                   LatentLoad,
    1002             :                                   OnOffAirFlowRat);
    1003             : 
    1004           0 :             ihp.AirFlowSavInAirLoop = airMassFlowRate;
    1005             :         }
    1006             : 
    1007           0 :         ihp.TankSourceWaterMassFlowRate = state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate;
    1008           0 :         break;
    1009       12661 :     case IHPOperationMode::Idle:
    1010             :     default: // clear up
    1011       37983 :         SimVariableSpeedCoils(state,
    1012       25322 :                               std::string(),
    1013             :                               ihp.SCDWHCoolCoilIndex,
    1014             :                               CyclingScheme,
    1015             :                               MaxONOFFCyclesperHour,
    1016             :                               HPTimeConstant,
    1017             :                               FanDelayTime,
    1018             :                               CompressorOp,
    1019             :                               0.0,
    1020             :                               1,
    1021             :                               0.0,
    1022             :                               0.0,
    1023             :                               0.0,
    1024             :                               OnOffAirFlowRat);
    1025       37983 :         SimVariableSpeedCoils(state,
    1026       25322 :                               std::string(),
    1027             :                               ihp.SCDWHWHCoilIndex,
    1028             :                               CyclingScheme,
    1029             :                               MaxONOFFCyclesperHour,
    1030             :                               HPTimeConstant,
    1031             :                               FanDelayTime,
    1032             :                               CompressorOp,
    1033             :                               0.0,
    1034             :                               1,
    1035             :                               0.0,
    1036             :                               0.0,
    1037             :                               0.0,
    1038             :                               OnOffAirFlowRat);
    1039       37983 :         SimVariableSpeedCoils(state,
    1040       25322 :                               std::string(),
    1041             :                               ihp.SHDWHHeatCoilIndex,
    1042             :                               CyclingScheme,
    1043             :                               MaxONOFFCyclesperHour,
    1044             :                               HPTimeConstant,
    1045             :                               FanDelayTime,
    1046             :                               CompressorOp,
    1047             :                               0.0,
    1048             :                               1,
    1049             :                               0.0,
    1050             :                               0.0,
    1051             :                               0.0,
    1052             :                               OnOffAirFlowRat);
    1053       37983 :         SimVariableSpeedCoils(state,
    1054       25322 :                               std::string(),
    1055             :                               ihp.SHDWHWHCoilIndex,
    1056             :                               CyclingScheme,
    1057             :                               MaxONOFFCyclesperHour,
    1058             :                               HPTimeConstant,
    1059             :                               FanDelayTime,
    1060             :                               CompressorOp,
    1061             :                               0.0,
    1062             :                               1,
    1063             :                               0.0,
    1064             :                               0.0,
    1065             :                               0.0,
    1066             :                               OnOffAirFlowRat);
    1067       37983 :         SimVariableSpeedCoils(state,
    1068       25322 :                               std::string(),
    1069             :                               ihp.SCWHCoilIndex,
    1070             :                               CyclingScheme,
    1071             :                               MaxONOFFCyclesperHour,
    1072             :                               HPTimeConstant,
    1073             :                               FanDelayTime,
    1074             :                               CompressorOp,
    1075             :                               0.0,
    1076             :                               1,
    1077             :                               0.0,
    1078             :                               0.0,
    1079             :                               0.0,
    1080             :                               OnOffAirFlowRat);
    1081       37983 :         SimVariableSpeedCoils(state,
    1082       25322 :                               std::string(),
    1083             :                               ihp.SCCoilIndex,
    1084             :                               CyclingScheme,
    1085             :                               MaxONOFFCyclesperHour,
    1086             :                               HPTimeConstant,
    1087             :                               FanDelayTime,
    1088             :                               CompressorOp,
    1089             :                               0.0,
    1090             :                               1,
    1091             :                               0.0,
    1092             :                               0.0,
    1093             :                               0.0,
    1094             :                               OnOffAirFlowRat);
    1095       37983 :         SimVariableSpeedCoils(state,
    1096       25322 :                               std::string(),
    1097             :                               ihp.SHCoilIndex,
    1098             :                               CyclingScheme,
    1099             :                               MaxONOFFCyclesperHour,
    1100             :                               HPTimeConstant,
    1101             :                               FanDelayTime,
    1102             :                               CompressorOp,
    1103             :                               0.0,
    1104             :                               1,
    1105             :                               0.0,
    1106             :                               0.0,
    1107             :                               0.0,
    1108             :                               OnOffAirFlowRat);
    1109       37983 :         SimVariableSpeedCoils(state,
    1110       25322 :                               std::string(),
    1111             :                               ihp.DWHCoilIndex,
    1112             :                               CyclingScheme,
    1113             :                               MaxONOFFCyclesperHour,
    1114             :                               HPTimeConstant,
    1115             :                               FanDelayTime,
    1116             :                               CompressorOp,
    1117             :                               0.0,
    1118             :                               1,
    1119             :                               0.0,
    1120             :                               0.0,
    1121             :                               0.0,
    1122             :                               OnOffAirFlowRat);
    1123       12661 :         ihp.TankSourceWaterMassFlowRate = 0.0;
    1124       12661 :         ihp.AirFlowSavInAirLoop = 0.0;
    1125       12661 :         ihp.AirFlowSavInWaterLoop = 0.0;
    1126       12661 :         break;
    1127             :     }
    1128             : 
    1129      264111 :     UpdateIHP(state, DXCoilNum);
    1130      264111 : }
    1131             : 
    1132           3 : void GetIHPInput(EnergyPlusData &state)
    1133             : {
    1134             : 
    1135             :     // SUBROUTINE INFORMATION:
    1136             :     //       AUTHOR         Bo Shen
    1137             :     //       DATE WRITTEN   December, 2015
    1138             :     //       RE-ENGINEERED  na
    1139             : 
    1140             :     // PURPOSE OF THIS SUBROUTINE:
    1141             :     // Obtains input data for Integrated HPs and stores it in IHP data structures
    1142             : 
    1143             :     // METHODOLOGY EMPLOYED:
    1144             :     // Uses "Get" routines to read in data.
    1145             : 
    1146             :     // Using/Aliasing
    1147             :     using namespace NodeInputManager;
    1148             :     using BranchNodeConnections::OverrideNodeConnectionType;
    1149             :     using BranchNodeConnections::RegisterNodeConnection;
    1150             :     using BranchNodeConnections::SetUpCompSets;
    1151             :     using BranchNodeConnections::TestCompSet;
    1152             :     using GlobalNames::VerifyUniqueCoilName;
    1153             :     using VariableSpeedCoils::GetCoilIndexVariableSpeed;
    1154             : 
    1155             :     // SUBROUTINE PARAMETER DEFINITIONS:
    1156             :     static constexpr std::string_view RoutineName("GetIHPInput: "); // include trailing blank space
    1157             : 
    1158             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1159             :     int NumAlphas;                   // Number of variables in String format
    1160             :     int NumNums;                     // Number of variables in Numeric format
    1161             :     int NumParams;                   // Total number of input fields
    1162           3 :     int MaxNums(0);                  // Maximum number of numeric input fields
    1163           3 :     int MaxAlphas(0);                // Maximum number of alpha input fields
    1164           4 :     std::string InNodeName;          // Name of coil inlet node
    1165           4 :     std::string OutNodeName;         // Name of coil outlet node
    1166           4 :     std::string CurrentModuleObject; // for ease in getting objects
    1167           4 :     std::string sIHPType;            // specify IHP type
    1168           4 :     Array1D_string AlphArray;        // Alpha input items for object
    1169           4 :     Array1D_string cAlphaFields;     // Alpha field names
    1170           4 :     Array1D_string cNumericFields;   // Numeric field names
    1171           4 :     Array1D<Real64> NumArray;        // Numeric input items for object
    1172           4 :     Array1D_bool lAlphaBlanks;       // Logical array, alpha field input BLANK = .TRUE.
    1173           4 :     Array1D_bool lNumericBlanks;     // Logical array, numeric field input BLANK = .TRUE.
    1174             : 
    1175           3 :     bool ErrorsFound(false); // If errors detected in input
    1176             :     bool IsNotOK;            // Flag to verify name
    1177             :     bool errFlag;
    1178             :     int IOStat;
    1179           3 :     int InNode(0);         // inlet air or water node
    1180           3 :     int OutNode(0);        // outlet air or water node
    1181           3 :     int ChildCoilIndex(0); // refer to a child coil
    1182             : 
    1183           3 :     int NumASIHPs = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "COILSYSTEM:INTEGRATEDHEATPUMP:AIRSOURCE");
    1184             : 
    1185           3 :     if (NumASIHPs <= 0) return;
    1186             : 
    1187             :     // Allocate Arrays
    1188           1 :     state.dataIntegratedHP->IntegratedHeatPumps.allocate(NumASIHPs);
    1189             : 
    1190             :     // air-source integrated heat pump
    1191           1 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "COILSYSTEM:INTEGRATEDHEATPUMP:AIRSOURCE", NumParams, NumAlphas, NumNums);
    1192           1 :     MaxNums = max(MaxNums, NumNums);
    1193           1 :     MaxAlphas = max(MaxAlphas, NumAlphas);
    1194             : 
    1195           1 :     AlphArray.allocate(MaxAlphas);
    1196           1 :     cAlphaFields.allocate(MaxAlphas);
    1197           1 :     lAlphaBlanks.dimension(MaxAlphas, true);
    1198           1 :     cNumericFields.allocate(MaxNums);
    1199           1 :     lNumericBlanks.dimension(MaxNums, true);
    1200           1 :     NumArray.dimension(MaxNums, 0.0);
    1201             : 
    1202             :     // Get the data for air-source IHPs
    1203           1 :     CurrentModuleObject = "COILSYSTEM:INTEGRATEDHEATPUMP:AIRSOURCE"; // for reporting
    1204           1 :     sIHPType = "COILSYSTEM:INTEGRATEDHEATPUMP:AIRSOURCE";            // for checking
    1205             : 
    1206           2 :     for (int CoilCounter = 1; CoilCounter <= NumASIHPs; ++CoilCounter) {
    1207             : 
    1208           1 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1209             :                                                                  CurrentModuleObject,
    1210             :                                                                  CoilCounter,
    1211             :                                                                  AlphArray,
    1212             :                                                                  NumAlphas,
    1213             :                                                                  NumArray,
    1214             :                                                                  NumNums,
    1215             :                                                                  IOStat,
    1216             :                                                                  lNumericBlanks,
    1217             :                                                                  lAlphaBlanks,
    1218             :                                                                  cAlphaFields,
    1219             :                                                                  cNumericFields);
    1220             : 
    1221             :         // ErrorsFound will be set to True if problem was found, left untouched otherwise
    1222           1 :         VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, CurrentModuleObject + " Name");
    1223             : 
    1224           1 :         auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(CoilCounter);
    1225             : 
    1226           1 :         ihp.Name = AlphArray(1);
    1227           1 :         ihp.IHPtype = "AIRSOURCE_IHP";
    1228             : 
    1229             :         // AlphArray( 2 ) is the water sensor node
    1230             : 
    1231           1 :         ihp.SCCoilType = "COIL:COOLING:DX:VARIABLESPEED";
    1232           1 :         ihp.SCCoilName = AlphArray(3);
    1233           1 :         ihp.SCCoilTypeNum = DataLoopNode::ConnectionObjectType::CoilCoolingDXVariableSpeed;
    1234             : 
    1235           1 :         ValidateComponent(state, ihp.SCCoilType, ihp.SCCoilName, IsNotOK, CurrentModuleObject);
    1236           1 :         if (IsNotOK) {
    1237           0 :             ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
    1238           0 :             ErrorsFound = true;
    1239             :         } else {
    1240           1 :             errFlag = false;
    1241           1 :             ihp.SCCoilIndex = GetCoilIndexVariableSpeed(state, ihp.SCCoilType, ihp.SCCoilName, errFlag);
    1242           1 :             if (errFlag) {
    1243           0 :                 ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
    1244           0 :                 ErrorsFound = true;
    1245             :             }
    1246             :         }
    1247             : 
    1248           1 :         ihp.SHCoilType = "COIL:HEATING:DX:VARIABLESPEED";
    1249           1 :         ihp.SHCoilName = AlphArray(4);
    1250           1 :         ihp.SHCoilTypeNum = DataLoopNode::ConnectionObjectType::CoilHeatingDXVariableSpeed;
    1251             : 
    1252           1 :         ValidateComponent(state, ihp.SHCoilType, ihp.SHCoilName, IsNotOK, CurrentModuleObject);
    1253           1 :         if (IsNotOK) {
    1254           0 :             ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
    1255           0 :             ErrorsFound = true;
    1256             :         } else {
    1257           1 :             errFlag = false;
    1258           1 :             ihp.SHCoilIndex = GetCoilIndexVariableSpeed(state, ihp.SHCoilType, ihp.SHCoilName, errFlag);
    1259           1 :             if (errFlag) {
    1260           0 :                 ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
    1261           0 :                 ErrorsFound = true;
    1262             :             }
    1263             :         }
    1264             : 
    1265           1 :         ihp.DWHCoilType = "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED";
    1266           1 :         ihp.DWHCoilName = AlphArray(5);
    1267           1 :         ihp.DWHCoilTypeNum = DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpVariableSpeed;
    1268             : 
    1269           1 :         ValidateComponent(state, ihp.DWHCoilType, ihp.DWHCoilName, IsNotOK, CurrentModuleObject);
    1270           1 :         if (IsNotOK) {
    1271           0 :             ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
    1272           0 :             ErrorsFound = true;
    1273             :         } else {
    1274           1 :             errFlag = false;
    1275           1 :             ihp.DWHCoilIndex = GetCoilIndexVariableSpeed(state, ihp.DWHCoilType, ihp.DWHCoilName, errFlag);
    1276           1 :             if (errFlag) {
    1277           0 :                 ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
    1278           0 :                 ErrorsFound = true;
    1279             :             }
    1280             :         }
    1281             : 
    1282           1 :         ihp.SCWHCoilType = "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED";
    1283           1 :         ihp.SCWHCoilName = AlphArray(6);
    1284           1 :         ihp.SCWHCoilTypeNum = DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpVariableSpeed;
    1285             : 
    1286           1 :         ValidateComponent(state, ihp.SCWHCoilType, ihp.SCWHCoilName, IsNotOK, CurrentModuleObject);
    1287           1 :         if (IsNotOK) {
    1288           0 :             ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
    1289           0 :             ErrorsFound = true;
    1290             :         } else {
    1291           1 :             errFlag = false;
    1292           1 :             ihp.SCWHCoilIndex = GetCoilIndexVariableSpeed(state, ihp.SCWHCoilType, ihp.SCWHCoilName, errFlag);
    1293           1 :             if (errFlag) {
    1294           0 :                 ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
    1295           0 :                 ErrorsFound = true;
    1296             :             }
    1297             :         }
    1298             : 
    1299           1 :         ihp.SCDWHCoolCoilType = "COIL:COOLING:DX:VARIABLESPEED";
    1300           1 :         ihp.SCDWHCoolCoilName = AlphArray(7);
    1301           1 :         ihp.SCDWHCoolCoilTypeNum = DataLoopNode::ConnectionObjectType::CoilCoolingDXVariableSpeed;
    1302             : 
    1303           1 :         ValidateComponent(state, ihp.SCDWHCoolCoilType, ihp.SCDWHCoolCoilName, IsNotOK, CurrentModuleObject);
    1304           1 :         if (IsNotOK) {
    1305           0 :             ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
    1306           0 :             ErrorsFound = true;
    1307             :         } else {
    1308           1 :             errFlag = false;
    1309           1 :             ihp.SCDWHCoolCoilIndex = GetCoilIndexVariableSpeed(state, ihp.SCDWHCoolCoilType, ihp.SCDWHCoolCoilName, errFlag);
    1310           1 :             if (errFlag) {
    1311           0 :                 ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
    1312           0 :                 ErrorsFound = true;
    1313             :             }
    1314             :         }
    1315             : 
    1316           1 :         ihp.SCDWHWHCoilType = "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED";
    1317           1 :         ihp.SCDWHWHCoilName = AlphArray(8);
    1318           1 :         ihp.SCDWHWHCoilTypeNum = DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpVariableSpeed;
    1319             : 
    1320           1 :         ValidateComponent(state, ihp.SCDWHWHCoilType, ihp.SCDWHWHCoilName, IsNotOK, CurrentModuleObject);
    1321           1 :         if (IsNotOK) {
    1322           0 :             ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
    1323           0 :             ErrorsFound = true;
    1324             :         } else {
    1325           1 :             errFlag = false;
    1326           1 :             ihp.SCDWHWHCoilIndex = GetCoilIndexVariableSpeed(state, ihp.SCDWHWHCoilType, ihp.SCDWHWHCoilName, errFlag);
    1327           1 :             if (errFlag) {
    1328           0 :                 ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
    1329           0 :                 ErrorsFound = true;
    1330             :             } else {
    1331           1 :                 state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHWHCoilIndex).bIsDesuperheater = true;
    1332             :             }
    1333             :         }
    1334             : 
    1335           1 :         ihp.SHDWHHeatCoilType = "COIL:HEATING:DX:VARIABLESPEED";
    1336           1 :         ihp.SHDWHHeatCoilName = AlphArray(9);
    1337           1 :         ihp.SHDWHHeatCoilTypeNum = DataLoopNode::ConnectionObjectType::CoilHeatingDXVariableSpeed;
    1338             : 
    1339           1 :         ValidateComponent(state, ihp.SHDWHHeatCoilType, ihp.SHDWHHeatCoilName, IsNotOK, CurrentModuleObject);
    1340           1 :         if (IsNotOK) {
    1341           0 :             ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
    1342           0 :             ErrorsFound = true;
    1343             :         } else {
    1344           1 :             errFlag = false;
    1345           1 :             ihp.SHDWHHeatCoilIndex = GetCoilIndexVariableSpeed(state, ihp.SHDWHHeatCoilType, ihp.SHDWHHeatCoilName, errFlag);
    1346           1 :             if (errFlag) {
    1347           0 :                 ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
    1348           0 :                 ErrorsFound = true;
    1349             :             }
    1350             :         }
    1351             : 
    1352           1 :         ihp.SHDWHWHCoilType = "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED";
    1353           1 :         ihp.SHDWHWHCoilName = AlphArray(10);
    1354           1 :         ihp.SHDWHWHCoilTypeNum = DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpVariableSpeed;
    1355             : 
    1356           1 :         ValidateComponent(state, ihp.SHDWHWHCoilType, ihp.SHDWHWHCoilName, IsNotOK, CurrentModuleObject);
    1357           1 :         if (IsNotOK) {
    1358           0 :             ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
    1359           0 :             ErrorsFound = true;
    1360             :         } else {
    1361           1 :             errFlag = false;
    1362           1 :             ihp.SHDWHWHCoilIndex = GetCoilIndexVariableSpeed(state, ihp.SHDWHWHCoilType, ihp.SHDWHWHCoilName, errFlag);
    1363           1 :             if (errFlag) {
    1364           0 :                 ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
    1365           0 :                 ErrorsFound = true;
    1366             :             } else {
    1367           1 :                 state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).bIsDesuperheater = true;
    1368             :             }
    1369             :         }
    1370             : 
    1371           1 :         ihp.TindoorOverCoolAllow = NumArray(1);
    1372           1 :         ihp.TambientOverCoolAllow = NumArray(2);
    1373           1 :         ihp.TindoorWHHighPriority = NumArray(3);
    1374           1 :         ihp.TambientWHHighPriority = NumArray(4);
    1375           1 :         ihp.ModeMatchSCWH = int(NumArray(5));
    1376           1 :         ihp.MinSpedSCWH = int(NumArray(6));
    1377           1 :         ihp.WaterVolSCDWH = NumArray(7);
    1378           1 :         ihp.MinSpedSCDWH = int(NumArray(8));
    1379           1 :         ihp.TimeLimitSHDWH = NumArray(9);
    1380           1 :         ihp.MinSpedSHDWH = int(NumArray(10));
    1381             : 
    1382             :         // Due to the overlapping coil objects, compsets and node registrations are handled as follows:
    1383             :         //  1. The ASIHP coil object is registered as four different coils, Name+" Cooling Coil", Name+" Heating Coil",
    1384             :         //     Name+" Outdoor Coil", and Name+" Water Coil"
    1385             :         //  2. For each of these four coils, TestCompSet is called once to register it as a child object
    1386             :         //  3. For each of these four coils, RegisterNodeConnection is called twice to register the inlet and outlet nodes
    1387             :         //     RegisterNodeConnection is used instead of GetOnlySingleNode because the node names are not inputs here
    1388             :         //  4. The parent objects that reference the ASIHP coil must use the appropriate name suffixes when calling SetUpCompSets
    1389             :         //  5. The ASIHP calls SetUpCompSets to register the various child coils.  This is important so that the system energy
    1390             :         //     use is collected in SystemReports::CalcSystemEnergyUse
    1391             :         //  6. The child coil inlet/outlet node connections are reset to connection type "Internal" to avoid duplicate node problems
    1392             :         //     using OverrideNodeConnectionType
    1393             : 
    1394             :         // cooling coil air node connections
    1395           1 :         ChildCoilIndex = ihp.SCCoilIndex;
    1396           1 :         InNode = state.dataVariableSpeedCoils->VarSpeedCoil(ChildCoilIndex).AirInletNodeNum;
    1397           1 :         OutNode = state.dataVariableSpeedCoils->VarSpeedCoil(ChildCoilIndex).AirOutletNodeNum;
    1398           1 :         InNodeName = state.dataLoopNodes->NodeID(InNode);
    1399           1 :         OutNodeName = state.dataLoopNodes->NodeID(OutNode);
    1400             : 
    1401           1 :         ihp.AirCoolInletNodeNum = InNode;
    1402           1 :         ihp.AirHeatInletNodeNum = OutNode;
    1403             : 
    1404           1 :         TestCompSet(state, CurrentModuleObject, ihp.Name + " Cooling Coil", InNodeName, OutNodeName, "Cooling Air Nodes");
    1405           3 :         RegisterNodeConnection(state,
    1406             :                                InNode,
    1407           1 :                                state.dataLoopNodes->NodeID(InNode),
    1408             :                                DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
    1409           2 :                                ihp.Name + " Cooling Coil",
    1410             :                                DataLoopNode::ConnectionType::Inlet,
    1411             :                                NodeInputManager::CompFluidStream::Primary,
    1412             :                                ObjectIsNotParent,
    1413           1 :                                ErrorsFound);
    1414           3 :         RegisterNodeConnection(state,
    1415             :                                OutNode,
    1416           1 :                                state.dataLoopNodes->NodeID(OutNode),
    1417             :                                DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
    1418           2 :                                ihp.Name + " Cooling Coil",
    1419             :                                DataLoopNode::ConnectionType::Outlet,
    1420             :                                NodeInputManager::CompFluidStream::Primary,
    1421             :                                ObjectIsNotParent,
    1422           1 :                                ErrorsFound);
    1423             : 
    1424           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Cooling Coil", ihp.SCCoilType, ihp.SCCoilName, InNodeName, OutNodeName);
    1425           1 :         OverrideNodeConnectionType(state,
    1426             :                                    InNode,
    1427             :                                    InNodeName,
    1428             :                                    ihp.SCCoilTypeNum,
    1429             :                                    ihp.SCCoilName,
    1430             :                                    DataLoopNode::ConnectionType::Internal,
    1431             :                                    NodeInputManager::CompFluidStream::Primary,
    1432             :                                    ObjectIsNotParent,
    1433             :                                    ErrorsFound);
    1434           1 :         OverrideNodeConnectionType(state,
    1435             :                                    OutNode,
    1436             :                                    OutNodeName,
    1437             :                                    ihp.SCCoilTypeNum,
    1438             :                                    ihp.SCCoilName,
    1439             :                                    DataLoopNode::ConnectionType::Internal,
    1440             :                                    NodeInputManager::CompFluidStream::Primary,
    1441             :                                    ObjectIsNotParent,
    1442             :                                    ErrorsFound);
    1443             : 
    1444           2 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).AirInletNodeNum != InNode) ||
    1445           1 :             (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).AirOutletNodeNum != OutNode)) {
    1446           0 :             ShowContinueError(state, "Mistaken air node connection: " + CurrentModuleObject + ihp.SCWHCoilName + "-wrong coil node names.");
    1447           0 :             ErrorsFound = true;
    1448             :         }
    1449           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Cooling Coil", ihp.SCWHCoilType, ihp.SCWHCoilName, InNodeName, OutNodeName);
    1450           1 :         OverrideNodeConnectionType(state,
    1451             :                                    InNode,
    1452             :                                    InNodeName,
    1453             :                                    ihp.SCWHCoilTypeNum,
    1454             :                                    ihp.SCWHCoilName,
    1455             :                                    DataLoopNode::ConnectionType::Internal,
    1456             :                                    NodeInputManager::CompFluidStream::Primary,
    1457             :                                    ObjectIsNotParent,
    1458             :                                    ErrorsFound);
    1459           1 :         OverrideNodeConnectionType(state,
    1460             :                                    OutNode,
    1461             :                                    OutNodeName,
    1462             :                                    ihp.SCWHCoilTypeNum,
    1463             :                                    ihp.SCWHCoilName,
    1464             :                                    DataLoopNode::ConnectionType::Internal,
    1465             :                                    NodeInputManager::CompFluidStream::Primary,
    1466             :                                    ObjectIsNotParent,
    1467             :                                    ErrorsFound);
    1468             : 
    1469           2 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).AirInletNodeNum != InNode) ||
    1470           1 :             (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).AirOutletNodeNum != OutNode)) {
    1471           0 :             ShowContinueError(state, "Mistaken air node connection: " + CurrentModuleObject + ihp.SCDWHCoolCoilName + "-wrong coil node names.");
    1472           0 :             ErrorsFound = true;
    1473             :         }
    1474           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Cooling Coil", ihp.SCDWHCoolCoilType, ihp.SCDWHCoolCoilName, InNodeName, OutNodeName);
    1475           1 :         OverrideNodeConnectionType(state,
    1476             :                                    InNode,
    1477             :                                    InNodeName,
    1478             :                                    ihp.SCDWHCoolCoilTypeNum,
    1479             :                                    ihp.SCDWHCoolCoilName,
    1480             :                                    DataLoopNode::ConnectionType::Internal,
    1481             :                                    NodeInputManager::CompFluidStream::Primary,
    1482             :                                    ObjectIsNotParent,
    1483             :                                    ErrorsFound);
    1484           1 :         OverrideNodeConnectionType(state,
    1485             :                                    OutNode,
    1486             :                                    OutNodeName,
    1487             :                                    ihp.SCDWHCoolCoilTypeNum,
    1488             :                                    ihp.SCDWHCoolCoilName,
    1489             :                                    DataLoopNode::ConnectionType::Internal,
    1490             :                                    NodeInputManager::CompFluidStream::Primary,
    1491             :                                    ObjectIsNotParent,
    1492             :                                    ErrorsFound);
    1493             : 
    1494             :         // heating coil air node connections
    1495           1 :         ChildCoilIndex = ihp.SHCoilIndex;
    1496             : 
    1497           1 :         InNode = ihp.AirHeatInletNodeNum;
    1498           1 :         OutNode = state.dataVariableSpeedCoils->VarSpeedCoil(ChildCoilIndex).AirOutletNodeNum;
    1499           1 :         ihp.AirOutletNodeNum = OutNode;
    1500           1 :         InNodeName = state.dataLoopNodes->NodeID(InNode);
    1501           1 :         OutNodeName = state.dataLoopNodes->NodeID(OutNode);
    1502           1 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(ChildCoilIndex).AirInletNodeNum != InNode) {
    1503           0 :             ShowContinueError(state,
    1504           0 :                               format("Mistaken air node connection: {}- cooling coil outlet mismatches heating coil inlet.", CurrentModuleObject));
    1505           0 :             ErrorsFound = true;
    1506             :         }
    1507           1 :         TestCompSet(state, CurrentModuleObject, ihp.Name + " Heating Coil", InNodeName, OutNodeName, "Heating Air Nodes");
    1508           3 :         RegisterNodeConnection(state,
    1509             :                                InNode,
    1510           1 :                                state.dataLoopNodes->NodeID(InNode),
    1511             :                                DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
    1512           2 :                                ihp.Name + " Heating Coil",
    1513             :                                DataLoopNode::ConnectionType::Inlet,
    1514             :                                NodeInputManager::CompFluidStream::Primary,
    1515             :                                ObjectIsNotParent,
    1516           1 :                                ErrorsFound);
    1517           3 :         RegisterNodeConnection(state,
    1518             :                                OutNode,
    1519           1 :                                state.dataLoopNodes->NodeID(OutNode),
    1520             :                                DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
    1521           2 :                                ihp.Name + " Heating Coil",
    1522             :                                DataLoopNode::ConnectionType::Outlet,
    1523             :                                NodeInputManager::CompFluidStream::Primary,
    1524             :                                ObjectIsNotParent,
    1525           1 :                                ErrorsFound);
    1526             : 
    1527           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Heating Coil", ihp.SHCoilType, ihp.SHCoilName, InNodeName, OutNodeName);
    1528           1 :         OverrideNodeConnectionType(state,
    1529             :                                    InNode,
    1530             :                                    InNodeName,
    1531             :                                    ihp.SHCoilTypeNum,
    1532             :                                    ihp.SHCoilName,
    1533             :                                    DataLoopNode::ConnectionType::Internal,
    1534             :                                    NodeInputManager::CompFluidStream::Primary,
    1535             :                                    ObjectIsNotParent,
    1536             :                                    ErrorsFound);
    1537           1 :         OverrideNodeConnectionType(state,
    1538             :                                    OutNode,
    1539             :                                    OutNodeName,
    1540             :                                    ihp.SHCoilTypeNum,
    1541             :                                    ihp.SHCoilName,
    1542             :                                    DataLoopNode::ConnectionType::Internal,
    1543             :                                    NodeInputManager::CompFluidStream::Primary,
    1544             :                                    ObjectIsNotParent,
    1545             :                                    ErrorsFound);
    1546             : 
    1547           2 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHHeatCoilIndex).AirInletNodeNum != InNode) ||
    1548           1 :             (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHHeatCoilIndex).AirOutletNodeNum != OutNode)) {
    1549           0 :             ShowContinueError(state,
    1550           0 :                               format("Mistaken air node connection: {}:{}-wrong coil node names.", CurrentModuleObject, ihp.SHDWHHeatCoilName));
    1551           0 :             ErrorsFound = true;
    1552             :         }
    1553           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Heating Coil", ihp.SHDWHHeatCoilType, ihp.SHDWHHeatCoilName, InNodeName, OutNodeName);
    1554           1 :         OverrideNodeConnectionType(state,
    1555             :                                    InNode,
    1556             :                                    InNodeName,
    1557             :                                    ihp.SHDWHHeatCoilTypeNum,
    1558             :                                    ihp.SHDWHHeatCoilName,
    1559             :                                    DataLoopNode::ConnectionType::Internal,
    1560             :                                    NodeInputManager::CompFluidStream::Primary,
    1561             :                                    ObjectIsNotParent,
    1562             :                                    ErrorsFound);
    1563           1 :         OverrideNodeConnectionType(state,
    1564             :                                    OutNode,
    1565             :                                    OutNodeName,
    1566             :                                    ihp.SHDWHHeatCoilTypeNum,
    1567             :                                    ihp.SHDWHHeatCoilName,
    1568             :                                    DataLoopNode::ConnectionType::Internal,
    1569             :                                    NodeInputManager::CompFluidStream::Primary,
    1570             :                                    ObjectIsNotParent,
    1571             :                                    ErrorsFound);
    1572             : 
    1573             :         // water node connections
    1574           1 :         ChildCoilIndex = ihp.SCWHCoilIndex;
    1575             : 
    1576           1 :         InNode = state.dataVariableSpeedCoils->VarSpeedCoil(ChildCoilIndex).WaterInletNodeNum;
    1577           1 :         OutNode = state.dataVariableSpeedCoils->VarSpeedCoil(ChildCoilIndex).WaterOutletNodeNum;
    1578           1 :         InNodeName = state.dataLoopNodes->NodeID(InNode);
    1579           1 :         OutNodeName = state.dataLoopNodes->NodeID(OutNode);
    1580           1 :         ihp.WaterInletNodeNum = InNode;
    1581           1 :         ihp.WaterOutletNodeNum = OutNode;
    1582           2 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHWHCoilIndex).WaterInletNodeNum != InNode) ||
    1583           1 :             (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHWHCoilIndex).WaterOutletNodeNum != OutNode)) {
    1584           0 :             ShowContinueError(state, format("Mistaken air node connection: {}:{}-wrong coil node names.", CurrentModuleObject, ihp.SCDWHWHCoilName));
    1585           0 :             ErrorsFound = true;
    1586             :         }
    1587             : 
    1588           1 :         TestCompSet(state, CurrentModuleObject, ihp.Name + " Water Coil", InNodeName, OutNodeName, "Water Nodes");
    1589           3 :         RegisterNodeConnection(state,
    1590             :                                InNode,
    1591           1 :                                state.dataLoopNodes->NodeID(InNode),
    1592             :                                DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
    1593           2 :                                ihp.Name + " Water Coil",
    1594             :                                DataLoopNode::ConnectionType::Inlet,
    1595             :                                NodeInputManager::CompFluidStream::Primary,
    1596             :                                ObjectIsNotParent,
    1597           1 :                                ErrorsFound);
    1598           3 :         RegisterNodeConnection(state,
    1599             :                                OutNode,
    1600           1 :                                state.dataLoopNodes->NodeID(InNode),
    1601             :                                DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
    1602           2 :                                ihp.Name + " Water Coil",
    1603             :                                DataLoopNode::ConnectionType::Outlet,
    1604             :                                NodeInputManager::CompFluidStream::Primary,
    1605             :                                ObjectIsNotParent,
    1606           1 :                                ErrorsFound);
    1607             : 
    1608           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Water Coil", ihp.SCWHCoilType, ihp.SCWHCoilName, InNodeName, OutNodeName);
    1609           1 :         OverrideNodeConnectionType(state,
    1610             :                                    InNode,
    1611             :                                    InNodeName,
    1612             :                                    ihp.SCWHCoilTypeNum,
    1613             :                                    ihp.SCWHCoilName,
    1614             :                                    DataLoopNode::ConnectionType::Internal,
    1615             :                                    NodeInputManager::CompFluidStream::Secondary,
    1616             :                                    ObjectIsNotParent,
    1617             :                                    ErrorsFound);
    1618           1 :         OverrideNodeConnectionType(state,
    1619             :                                    OutNode,
    1620             :                                    OutNodeName,
    1621             :                                    ihp.SCWHCoilTypeNum,
    1622             :                                    ihp.SCWHCoilName,
    1623             :                                    DataLoopNode::ConnectionType::Internal,
    1624             :                                    NodeInputManager::CompFluidStream::Secondary,
    1625             :                                    ObjectIsNotParent,
    1626             :                                    ErrorsFound);
    1627             : 
    1628           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Water Coil", ihp.SCDWHWHCoilType, ihp.SCDWHWHCoilName, InNodeName, OutNodeName);
    1629           1 :         OverrideNodeConnectionType(state,
    1630             :                                    InNode,
    1631             :                                    InNodeName,
    1632             :                                    ihp.SCDWHWHCoilTypeNum,
    1633             :                                    ihp.SCDWHWHCoilName,
    1634             :                                    DataLoopNode::ConnectionType::Internal,
    1635             :                                    NodeInputManager::CompFluidStream::Secondary,
    1636             :                                    ObjectIsNotParent,
    1637             :                                    ErrorsFound);
    1638           1 :         OverrideNodeConnectionType(state,
    1639             :                                    OutNode,
    1640             :                                    OutNodeName,
    1641             :                                    ihp.SCDWHWHCoilTypeNum,
    1642             :                                    ihp.SCDWHWHCoilName,
    1643             :                                    DataLoopNode::ConnectionType::Internal,
    1644             :                                    NodeInputManager::CompFluidStream::Secondary,
    1645             :                                    ObjectIsNotParent,
    1646             :                                    ErrorsFound);
    1647             : 
    1648           2 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).WaterInletNodeNum != InNode) ||
    1649           1 :             (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).WaterOutletNodeNum != OutNode)) {
    1650           0 :             ShowContinueError(state, format("Mistaken air node connection: {}:{}-wrong coil node names.", CurrentModuleObject, ihp.SHDWHWHCoilName));
    1651           0 :             ErrorsFound = true;
    1652             :         }
    1653           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Water Coil", ihp.SHDWHWHCoilType, ihp.SHDWHWHCoilName, InNodeName, OutNodeName);
    1654           1 :         OverrideNodeConnectionType(state,
    1655             :                                    InNode,
    1656             :                                    InNodeName,
    1657             :                                    ihp.SHDWHWHCoilTypeNum,
    1658             :                                    ihp.SHDWHWHCoilName,
    1659             :                                    DataLoopNode::ConnectionType::Internal,
    1660             :                                    NodeInputManager::CompFluidStream::Secondary,
    1661             :                                    ObjectIsNotParent,
    1662             :                                    ErrorsFound);
    1663           1 :         OverrideNodeConnectionType(state,
    1664             :                                    OutNode,
    1665             :                                    OutNodeName,
    1666             :                                    ihp.SHDWHWHCoilTypeNum,
    1667             :                                    ihp.SHDWHWHCoilName,
    1668             :                                    DataLoopNode::ConnectionType::Internal,
    1669             :                                    NodeInputManager::CompFluidStream::Secondary,
    1670             :                                    ObjectIsNotParent,
    1671             :                                    ErrorsFound);
    1672             : 
    1673           2 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(ihp.DWHCoilIndex).WaterInletNodeNum != InNode) ||
    1674           1 :             (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.DWHCoilIndex).WaterOutletNodeNum != OutNode)) {
    1675           0 :             ShowContinueError(state, format("Mistaken air node connection: {}:{}-wrong coil node names.", CurrentModuleObject, ihp.DWHCoilName));
    1676           0 :             ErrorsFound = true;
    1677             :         }
    1678           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Water Coil", ihp.DWHCoilType, ihp.DWHCoilName, InNodeName, OutNodeName);
    1679           1 :         OverrideNodeConnectionType(state,
    1680             :                                    InNode,
    1681             :                                    InNodeName,
    1682             :                                    ihp.DWHCoilTypeNum,
    1683             :                                    ihp.DWHCoilName,
    1684             :                                    DataLoopNode::ConnectionType::Internal,
    1685             :                                    NodeInputManager::CompFluidStream::Secondary,
    1686             :                                    ObjectIsNotParent,
    1687             :                                    ErrorsFound);
    1688           1 :         OverrideNodeConnectionType(state,
    1689             :                                    OutNode,
    1690             :                                    OutNodeName,
    1691             :                                    ihp.DWHCoilTypeNum,
    1692             :                                    ihp.DWHCoilName,
    1693             :                                    DataLoopNode::ConnectionType::Internal,
    1694             :                                    NodeInputManager::CompFluidStream::Secondary,
    1695             :                                    ObjectIsNotParent,
    1696             :                                    ErrorsFound);
    1697             : 
    1698           1 :         ihp.WaterTankoutNod = GetOnlySingleNode(state,
    1699           1 :                                                 AlphArray(2),
    1700             :                                                 ErrorsFound,
    1701             :                                                 DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
    1702           1 :                                                 AlphArray(1),
    1703             :                                                 DataLoopNode::NodeFluidType::Water,
    1704             :                                                 DataLoopNode::ConnectionType::Sensor,
    1705             :                                                 NodeInputManager::CompFluidStream::Secondary,
    1706           1 :                                                 ObjectIsNotParent);
    1707             : 
    1708             :         // outdoor air node connections for water heating coils
    1709             :         // DWH, SCDWH, SHDWH coils have the same outdoor air nodes
    1710           1 :         ChildCoilIndex = ihp.DWHCoilIndex;
    1711           1 :         InNode = state.dataVariableSpeedCoils->VarSpeedCoil(ChildCoilIndex).AirInletNodeNum;
    1712           1 :         OutNode = state.dataVariableSpeedCoils->VarSpeedCoil(ChildCoilIndex).AirOutletNodeNum;
    1713           1 :         InNodeName = state.dataLoopNodes->NodeID(InNode);
    1714           1 :         OutNodeName = state.dataLoopNodes->NodeID(OutNode);
    1715           1 :         ihp.ODAirInletNodeNum = InNode;
    1716           1 :         ihp.ODAirOutletNodeNum = OutNode;
    1717           2 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHWHCoilIndex).AirInletNodeNum != InNode) ||
    1718           1 :             (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHWHCoilIndex).AirOutletNodeNum != OutNode)) {
    1719           0 :             ShowContinueError(state, format("Mistaken air node connection: {}:{}-wrong coil node names.", CurrentModuleObject, ihp.SCDWHWHCoilName));
    1720           0 :             ErrorsFound = true;
    1721             :         }
    1722             : 
    1723           1 :         TestCompSet(state, CurrentModuleObject, ihp.Name + " Outdoor Coil", InNodeName, OutNodeName, "Outdoor Air Nodes");
    1724           3 :         RegisterNodeConnection(state,
    1725             :                                InNode,
    1726           1 :                                state.dataLoopNodes->NodeID(InNode),
    1727             :                                DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
    1728           2 :                                ihp.Name + " Outdoor Coil",
    1729             :                                DataLoopNode::ConnectionType::Inlet,
    1730             :                                NodeInputManager::CompFluidStream::Primary,
    1731             :                                ObjectIsNotParent,
    1732           1 :                                ErrorsFound);
    1733           3 :         RegisterNodeConnection(state,
    1734             :                                OutNode,
    1735           1 :                                state.dataLoopNodes->NodeID(InNode),
    1736             :                                DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
    1737           2 :                                ihp.Name + " Outdoor Coil",
    1738             :                                DataLoopNode::ConnectionType::Outlet,
    1739             :                                NodeInputManager::CompFluidStream::Primary,
    1740             :                                ObjectIsNotParent,
    1741           1 :                                ErrorsFound);
    1742             : 
    1743           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Outdoor Coil", ihp.DWHCoilType, ihp.DWHCoilName, InNodeName, OutNodeName);
    1744           1 :         OverrideNodeConnectionType(state,
    1745             :                                    InNode,
    1746             :                                    InNodeName,
    1747             :                                    ihp.DWHCoilTypeNum,
    1748             :                                    ihp.DWHCoilName,
    1749             :                                    DataLoopNode::ConnectionType::Internal,
    1750             :                                    NodeInputManager::CompFluidStream::Primary,
    1751             :                                    ObjectIsNotParent,
    1752             :                                    ErrorsFound);
    1753           1 :         OverrideNodeConnectionType(state,
    1754             :                                    OutNode,
    1755             :                                    OutNodeName,
    1756             :                                    ihp.DWHCoilTypeNum,
    1757             :                                    ihp.DWHCoilName,
    1758             :                                    DataLoopNode::ConnectionType::Internal,
    1759             :                                    NodeInputManager::CompFluidStream::Primary,
    1760             :                                    ObjectIsNotParent,
    1761             :                                    ErrorsFound);
    1762             : 
    1763           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Outdoor Coil", ihp.SCDWHWHCoilType, ihp.SCDWHWHCoilName, InNodeName, OutNodeName);
    1764           1 :         OverrideNodeConnectionType(state,
    1765             :                                    InNode,
    1766             :                                    InNodeName,
    1767             :                                    ihp.SCDWHWHCoilTypeNum,
    1768             :                                    ihp.SCDWHWHCoilName,
    1769             :                                    DataLoopNode::ConnectionType::Internal,
    1770             :                                    NodeInputManager::CompFluidStream::Primary,
    1771             :                                    ObjectIsNotParent,
    1772             :                                    ErrorsFound);
    1773           1 :         OverrideNodeConnectionType(state,
    1774             :                                    OutNode,
    1775             :                                    OutNodeName,
    1776             :                                    ihp.SCDWHWHCoilTypeNum,
    1777             :                                    ihp.SCDWHWHCoilName,
    1778             :                                    DataLoopNode::ConnectionType::Internal,
    1779             :                                    NodeInputManager::CompFluidStream::Primary,
    1780             :                                    ObjectIsNotParent,
    1781             :                                    ErrorsFound);
    1782             : 
    1783             :         // why was this here
    1784             :         //        state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).AirInletNodeNum = InNode;
    1785             :         //        state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).AirOutletNodeNum = OutNode;
    1786             : 
    1787           2 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).AirInletNodeNum != InNode) ||
    1788           1 :             (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).AirOutletNodeNum != OutNode)) {
    1789           0 :             ShowContinueError(state, format("Mistaken air node connection: {}:{}-wrong coil node names.", CurrentModuleObject, ihp.SHDWHWHCoilName));
    1790           0 :             ErrorsFound = true;
    1791             :         }
    1792           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Outdoor Coil", ihp.SHDWHWHCoilType, ihp.SHDWHWHCoilName, InNodeName, OutNodeName);
    1793           1 :         OverrideNodeConnectionType(state,
    1794             :                                    InNode,
    1795             :                                    InNodeName,
    1796             :                                    ihp.SHDWHWHCoilTypeNum,
    1797             :                                    ihp.SHDWHWHCoilName,
    1798             :                                    DataLoopNode::ConnectionType::Internal,
    1799             :                                    NodeInputManager::CompFluidStream::Primary,
    1800             :                                    ObjectIsNotParent,
    1801             :                                    ErrorsFound);
    1802           1 :         OverrideNodeConnectionType(state,
    1803             :                                    OutNode,
    1804             :                                    OutNodeName,
    1805             :                                    ihp.SHDWHWHCoilTypeNum,
    1806             :                                    ihp.SHDWHWHCoilName,
    1807             :                                    DataLoopNode::ConnectionType::Internal,
    1808             :                                    NodeInputManager::CompFluidStream::Primary,
    1809             :                                    ObjectIsNotParent,
    1810             :                                    ErrorsFound);
    1811             : 
    1812           1 :         ihp.IHPCoilsSized = false;
    1813           1 :         ihp.CoolVolFlowScale = 1.0; // scale coil flow rates to match the parent fan object
    1814           1 :         ihp.HeatVolFlowScale = 1.0; // scale coil flow rates to match the parent fan object
    1815           1 :         ihp.CurMode = IHPOperationMode::Idle;
    1816           1 :         ihp.MaxHeatAirMassFlow = 1e10;
    1817           1 :         ihp.MaxHeatAirVolFlow = 1e10;
    1818           1 :         ihp.MaxCoolAirMassFlow = 1e10;
    1819           1 :         ihp.MaxCoolAirVolFlow = 1e10;
    1820             :     }
    1821             : 
    1822           1 :     if (ErrorsFound) {
    1823           0 :         ShowFatalError(state,
    1824           0 :                        format("{} Errors found in getting {} input. Preceding condition(s) causes termination.", RoutineName, CurrentModuleObject));
    1825             :     }
    1826             : 
    1827           2 :     for (int CoilCounter = 1; CoilCounter <= NumASIHPs; ++CoilCounter) {
    1828             : 
    1829           1 :         auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(CoilCounter);
    1830             : 
    1831             :         // set up output variables, not reported in the individual coil models
    1832           2 :         SetupOutputVariable(state,
    1833             :                             "Integrated Heat Pump Air Loop Mass Flow Rate",
    1834             :                             OutputProcessor::Unit::kg_s,
    1835             :                             ihp.AirLoopFlowRate,
    1836             :                             OutputProcessor::SOVTimeStepType::System,
    1837             :                             OutputProcessor::SOVStoreType::Average,
    1838           1 :                             ihp.Name);
    1839           2 :         SetupOutputVariable(state,
    1840             :                             "Integrated Heat Pump Condenser Water Mass Flow Rate",
    1841             :                             OutputProcessor::Unit::kg_s,
    1842             :                             ihp.TankSourceWaterMassFlowRate,
    1843             :                             OutputProcessor::SOVTimeStepType::System,
    1844             :                             OutputProcessor::SOVStoreType::Average,
    1845           1 :                             ihp.Name);
    1846           2 :         SetupOutputVariable(state,
    1847             :                             "Integrated Heat Pump Air Total Cooling Rate",
    1848             :                             OutputProcessor::Unit::W,
    1849             :                             ihp.TotalCoolingRate,
    1850             :                             OutputProcessor::SOVTimeStepType::System,
    1851             :                             OutputProcessor::SOVStoreType::Average,
    1852           1 :                             ihp.Name);
    1853           2 :         SetupOutputVariable(state,
    1854             :                             "Integrated Heat Pump Air Heating Rate",
    1855             :                             OutputProcessor::Unit::W,
    1856             :                             ihp.TotalSpaceHeatingRate,
    1857             :                             OutputProcessor::SOVTimeStepType::System,
    1858             :                             OutputProcessor::SOVStoreType::Average,
    1859           1 :                             ihp.Name);
    1860           2 :         SetupOutputVariable(state,
    1861             :                             "Integrated Heat Pump Water Heating Rate",
    1862             :                             OutputProcessor::Unit::W,
    1863             :                             ihp.TotalWaterHeatingRate,
    1864             :                             OutputProcessor::SOVTimeStepType::System,
    1865             :                             OutputProcessor::SOVStoreType::Average,
    1866           1 :                             ihp.Name);
    1867           2 :         SetupOutputVariable(state,
    1868             :                             "Integrated Heat Pump Electricity Rate",
    1869             :                             OutputProcessor::Unit::W,
    1870             :                             ihp.TotalPower,
    1871             :                             OutputProcessor::SOVTimeStepType::System,
    1872             :                             OutputProcessor::SOVStoreType::Average,
    1873           1 :                             ihp.Name);
    1874           2 :         SetupOutputVariable(state,
    1875             :                             "Integrated Heat Pump Air Latent Cooling Rate",
    1876             :                             OutputProcessor::Unit::W,
    1877             :                             ihp.TotalLatentLoad,
    1878             :                             OutputProcessor::SOVTimeStepType::System,
    1879             :                             OutputProcessor::SOVStoreType::Average,
    1880           1 :                             ihp.Name);
    1881           2 :         SetupOutputVariable(state,
    1882             :                             "Integrated Heat Pump Source Heat Transfer Rate",
    1883             :                             OutputProcessor::Unit::W,
    1884             :                             ihp.Qsource,
    1885             :                             OutputProcessor::SOVTimeStepType::System,
    1886             :                             OutputProcessor::SOVStoreType::Average,
    1887           1 :                             ihp.Name);
    1888           2 :         SetupOutputVariable(state,
    1889             :                             "Integrated Heat Pump COP",
    1890             :                             OutputProcessor::Unit::None,
    1891             :                             ihp.TotalCOP,
    1892             :                             OutputProcessor::SOVTimeStepType::System,
    1893             :                             OutputProcessor::SOVStoreType::Average,
    1894           1 :                             ihp.Name);
    1895           2 :         SetupOutputVariable(state,
    1896             :                             "Integrated Heat Pump Electricity Energy",
    1897             :                             OutputProcessor::Unit::J,
    1898             :                             ihp.Energy,
    1899             :                             OutputProcessor::SOVTimeStepType::System,
    1900             :                             OutputProcessor::SOVStoreType::Summed,
    1901           1 :                             ihp.Name);
    1902           2 :         SetupOutputVariable(state,
    1903             :                             "Integrated Heat Pump Air Total Cooling Energy",
    1904             :                             OutputProcessor::Unit::J,
    1905             :                             ihp.EnergyLoadTotalCooling,
    1906             :                             OutputProcessor::SOVTimeStepType::System,
    1907             :                             OutputProcessor::SOVStoreType::Summed,
    1908           1 :                             ihp.Name);
    1909           2 :         SetupOutputVariable(state,
    1910             :                             "Integrated Heat Pump Air Heating Energy",
    1911             :                             OutputProcessor::Unit::J,
    1912             :                             ihp.EnergyLoadTotalHeating,
    1913             :                             OutputProcessor::SOVTimeStepType::System,
    1914             :                             OutputProcessor::SOVStoreType::Summed,
    1915           1 :                             ihp.Name);
    1916           2 :         SetupOutputVariable(state,
    1917             :                             "Integrated Heat Pump Water Heating Energy",
    1918             :                             OutputProcessor::Unit::J,
    1919             :                             ihp.EnergyLoadTotalWaterHeating,
    1920             :                             OutputProcessor::SOVTimeStepType::System,
    1921             :                             OutputProcessor::SOVStoreType::Summed,
    1922           1 :                             ihp.Name);
    1923           2 :         SetupOutputVariable(state,
    1924             :                             "Integrated Heat Pump Air Latent Cooling Energy",
    1925             :                             OutputProcessor::Unit::J,
    1926             :                             ihp.EnergyLatent,
    1927             :                             OutputProcessor::SOVTimeStepType::System,
    1928             :                             OutputProcessor::SOVStoreType::Summed,
    1929           1 :                             ihp.Name);
    1930           2 :         SetupOutputVariable(state,
    1931             :                             "Integrated Heat Pump Source Heat Transfer Energy",
    1932             :                             OutputProcessor::Unit::J,
    1933             :                             ihp.EnergySource,
    1934             :                             OutputProcessor::SOVTimeStepType::System,
    1935             :                             OutputProcessor::SOVStoreType::Summed,
    1936           1 :                             ihp.Name);
    1937             :     }
    1938             : }
    1939             : 
    1940           3 : void SizeIHP(EnergyPlusData &state, int const DXCoilNum)
    1941             : {
    1942             :     using DataSizing::AutoSize;
    1943             :     using VariableSpeedCoils::SetVarSpeedCoilData;
    1944             :     using VariableSpeedCoils::SimVariableSpeedCoils;
    1945             :     using VariableSpeedCoils::SizeVarSpeedCoil;
    1946             : 
    1947           3 :     bool ErrorsFound = false;
    1948           3 :     Real64 RatedCapacity(0.0); // rated building cooling load
    1949             : 
    1950             :     // Obtains and Allocates AS-IHP related parameters from input file
    1951           3 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    1952           0 :         GetIHPInput(state);
    1953           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    1954             :     };
    1955             : 
    1956           3 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    1957           0 :         ShowFatalError(state,
    1958           0 :                        format("SizeIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    1959             :                               DXCoilNum,
    1960           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    1961             :     }
    1962             : 
    1963           3 :     if (state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum).IHPCoilsSized) {
    1964           2 :         return;
    1965             :     }
    1966             : 
    1967           1 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    1968             : 
    1969             :     // associate SC coil with SH coil
    1970           1 :     bool errFlag = false;
    1971           1 :     SetVarSpeedCoilData(state, ihp.SCCoilIndex, errFlag, _, ihp.SHCoilIndex);
    1972           1 :     if (errFlag) {
    1973           0 :         ShowSevereError(state, format(R"(SizeIHP: Could not match cooling coil"{}" with heating coil="{}")", ihp.SCCoilName, ihp.SHCoilName));
    1974           0 :         ErrorsFound = true;
    1975             :     };
    1976             : 
    1977           1 :     errFlag = false;
    1978           1 :     SizeVarSpeedCoil(state, ihp.SCCoilIndex, errFlag); // size cooling coil
    1979           1 :     if (errFlag) {
    1980           0 :         ShowSevereError(state, format("SizeIHP: failed to size SC coil\"{}\"", ihp.SCCoilName));
    1981           0 :         ErrorsFound = true;
    1982             :     } else {
    1983           1 :         RatedCapacity = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCCoilIndex).RatedCapCoolTotal;
    1984             :     };
    1985             : 
    1986           1 :     errFlag = false;
    1987           1 :     SizeVarSpeedCoil(state, ihp.SHCoilIndex, errFlag); // size heating coil
    1988           1 :     if (errFlag) {
    1989           0 :         ShowSevereError(state, format("SizeIHP: failed to size SH coil\"{}\"", ihp.SHCoilName));
    1990           0 :         ErrorsFound = true;
    1991             :     };
    1992             : 
    1993             :     // pass SC coil capacity to SCDWH cool coil
    1994           1 :     if (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).RatedCapCoolTotal == AutoSize) {
    1995           0 :         state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).RatedCapCoolTotal = RatedCapacity;
    1996             :     };
    1997             : 
    1998             :     // associate SCDWH air coil to SHDWH air coil
    1999           1 :     errFlag = false;
    2000           1 :     SetVarSpeedCoilData(state, ihp.SCDWHCoolCoilIndex, errFlag, _, ihp.SHDWHHeatCoilIndex);
    2001             :     // size SCDWH air coil
    2002           1 :     SizeVarSpeedCoil(state, ihp.SCDWHCoolCoilIndex, errFlag);
    2003           1 :     if (errFlag) {
    2004           0 :         ShowSevereError(state, format("SizeIHP: failed to size SCDWH cooling coil\"{}\"", ihp.SCDWHCoolCoilName));
    2005           0 :         ErrorsFound = true;
    2006             :     };
    2007             : 
    2008             :     // size SHDWH air coil
    2009           1 :     errFlag = false;
    2010           1 :     SizeVarSpeedCoil(state, ihp.SHDWHHeatCoilIndex, errFlag);
    2011           1 :     if (errFlag) {
    2012           0 :         ShowSevereError(state, format("SizeIHP: failed to size SHDWH heating coil\"{}\"", ihp.SHDWHHeatCoilName));
    2013           0 :         ErrorsFound = true;
    2014             :     };
    2015             : 
    2016             :     // size the water coils below
    2017             :     // size SCWH water coil
    2018           1 :     if (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).RatedCapWH == AutoSize) {
    2019           0 :         state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).RatedCapWH =
    2020           0 :             RatedCapacity / (1.0 - 1.0 / state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).RatedCOPHeat);
    2021             :     }
    2022             : 
    2023           1 :     errFlag = false;
    2024           1 :     SizeVarSpeedCoil(state, ihp.SCWHCoilIndex, errFlag);
    2025           1 :     if (errFlag) {
    2026           0 :         ShowSevereError(state, format("SizeIHP: failed to size SCWH coil\"{}\"", ihp.SCWHCoilName));
    2027           0 :         ErrorsFound = true;
    2028             :     };
    2029             : 
    2030             :     // size DWH water coil
    2031           1 :     if (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.DWHCoilIndex).RatedCapWH == AutoSize) {
    2032           0 :         state.dataVariableSpeedCoils->VarSpeedCoil(ihp.DWHCoilIndex).RatedCapWH = RatedCapacity;
    2033             :     }
    2034             : 
    2035           1 :     errFlag = false;
    2036           1 :     SizeVarSpeedCoil(state, ihp.DWHCoilIndex, errFlag);
    2037           1 :     if (errFlag) {
    2038           0 :         ShowSevereError(state, format("SizeIHP: failed to size DWH coil\"{}\"", ihp.DWHCoilName));
    2039           0 :         ErrorsFound = true;
    2040             :     };
    2041             : 
    2042             :     // size SCDWH water coil
    2043           1 :     if (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHWHCoilIndex).RatedCapWH == AutoSize) {
    2044           0 :         state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHWHCoilIndex).RatedCapWH = RatedCapacity * 0.13;
    2045             :     }
    2046             : 
    2047           1 :     errFlag = false;
    2048           1 :     SizeVarSpeedCoil(state, ihp.SCDWHWHCoilIndex, errFlag);
    2049           1 :     if (errFlag) {
    2050           0 :         ShowSevereError(state, format("SizeIHP: failed to size SCDWH water heating coil\"{}\"", ihp.SCDWHWHCoilName));
    2051           0 :         ErrorsFound = true;
    2052             :     };
    2053             : 
    2054             :     // size SHDWH water coil
    2055           1 :     if (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).RatedCapWH == AutoSize) {
    2056           0 :         state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).RatedCapWH = RatedCapacity * 0.1;
    2057             :     }
    2058             : 
    2059           1 :     errFlag = false;
    2060           1 :     SizeVarSpeedCoil(state, ihp.SHDWHWHCoilIndex, errFlag);
    2061           1 :     if (errFlag) {
    2062           0 :         ShowSevereError(state, format("SizeIHP: failed to size SHDWH water heating coil\"{}\"", ihp.SHDWHWHCoilName));
    2063           0 :         ErrorsFound = true;
    2064             :     };
    2065             : 
    2066           1 :     if (ErrorsFound) {
    2067           0 :         ShowFatalError(state, "Program terminates due to preceding condition(s).");
    2068             :     }
    2069             : 
    2070           1 :     ihp.IHPCoilsSized = true;
    2071             : }
    2072             : 
    2073      264111 : void InitializeIHP(EnergyPlusData &state, int const DXCoilNum)
    2074             : {
    2075             :     // Obtains and Allocates AS-IHP related parameters from input file
    2076      264111 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2077           0 :         GetIHPInput(state);
    2078           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2079             :     }
    2080             : 
    2081      264111 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    2082           0 :         ShowFatalError(state,
    2083           0 :                        format("InitializeIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    2084             :                               DXCoilNum,
    2085           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    2086             :     }
    2087             : 
    2088      264111 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    2089             : 
    2090      264111 :     ihp.AirLoopFlowRate = 0.0;             // air loop mass flow rate [kg/s]
    2091      264111 :     ihp.TankSourceWaterMassFlowRate = 0.0; // water loop mass flow rate [kg/s]
    2092      264111 :     ihp.TotalCoolingRate = 0.0;            // total cooling rate [w]
    2093      264111 :     ihp.TotalWaterHeatingRate = 0.0;       // total water heating rate [w]
    2094      264111 :     ihp.TotalSpaceHeatingRate = 0.0;       // total space heating rate [w]
    2095      264111 :     ihp.TotalPower = 0.0;                  // total power consumption  [w]
    2096      264111 :     ihp.TotalLatentLoad = 0.0;             // total latent cooling rate [w]
    2097      264111 :     ihp.Qsource = 0.0;                     // source energy rate, [w]
    2098      264111 :     ihp.Energy = 0.0;                      // total electric energy consumption [J]
    2099      264111 :     ihp.EnergyLoadTotalCooling = 0.0;      // total cooling energy [J]
    2100      264111 :     ihp.EnergyLoadTotalHeating = 0.0;      // total heating energy [J]
    2101      264111 :     ihp.EnergyLoadTotalWaterHeating = 0.0; // total heating energy [J]
    2102      264111 :     ihp.EnergyLatent = 0.0;                // total latent energy [J]
    2103      264111 :     ihp.EnergySource = 0.0;                // total source energy
    2104      264111 :     ihp.TotalCOP = 0.0;
    2105      264111 : }
    2106             : 
    2107      264111 : void UpdateIHP(EnergyPlusData &state, int const DXCoilNum)
    2108             : {
    2109      264111 :     auto &TimeStepSys = state.dataHVACGlobal->TimeStepSys;
    2110             : 
    2111             :     // Obtains and Allocates AS-IHP related parameters from input file
    2112      264111 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2113           0 :         GetIHPInput(state);
    2114           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2115             :     }
    2116             : 
    2117      264111 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    2118           0 :         ShowFatalError(state,
    2119           0 :                        format("UpdateIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    2120             :                               DXCoilNum,
    2121           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    2122             :     }
    2123             : 
    2124      264111 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    2125             : 
    2126      264111 :     switch (ihp.CurMode) {
    2127       68344 :     case IHPOperationMode::SpaceClg:
    2128       68344 :         ihp.TotalCoolingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCCoilIndex).QLoadTotal; // total cooling rate [w]
    2129       68344 :         ihp.TotalWaterHeatingRate = 0.0;                                                               // total water heating rate [w]
    2130       68344 :         ihp.TotalSpaceHeatingRate = 0.0;                                                               // total space heating rate [w]
    2131       68344 :         ihp.TotalPower = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCCoilIndex).Power;            // total power consumption  [w]
    2132       68344 :         ihp.TotalLatentLoad = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCCoilIndex).QLatent;     // total latent cooling rate [w]
    2133       68344 :         ihp.Qsource = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCCoilIndex).QSource;             // source energy rate, [w]
    2134       68344 :         break;
    2135       75114 :     case IHPOperationMode::SpaceHtg:
    2136       75114 :         ihp.TotalCoolingRate = 0.0;                                                                         // total cooling rate [w]
    2137       75114 :         ihp.TotalWaterHeatingRate = 0.0;                                                                    // total water heating rate [w]
    2138       75114 :         ihp.TotalSpaceHeatingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHCoilIndex).QLoadTotal; // total space heating rate [w]
    2139       75114 :         ihp.TotalPower = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHCoilIndex).Power;                 // total power consumption  [w]
    2140       75114 :         ihp.TotalLatentLoad = 0.0;                                                                          // total latent cooling rate [w]
    2141       75114 :         ihp.Qsource = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHCoilIndex).QSource;                  // source energy rate, [w]
    2142       75114 :         break;
    2143        2336 :     case IHPOperationMode::DedicatedWaterHtg:
    2144        2336 :         ihp.TotalCoolingRate = 0.0;                                                                       // total cooling rate [w]
    2145        2336 :         ihp.TotalWaterHeatingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.DWHCoilIndex).QSource; // total water heating rate [w]
    2146        2336 :         ihp.TotalSpaceHeatingRate = 0.0;                                                                  // total space heating rate [w]
    2147        2336 :         ihp.TotalPower = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.DWHCoilIndex).Power;              // total power consumption  [w]
    2148        2336 :         ihp.TotalLatentLoad = 0.0;                                                                        // total latent cooling rate [w]
    2149        2336 :         ihp.Qsource = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.DWHCoilIndex).QLoadTotal;            // source energy rate, [w]
    2150        2336 :         break;
    2151        3472 :     case IHPOperationMode::SCWHMatchSC:
    2152             :     case IHPOperationMode::SCWHMatchWH:
    2153        3472 :         ihp.TotalCoolingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).QLoadTotal;   // total cooling rate [w]
    2154        3472 :         ihp.TotalWaterHeatingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).QSource; // total water heating rate [w]
    2155        3472 :         ihp.TotalSpaceHeatingRate = 0.0;                                                                   // total space heating rate [w]
    2156        3472 :         ihp.TotalPower = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).Power;              // total power consumption  [w]
    2157        3472 :         ihp.TotalLatentLoad = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).QLatent;       // total latent cooling rate [w]
    2158        3472 :         ihp.Qsource = 0.0;                                                                                 // source energy rate, [w]
    2159        3472 :         break;
    2160      102184 :     case IHPOperationMode::SpaceClgDedicatedWaterHtg:
    2161      102184 :         ihp.TotalCoolingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).QLoadTotal; // total cooling rate [w]
    2162      102184 :         ihp.TotalSpaceHeatingRate = 0.0;                                                                      // total space heating rate [w]
    2163      102184 :         ihp.TotalPower = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).Power;            // total power consumption  [w]
    2164      102184 :         ihp.TotalLatentLoad = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).QLatent;     // total latent cooling rate [w]
    2165      102184 :         ihp.Qsource = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).QSource;             // source energy rate, [w]
    2166             : 
    2167      102184 :         ihp.TotalWaterHeatingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHWHCoilIndex).QSource; // total water heating rate [w]
    2168             : 
    2169      102184 :         break;
    2170           0 :     case IHPOperationMode::SHDWHElecHeatOff:
    2171             :     case IHPOperationMode::SHDWHElecHeatOn:
    2172           0 :         ihp.TotalCoolingRate = 0.0;                                                                                // total cooling rate [w]
    2173           0 :         ihp.TotalSpaceHeatingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHHeatCoilIndex).QLoadTotal; // total space heating rate [w]
    2174           0 :         ihp.TotalPower = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHHeatCoilIndex).Power;                 // total power consumption  [w]
    2175           0 :         ihp.TotalLatentLoad = 0.0;                                                                                 // total latent cooling rate [w]
    2176           0 :         ihp.Qsource = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHHeatCoilIndex).QSource;                  // source energy rate, [w]
    2177             : 
    2178           0 :         ihp.TotalWaterHeatingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).QSource; // total water heating rate [w]
    2179             : 
    2180           0 :         break;
    2181       12661 :     case IHPOperationMode::Idle:
    2182             :     default:
    2183       12661 :         break;
    2184             :     }
    2185             : 
    2186      264111 :     Real64 ReportingConstant = TimeStepSys * DataGlobalConstants::SecInHour;
    2187             : 
    2188      264111 :     ihp.Energy = ihp.TotalPower * ReportingConstant;                                 // total electric energy consumption
    2189             :                                                                                      // [J]
    2190      264111 :     ihp.EnergyLoadTotalCooling = ihp.TotalCoolingRate * ReportingConstant;           // total cooling energy [J]
    2191      264111 :     ihp.EnergyLoadTotalHeating = ihp.TotalSpaceHeatingRate * ReportingConstant;      // total heating energy [J]
    2192      264111 :     ihp.EnergyLoadTotalWaterHeating = ihp.TotalWaterHeatingRate * ReportingConstant; // total heating energy [J]
    2193      264111 :     ihp.EnergyLatent = ihp.TotalLatentLoad * ReportingConstant;                      // total latent energy [J]
    2194      264111 :     ihp.EnergySource = ihp.Qsource * ReportingConstant;                              // total source energy
    2195             : 
    2196      264111 :     if (ihp.TotalPower > 0.0) {
    2197      150158 :         Real64 TotalDelivery = ihp.TotalCoolingRate + ihp.TotalSpaceHeatingRate + ihp.TotalWaterHeatingRate;
    2198      150158 :         ihp.TotalCOP = TotalDelivery / ihp.TotalPower;
    2199             :     }
    2200      264111 : }
    2201             : 
    2202        5050 : void DecideWorkMode(EnergyPlusData &state,
    2203             :                     int const DXCoilNum,
    2204             :                     Real64 const SensLoad,  // Sensible demand load [W]
    2205             :                     Real64 const LatentLoad // Latent demand load [W]
    2206             :                     )                       // shall be called from a air loop parent
    2207             : {
    2208             :     //       AUTHOR         Bo Shen, ORNL
    2209             :     //       DATE WRITTEN   March 2016
    2210             :     //       RE-ENGINEERED  na
    2211             : 
    2212             :     // PURPOSE OF THIS SUBROUTINE:
    2213             :     // This subroutine determine the IHP working mode in the next time step,
    2214             :     // it should be called by an air loop parent object, when FirstHVACIteration == true
    2215             : 
    2216             :     // Using/Aliasing
    2217             :     using DataHVACGlobals::SmallLoad;
    2218             :     using WaterThermalTanks::GetWaterThermalTankInput;
    2219             : 
    2220        5050 :     auto &TimeStepSys = state.dataHVACGlobal->TimeStepSys;
    2221             : 
    2222        5050 :     Real64 MyLoad(0.0);
    2223        5050 :     Real64 WHHeatTimeSav(0.0); // time accumulation for water heating
    2224        5050 :     Real64 WHHeatVolSave(0.0); // volume accumulation for water heating
    2225             : 
    2226             :     // Obtains and Allocates AS-IHP related parameters from input file
    2227        5050 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2228           0 :         GetIHPInput(state);
    2229           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2230             :     }
    2231             : 
    2232        5050 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    2233           0 :         ShowFatalError(state,
    2234           0 :                        format("DecideWorkMode: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    2235             :                               DXCoilNum,
    2236           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    2237             :     }
    2238             : 
    2239        5050 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    2240             : 
    2241        5050 :     if (ihp.IHPCoilsSized == false) SizeIHP(state, DXCoilNum);
    2242             : 
    2243             :     // decide working mode at the first moment
    2244             :     // check if there is a water heating call
    2245        5050 :     ihp.IsWHCallAvail = false;
    2246        5050 :     ihp.CheckWHCall = true; // set checking flag
    2247        5050 :     if (ihp.WHtankID == 0)  // not initialized yet
    2248             :     {
    2249           2 :         ihp.IsWHCallAvail = false;
    2250             :     } else {
    2251        5048 :         state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate = GetWaterVolFlowRateIHP(state, DXCoilNum, 1.0, 1.0) * WaterDensity;
    2252        5048 :         state.dataLoopNodes->Node(ihp.WaterOutletNodeNum).Temp = state.dataLoopNodes->Node(ihp.WaterInletNodeNum).Temp;
    2253             : 
    2254        5048 :         DataPlant::PlantEquipmentType tankType = ihp.WHtankType;
    2255             : 
    2256        5048 :         switch (tankType) {
    2257           0 :         case DataPlant::PlantEquipmentType::WtrHeaterMixed:
    2258             :         case DataPlant::PlantEquipmentType::WtrHeaterStratified:
    2259             :         case DataPlant::PlantEquipmentType::ChilledWaterTankMixed:
    2260             :         case DataPlant::PlantEquipmentType::ChilledWaterTankStratified:
    2261             : 
    2262             :         {
    2263           0 :             int tankIDX = WaterThermalTanks::getTankIDX(state, ihp.WHtankName, ihp.WHtankID);
    2264           0 :             auto &tank = state.dataWaterThermalTanks->WaterThermalTank(tankIDX);
    2265           0 :             tank.callerLoopNum = ihp.LoopNum;
    2266           0 :             PlantLocation A(0, DataPlant::LoopSideLocation::Invalid, 0, 0);
    2267           0 :             tank.simulate(state, A, true, MyLoad, true);
    2268           0 :             tank.callerLoopNum = 0;
    2269             : 
    2270           0 :             break;
    2271             :         }
    2272        5048 :         case DataPlant::PlantEquipmentType::HeatPumpWtrHeaterPumped:
    2273             :         case DataPlant::PlantEquipmentType::HeatPumpWtrHeaterWrapped:
    2274             : 
    2275             :         {
    2276        5048 :             int hpIDX = WaterThermalTanks::getHPTankIDX(state, ihp.WHtankName, ihp.WHtankID);
    2277        5048 :             auto &HPWH = state.dataWaterThermalTanks->HPWaterHeater(hpIDX);
    2278        5048 :             int tankIDX = HPWH.WaterHeaterTankNum;
    2279        5048 :             auto &tank = state.dataWaterThermalTanks->WaterThermalTank(tankIDX);
    2280        5048 :             tank.callerLoopNum = ihp.LoopNum;
    2281        5048 :             ihp.WHtankType = tankType;
    2282        5048 :             PlantLocation A(0, DataPlant::LoopSideLocation::Invalid, 0, 0);
    2283        5048 :             HPWH.simulate(state, A, true, MyLoad, true);
    2284        5048 :             tank.callerLoopNum = 0;
    2285        5048 :             break;
    2286             :         }
    2287           0 :         default:
    2288           0 :             break;
    2289             :         }
    2290             :     }
    2291        5050 :     ihp.CheckWHCall = false; // clear checking flag
    2292             : 
    2293             :     // keep the water heating time and volume history
    2294        5050 :     WHHeatTimeSav = ihp.SHDWHRunTime;
    2295        5050 :     if (IHPOperationMode::SpaceClgDedicatedWaterHtg == ihp.CurMode) {
    2296        1145 :         WHHeatVolSave = ihp.WaterFlowAccumVol + state.dataLoopNodes->Node(ihp.WaterTankoutNod).MassFlowRate / 983.0 * TimeStepSys *
    2297             :                                                     DataGlobalConstants::SecInHour; // 983 - water density at 60 C
    2298             :     } else {
    2299        3905 :         WHHeatVolSave = 0.0;
    2300             :     }
    2301             : 
    2302             :     // clear the accumulation amount for other modes
    2303        5050 :     ihp.SHDWHRunTime = 0.0;
    2304        5050 :     ihp.WaterFlowAccumVol = 0.0;
    2305             : 
    2306        5050 :     if (!ihp.IsWHCallAvail) // no water heating call
    2307             :     {
    2308        3792 :         if ((SensLoad < (-1.0 * SmallLoad)) || (LatentLoad < (-1.0 * SmallLoad))) // space cooling mode
    2309             :         {
    2310         779 :             ihp.CurMode = IHPOperationMode::SpaceClg;
    2311        3013 :         } else if (SensLoad > SmallLoad) {
    2312        2344 :             if ((ihp.ControlledZoneTemp > ihp.TindoorOverCoolAllow) &&
    2313           0 :                 (state.dataEnvrn->OutDryBulbTemp > ihp.TambientOverCoolAllow)) // used for cooling season, avoid heating after SCWH mode
    2314           0 :                 ihp.CurMode = IHPOperationMode::Idle;
    2315             :             else
    2316        2344 :                 ihp.CurMode = IHPOperationMode::SpaceHtg;
    2317             :         } else {
    2318         669 :             ihp.CurMode = IHPOperationMode::Idle;
    2319             :         }
    2320             :     }
    2321             :     // below has water heating calls
    2322        1258 :     else if ((SensLoad < (-1.0 * SmallLoad)) || (LatentLoad < (-1.0 * SmallLoad))) // simultaneous SC and WH calls
    2323             :     {
    2324        2292 :         if (WHHeatVolSave < ihp.WaterVolSCDWH) // small water heating amount
    2325             :         {
    2326        1146 :             ihp.CurMode = IHPOperationMode::SpaceClgDedicatedWaterHtg;
    2327        1146 :             ihp.WaterFlowAccumVol = WHHeatVolSave;
    2328             :         } else {
    2329           0 :             if (1 == ihp.ModeMatchSCWH) // water heating priority
    2330           0 :                 ihp.CurMode = IHPOperationMode::SCWHMatchWH;
    2331             :             else // space cooling priority
    2332           0 :                 ihp.CurMode = IHPOperationMode::SCWHMatchSC;
    2333             :         };
    2334             : 
    2335         224 :     } else if ((ihp.ControlledZoneTemp > ihp.TindoorOverCoolAllow) &&
    2336         112 :                (state.dataEnvrn->OutDryBulbTemp > ihp.TambientOverCoolAllow)) // over-cooling allowed, water heating priority
    2337             :     {
    2338          56 :         ihp.CurMode = IHPOperationMode::SCWHMatchWH;
    2339         112 :     } else if ((ihp.ControlledZoneTemp > ihp.TindoorWHHighPriority) &&
    2340          56 :                (state.dataEnvrn->OutDryBulbTemp > ihp.TambientWHHighPriority)) // ignore space heating request
    2341             :     {
    2342          56 :         ihp.CurMode = IHPOperationMode::DedicatedWaterHtg;
    2343           0 :     } else if (SensLoad > SmallLoad) {
    2344           0 :         ihp.SHDWHRunTime = WHHeatTimeSav + TimeStepSys * DataGlobalConstants::SecInHour;
    2345             : 
    2346           0 :         if (WHHeatTimeSav > ihp.TimeLimitSHDWH) {
    2347           0 :             ihp.CurMode = IHPOperationMode::SHDWHElecHeatOn;
    2348             :         } else {
    2349           0 :             ihp.CurMode = IHPOperationMode::SHDWHElecHeatOff;
    2350             :         };
    2351             :     } else {
    2352           0 :         ihp.CurMode = IHPOperationMode::DedicatedWaterHtg;
    2353             :     }
    2354             : 
    2355             :     // clear up, important
    2356        5050 :     ClearCoils(state, DXCoilNum);
    2357        5050 : }
    2358             : 
    2359        7584 : void ClearCoils(EnergyPlusData &state, int const DXCoilNum)
    2360             : {
    2361             :     using VariableSpeedCoils::SimVariableSpeedCoils;
    2362             : 
    2363        7584 :     Real64 EMP1(0.0), EMP2(0.0), EMP3(0.0); // place holder to calling clear up function
    2364        7584 :     int CycFanCycCoil(1);                   // fan cycl manner place holder
    2365             : 
    2366             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    2367        7584 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2368           0 :         GetIHPInput(state);
    2369           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2370             :     }
    2371             : 
    2372        7584 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    2373           0 :         ShowFatalError(state,
    2374           0 :                        format("ClearCoils: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    2375             :                               DXCoilNum,
    2376           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    2377             :     }
    2378             : 
    2379        7584 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    2380             : 
    2381             :     // clear up
    2382       22752 :     SimVariableSpeedCoils(state,
    2383       15168 :                           std::string(),
    2384             :                           ihp.SCDWHCoolCoilIndex,
    2385             :                           CycFanCycCoil,
    2386             :                           EMP1,
    2387             :                           EMP2,
    2388             :                           EMP3,
    2389             :                           DataHVACGlobals::CompressorOperation::On,
    2390             :                           0.0,
    2391             :                           1.0,
    2392             :                           0.0,
    2393             :                           0.0,
    2394             :                           0.0,
    2395             :                           1.0);
    2396       22752 :     SimVariableSpeedCoils(state,
    2397       15168 :                           std::string(),
    2398             :                           ihp.SCDWHWHCoilIndex,
    2399             :                           CycFanCycCoil,
    2400             :                           EMP1,
    2401             :                           EMP2,
    2402             :                           EMP3,
    2403             :                           DataHVACGlobals::CompressorOperation::On,
    2404             :                           0.0,
    2405             :                           1.0,
    2406             :                           0.0,
    2407             :                           0.0,
    2408             :                           0.0,
    2409             :                           1.0);
    2410       22752 :     SimVariableSpeedCoils(state,
    2411       15168 :                           std::string(),
    2412             :                           ihp.SHDWHHeatCoilIndex,
    2413             :                           CycFanCycCoil,
    2414             :                           EMP1,
    2415             :                           EMP2,
    2416             :                           EMP3,
    2417             :                           DataHVACGlobals::CompressorOperation::On,
    2418             :                           0.0,
    2419             :                           1.0,
    2420             :                           0.0,
    2421             :                           0.0,
    2422             :                           0.0,
    2423             :                           1.0);
    2424       22752 :     SimVariableSpeedCoils(state,
    2425       15168 :                           std::string(),
    2426             :                           ihp.SHDWHWHCoilIndex,
    2427             :                           CycFanCycCoil,
    2428             :                           EMP1,
    2429             :                           EMP2,
    2430             :                           EMP3,
    2431             :                           DataHVACGlobals::CompressorOperation::On,
    2432             :                           0.0,
    2433             :                           1.0,
    2434             :                           0.0,
    2435             :                           0.0,
    2436             :                           0.0,
    2437             :                           1.0);
    2438       22752 :     SimVariableSpeedCoils(state,
    2439       15168 :                           std::string(),
    2440             :                           ihp.SCWHCoilIndex,
    2441             :                           CycFanCycCoil,
    2442             :                           EMP1,
    2443             :                           EMP2,
    2444             :                           EMP3,
    2445             :                           DataHVACGlobals::CompressorOperation::On,
    2446             :                           0.0,
    2447             :                           1.0,
    2448             :                           0.0,
    2449             :                           0.0,
    2450             :                           0.0,
    2451             :                           1.0);
    2452       22752 :     SimVariableSpeedCoils(state,
    2453       15168 :                           std::string(),
    2454             :                           ihp.SCCoilIndex,
    2455             :                           CycFanCycCoil,
    2456             :                           EMP1,
    2457             :                           EMP2,
    2458             :                           EMP3,
    2459             :                           DataHVACGlobals::CompressorOperation::On,
    2460             :                           0.0,
    2461             :                           1.0,
    2462             :                           0.0,
    2463             :                           0.0,
    2464             :                           0.0,
    2465             :                           1.0);
    2466       22752 :     SimVariableSpeedCoils(state,
    2467       15168 :                           std::string(),
    2468             :                           ihp.SHCoilIndex,
    2469             :                           CycFanCycCoil,
    2470             :                           EMP1,
    2471             :                           EMP2,
    2472             :                           EMP3,
    2473             :                           DataHVACGlobals::CompressorOperation::On,
    2474             :                           0.0,
    2475             :                           1.0,
    2476             :                           0.0,
    2477             :                           0.0,
    2478             :                           0.0,
    2479             :                           1.0);
    2480       22752 :     SimVariableSpeedCoils(state,
    2481       15168 :                           std::string(),
    2482             :                           ihp.DWHCoilIndex,
    2483             :                           CycFanCycCoil,
    2484             :                           EMP1,
    2485             :                           EMP2,
    2486             :                           EMP3,
    2487             :                           DataHVACGlobals::CompressorOperation::On,
    2488             :                           0.0,
    2489             :                           1.0,
    2490             :                           0.0,
    2491             :                           0.0,
    2492             :                           0.0,
    2493             :                           1.0);
    2494        7584 : }
    2495             : 
    2496       22761 : IHPOperationMode GetCurWorkMode(EnergyPlusData &state, int const DXCoilNum)
    2497             : {
    2498             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    2499       22761 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2500           0 :         GetIHPInput(state);
    2501           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2502             :     }
    2503             : 
    2504       22761 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    2505           0 :         ShowFatalError(state,
    2506           0 :                        format("GetCurWorkMode: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    2507             :                               DXCoilNum,
    2508           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    2509             :     }
    2510             : 
    2511       22761 :     if (state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum).IHPCoilsSized == false) SizeIHP(state, DXCoilNum);
    2512             : 
    2513       22761 :     return (state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum).CurMode);
    2514             : }
    2515             : 
    2516           7 : bool IHPInModel(EnergyPlusData &state)
    2517             : {
    2518           7 :     if (state.dataIntegratedHP->GetCoilsInputFlag) {
    2519           2 :         GetIHPInput(state);
    2520           2 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2521             :     }
    2522           7 :     return !state.dataIntegratedHP->IntegratedHeatPumps.empty();
    2523             : }
    2524             : 
    2525           3 : int GetCoilIndexIHP(EnergyPlusData &state,
    2526             :                     std::string const &CoilType, // must match coil types in this module
    2527             :                     std::string const &CoilName, // must match coil names for the coil type
    2528             :                     bool &ErrorsFound            // set to true if problem
    2529             : )
    2530             : {
    2531             : 
    2532             :     // FUNCTION INFORMATION:
    2533             :     //       AUTHOR         Bo Shen
    2534             :     //       DATE WRITTEN   March 2016
    2535             :     //       MODIFIED       na
    2536             :     //       RE-ENGINEERED  na
    2537             : 
    2538             :     // PURPOSE OF THIS FUNCTION:
    2539             :     // This function looks up the coil index for the given coil and returns it.  If
    2540             :     // incorrect coil type or name is given, ErrorsFound is returned as true and index is returned
    2541             :     // as zero.
    2542             : 
    2543             :     // Return value
    2544             :     int IndexNum; // returned index of matched coil
    2545             : 
    2546             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    2547           3 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2548           1 :         GetIHPInput(state);
    2549           1 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2550             :     }
    2551             : 
    2552           3 :     IndexNum = UtilityRoutines::FindItemInList(CoilName, state.dataIntegratedHP->IntegratedHeatPumps);
    2553             : 
    2554           3 :     if (IndexNum == 0) {
    2555           0 :         ShowSevereError(state, format(R"(GetCoilIndexIHP: Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    2556           0 :         ErrorsFound = true;
    2557             :     }
    2558             : 
    2559           3 :     return IndexNum;
    2560             : }
    2561             : 
    2562           1 : int GetCoilInletNodeIHP(EnergyPlusData &state,
    2563             :                         std::string const &CoilType, // must match coil types in this module
    2564             :                         std::string const &CoilName, // must match coil names for the coil type
    2565             :                         bool &ErrorsFound            // set to true if problem
    2566             : )
    2567             : {
    2568             :     // FUNCTION INFORMATION:
    2569             :     //       AUTHOR         Bo Shen
    2570             :     //       DATE WRITTEN   March 2016
    2571             :     //       MODIFIED       na
    2572             :     //       RE-ENGINEERED  na
    2573             : 
    2574             :     // PURPOSE OF THIS FUNCTION:
    2575             :     // This function looks up the given coil and returns the inlet node.  If
    2576             :     // incorrect coil type or name is given, ErrorsFound is returned as true and value is returned
    2577             :     // as zero.
    2578             : 
    2579             :     // Return value
    2580           1 :     int NodeNumber(0); // returned outlet node of matched coil
    2581             : 
    2582             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
    2583             :     int WhichCoil;
    2584             : 
    2585             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    2586           1 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2587           0 :         GetIHPInput(state);
    2588           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2589             :     }
    2590             : 
    2591           1 :     WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataIntegratedHP->IntegratedHeatPumps);
    2592           1 :     if (WhichCoil != 0) {
    2593           1 :         NodeNumber = state.dataIntegratedHP->IntegratedHeatPumps(WhichCoil).AirCoolInletNodeNum;
    2594             :     }
    2595             : 
    2596           1 :     if (WhichCoil == 0) {
    2597           0 :         ShowSevereError(state, format(R"(GetCoilInletNodeIHP: Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    2598           0 :         ErrorsFound = true;
    2599           0 :         NodeNumber = 0;
    2600             :     }
    2601             : 
    2602           1 :     return NodeNumber;
    2603             : }
    2604             : 
    2605           1 : int GetDWHCoilInletNodeIHP(EnergyPlusData &state,
    2606             :                            std::string const &CoilType, // must match coil types in this module
    2607             :                            std::string const &CoilName, // must match coil names for the coil type
    2608             :                            bool &ErrorsFound            // set to true if problem
    2609             : )
    2610             : {
    2611             :     // FUNCTION INFORMATION:
    2612             :     //       AUTHOR         Bo Shen
    2613             :     //       DATE WRITTEN   July 2016
    2614             :     //       MODIFIED       na
    2615             :     //       RE-ENGINEERED  na
    2616             : 
    2617             :     // PURPOSE OF THIS FUNCTION:
    2618             :     // This function looks up the given coil and returns the inlet node.  If
    2619             :     // incorrect coil type or name is given, ErrorsFound is returned as true and value is returned
    2620             :     // as zero.
    2621             : 
    2622             :     // Return value
    2623           1 :     int NodeNumber(0); // returned outlet node of matched coil
    2624             : 
    2625             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
    2626             :     int WhichCoil;
    2627             : 
    2628             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    2629           1 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2630           0 :         GetIHPInput(state);
    2631           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2632             :     }
    2633             : 
    2634           1 :     WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataIntegratedHP->IntegratedHeatPumps);
    2635           1 :     if (WhichCoil != 0) {
    2636           1 :         NodeNumber = state.dataIntegratedHP->IntegratedHeatPumps(WhichCoil).ODAirInletNodeNum;
    2637             :     }
    2638             : 
    2639           1 :     if (WhichCoil == 0) {
    2640           0 :         ShowSevereError(state, format(R"(GetCoilInletNodeIHP: Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    2641           0 :         ErrorsFound = true;
    2642           0 :         NodeNumber = 0;
    2643             :     }
    2644             : 
    2645           1 :     return NodeNumber;
    2646             : }
    2647             : 
    2648           1 : int GetDWHCoilOutletNodeIHP(EnergyPlusData &state,
    2649             :                             std::string const &CoilType, // must match coil types in this module
    2650             :                             std::string const &CoilName, // must match coil names for the coil type
    2651             :                             bool &ErrorsFound            // set to true if problem
    2652             : )
    2653             : {
    2654             :     // FUNCTION INFORMATION:
    2655             :     //       AUTHOR         Bo Shen
    2656             :     //       DATE WRITTEN   July 2016
    2657             :     //       MODIFIED       na
    2658             :     //       RE-ENGINEERED  na
    2659             : 
    2660             :     // PURPOSE OF THIS FUNCTION:
    2661             :     // This function looks up the given coil and returns the outlet node.  If
    2662             :     // incorrect coil type or name is given, ErrorsFound is returned as true and value is returned
    2663             :     // as zero.
    2664             : 
    2665             :     // Return value
    2666           1 :     int NodeNumber(0); // returned outlet node of matched coil
    2667             : 
    2668             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
    2669             :     int WhichCoil;
    2670             : 
    2671             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    2672           1 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2673           0 :         GetIHPInput(state);
    2674           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2675             :     }
    2676             : 
    2677           1 :     WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataIntegratedHP->IntegratedHeatPumps);
    2678           1 :     if (WhichCoil != 0) {
    2679           1 :         NodeNumber = state.dataIntegratedHP->IntegratedHeatPumps(WhichCoil).ODAirOutletNodeNum;
    2680             :     }
    2681             : 
    2682           1 :     if (WhichCoil == 0) {
    2683           0 :         ShowSevereError(state, format(R"(GetCoilInletNodeIHP: Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    2684           0 :         ErrorsFound = true;
    2685           0 :         NodeNumber = 0;
    2686             :     }
    2687             : 
    2688           1 :     return NodeNumber;
    2689             : }
    2690             : 
    2691           1 : int GetIHPDWHCoilPLFFPLR(EnergyPlusData &state,
    2692             :                          std::string const &CoilType,                  // must match coil types in this module
    2693             :                          std::string const &CoilName,                  // must match coil names for the coil type
    2694             :                          [[maybe_unused]] IHPOperationMode const Mode, // mode coil type
    2695             :                          bool &ErrorsFound                             // set to true if problem
    2696             : )
    2697             : {
    2698             :     // FUNCTION INFORMATION:
    2699             :     //       AUTHOR         Bo Shen
    2700             :     //       DATE WRITTEN   March, 2016
    2701             :     //       MODIFIED       na
    2702             :     //       RE-ENGINEERED  na
    2703             : 
    2704             :     // PURPOSE OF THIS FUNCTION:
    2705             :     // This function looks up the given coil and returns PLR curve index.  If
    2706             :     // incorrect coil type or name is given, ErrorsFound is returned as true and value is returned
    2707             :     // as zero.
    2708             : 
    2709             :     // Using/Aliasing
    2710             :     using VariableSpeedCoils::GetVSCoilPLFFPLR;
    2711             : 
    2712             :     // Return value
    2713           1 :     int PLRNumber(0); // returned outlet node of matched coil
    2714             : 
    2715             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    2716           1 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2717           0 :         GetIHPInput(state);
    2718           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2719             :     }
    2720             : 
    2721           1 :     int WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataIntegratedHP->IntegratedHeatPumps);
    2722           1 :     if (WhichCoil != 0) {
    2723             : 
    2724           1 :         auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(WhichCoil);
    2725             : 
    2726             :         // this will be called by HPWH parent
    2727           1 :         if (ihp.DWHCoilIndex > 0)
    2728           1 :             PLRNumber = GetVSCoilPLFFPLR(state, ihp.DWHCoilType, ihp.DWHCoilName, ErrorsFound);
    2729             :         else
    2730           0 :             PLRNumber = GetVSCoilPLFFPLR(state, ihp.SCWHCoilType, ihp.SCWHCoilName, ErrorsFound);
    2731             :     } else {
    2732           0 :         WhichCoil = 0;
    2733             :     }
    2734             : 
    2735           1 :     if (WhichCoil == 0) {
    2736           0 :         ShowSevereError(state, format(R"(GetIHPDWHCoilPLFFPLR: Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    2737           0 :         ErrorsFound = true;
    2738           0 :         PLRNumber = 0;
    2739             :     }
    2740             : 
    2741           1 :     return PLRNumber;
    2742             : }
    2743             : 
    2744           1 : Real64 GetDWHCoilCapacityIHP(EnergyPlusData &state,
    2745             :                              std::string const &CoilType,                  // must match coil types in this module
    2746             :                              std::string const &CoilName,                  // must match coil names for the coil type
    2747             :                              [[maybe_unused]] IHPOperationMode const Mode, // mode coil type
    2748             :                              bool &ErrorsFound                             // set to true if problem
    2749             : )
    2750             : {
    2751             : 
    2752             :     // FUNCTION INFORMATION:
    2753             :     //       AUTHOR         Bo Shen
    2754             :     //       DATE WRITTEN   Jan 2016
    2755             :     //       MODIFIED       na
    2756             :     //       RE-ENGINEERED  na
    2757             : 
    2758             :     // PURPOSE OF THIS FUNCTION:
    2759             :     // This function looks up the rated coil capacity at the nominal speed level for the given coil and returns it.  If
    2760             :     // incorrect coil type or name is given, ErrorsFound is returned as true and capacity is returned
    2761             :     // as negative.
    2762             : 
    2763             :     // Using/Aliasing
    2764             :     using VariableSpeedCoils::GetCoilCapacityVariableSpeed;
    2765             : 
    2766             :     // Return value
    2767             :     Real64 CoilCapacity; // returned capacity of matched coil
    2768             : 
    2769             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    2770           1 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2771           0 :         GetIHPInput(state);
    2772           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2773             :     }
    2774             : 
    2775           1 :     int WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataIntegratedHP->IntegratedHeatPumps);
    2776           1 :     if (WhichCoil != 0) {
    2777             : 
    2778           1 :         auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(WhichCoil);
    2779             : 
    2780           1 :         if (ihp.IHPCoilsSized == false) SizeIHP(state, WhichCoil);
    2781             : 
    2782           1 :         if (ihp.DWHCoilIndex > 0) {
    2783           1 :             CoilCapacity = GetCoilCapacityVariableSpeed(state, ihp.DWHCoilType, ihp.DWHCoilName, ErrorsFound);
    2784             :         } else {
    2785           0 :             CoilCapacity = GetCoilCapacityVariableSpeed(state, ihp.SCWHCoilType, ihp.SCWHCoilName, ErrorsFound);
    2786             :         }
    2787             :     } else {
    2788           0 :         WhichCoil = 0;
    2789             :     }
    2790             : 
    2791           1 :     if (WhichCoil == 0) {
    2792           0 :         ShowSevereError(state, format(R"(GetCoilCapacityVariableSpeed: Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    2793           0 :         ErrorsFound = true;
    2794           0 :         CoilCapacity = -1000.0;
    2795             :     }
    2796             : 
    2797           1 :     return CoilCapacity;
    2798             : }
    2799             : 
    2800        1531 : int GetLowSpeedNumIHP(EnergyPlusData &state, int const DXCoilNum)
    2801             : {
    2802        1531 :     int SpeedNum(0);
    2803             : 
    2804             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    2805        1531 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2806           0 :         GetIHPInput(state);
    2807           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2808             :     }
    2809             : 
    2810        1531 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    2811           0 :         ShowFatalError(state,
    2812           0 :                        format("GetLowSpeedNumIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    2813             :                               DXCoilNum,
    2814           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    2815             :     }
    2816             : 
    2817        1531 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    2818             : 
    2819        1531 :     switch (ihp.CurMode) {
    2820         161 :     case IHPOperationMode::Idle:
    2821             :     case IHPOperationMode::SpaceClg:
    2822             :     case IHPOperationMode::SpaceHtg:
    2823             :     case IHPOperationMode::DedicatedWaterHtg:
    2824         161 :         SpeedNum = 1;
    2825         161 :         break;
    2826         224 :     case IHPOperationMode::SCWHMatchSC:
    2827             :     case IHPOperationMode::SCWHMatchWH:
    2828         224 :         SpeedNum = ihp.MinSpedSCWH;
    2829         224 :         break;
    2830        1146 :     case IHPOperationMode::SpaceClgDedicatedWaterHtg:
    2831        1146 :         SpeedNum = ihp.MinSpedSCDWH;
    2832        1146 :         break;
    2833           0 :     case IHPOperationMode::SHDWHElecHeatOff:
    2834             :     case IHPOperationMode::SHDWHElecHeatOn:
    2835           0 :         SpeedNum = ihp.MinSpedSHDWH;
    2836           0 :         break;
    2837           0 :     default:
    2838           0 :         SpeedNum = 1;
    2839           0 :         break;
    2840             :     }
    2841             : 
    2842        1531 :     return (SpeedNum);
    2843             : }
    2844             : 
    2845       68016 : int GetMaxSpeedNumIHP(EnergyPlusData &state, int const DXCoilNum)
    2846             : {
    2847             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    2848       68016 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2849           0 :         GetIHPInput(state);
    2850           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2851             :     }
    2852             : 
    2853       68016 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    2854           0 :         ShowFatalError(state,
    2855           0 :                        format("GetMaxSpeedNumIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    2856             :                               DXCoilNum,
    2857           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    2858             :     }
    2859             : 
    2860       68016 :     int SpeedNum(0);
    2861       68016 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    2862             : 
    2863       68016 :     switch (ihp.CurMode) {
    2864       17862 :     case IHPOperationMode::Idle:
    2865             :     case IHPOperationMode::SpaceClg:
    2866       17862 :         SpeedNum = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCCoilIndex).NumOfSpeeds;
    2867       17862 :         break;
    2868       23466 :     case IHPOperationMode::SpaceHtg:
    2869       23466 :         SpeedNum = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHCoilIndex).NumOfSpeeds;
    2870       23466 :         break;
    2871         112 :     case IHPOperationMode::DedicatedWaterHtg:
    2872         112 :         SpeedNum = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.DWHCoilIndex).NumOfSpeeds;
    2873         112 :         break;
    2874         168 :     case IHPOperationMode::SCWHMatchSC:
    2875             :     case IHPOperationMode::SCWHMatchWH:
    2876         168 :         SpeedNum = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).NumOfSpeeds;
    2877         168 :         break;
    2878       26408 :     case IHPOperationMode::SpaceClgDedicatedWaterHtg:
    2879       26408 :         SpeedNum = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).NumOfSpeeds;
    2880       26408 :         break;
    2881           0 :     case IHPOperationMode::SHDWHElecHeatOff:
    2882             :     case IHPOperationMode::SHDWHElecHeatOn:
    2883           0 :         SpeedNum = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHHeatCoilIndex).NumOfSpeeds;
    2884           0 :         break;
    2885           0 :     default:
    2886           0 :         SpeedNum = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCCoilIndex).NumOfSpeeds;
    2887           0 :         break;
    2888             :     }
    2889             : 
    2890       68016 :     return (SpeedNum);
    2891             : }
    2892             : 
    2893       19516 : Real64 GetAirVolFlowRateIHP(EnergyPlusData &state,
    2894             :                             int const DXCoilNum,
    2895             :                             int const SpeedNum,
    2896             :                             Real64 const SpeedRatio,
    2897             :                             bool const IsCallbyWH // whether the call from the water heating loop or air loop, true = from water heating loop
    2898             : )
    2899             : {
    2900       19516 :     int IHPCoilIndex(0);
    2901       19516 :     Real64 AirVolFlowRate(0.0);
    2902       19516 :     Real64 FlowScale(1.0);
    2903       19516 :     bool IsResultFlow(false); // IsResultFlow = true, the air flow rate will be from a simultaneous mode, won't be re-calculated
    2904             : 
    2905             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    2906       19516 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2907           0 :         GetIHPInput(state);
    2908           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2909             :     }
    2910             : 
    2911       19516 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    2912           0 :         ShowFatalError(state,
    2913           0 :                        format("GetAirVolFlowRateIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    2914             :                               DXCoilNum,
    2915           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    2916             :     }
    2917             : 
    2918       19516 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    2919             : 
    2920       19516 :     if (!ihp.IHPCoilsSized) SizeIHP(state, DXCoilNum);
    2921             : 
    2922       19516 :     FlowScale = 0.0;
    2923       19516 :     switch (ihp.CurMode) {
    2924         834 :     case IHPOperationMode::Idle:
    2925         834 :         IHPCoilIndex = ihp.SCCoilIndex;
    2926         834 :         break;
    2927          16 :     case IHPOperationMode::SpaceClg:
    2928          16 :         IHPCoilIndex = ihp.SCCoilIndex;
    2929          16 :         if (!IsCallbyWH) // call from air loop
    2930             :         {
    2931           0 :             FlowScale = ihp.CoolVolFlowScale;
    2932             :         }
    2933             : 
    2934          16 :         break;
    2935        9374 :     case IHPOperationMode::SpaceHtg:
    2936        9374 :         IHPCoilIndex = ihp.SHCoilIndex;
    2937        9374 :         if (!IsCallbyWH) // call from air loop
    2938             :         {
    2939           0 :             FlowScale = ihp.HeatVolFlowScale;
    2940             :         }
    2941        9374 :         break;
    2942        1432 :     case IHPOperationMode::DedicatedWaterHtg:
    2943        1432 :         IHPCoilIndex = ihp.DWHCoilIndex;
    2944        1432 :         FlowScale = 1.0;
    2945        1432 :         break;
    2946           0 :     case IHPOperationMode::SCWHMatchSC:
    2947           0 :         IHPCoilIndex = ihp.SCWHCoilIndex;
    2948           0 :         FlowScale = ihp.CoolVolFlowScale;
    2949           0 :         if (IsCallbyWH) // call from water loop
    2950             :         {
    2951           0 :             IsResultFlow = true;
    2952           0 :             AirVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).AirVolFlowRate;
    2953             :         }
    2954           0 :         break;
    2955        3282 :     case IHPOperationMode::SCWHMatchWH:
    2956        3282 :         IHPCoilIndex = ihp.SCWHCoilIndex;
    2957        3282 :         FlowScale = ihp.CoolVolFlowScale;
    2958        3282 :         if (!IsCallbyWH) {
    2959           0 :             IsResultFlow = true;
    2960           0 :             AirVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).AirVolFlowRate;
    2961             :         }
    2962        3282 :         break;
    2963        4578 :     case IHPOperationMode::SpaceClgDedicatedWaterHtg:
    2964        4578 :         IHPCoilIndex = ihp.SCDWHCoolCoilIndex;
    2965        4578 :         FlowScale = ihp.CoolVolFlowScale;
    2966        4578 :         if (IsCallbyWH) {
    2967        4578 :             IsResultFlow = true;
    2968        4578 :             AirVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).AirVolFlowRate;
    2969             :         }
    2970        4578 :         break;
    2971           0 :     case IHPOperationMode::SHDWHElecHeatOff:
    2972             :     case IHPOperationMode::SHDWHElecHeatOn:
    2973           0 :         IHPCoilIndex = ihp.SHDWHHeatCoilIndex;
    2974           0 :         FlowScale = ihp.HeatVolFlowScale;
    2975           0 :         if (IsCallbyWH) {
    2976           0 :             IsResultFlow = true;
    2977           0 :             AirVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHHeatCoilIndex).AirVolFlowRate;
    2978             :         }
    2979           0 :         break;
    2980           0 :     default:
    2981           0 :         IHPCoilIndex = ihp.SCCoilIndex;
    2982           0 :         FlowScale = 0.0;
    2983           0 :         break;
    2984             :     }
    2985             : 
    2986       19516 :     if (!IsResultFlow) {
    2987       14938 :         if (1 == SpeedNum)
    2988       12074 :             AirVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedAirVolFlowRate(SpeedNum);
    2989             :         else
    2990        5728 :             AirVolFlowRate = SpeedRatio * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedAirVolFlowRate(SpeedNum) +
    2991        2864 :                              (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedAirVolFlowRate(SpeedNum - 1);
    2992             : 
    2993       14938 :         AirVolFlowRate = AirVolFlowRate * FlowScale;
    2994             :     }
    2995             : 
    2996       19516 :     if (AirVolFlowRate > ihp.MaxCoolAirVolFlow) AirVolFlowRate = ihp.MaxCoolAirVolFlow;
    2997       19516 :     if (AirVolFlowRate > ihp.MaxHeatAirVolFlow) AirVolFlowRate = ihp.MaxHeatAirVolFlow;
    2998             : 
    2999       19516 :     return (AirVolFlowRate);
    3000             : }
    3001             : 
    3002      125598 : Real64 GetWaterVolFlowRateIHP(EnergyPlusData &state, int const DXCoilNum, int const SpeedNum, Real64 const SpeedRatio)
    3003             : {
    3004      125598 :     int IHPCoilIndex(0);
    3005      125598 :     Real64 WaterVolFlowRate(0.0);
    3006             : 
    3007             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    3008      125598 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    3009           0 :         GetIHPInput(state);
    3010           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    3011             :     }
    3012             : 
    3013      125598 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    3014           0 :         ShowFatalError(state,
    3015           0 :                        format("GetWaterVolFlowRateIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    3016             :                               DXCoilNum,
    3017           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    3018             :     }
    3019             : 
    3020      125598 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    3021             : 
    3022      125598 :     if (!ihp.IHPCoilsSized) SizeIHP(state, DXCoilNum);
    3023             : 
    3024      125598 :     switch (ihp.CurMode) {
    3025       14015 :     case IHPOperationMode::Idle:
    3026             :     case IHPOperationMode::SpaceClg:
    3027             :     case IHPOperationMode::SpaceHtg:
    3028       14015 :         WaterVolFlowRate = 0.0;
    3029       14015 :         break;
    3030        1488 :     case IHPOperationMode::DedicatedWaterHtg:
    3031        1488 :         IHPCoilIndex = ihp.DWHCoilIndex;
    3032        1488 :         if (1 == SpeedNum)
    3033         448 :             WaterVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum);
    3034             :         else
    3035        2080 :             WaterVolFlowRate = SpeedRatio * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum) +
    3036        1040 :                                (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum - 1);
    3037        1488 :         break;
    3038        3338 :     case IHPOperationMode::SCWHMatchSC:
    3039             :     case IHPOperationMode::SCWHMatchWH:
    3040        3338 :         IHPCoilIndex = ihp.SCWHCoilIndex;
    3041        3338 :         if (1 == SpeedNum)
    3042        1658 :             WaterVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum);
    3043             :         else
    3044        3360 :             WaterVolFlowRate = SpeedRatio * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum) +
    3045        1680 :                                (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum - 1);
    3046        3338 :         break;
    3047      106757 :     case IHPOperationMode::SpaceClgDedicatedWaterHtg:
    3048      106757 :         IHPCoilIndex = ihp.SCDWHWHCoilIndex;
    3049      106757 :         if (1 == SpeedNum)
    3050       41249 :             WaterVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum);
    3051             :         else
    3052      131016 :             WaterVolFlowRate = SpeedRatio * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum) +
    3053       65508 :                                (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum - 1);
    3054      106757 :         break;
    3055           0 :     case IHPOperationMode::SHDWHElecHeatOff:
    3056             :     case IHPOperationMode::SHDWHElecHeatOn:
    3057           0 :         IHPCoilIndex = ihp.SHDWHWHCoilIndex;
    3058           0 :         if (1 == SpeedNum)
    3059           0 :             WaterVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum);
    3060             :         else
    3061           0 :             WaterVolFlowRate = SpeedRatio * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum) +
    3062           0 :                                (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum - 1);
    3063           0 :         break;
    3064           0 :     default:
    3065           0 :         WaterVolFlowRate = 0.0;
    3066           0 :         break;
    3067             :     }
    3068             : 
    3069      125598 :     return (WaterVolFlowRate);
    3070             : }
    3071             : 
    3072      256672 : Real64 GetAirMassFlowRateIHP(EnergyPlusData &state,
    3073             :                              int const DXCoilNum,
    3074             :                              int const SpeedNum,
    3075             :                              Real64 const SpeedRatio,
    3076             :                              bool const IsCallbyWH // whether the call from the water heating loop or air loop, true = from water heating loop
    3077             : )
    3078             : {
    3079      256672 :     int IHPCoilIndex(0);
    3080      256672 :     Real64 AirMassFlowRate(0.0);
    3081      256672 :     Real64 FlowScale(1.0);
    3082      256672 :     bool IsResultFlow(false); // IsResultFlow = true, the air flow rate will be from a simultaneous mode, won't be re-calculated
    3083             : 
    3084             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    3085      256672 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    3086           0 :         GetIHPInput(state);
    3087           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    3088             :     }
    3089             : 
    3090      256672 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    3091           0 :         ShowFatalError(state,
    3092           0 :                        format("GetAirMassFlowRateIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    3093             :                               DXCoilNum,
    3094           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    3095             :     }
    3096             : 
    3097      256672 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    3098             : 
    3099      256672 :     if (!ihp.IHPCoilsSized) SizeIHP(state, DXCoilNum);
    3100             : 
    3101      256672 :     FlowScale = 0.0;
    3102      256672 :     switch (ihp.CurMode) {
    3103         834 :     case IHPOperationMode::Idle:
    3104         834 :         IHPCoilIndex = ihp.SCCoilIndex;
    3105         834 :         AirMassFlowRate = 0.0;
    3106         834 :         break;
    3107       65236 :     case IHPOperationMode::SpaceClg:
    3108       65236 :         IHPCoilIndex = ihp.SCCoilIndex;
    3109       65236 :         if (!IsCallbyWH) {
    3110       65220 :             FlowScale = ihp.CoolVolFlowScale;
    3111             :         } else {
    3112          16 :             IsResultFlow = true;
    3113          16 :             AirMassFlowRate = ihp.AirFlowSavInAirLoop;
    3114             :         }
    3115       65236 :         break;
    3116       84486 :     case IHPOperationMode::SpaceHtg:
    3117       84486 :         IHPCoilIndex = ihp.SHCoilIndex;
    3118       84486 :         if (!IsCallbyWH) {
    3119       75112 :             FlowScale = ihp.HeatVolFlowScale;
    3120             :         } else {
    3121        9374 :             IsResultFlow = true;
    3122        9374 :             AirMassFlowRate = ihp.AirFlowSavInAirLoop;
    3123             :         }
    3124       84486 :         break;
    3125        1464 :     case IHPOperationMode::DedicatedWaterHtg:
    3126        1464 :         IHPCoilIndex = ihp.DWHCoilIndex;
    3127        1464 :         FlowScale = 1.0;
    3128        1464 :         break;
    3129           0 :     case IHPOperationMode::SCWHMatchSC:
    3130           0 :         IHPCoilIndex = ihp.SCWHCoilIndex;
    3131           0 :         FlowScale = ihp.CoolVolFlowScale;
    3132           0 :         state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate = GetWaterVolFlowRateIHP(state, DXCoilNum, SpeedNum, SpeedRatio) * WaterDensity;
    3133           0 :         if (IsCallbyWH) {
    3134           0 :             IsResultFlow = true;
    3135           0 :             AirMassFlowRate = ihp.AirFlowSavInAirLoop;
    3136             :         }
    3137           0 :         break;
    3138        3618 :     case IHPOperationMode::SCWHMatchWH:
    3139        3618 :         IHPCoilIndex = ihp.SCWHCoilIndex;
    3140        3618 :         FlowScale = ihp.CoolVolFlowScale;
    3141        3618 :         if (!IsCallbyWH) {
    3142         336 :             IsResultFlow = true;
    3143         336 :             AirMassFlowRate = ihp.AirFlowSavInWaterLoop;
    3144             :         }
    3145        3618 :         break;
    3146      101034 :     case IHPOperationMode::SpaceClgDedicatedWaterHtg:
    3147      101034 :         IHPCoilIndex = ihp.SCDWHCoolCoilIndex;
    3148      101034 :         FlowScale = ihp.CoolVolFlowScale;
    3149      101034 :         state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate = GetWaterVolFlowRateIHP(state, DXCoilNum, SpeedNum, SpeedRatio) * WaterDensity;
    3150      101034 :         if (IsCallbyWH) {
    3151        4578 :             IsResultFlow = true;
    3152        4578 :             AirMassFlowRate = ihp.AirFlowSavInAirLoop;
    3153             :         }
    3154      101034 :         break;
    3155           0 :     case IHPOperationMode::SHDWHElecHeatOff:
    3156             :     case IHPOperationMode::SHDWHElecHeatOn:
    3157           0 :         IHPCoilIndex = ihp.SHDWHHeatCoilIndex;
    3158           0 :         FlowScale = ihp.HeatVolFlowScale;
    3159           0 :         state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate = GetWaterVolFlowRateIHP(state, DXCoilNum, SpeedNum, SpeedRatio) * WaterDensity;
    3160           0 :         if (IsCallbyWH) {
    3161           0 :             IsResultFlow = true;
    3162           0 :             AirMassFlowRate = ihp.AirFlowSavInAirLoop;
    3163             :         }
    3164           0 :         break;
    3165           0 :     default:
    3166           0 :         IHPCoilIndex = ihp.SCCoilIndex;
    3167           0 :         FlowScale = 0.0;
    3168           0 :         break;
    3169             :     }
    3170             : 
    3171      256672 :     if (!IsResultFlow) {
    3172      242368 :         if (SpeedNum == 1) {
    3173       61613 :             AirMassFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedAirMassFlowRate(SpeedNum);
    3174             :         } else {
    3175      361510 :             AirMassFlowRate = SpeedRatio * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedAirMassFlowRate(SpeedNum) +
    3176      180755 :                               (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedAirMassFlowRate(SpeedNum - 1);
    3177             :         }
    3178             : 
    3179      242368 :         AirMassFlowRate = AirMassFlowRate * FlowScale;
    3180             :     }
    3181             : 
    3182      256672 :     if (AirMassFlowRate > ihp.MaxCoolAirMassFlow) {
    3183           0 :         AirMassFlowRate = ihp.MaxCoolAirMassFlow;
    3184             :     }
    3185      256672 :     if (AirMassFlowRate > ihp.MaxHeatAirMassFlow) {
    3186           0 :         AirMassFlowRate = ihp.MaxHeatAirMassFlow;
    3187             :     }
    3188             : 
    3189             :     // set max air flow rate
    3190      256672 :     state.dataLoopNodes->Node(ihp.AirCoolInletNodeNum).MassFlowRateMax = AirMassFlowRate;
    3191      256672 :     state.dataLoopNodes->Node(ihp.AirHeatInletNodeNum).MassFlowRateMax = AirMassFlowRate;
    3192      256672 :     state.dataLoopNodes->Node(ihp.AirOutletNodeNum).MassFlowRateMax = AirMassFlowRate;
    3193             : 
    3194      256672 :     return AirMassFlowRate;
    3195             : }
    3196             : 
    3197        2313 : } // namespace EnergyPlus::IntegratedHeatPump

Generated by: LCOV version 1.13