LCOV - code coverage report
Current view: top level - EnergyPlus - IntegratedHeatPump.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 839 1143 73.4 %
Date: 2024-08-24 18:31:18 Functions: 20 20 100.0 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2024, The Board of Trustees of the University of Illinois,
       2             : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3             : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4             : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5             : // contributors. All rights reserved.
       6             : //
       7             : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8             : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9             : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10             : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11             : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12             : //
      13             : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14             : // provided that the following conditions are met:
      15             : //
      16             : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17             : //     conditions and the following disclaimer.
      18             : //
      19             : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20             : //     conditions and the following disclaimer in the documentation and/or other materials
      21             : //     provided with the distribution.
      22             : //
      23             : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24             : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25             : //     used to endorse or promote products derived from this software without specific prior
      26             : //     written permission.
      27             : //
      28             : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29             : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30             : //     reference solely to the software portion of its product, Licensee must refer to the
      31             : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32             : //     obtained under this License and may not use a different name for the software. Except as
      33             : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34             : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35             : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36             : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37             : //
      38             : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39             : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40             : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41             : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42             : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43             : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44             : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45             : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46             : // POSSIBILITY OF SUCH DAMAGE.
      47             : 
      48             : // 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      263711 : void SimIHP(EnergyPlusData &state,
      77             :             std::string_view CompName,             // Coil Name
      78             :             int &CompIndex,                        // Index for Component name
      79             :             HVAC::FanOp const fanOp,               // Continuous fan OR cycling compressor
      80             :             HVAC::CompressorOp const compressorOp, // compressor on/off. 0 = off; 1= on
      81             :             Real64 const PartLoadFrac,             // part load fraction
      82             :             int const SpeedNum,                    // compressor speed number
      83             :             Real64 const SpeedRatio,               // compressor speed ratio
      84             :             Real64 const SensLoad,                 // Sensible demand load [W]
      85             :             Real64 const LatentLoad,               // Latent demand load [W]
      86             :             bool const IsCallbyWH,                 // whether the call from the water heating loop or air loop, true = from water heating loop
      87             :             [[maybe_unused]] bool const FirstHVACIteration,   // TRUE if First iteration of simulation
      88             :             ObjexxFCL::Optional<Real64 const> OnOffAirFlowRat // ratio of comp on to comp off air flow rate
      89             : )
      90             : {
      91             : 
      92             :     //       AUTHOR         Bo Shen, ORNL
      93             :     //       DATE WRITTEN   March 2016
      94             :     //       RE-ENGINEERED  na
      95             : 
      96             :     // PURPOSE OF THIS SUBROUTINE:
      97             :     // This subroutine manages variable-speed integrated Air source heat pump simulation.
      98             : 
      99             :     // Using/Aliasing
     100             :     using VariableSpeedCoils::InitVarSpeedCoil;
     101             :     using VariableSpeedCoils::SimVariableSpeedCoils;
     102             :     using VariableSpeedCoils::UpdateVarSpeedCoil;
     103             : 
     104             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     105      263711 :     int DXCoilNum(0); // The IHP No that you are currently dealing with
     106             : 
     107             :     // Obtains and Allocates ASIHP related parameters from input file
     108      263711 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
     109           0 :         GetIHPInput(state);
     110           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
     111             :     }
     112             : 
     113      263711 :     if (CompIndex == 0) {
     114           0 :         DXCoilNum = Util::FindItemInList(CompName, state.dataIntegratedHP->IntegratedHeatPumps);
     115           0 :         if (DXCoilNum == 0) {
     116           0 :             ShowFatalError(state, format("Integrated Heat Pump not found={}", CompName));
     117             :         }
     118           0 :         CompIndex = DXCoilNum;
     119             :     } else {
     120      263711 :         DXCoilNum = CompIndex;
     121      263711 :         if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
     122           0 :             ShowFatalError(state,
     123           0 :                            format("SimIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name={}",
     124             :                                   DXCoilNum,
     125           0 :                                   state.dataIntegratedHP->IntegratedHeatPumps.size(),
     126             :                                   CompName));
     127             :         }
     128      263711 :         if (!CompName.empty() && CompName != state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum).Name) {
     129           0 :             ShowFatalError(state,
     130           0 :                            format("SimIHP: Invalid CompIndex passed={}, Integrated HP name={}, stored Integrated HP Name for that index={}",
     131             :                                   DXCoilNum,
     132             :                                   CompName,
     133           0 :                                   state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum).Name));
     134             :         }
     135             :     };
     136             : 
     137      263711 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
     138             : 
     139      263711 :     if (!ihp.IHPCoilsSized) SizeIHP(state, DXCoilNum);
     140             : 
     141      263711 :     InitializeIHP(state, DXCoilNum);
     142             : 
     143      263711 :     Real64 airMassFlowRate = state.dataLoopNodes->Node(ihp.AirCoolInletNodeNum).MassFlowRate;
     144      263711 :     ihp.AirLoopFlowRate = airMassFlowRate;
     145             : 
     146      263711 :     switch (ihp.CurMode) {
     147       68656 :     case IHPOperationMode::SpaceClg:
     148       68656 :         if (!IsCallbyWH) // process when called from air loop
     149             :         {
     150       65528 :             SimVariableSpeedCoils(state, std::string(), ihp.SCDWHCoolCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     151       65528 :             SimVariableSpeedCoils(state, std::string(), ihp.SCDWHWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     152       65528 :             SimVariableSpeedCoils(state, std::string(), ihp.SHDWHHeatCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     153       65528 :             SimVariableSpeedCoils(state, std::string(), ihp.SHDWHWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     154       65528 :             SimVariableSpeedCoils(state, std::string(), ihp.SCWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     155       65528 :             SimVariableSpeedCoils(state, std::string(), ihp.DWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     156             : 
     157      131056 :             SimVariableSpeedCoils(state,
     158       65528 :                                   std::string(),
     159       65528 :                                   ihp.SCCoilIndex,
     160             :                                   fanOp,
     161             :                                   compressorOp,
     162             :                                   PartLoadFrac,
     163             :                                   SpeedNum,
     164             :                                   SpeedRatio,
     165             :                                   SensLoad,
     166             :                                   LatentLoad,
     167             :                                   OnOffAirFlowRat);
     168             : 
     169       65528 :             SimVariableSpeedCoils(state, std::string(), ihp.SHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     170             : 
     171       65528 :             ihp.AirFlowSavInAirLoop = airMassFlowRate;
     172             :         }
     173             : 
     174       68656 :         ihp.TankSourceWaterMassFlowRate = 0.0;
     175       68656 :         break;
     176       74506 :     case IHPOperationMode::SpaceHtg:
     177       74506 :         if (!IsCallbyWH) // process when called from air loop
     178             :         {
     179       74504 :             SimVariableSpeedCoils(state, std::string(), ihp.SCDWHCoolCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     180       74504 :             SimVariableSpeedCoils(state, std::string(), ihp.SCDWHWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     181       74504 :             SimVariableSpeedCoils(state, std::string(), ihp.SHDWHHeatCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     182       74504 :             SimVariableSpeedCoils(state, std::string(), ihp.SHDWHWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     183       74504 :             SimVariableSpeedCoils(state, std::string(), ihp.SCWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     184       74504 :             SimVariableSpeedCoils(state, std::string(), ihp.SCCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     185       74504 :             SimVariableSpeedCoils(state, std::string(), ihp.DWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     186             : 
     187      149008 :             SimVariableSpeedCoils(state,
     188       74504 :                                   std::string(),
     189       74504 :                                   ihp.SHCoilIndex,
     190             :                                   fanOp,
     191             :                                   compressorOp,
     192             :                                   PartLoadFrac,
     193             :                                   SpeedNum,
     194             :                                   SpeedRatio,
     195             :                                   SensLoad,
     196             :                                   LatentLoad,
     197             :                                   OnOffAirFlowRat);
     198             : 
     199       74504 :             ihp.AirFlowSavInAirLoop = airMassFlowRate;
     200             :         }
     201       74506 :         ihp.TankSourceWaterMassFlowRate = 0.0;
     202       74506 :         break;
     203        2336 :     case IHPOperationMode::DedicatedWaterHtg:
     204        2336 :         if (IsCallbyWH) // process when called from water loop
     205             :         {
     206        1440 :             SimVariableSpeedCoils(state, std::string(), ihp.SCDWHCoolCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     207        1440 :             SimVariableSpeedCoils(state, std::string(), ihp.SCDWHWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     208        1440 :             SimVariableSpeedCoils(state, std::string(), ihp.SHDWHHeatCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     209        1440 :             SimVariableSpeedCoils(state, std::string(), ihp.SHDWHWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     210        1440 :             SimVariableSpeedCoils(state, std::string(), ihp.SCWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     211        1440 :             SimVariableSpeedCoils(state, std::string(), ihp.SCCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     212        1440 :             SimVariableSpeedCoils(state, std::string(), ihp.SHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     213             : 
     214        2880 :             SimVariableSpeedCoils(state,
     215        1440 :                                   std::string(),
     216        1440 :                                   ihp.DWHCoilIndex,
     217             :                                   fanOp,
     218             :                                   compressorOp,
     219             :                                   PartLoadFrac,
     220             :                                   SpeedNum,
     221             :                                   SpeedRatio,
     222             :                                   SensLoad,
     223             :                                   LatentLoad,
     224             :                                   OnOffAirFlowRat);
     225             :             // IntegratedHeatPumps(DXCoilNum).TotalHeatingEnergyRate =
     226             :             // VarSpeedCoil(IntegratedHeatPumps(DXCoilNum).DWHCoilIndex).TotalHeatingEnergyRate;
     227             :         }
     228             : 
     229        2336 :         ihp.TankSourceWaterMassFlowRate = state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate;
     230        2336 :         break;
     231           0 :     case IHPOperationMode::SCWHMatchSC:
     232           0 :         if (!IsCallbyWH) // process when called from air loop
     233             :         {
     234           0 :             SimVariableSpeedCoils(state, std::string(), ihp.SCDWHCoolCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     235           0 :             SimVariableSpeedCoils(state, std::string(), ihp.SCDWHWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     236           0 :             SimVariableSpeedCoils(state, std::string(), ihp.SHDWHHeatCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     237           0 :             SimVariableSpeedCoils(state, std::string(), ihp.SHDWHWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     238           0 :             SimVariableSpeedCoils(state, std::string(), ihp.SCCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     239           0 :             SimVariableSpeedCoils(state, std::string(), ihp.DWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     240             : 
     241           0 :             SimVariableSpeedCoils(state,
     242           0 :                                   std::string(),
     243           0 :                                   ihp.SCWHCoilIndex,
     244             :                                   fanOp,
     245             :                                   compressorOp,
     246             :                                   PartLoadFrac,
     247             :                                   SpeedNum,
     248             :                                   SpeedRatio,
     249             :                                   SensLoad,
     250             :                                   LatentLoad,
     251             :                                   OnOffAirFlowRat);
     252             : 
     253           0 :             SimVariableSpeedCoils(state, std::string(), ihp.SHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     254             : 
     255           0 :             ihp.AirFlowSavInAirLoop = airMassFlowRate;
     256             :         }
     257             : 
     258           0 :         ihp.TankSourceWaterMassFlowRate = state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate;
     259             : 
     260           0 :         break;
     261        3472 :     case IHPOperationMode::SCWHMatchWH:
     262        3472 :         if (IsCallbyWH) // process when called from water loop
     263             :         {
     264        2128 :             SimVariableSpeedCoils(state, std::string(), ihp.SCDWHCoolCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     265        2128 :             SimVariableSpeedCoils(state, std::string(), ihp.SCDWHWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     266        2128 :             SimVariableSpeedCoils(state, std::string(), ihp.SHDWHHeatCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     267        2128 :             SimVariableSpeedCoils(state, std::string(), ihp.SHDWHWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     268        2128 :             SimVariableSpeedCoils(state, std::string(), ihp.SCCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     269        2128 :             SimVariableSpeedCoils(state, std::string(), ihp.DWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     270             : 
     271        4256 :             SimVariableSpeedCoils(state,
     272        2128 :                                   std::string(),
     273        2128 :                                   ihp.SCWHCoilIndex,
     274             :                                   fanOp,
     275             :                                   compressorOp,
     276             :                                   PartLoadFrac,
     277             :                                   SpeedNum,
     278             :                                   SpeedRatio,
     279             :                                   SensLoad,
     280             :                                   LatentLoad,
     281             :                                   OnOffAirFlowRat);
     282             : 
     283        2128 :             SimVariableSpeedCoils(state, std::string(), ihp.SHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     284             : 
     285        2128 :             ihp.AirFlowSavInWaterLoop = airMassFlowRate;
     286             :         }
     287             : 
     288        3472 :         ihp.TankSourceWaterMassFlowRate = state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate;
     289        3472 :         break;
     290      102224 :     case IHPOperationMode::SpaceClgDedicatedWaterHtg:
     291      102224 :         if (!IsCallbyWH) // process when called from air loop
     292             :         {
     293       96496 :             SimVariableSpeedCoils(state, std::string(), ihp.SHDWHHeatCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     294       96496 :             SimVariableSpeedCoils(state, std::string(), ihp.SHDWHWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     295       96496 :             SimVariableSpeedCoils(state, std::string(), ihp.SCWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     296       96496 :             SimVariableSpeedCoils(state, std::string(), ihp.SCCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     297       96496 :             SimVariableSpeedCoils(state, std::string(), ihp.DWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     298             : 
     299      192992 :             SimVariableSpeedCoils(state,
     300       96496 :                                   std::string(),
     301       96496 :                                   ihp.SCDWHWHCoilIndex,
     302             :                                   fanOp,
     303             :                                   compressorOp,
     304             :                                   PartLoadFrac,
     305             :                                   SpeedNum,
     306             :                                   SpeedRatio,
     307             :                                   SensLoad,
     308             :                                   LatentLoad,
     309             :                                   OnOffAirFlowRat);
     310      192992 :             SimVariableSpeedCoils(state,
     311       96496 :                                   std::string(),
     312       96496 :                                   ihp.SCDWHCoolCoilIndex,
     313             :                                   fanOp,
     314             :                                   compressorOp,
     315             :                                   PartLoadFrac,
     316             :                                   SpeedNum,
     317             :                                   SpeedRatio,
     318             :                                   SensLoad,
     319             :                                   LatentLoad,
     320             :                                   OnOffAirFlowRat);
     321             : 
     322       96496 :             SimVariableSpeedCoils(state, std::string(), ihp.SHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     323             : 
     324       96496 :             ihp.AirFlowSavInAirLoop = airMassFlowRate;
     325             :         }
     326             : 
     327      102224 :         ihp.TankSourceWaterMassFlowRate = state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate;
     328      102224 :         break;
     329           0 :     case IHPOperationMode::SHDWHElecHeatOff:
     330             :     case IHPOperationMode::SHDWHElecHeatOn:
     331           0 :         if (!IsCallbyWH) // process when called from air loop
     332             :         {
     333           0 :             SimVariableSpeedCoils(state, std::string(), ihp.SCDWHCoolCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     334           0 :             SimVariableSpeedCoils(state, std::string(), ihp.SCDWHWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     335           0 :             SimVariableSpeedCoils(state, std::string(), ihp.SCWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     336           0 :             SimVariableSpeedCoils(state, std::string(), ihp.SCCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     337           0 :             SimVariableSpeedCoils(state, std::string(), ihp.SHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     338           0 :             SimVariableSpeedCoils(state, std::string(), ihp.DWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     339             : 
     340           0 :             SimVariableSpeedCoils(state,
     341           0 :                                   std::string(),
     342           0 :                                   ihp.SHDWHWHCoilIndex,
     343             :                                   fanOp,
     344             :                                   compressorOp,
     345             :                                   PartLoadFrac,
     346             :                                   SpeedNum,
     347             :                                   SpeedRatio,
     348             :                                   SensLoad,
     349             :                                   LatentLoad,
     350             :                                   OnOffAirFlowRat);
     351           0 :             SimVariableSpeedCoils(state,
     352           0 :                                   std::string(),
     353           0 :                                   ihp.SHDWHHeatCoilIndex,
     354             :                                   fanOp,
     355             :                                   compressorOp,
     356             :                                   PartLoadFrac,
     357             :                                   SpeedNum,
     358             :                                   SpeedRatio,
     359             :                                   SensLoad,
     360             :                                   LatentLoad,
     361             :                                   OnOffAirFlowRat);
     362             : 
     363           0 :             ihp.AirFlowSavInAirLoop = airMassFlowRate;
     364             :         }
     365             : 
     366           0 :         ihp.TankSourceWaterMassFlowRate = state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate;
     367           0 :         break;
     368       12517 :     case IHPOperationMode::Idle:
     369             :     default: // clear up
     370       12517 :         SimVariableSpeedCoils(state, std::string(), ihp.SCDWHCoolCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     371       12517 :         SimVariableSpeedCoils(state, std::string(), ihp.SCDWHWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     372       12517 :         SimVariableSpeedCoils(state, std::string(), ihp.SHDWHHeatCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     373       12517 :         SimVariableSpeedCoils(state, std::string(), ihp.SHDWHWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     374       12517 :         SimVariableSpeedCoils(state, std::string(), ihp.SCWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     375       12517 :         SimVariableSpeedCoils(state, std::string(), ihp.SCCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     376       12517 :         SimVariableSpeedCoils(state, std::string(), ihp.SHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     377       12517 :         SimVariableSpeedCoils(state, std::string(), ihp.DWHCoilIndex, fanOp, compressorOp, 0.0, 1, 0.0, 0.0, 0.0, OnOffAirFlowRat);
     378       12517 :         ihp.TankSourceWaterMassFlowRate = 0.0;
     379       12517 :         ihp.AirFlowSavInAirLoop = 0.0;
     380       12517 :         ihp.AirFlowSavInWaterLoop = 0.0;
     381       12517 :         break;
     382             :     }
     383             : 
     384      263711 :     UpdateIHP(state, DXCoilNum);
     385      263711 : }
     386             : 
     387           3 : void GetIHPInput(EnergyPlusData &state)
     388             : {
     389             : 
     390             :     // SUBROUTINE INFORMATION:
     391             :     //       AUTHOR         Bo Shen
     392             :     //       DATE WRITTEN   December, 2015
     393             :     //       RE-ENGINEERED  na
     394             : 
     395             :     // PURPOSE OF THIS SUBROUTINE:
     396             :     // Obtains input data for Integrated HPs and stores it in IHP data structures
     397             : 
     398             :     // METHODOLOGY EMPLOYED:
     399             :     // Uses "Get" routines to read in data.
     400             : 
     401             :     // Using/Aliasing
     402             :     using namespace NodeInputManager;
     403             :     using BranchNodeConnections::OverrideNodeConnectionType;
     404             :     using BranchNodeConnections::RegisterNodeConnection;
     405             :     using BranchNodeConnections::SetUpCompSets;
     406             :     using BranchNodeConnections::TestCompSet;
     407             :     using GlobalNames::VerifyUniqueCoilName;
     408             :     using VariableSpeedCoils::GetCoilIndexVariableSpeed;
     409             : 
     410             :     // SUBROUTINE PARAMETER DEFINITIONS:
     411             :     static constexpr std::string_view RoutineName("GetIHPInput: "); // include trailing blank space
     412             : 
     413             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     414             :     int NumAlphas;                   // Number of variables in String format
     415             :     int NumNums;                     // Number of variables in Numeric format
     416             :     int NumParams;                   // Total number of input fields
     417           3 :     int MaxNums(0);                  // Maximum number of numeric input fields
     418           3 :     int MaxAlphas(0);                // Maximum number of alpha input fields
     419           3 :     std::string InNodeName;          // Name of coil inlet node
     420           3 :     std::string OutNodeName;         // Name of coil outlet node
     421           3 :     std::string CurrentModuleObject; // for ease in getting objects
     422           3 :     std::string sIHPType;            // specify IHP type
     423           3 :     Array1D_string AlphArray;        // Alpha input items for object
     424           3 :     Array1D_string cAlphaFields;     // Alpha field names
     425           3 :     Array1D_string cNumericFields;   // Numeric field names
     426           3 :     Array1D<Real64> NumArray;        // Numeric input items for object
     427           3 :     Array1D_bool lAlphaBlanks;       // Logical array, alpha field input BLANK = .TRUE.
     428           3 :     Array1D_bool lNumericBlanks;     // Logical array, numeric field input BLANK = .TRUE.
     429             : 
     430           3 :     bool ErrorsFound(false); // If errors detected in input
     431             :     bool IsNotOK;            // Flag to verify name
     432             :     bool errFlag;
     433             :     int IOStat;
     434           3 :     int InNode(0);         // inlet air or water node
     435           3 :     int OutNode(0);        // outlet air or water node
     436           3 :     int ChildCoilIndex(0); // refer to a child coil
     437             : 
     438           3 :     int NumASIHPs = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "COILSYSTEM:INTEGRATEDHEATPUMP:AIRSOURCE");
     439             : 
     440           3 :     if (NumASIHPs <= 0) return;
     441             : 
     442             :     // Allocate Arrays
     443           1 :     state.dataIntegratedHP->IntegratedHeatPumps.allocate(NumASIHPs);
     444             : 
     445             :     // air-source integrated heat pump
     446           1 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "COILSYSTEM:INTEGRATEDHEATPUMP:AIRSOURCE", NumParams, NumAlphas, NumNums);
     447           1 :     MaxNums = max(MaxNums, NumNums);
     448           1 :     MaxAlphas = max(MaxAlphas, NumAlphas);
     449             : 
     450           1 :     AlphArray.allocate(MaxAlphas);
     451           1 :     cAlphaFields.allocate(MaxAlphas);
     452           1 :     lAlphaBlanks.dimension(MaxAlphas, true);
     453           1 :     cNumericFields.allocate(MaxNums);
     454           1 :     lNumericBlanks.dimension(MaxNums, true);
     455           1 :     NumArray.dimension(MaxNums, 0.0);
     456             : 
     457             :     // Get the data for air-source IHPs
     458           1 :     CurrentModuleObject = "COILSYSTEM:INTEGRATEDHEATPUMP:AIRSOURCE"; // for reporting
     459           1 :     sIHPType = "COILSYSTEM:INTEGRATEDHEATPUMP:AIRSOURCE";            // for checking
     460             : 
     461           2 :     for (int CoilCounter = 1; CoilCounter <= NumASIHPs; ++CoilCounter) {
     462             : 
     463           1 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
     464             :                                                                  CurrentModuleObject,
     465             :                                                                  CoilCounter,
     466             :                                                                  AlphArray,
     467             :                                                                  NumAlphas,
     468             :                                                                  NumArray,
     469             :                                                                  NumNums,
     470             :                                                                  IOStat,
     471             :                                                                  lNumericBlanks,
     472             :                                                                  lAlphaBlanks,
     473             :                                                                  cAlphaFields,
     474             :                                                                  cNumericFields);
     475             : 
     476             :         // ErrorsFound will be set to True if problem was found, left untouched otherwise
     477           1 :         VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, CurrentModuleObject + " Name");
     478             : 
     479           1 :         auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(CoilCounter);
     480             : 
     481           1 :         ihp.Name = AlphArray(1);
     482           1 :         ihp.IHPtype = "AIRSOURCE_IHP";
     483             : 
     484             :         // AlphArray( 2 ) is the water sensor node
     485             : 
     486           1 :         ihp.SCCoilType = "COIL:COOLING:DX:VARIABLESPEED";
     487           1 :         ihp.SCCoilName = AlphArray(3);
     488           1 :         ihp.SCCoilTypeNum = DataLoopNode::ConnectionObjectType::CoilCoolingDXVariableSpeed;
     489             : 
     490           1 :         ValidateComponent(state, ihp.SCCoilType, ihp.SCCoilName, IsNotOK, CurrentModuleObject);
     491           1 :         if (IsNotOK) {
     492           0 :             ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
     493           0 :             ErrorsFound = true;
     494             :         } else {
     495           1 :             errFlag = false;
     496           1 :             ihp.SCCoilIndex = GetCoilIndexVariableSpeed(state, ihp.SCCoilType, ihp.SCCoilName, errFlag);
     497           1 :             if (errFlag) {
     498           0 :                 ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
     499           0 :                 ErrorsFound = true;
     500             :             }
     501             :         }
     502             : 
     503           1 :         ihp.SHCoilType = "COIL:HEATING:DX:VARIABLESPEED";
     504           1 :         ihp.SHCoilName = AlphArray(4);
     505           1 :         ihp.SHCoilTypeNum = DataLoopNode::ConnectionObjectType::CoilHeatingDXVariableSpeed;
     506             : 
     507           1 :         ValidateComponent(state, ihp.SHCoilType, ihp.SHCoilName, IsNotOK, CurrentModuleObject);
     508           1 :         if (IsNotOK) {
     509           0 :             ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
     510           0 :             ErrorsFound = true;
     511             :         } else {
     512           1 :             errFlag = false;
     513           1 :             ihp.SHCoilIndex = GetCoilIndexVariableSpeed(state, ihp.SHCoilType, ihp.SHCoilName, errFlag);
     514           1 :             if (errFlag) {
     515           0 :                 ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
     516           0 :                 ErrorsFound = true;
     517             :             }
     518             :         }
     519             : 
     520           1 :         ihp.DWHCoilType = "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED";
     521           1 :         ihp.DWHCoilName = AlphArray(5);
     522           1 :         ihp.DWHCoilTypeNum = DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpVariableSpeed;
     523             : 
     524           1 :         ValidateComponent(state, ihp.DWHCoilType, ihp.DWHCoilName, IsNotOK, CurrentModuleObject);
     525           1 :         if (IsNotOK) {
     526           0 :             ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
     527           0 :             ErrorsFound = true;
     528             :         } else {
     529           1 :             errFlag = false;
     530           1 :             ihp.DWHCoilIndex = GetCoilIndexVariableSpeed(state, ihp.DWHCoilType, ihp.DWHCoilName, errFlag);
     531           1 :             if (errFlag) {
     532           0 :                 ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
     533           0 :                 ErrorsFound = true;
     534             :             }
     535             :         }
     536             : 
     537           1 :         ihp.SCWHCoilType = "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED";
     538           1 :         ihp.SCWHCoilName = AlphArray(6);
     539           1 :         ihp.SCWHCoilTypeNum = DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpVariableSpeed;
     540             : 
     541           1 :         ValidateComponent(state, ihp.SCWHCoilType, ihp.SCWHCoilName, IsNotOK, CurrentModuleObject);
     542           1 :         if (IsNotOK) {
     543           0 :             ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
     544           0 :             ErrorsFound = true;
     545             :         } else {
     546           1 :             errFlag = false;
     547           1 :             ihp.SCWHCoilIndex = GetCoilIndexVariableSpeed(state, ihp.SCWHCoilType, ihp.SCWHCoilName, errFlag);
     548           1 :             if (errFlag) {
     549           0 :                 ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
     550           0 :                 ErrorsFound = true;
     551             :             }
     552             :         }
     553             : 
     554           1 :         ihp.SCDWHCoolCoilType = "COIL:COOLING:DX:VARIABLESPEED";
     555           1 :         ihp.SCDWHCoolCoilName = AlphArray(7);
     556           1 :         ihp.SCDWHCoolCoilTypeNum = DataLoopNode::ConnectionObjectType::CoilCoolingDXVariableSpeed;
     557             : 
     558           1 :         ValidateComponent(state, ihp.SCDWHCoolCoilType, ihp.SCDWHCoolCoilName, IsNotOK, CurrentModuleObject);
     559           1 :         if (IsNotOK) {
     560           0 :             ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
     561           0 :             ErrorsFound = true;
     562             :         } else {
     563           1 :             errFlag = false;
     564           1 :             ihp.SCDWHCoolCoilIndex = GetCoilIndexVariableSpeed(state, ihp.SCDWHCoolCoilType, ihp.SCDWHCoolCoilName, errFlag);
     565           1 :             if (errFlag) {
     566           0 :                 ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
     567           0 :                 ErrorsFound = true;
     568             :             }
     569             :         }
     570             : 
     571           1 :         ihp.SCDWHWHCoilType = "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED";
     572           1 :         ihp.SCDWHWHCoilName = AlphArray(8);
     573           1 :         ihp.SCDWHWHCoilTypeNum = DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpVariableSpeed;
     574             : 
     575           1 :         ValidateComponent(state, ihp.SCDWHWHCoilType, ihp.SCDWHWHCoilName, IsNotOK, CurrentModuleObject);
     576           1 :         if (IsNotOK) {
     577           0 :             ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
     578           0 :             ErrorsFound = true;
     579             :         } else {
     580           1 :             errFlag = false;
     581           1 :             ihp.SCDWHWHCoilIndex = GetCoilIndexVariableSpeed(state, ihp.SCDWHWHCoilType, ihp.SCDWHWHCoilName, errFlag);
     582           1 :             if (errFlag) {
     583           0 :                 ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
     584           0 :                 ErrorsFound = true;
     585             :             } else {
     586           1 :                 state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHWHCoilIndex).bIsDesuperheater = true;
     587             :             }
     588             :         }
     589             : 
     590           1 :         ihp.SHDWHHeatCoilType = "COIL:HEATING:DX:VARIABLESPEED";
     591           1 :         ihp.SHDWHHeatCoilName = AlphArray(9);
     592           1 :         ihp.SHDWHHeatCoilTypeNum = DataLoopNode::ConnectionObjectType::CoilHeatingDXVariableSpeed;
     593             : 
     594           1 :         ValidateComponent(state, ihp.SHDWHHeatCoilType, ihp.SHDWHHeatCoilName, IsNotOK, CurrentModuleObject);
     595           1 :         if (IsNotOK) {
     596           0 :             ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
     597           0 :             ErrorsFound = true;
     598             :         } else {
     599           1 :             errFlag = false;
     600           1 :             ihp.SHDWHHeatCoilIndex = GetCoilIndexVariableSpeed(state, ihp.SHDWHHeatCoilType, ihp.SHDWHHeatCoilName, errFlag);
     601           1 :             if (errFlag) {
     602           0 :                 ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
     603           0 :                 ErrorsFound = true;
     604             :             }
     605             :         }
     606             : 
     607           1 :         ihp.SHDWHWHCoilType = "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED";
     608           1 :         ihp.SHDWHWHCoilName = AlphArray(10);
     609           1 :         ihp.SHDWHWHCoilTypeNum = DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpVariableSpeed;
     610             : 
     611           1 :         ValidateComponent(state, ihp.SHDWHWHCoilType, ihp.SHDWHWHCoilName, IsNotOK, CurrentModuleObject);
     612           1 :         if (IsNotOK) {
     613           0 :             ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
     614           0 :             ErrorsFound = true;
     615             :         } else {
     616           1 :             errFlag = false;
     617           1 :             ihp.SHDWHWHCoilIndex = GetCoilIndexVariableSpeed(state, ihp.SHDWHWHCoilType, ihp.SHDWHWHCoilName, errFlag);
     618           1 :             if (errFlag) {
     619           0 :                 ShowContinueError(state, format("...specified in {}=\"{}\".", CurrentModuleObject, AlphArray(1)));
     620           0 :                 ErrorsFound = true;
     621             :             } else {
     622           1 :                 state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).bIsDesuperheater = true;
     623             :             }
     624             :         }
     625             : 
     626           1 :         ihp.TindoorOverCoolAllow = NumArray(1);
     627           1 :         ihp.TambientOverCoolAllow = NumArray(2);
     628           1 :         ihp.TindoorWHHighPriority = NumArray(3);
     629           1 :         ihp.TambientWHHighPriority = NumArray(4);
     630           1 :         ihp.ModeMatchSCWH = int(NumArray(5));
     631           1 :         ihp.MinSpedSCWH = int(NumArray(6));
     632           1 :         ihp.WaterVolSCDWH = NumArray(7);
     633           1 :         ihp.MinSpedSCDWH = int(NumArray(8));
     634           1 :         ihp.TimeLimitSHDWH = NumArray(9);
     635           1 :         ihp.MinSpedSHDWH = int(NumArray(10));
     636             : 
     637             :         // Due to the overlapping coil objects, compsets and node registrations are handled as follows:
     638             :         //  1. The ASIHP coil object is registered as four different coils, Name+" Cooling Coil", Name+" Heating Coil",
     639             :         //     Name+" Outdoor Coil", and Name+" Water Coil"
     640             :         //  2. For each of these four coils, TestCompSet is called once to register it as a child object
     641             :         //  3. For each of these four coils, RegisterNodeConnection is called twice to register the inlet and outlet nodes
     642             :         //     RegisterNodeConnection is used instead of GetOnlySingleNode because the node names are not inputs here
     643             :         //  4. The parent objects that reference the ASIHP coil must use the appropriate name suffixes when calling SetUpCompSets
     644             :         //  5. The ASIHP calls SetUpCompSets to register the various child coils.  This is important so that the system energy
     645             :         //     use is collected in SystemReports::CalcSystemEnergyUse
     646             :         //  6. The child coil inlet/outlet node connections are reset to connection type "Internal" to avoid duplicate node problems
     647             :         //     using OverrideNodeConnectionType
     648             : 
     649             :         // cooling coil air node connections
     650           1 :         ChildCoilIndex = ihp.SCCoilIndex;
     651           1 :         InNode = state.dataVariableSpeedCoils->VarSpeedCoil(ChildCoilIndex).AirInletNodeNum;
     652           1 :         OutNode = state.dataVariableSpeedCoils->VarSpeedCoil(ChildCoilIndex).AirOutletNodeNum;
     653           1 :         InNodeName = state.dataLoopNodes->NodeID(InNode);
     654           1 :         OutNodeName = state.dataLoopNodes->NodeID(OutNode);
     655             : 
     656           1 :         ihp.AirCoolInletNodeNum = InNode;
     657           1 :         ihp.AirHeatInletNodeNum = OutNode;
     658             : 
     659           1 :         TestCompSet(state, CurrentModuleObject, ihp.Name + " Cooling Coil", InNodeName, OutNodeName, "Cooling Air Nodes");
     660           3 :         RegisterNodeConnection(state,
     661             :                                InNode,
     662           1 :                                state.dataLoopNodes->NodeID(InNode),
     663             :                                DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
     664           2 :                                ihp.Name + " Cooling Coil",
     665             :                                DataLoopNode::ConnectionType::Inlet,
     666             :                                NodeInputManager::CompFluidStream::Primary,
     667             :                                ObjectIsNotParent,
     668             :                                ErrorsFound);
     669           3 :         RegisterNodeConnection(state,
     670             :                                OutNode,
     671           1 :                                state.dataLoopNodes->NodeID(OutNode),
     672             :                                DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
     673           2 :                                ihp.Name + " Cooling Coil",
     674             :                                DataLoopNode::ConnectionType::Outlet,
     675             :                                NodeInputManager::CompFluidStream::Primary,
     676             :                                ObjectIsNotParent,
     677             :                                ErrorsFound);
     678             : 
     679           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Cooling Coil", ihp.SCCoilType, ihp.SCCoilName, InNodeName, OutNodeName);
     680           1 :         OverrideNodeConnectionType(state,
     681             :                                    InNode,
     682             :                                    InNodeName,
     683             :                                    ihp.SCCoilTypeNum,
     684           1 :                                    ihp.SCCoilName,
     685             :                                    DataLoopNode::ConnectionType::Internal,
     686             :                                    NodeInputManager::CompFluidStream::Primary,
     687             :                                    ObjectIsNotParent,
     688             :                                    ErrorsFound);
     689           1 :         OverrideNodeConnectionType(state,
     690             :                                    OutNode,
     691             :                                    OutNodeName,
     692             :                                    ihp.SCCoilTypeNum,
     693           1 :                                    ihp.SCCoilName,
     694             :                                    DataLoopNode::ConnectionType::Internal,
     695             :                                    NodeInputManager::CompFluidStream::Primary,
     696             :                                    ObjectIsNotParent,
     697             :                                    ErrorsFound);
     698             : 
     699           2 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).AirInletNodeNum != InNode) ||
     700           1 :             (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).AirOutletNodeNum != OutNode)) {
     701           0 :             ShowContinueError(state, format("Mistaken air node connection: {}{}-wrong coil node names.", CurrentModuleObject, ihp.SCWHCoilName));
     702           0 :             ErrorsFound = true;
     703             :         }
     704           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Cooling Coil", ihp.SCWHCoilType, ihp.SCWHCoilName, InNodeName, OutNodeName);
     705           1 :         OverrideNodeConnectionType(state,
     706             :                                    InNode,
     707             :                                    InNodeName,
     708             :                                    ihp.SCWHCoilTypeNum,
     709           1 :                                    ihp.SCWHCoilName,
     710             :                                    DataLoopNode::ConnectionType::Internal,
     711             :                                    NodeInputManager::CompFluidStream::Primary,
     712             :                                    ObjectIsNotParent,
     713             :                                    ErrorsFound);
     714           1 :         OverrideNodeConnectionType(state,
     715             :                                    OutNode,
     716             :                                    OutNodeName,
     717             :                                    ihp.SCWHCoilTypeNum,
     718           1 :                                    ihp.SCWHCoilName,
     719             :                                    DataLoopNode::ConnectionType::Internal,
     720             :                                    NodeInputManager::CompFluidStream::Primary,
     721             :                                    ObjectIsNotParent,
     722             :                                    ErrorsFound);
     723             : 
     724           2 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).AirInletNodeNum != InNode) ||
     725           1 :             (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).AirOutletNodeNum != OutNode)) {
     726           0 :             ShowContinueError(state, format("Mistaken air node connection: {}{}-wrong coil node names.", CurrentModuleObject, ihp.SCDWHCoolCoilName));
     727           0 :             ErrorsFound = true;
     728             :         }
     729           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Cooling Coil", ihp.SCDWHCoolCoilType, ihp.SCDWHCoolCoilName, InNodeName, OutNodeName);
     730           1 :         OverrideNodeConnectionType(state,
     731             :                                    InNode,
     732             :                                    InNodeName,
     733             :                                    ihp.SCDWHCoolCoilTypeNum,
     734           1 :                                    ihp.SCDWHCoolCoilName,
     735             :                                    DataLoopNode::ConnectionType::Internal,
     736             :                                    NodeInputManager::CompFluidStream::Primary,
     737             :                                    ObjectIsNotParent,
     738             :                                    ErrorsFound);
     739           1 :         OverrideNodeConnectionType(state,
     740             :                                    OutNode,
     741             :                                    OutNodeName,
     742             :                                    ihp.SCDWHCoolCoilTypeNum,
     743           1 :                                    ihp.SCDWHCoolCoilName,
     744             :                                    DataLoopNode::ConnectionType::Internal,
     745             :                                    NodeInputManager::CompFluidStream::Primary,
     746             :                                    ObjectIsNotParent,
     747             :                                    ErrorsFound);
     748             : 
     749             :         // heating coil air node connections
     750           1 :         ChildCoilIndex = ihp.SHCoilIndex;
     751             : 
     752           1 :         InNode = ihp.AirHeatInletNodeNum;
     753           1 :         OutNode = state.dataVariableSpeedCoils->VarSpeedCoil(ChildCoilIndex).AirOutletNodeNum;
     754           1 :         ihp.AirOutletNodeNum = OutNode;
     755           1 :         InNodeName = state.dataLoopNodes->NodeID(InNode);
     756           1 :         OutNodeName = state.dataLoopNodes->NodeID(OutNode);
     757           1 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(ChildCoilIndex).AirInletNodeNum != InNode) {
     758           0 :             ShowContinueError(state,
     759           0 :                               format("Mistaken air node connection: {}- cooling coil outlet mismatches heating coil inlet.", CurrentModuleObject));
     760           0 :             ErrorsFound = true;
     761             :         }
     762           1 :         TestCompSet(state, CurrentModuleObject, ihp.Name + " Heating Coil", InNodeName, OutNodeName, "Heating Air Nodes");
     763           3 :         RegisterNodeConnection(state,
     764             :                                InNode,
     765           1 :                                state.dataLoopNodes->NodeID(InNode),
     766             :                                DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
     767           2 :                                ihp.Name + " Heating Coil",
     768             :                                DataLoopNode::ConnectionType::Inlet,
     769             :                                NodeInputManager::CompFluidStream::Primary,
     770             :                                ObjectIsNotParent,
     771             :                                ErrorsFound);
     772           3 :         RegisterNodeConnection(state,
     773             :                                OutNode,
     774           1 :                                state.dataLoopNodes->NodeID(OutNode),
     775             :                                DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
     776           2 :                                ihp.Name + " Heating Coil",
     777             :                                DataLoopNode::ConnectionType::Outlet,
     778             :                                NodeInputManager::CompFluidStream::Primary,
     779             :                                ObjectIsNotParent,
     780             :                                ErrorsFound);
     781             : 
     782           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Heating Coil", ihp.SHCoilType, ihp.SHCoilName, InNodeName, OutNodeName);
     783           1 :         OverrideNodeConnectionType(state,
     784             :                                    InNode,
     785             :                                    InNodeName,
     786             :                                    ihp.SHCoilTypeNum,
     787           1 :                                    ihp.SHCoilName,
     788             :                                    DataLoopNode::ConnectionType::Internal,
     789             :                                    NodeInputManager::CompFluidStream::Primary,
     790             :                                    ObjectIsNotParent,
     791             :                                    ErrorsFound);
     792           1 :         OverrideNodeConnectionType(state,
     793             :                                    OutNode,
     794             :                                    OutNodeName,
     795             :                                    ihp.SHCoilTypeNum,
     796           1 :                                    ihp.SHCoilName,
     797             :                                    DataLoopNode::ConnectionType::Internal,
     798             :                                    NodeInputManager::CompFluidStream::Primary,
     799             :                                    ObjectIsNotParent,
     800             :                                    ErrorsFound);
     801             : 
     802           2 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHHeatCoilIndex).AirInletNodeNum != InNode) ||
     803           1 :             (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHHeatCoilIndex).AirOutletNodeNum != OutNode)) {
     804           0 :             ShowContinueError(state,
     805           0 :                               format("Mistaken air node connection: {}:{}-wrong coil node names.", CurrentModuleObject, ihp.SHDWHHeatCoilName));
     806           0 :             ErrorsFound = true;
     807             :         }
     808           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Heating Coil", ihp.SHDWHHeatCoilType, ihp.SHDWHHeatCoilName, InNodeName, OutNodeName);
     809           1 :         OverrideNodeConnectionType(state,
     810             :                                    InNode,
     811             :                                    InNodeName,
     812             :                                    ihp.SHDWHHeatCoilTypeNum,
     813           1 :                                    ihp.SHDWHHeatCoilName,
     814             :                                    DataLoopNode::ConnectionType::Internal,
     815             :                                    NodeInputManager::CompFluidStream::Primary,
     816             :                                    ObjectIsNotParent,
     817             :                                    ErrorsFound);
     818           1 :         OverrideNodeConnectionType(state,
     819             :                                    OutNode,
     820             :                                    OutNodeName,
     821             :                                    ihp.SHDWHHeatCoilTypeNum,
     822           1 :                                    ihp.SHDWHHeatCoilName,
     823             :                                    DataLoopNode::ConnectionType::Internal,
     824             :                                    NodeInputManager::CompFluidStream::Primary,
     825             :                                    ObjectIsNotParent,
     826             :                                    ErrorsFound);
     827             : 
     828             :         // water node connections
     829           1 :         ChildCoilIndex = ihp.SCWHCoilIndex;
     830             : 
     831           1 :         InNode = state.dataVariableSpeedCoils->VarSpeedCoil(ChildCoilIndex).WaterInletNodeNum;
     832           1 :         OutNode = state.dataVariableSpeedCoils->VarSpeedCoil(ChildCoilIndex).WaterOutletNodeNum;
     833           1 :         InNodeName = state.dataLoopNodes->NodeID(InNode);
     834           1 :         OutNodeName = state.dataLoopNodes->NodeID(OutNode);
     835           1 :         ihp.WaterInletNodeNum = InNode;
     836           1 :         ihp.WaterOutletNodeNum = OutNode;
     837           2 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHWHCoilIndex).WaterInletNodeNum != InNode) ||
     838           1 :             (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHWHCoilIndex).WaterOutletNodeNum != OutNode)) {
     839           0 :             ShowContinueError(state, format("Mistaken air node connection: {}:{}-wrong coil node names.", CurrentModuleObject, ihp.SCDWHWHCoilName));
     840           0 :             ErrorsFound = true;
     841             :         }
     842             : 
     843           1 :         TestCompSet(state, CurrentModuleObject, ihp.Name + " Water Coil", InNodeName, OutNodeName, "Water Nodes");
     844           3 :         RegisterNodeConnection(state,
     845             :                                InNode,
     846           1 :                                state.dataLoopNodes->NodeID(InNode),
     847             :                                DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
     848           2 :                                ihp.Name + " Water Coil",
     849             :                                DataLoopNode::ConnectionType::Inlet,
     850             :                                NodeInputManager::CompFluidStream::Primary,
     851             :                                ObjectIsNotParent,
     852             :                                ErrorsFound);
     853           3 :         RegisterNodeConnection(state,
     854             :                                OutNode,
     855           1 :                                state.dataLoopNodes->NodeID(InNode),
     856             :                                DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
     857           2 :                                ihp.Name + " Water Coil",
     858             :                                DataLoopNode::ConnectionType::Outlet,
     859             :                                NodeInputManager::CompFluidStream::Primary,
     860             :                                ObjectIsNotParent,
     861             :                                ErrorsFound);
     862             : 
     863           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Water Coil", ihp.SCWHCoilType, ihp.SCWHCoilName, InNodeName, OutNodeName);
     864           1 :         OverrideNodeConnectionType(state,
     865             :                                    InNode,
     866             :                                    InNodeName,
     867             :                                    ihp.SCWHCoilTypeNum,
     868           1 :                                    ihp.SCWHCoilName,
     869             :                                    DataLoopNode::ConnectionType::Internal,
     870             :                                    NodeInputManager::CompFluidStream::Secondary,
     871             :                                    ObjectIsNotParent,
     872             :                                    ErrorsFound);
     873           1 :         OverrideNodeConnectionType(state,
     874             :                                    OutNode,
     875             :                                    OutNodeName,
     876             :                                    ihp.SCWHCoilTypeNum,
     877           1 :                                    ihp.SCWHCoilName,
     878             :                                    DataLoopNode::ConnectionType::Internal,
     879             :                                    NodeInputManager::CompFluidStream::Secondary,
     880             :                                    ObjectIsNotParent,
     881             :                                    ErrorsFound);
     882             : 
     883           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Water Coil", ihp.SCDWHWHCoilType, ihp.SCDWHWHCoilName, InNodeName, OutNodeName);
     884           1 :         OverrideNodeConnectionType(state,
     885             :                                    InNode,
     886             :                                    InNodeName,
     887             :                                    ihp.SCDWHWHCoilTypeNum,
     888           1 :                                    ihp.SCDWHWHCoilName,
     889             :                                    DataLoopNode::ConnectionType::Internal,
     890             :                                    NodeInputManager::CompFluidStream::Secondary,
     891             :                                    ObjectIsNotParent,
     892             :                                    ErrorsFound);
     893           1 :         OverrideNodeConnectionType(state,
     894             :                                    OutNode,
     895             :                                    OutNodeName,
     896             :                                    ihp.SCDWHWHCoilTypeNum,
     897           1 :                                    ihp.SCDWHWHCoilName,
     898             :                                    DataLoopNode::ConnectionType::Internal,
     899             :                                    NodeInputManager::CompFluidStream::Secondary,
     900             :                                    ObjectIsNotParent,
     901             :                                    ErrorsFound);
     902             : 
     903           2 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).WaterInletNodeNum != InNode) ||
     904           1 :             (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).WaterOutletNodeNum != OutNode)) {
     905           0 :             ShowContinueError(state, format("Mistaken air node connection: {}:{}-wrong coil node names.", CurrentModuleObject, ihp.SHDWHWHCoilName));
     906           0 :             ErrorsFound = true;
     907             :         }
     908           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Water Coil", ihp.SHDWHWHCoilType, ihp.SHDWHWHCoilName, InNodeName, OutNodeName);
     909           1 :         OverrideNodeConnectionType(state,
     910             :                                    InNode,
     911             :                                    InNodeName,
     912             :                                    ihp.SHDWHWHCoilTypeNum,
     913           1 :                                    ihp.SHDWHWHCoilName,
     914             :                                    DataLoopNode::ConnectionType::Internal,
     915             :                                    NodeInputManager::CompFluidStream::Secondary,
     916             :                                    ObjectIsNotParent,
     917             :                                    ErrorsFound);
     918           1 :         OverrideNodeConnectionType(state,
     919             :                                    OutNode,
     920             :                                    OutNodeName,
     921             :                                    ihp.SHDWHWHCoilTypeNum,
     922           1 :                                    ihp.SHDWHWHCoilName,
     923             :                                    DataLoopNode::ConnectionType::Internal,
     924             :                                    NodeInputManager::CompFluidStream::Secondary,
     925             :                                    ObjectIsNotParent,
     926             :                                    ErrorsFound);
     927             : 
     928           2 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(ihp.DWHCoilIndex).WaterInletNodeNum != InNode) ||
     929           1 :             (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.DWHCoilIndex).WaterOutletNodeNum != OutNode)) {
     930           0 :             ShowContinueError(state, format("Mistaken air node connection: {}:{}-wrong coil node names.", CurrentModuleObject, ihp.DWHCoilName));
     931           0 :             ErrorsFound = true;
     932             :         }
     933           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Water Coil", ihp.DWHCoilType, ihp.DWHCoilName, InNodeName, OutNodeName);
     934           1 :         OverrideNodeConnectionType(state,
     935             :                                    InNode,
     936             :                                    InNodeName,
     937             :                                    ihp.DWHCoilTypeNum,
     938           1 :                                    ihp.DWHCoilName,
     939             :                                    DataLoopNode::ConnectionType::Internal,
     940             :                                    NodeInputManager::CompFluidStream::Secondary,
     941             :                                    ObjectIsNotParent,
     942             :                                    ErrorsFound);
     943           1 :         OverrideNodeConnectionType(state,
     944             :                                    OutNode,
     945             :                                    OutNodeName,
     946             :                                    ihp.DWHCoilTypeNum,
     947           1 :                                    ihp.DWHCoilName,
     948             :                                    DataLoopNode::ConnectionType::Internal,
     949             :                                    NodeInputManager::CompFluidStream::Secondary,
     950             :                                    ObjectIsNotParent,
     951             :                                    ErrorsFound);
     952             : 
     953           1 :         ihp.WaterTankoutNod = GetOnlySingleNode(state,
     954           1 :                                                 AlphArray(2),
     955             :                                                 ErrorsFound,
     956             :                                                 DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
     957           1 :                                                 AlphArray(1),
     958             :                                                 DataLoopNode::NodeFluidType::Water,
     959             :                                                 DataLoopNode::ConnectionType::Sensor,
     960             :                                                 NodeInputManager::CompFluidStream::Secondary,
     961             :                                                 ObjectIsNotParent);
     962             : 
     963             :         // outdoor air node connections for water heating coils
     964             :         // DWH, SCDWH, SHDWH coils have the same outdoor air nodes
     965           1 :         ChildCoilIndex = ihp.DWHCoilIndex;
     966           1 :         InNode = state.dataVariableSpeedCoils->VarSpeedCoil(ChildCoilIndex).AirInletNodeNum;
     967           1 :         OutNode = state.dataVariableSpeedCoils->VarSpeedCoil(ChildCoilIndex).AirOutletNodeNum;
     968           1 :         InNodeName = state.dataLoopNodes->NodeID(InNode);
     969           1 :         OutNodeName = state.dataLoopNodes->NodeID(OutNode);
     970           1 :         ihp.ODAirInletNodeNum = InNode;
     971           1 :         ihp.ODAirOutletNodeNum = OutNode;
     972           2 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHWHCoilIndex).AirInletNodeNum != InNode) ||
     973           1 :             (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHWHCoilIndex).AirOutletNodeNum != OutNode)) {
     974           0 :             ShowContinueError(state, format("Mistaken air node connection: {}:{}-wrong coil node names.", CurrentModuleObject, ihp.SCDWHWHCoilName));
     975           0 :             ErrorsFound = true;
     976             :         }
     977             : 
     978           1 :         TestCompSet(state, CurrentModuleObject, ihp.Name + " Outdoor Coil", InNodeName, OutNodeName, "Outdoor Air Nodes");
     979           3 :         RegisterNodeConnection(state,
     980             :                                InNode,
     981           1 :                                state.dataLoopNodes->NodeID(InNode),
     982             :                                DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
     983           2 :                                ihp.Name + " Outdoor Coil",
     984             :                                DataLoopNode::ConnectionType::Inlet,
     985             :                                NodeInputManager::CompFluidStream::Primary,
     986             :                                ObjectIsNotParent,
     987             :                                ErrorsFound);
     988           3 :         RegisterNodeConnection(state,
     989             :                                OutNode,
     990           1 :                                state.dataLoopNodes->NodeID(InNode),
     991             :                                DataLoopNode::ConnectionObjectType::CoilSystemIntegratedHeatPumpAirSource,
     992           2 :                                ihp.Name + " Outdoor Coil",
     993             :                                DataLoopNode::ConnectionType::Outlet,
     994             :                                NodeInputManager::CompFluidStream::Primary,
     995             :                                ObjectIsNotParent,
     996             :                                ErrorsFound);
     997             : 
     998           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Outdoor Coil", ihp.DWHCoilType, ihp.DWHCoilName, InNodeName, OutNodeName);
     999           1 :         OverrideNodeConnectionType(state,
    1000             :                                    InNode,
    1001             :                                    InNodeName,
    1002             :                                    ihp.DWHCoilTypeNum,
    1003           1 :                                    ihp.DWHCoilName,
    1004             :                                    DataLoopNode::ConnectionType::Internal,
    1005             :                                    NodeInputManager::CompFluidStream::Primary,
    1006             :                                    ObjectIsNotParent,
    1007             :                                    ErrorsFound);
    1008           1 :         OverrideNodeConnectionType(state,
    1009             :                                    OutNode,
    1010             :                                    OutNodeName,
    1011             :                                    ihp.DWHCoilTypeNum,
    1012           1 :                                    ihp.DWHCoilName,
    1013             :                                    DataLoopNode::ConnectionType::Internal,
    1014             :                                    NodeInputManager::CompFluidStream::Primary,
    1015             :                                    ObjectIsNotParent,
    1016             :                                    ErrorsFound);
    1017             : 
    1018           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Outdoor Coil", ihp.SCDWHWHCoilType, ihp.SCDWHWHCoilName, InNodeName, OutNodeName);
    1019           1 :         OverrideNodeConnectionType(state,
    1020             :                                    InNode,
    1021             :                                    InNodeName,
    1022             :                                    ihp.SCDWHWHCoilTypeNum,
    1023           1 :                                    ihp.SCDWHWHCoilName,
    1024             :                                    DataLoopNode::ConnectionType::Internal,
    1025             :                                    NodeInputManager::CompFluidStream::Primary,
    1026             :                                    ObjectIsNotParent,
    1027             :                                    ErrorsFound);
    1028           1 :         OverrideNodeConnectionType(state,
    1029             :                                    OutNode,
    1030             :                                    OutNodeName,
    1031             :                                    ihp.SCDWHWHCoilTypeNum,
    1032           1 :                                    ihp.SCDWHWHCoilName,
    1033             :                                    DataLoopNode::ConnectionType::Internal,
    1034             :                                    NodeInputManager::CompFluidStream::Primary,
    1035             :                                    ObjectIsNotParent,
    1036             :                                    ErrorsFound);
    1037             : 
    1038             :         // why was this here
    1039             :         //        state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).AirInletNodeNum = InNode;
    1040             :         //        state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).AirOutletNodeNum = OutNode;
    1041             : 
    1042           2 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).AirInletNodeNum != InNode) ||
    1043           1 :             (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).AirOutletNodeNum != OutNode)) {
    1044           0 :             ShowContinueError(state, format("Mistaken air node connection: {}:{}-wrong coil node names.", CurrentModuleObject, ihp.SHDWHWHCoilName));
    1045           0 :             ErrorsFound = true;
    1046             :         }
    1047           1 :         SetUpCompSets(state, CurrentModuleObject, ihp.Name + " Outdoor Coil", ihp.SHDWHWHCoilType, ihp.SHDWHWHCoilName, InNodeName, OutNodeName);
    1048           1 :         OverrideNodeConnectionType(state,
    1049             :                                    InNode,
    1050             :                                    InNodeName,
    1051             :                                    ihp.SHDWHWHCoilTypeNum,
    1052           1 :                                    ihp.SHDWHWHCoilName,
    1053             :                                    DataLoopNode::ConnectionType::Internal,
    1054             :                                    NodeInputManager::CompFluidStream::Primary,
    1055             :                                    ObjectIsNotParent,
    1056             :                                    ErrorsFound);
    1057           1 :         OverrideNodeConnectionType(state,
    1058             :                                    OutNode,
    1059             :                                    OutNodeName,
    1060             :                                    ihp.SHDWHWHCoilTypeNum,
    1061           1 :                                    ihp.SHDWHWHCoilName,
    1062             :                                    DataLoopNode::ConnectionType::Internal,
    1063             :                                    NodeInputManager::CompFluidStream::Primary,
    1064             :                                    ObjectIsNotParent,
    1065             :                                    ErrorsFound);
    1066             : 
    1067           1 :         ihp.IHPCoilsSized = false;
    1068           1 :         ihp.CoolVolFlowScale = 1.0; // scale coil flow rates to match the parent fan object
    1069           1 :         ihp.HeatVolFlowScale = 1.0; // scale coil flow rates to match the parent fan object
    1070           1 :         ihp.CurMode = IHPOperationMode::Idle;
    1071           1 :         ihp.MaxHeatAirMassFlow = 1e10;
    1072           1 :         ihp.MaxHeatAirVolFlow = 1e10;
    1073           1 :         ihp.MaxCoolAirMassFlow = 1e10;
    1074           1 :         ihp.MaxCoolAirVolFlow = 1e10;
    1075             :     }
    1076             : 
    1077           1 :     if (ErrorsFound) {
    1078           0 :         ShowFatalError(state,
    1079           0 :                        format("{} Errors found in getting {} input. Preceding condition(s) causes termination.", RoutineName, CurrentModuleObject));
    1080             :     }
    1081             : 
    1082           2 :     for (int CoilCounter = 1; CoilCounter <= NumASIHPs; ++CoilCounter) {
    1083             : 
    1084           1 :         auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(CoilCounter);
    1085             : 
    1086             :         // set up output variables, not reported in the individual coil models
    1087           2 :         SetupOutputVariable(state,
    1088             :                             "Integrated Heat Pump Air Loop Mass Flow Rate",
    1089             :                             Constant::Units::kg_s,
    1090           1 :                             ihp.AirLoopFlowRate,
    1091             :                             OutputProcessor::TimeStepType::System,
    1092             :                             OutputProcessor::StoreType::Average,
    1093           1 :                             ihp.Name);
    1094           2 :         SetupOutputVariable(state,
    1095             :                             "Integrated Heat Pump Condenser Water Mass Flow Rate",
    1096             :                             Constant::Units::kg_s,
    1097           1 :                             ihp.TankSourceWaterMassFlowRate,
    1098             :                             OutputProcessor::TimeStepType::System,
    1099             :                             OutputProcessor::StoreType::Average,
    1100           1 :                             ihp.Name);
    1101           2 :         SetupOutputVariable(state,
    1102             :                             "Integrated Heat Pump Air Total Cooling Rate",
    1103             :                             Constant::Units::W,
    1104           1 :                             ihp.TotalCoolingRate,
    1105             :                             OutputProcessor::TimeStepType::System,
    1106             :                             OutputProcessor::StoreType::Average,
    1107           1 :                             ihp.Name);
    1108           2 :         SetupOutputVariable(state,
    1109             :                             "Integrated Heat Pump Air Heating Rate",
    1110             :                             Constant::Units::W,
    1111           1 :                             ihp.TotalSpaceHeatingRate,
    1112             :                             OutputProcessor::TimeStepType::System,
    1113             :                             OutputProcessor::StoreType::Average,
    1114           1 :                             ihp.Name);
    1115           2 :         SetupOutputVariable(state,
    1116             :                             "Integrated Heat Pump Water Heating Rate",
    1117             :                             Constant::Units::W,
    1118           1 :                             ihp.TotalWaterHeatingRate,
    1119             :                             OutputProcessor::TimeStepType::System,
    1120             :                             OutputProcessor::StoreType::Average,
    1121           1 :                             ihp.Name);
    1122           2 :         SetupOutputVariable(state,
    1123             :                             "Integrated Heat Pump Electricity Rate",
    1124             :                             Constant::Units::W,
    1125           1 :                             ihp.TotalPower,
    1126             :                             OutputProcessor::TimeStepType::System,
    1127             :                             OutputProcessor::StoreType::Average,
    1128           1 :                             ihp.Name);
    1129           2 :         SetupOutputVariable(state,
    1130             :                             "Integrated Heat Pump Air Latent Cooling Rate",
    1131             :                             Constant::Units::W,
    1132           1 :                             ihp.TotalLatentLoad,
    1133             :                             OutputProcessor::TimeStepType::System,
    1134             :                             OutputProcessor::StoreType::Average,
    1135           1 :                             ihp.Name);
    1136           2 :         SetupOutputVariable(state,
    1137             :                             "Integrated Heat Pump Source Heat Transfer Rate",
    1138             :                             Constant::Units::W,
    1139           1 :                             ihp.Qsource,
    1140             :                             OutputProcessor::TimeStepType::System,
    1141             :                             OutputProcessor::StoreType::Average,
    1142           1 :                             ihp.Name);
    1143           2 :         SetupOutputVariable(state,
    1144             :                             "Integrated Heat Pump COP",
    1145             :                             Constant::Units::None,
    1146           1 :                             ihp.TotalCOP,
    1147             :                             OutputProcessor::TimeStepType::System,
    1148             :                             OutputProcessor::StoreType::Average,
    1149           1 :                             ihp.Name);
    1150           2 :         SetupOutputVariable(state,
    1151             :                             "Integrated Heat Pump Electricity Energy",
    1152             :                             Constant::Units::J,
    1153           1 :                             ihp.Energy,
    1154             :                             OutputProcessor::TimeStepType::System,
    1155             :                             OutputProcessor::StoreType::Sum,
    1156           1 :                             ihp.Name);
    1157           2 :         SetupOutputVariable(state,
    1158             :                             "Integrated Heat Pump Air Total Cooling Energy",
    1159             :                             Constant::Units::J,
    1160           1 :                             ihp.EnergyLoadTotalCooling,
    1161             :                             OutputProcessor::TimeStepType::System,
    1162             :                             OutputProcessor::StoreType::Sum,
    1163           1 :                             ihp.Name);
    1164           2 :         SetupOutputVariable(state,
    1165             :                             "Integrated Heat Pump Air Heating Energy",
    1166             :                             Constant::Units::J,
    1167           1 :                             ihp.EnergyLoadTotalHeating,
    1168             :                             OutputProcessor::TimeStepType::System,
    1169             :                             OutputProcessor::StoreType::Sum,
    1170           1 :                             ihp.Name);
    1171           2 :         SetupOutputVariable(state,
    1172             :                             "Integrated Heat Pump Water Heating Energy",
    1173             :                             Constant::Units::J,
    1174           1 :                             ihp.EnergyLoadTotalWaterHeating,
    1175             :                             OutputProcessor::TimeStepType::System,
    1176             :                             OutputProcessor::StoreType::Sum,
    1177           1 :                             ihp.Name);
    1178           2 :         SetupOutputVariable(state,
    1179             :                             "Integrated Heat Pump Air Latent Cooling Energy",
    1180             :                             Constant::Units::J,
    1181           1 :                             ihp.EnergyLatent,
    1182             :                             OutputProcessor::TimeStepType::System,
    1183             :                             OutputProcessor::StoreType::Sum,
    1184           1 :                             ihp.Name);
    1185           2 :         SetupOutputVariable(state,
    1186             :                             "Integrated Heat Pump Source Heat Transfer Energy",
    1187             :                             Constant::Units::J,
    1188           1 :                             ihp.EnergySource,
    1189             :                             OutputProcessor::TimeStepType::System,
    1190             :                             OutputProcessor::StoreType::Sum,
    1191           1 :                             ihp.Name);
    1192             :     }
    1193          21 : }
    1194             : 
    1195           3 : void SizeIHP(EnergyPlusData &state, int const DXCoilNum)
    1196             : {
    1197             :     using DataSizing::AutoSize;
    1198             :     using VariableSpeedCoils::SetVarSpeedCoilData;
    1199             :     using VariableSpeedCoils::SimVariableSpeedCoils;
    1200             :     using VariableSpeedCoils::SizeVarSpeedCoil;
    1201             : 
    1202           3 :     bool ErrorsFound = false;
    1203           3 :     Real64 RatedCapacity(0.0); // rated building cooling load
    1204             : 
    1205             :     // Obtains and Allocates AS-IHP related parameters from input file
    1206           3 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    1207           0 :         GetIHPInput(state);
    1208           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    1209             :     };
    1210             : 
    1211           3 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    1212           0 :         ShowFatalError(state,
    1213           0 :                        format("SizeIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    1214             :                               DXCoilNum,
    1215           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    1216             :     }
    1217             : 
    1218           3 :     if (state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum).IHPCoilsSized) {
    1219           2 :         return;
    1220             :     }
    1221             : 
    1222           1 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    1223             : 
    1224             :     // associate SC coil with SH coil
    1225           1 :     bool errFlag = false;
    1226           1 :     SetVarSpeedCoilData(state, ihp.SCCoilIndex, errFlag, _, ihp.SHCoilIndex);
    1227           1 :     if (errFlag) {
    1228           0 :         ShowSevereError(state, format(R"(SizeIHP: Could not match cooling coil"{}" with heating coil="{}")", ihp.SCCoilName, ihp.SHCoilName));
    1229           0 :         ErrorsFound = true;
    1230             :     };
    1231             : 
    1232           1 :     errFlag = false;
    1233           1 :     SizeVarSpeedCoil(state, ihp.SCCoilIndex, errFlag); // size cooling coil
    1234           1 :     if (errFlag) {
    1235           0 :         ShowSevereError(state, format("SizeIHP: failed to size SC coil\"{}\"", ihp.SCCoilName));
    1236           0 :         ErrorsFound = true;
    1237             :     } else {
    1238           1 :         RatedCapacity = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCCoilIndex).RatedCapCoolTotal;
    1239             :     };
    1240             : 
    1241           1 :     errFlag = false;
    1242           1 :     SizeVarSpeedCoil(state, ihp.SHCoilIndex, errFlag); // size heating coil
    1243           1 :     if (errFlag) {
    1244           0 :         ShowSevereError(state, format("SizeIHP: failed to size SH coil\"{}\"", ihp.SHCoilName));
    1245           0 :         ErrorsFound = true;
    1246             :     };
    1247             : 
    1248             :     // pass SC coil capacity to SCDWH cool coil
    1249           1 :     if (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).RatedCapCoolTotal == AutoSize) {
    1250           0 :         state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).RatedCapCoolTotal = RatedCapacity;
    1251             :     };
    1252             : 
    1253             :     // associate SCDWH air coil to SHDWH air coil
    1254           1 :     errFlag = false;
    1255           1 :     SetVarSpeedCoilData(state, ihp.SCDWHCoolCoilIndex, errFlag, _, ihp.SHDWHHeatCoilIndex);
    1256             :     // size SCDWH air coil
    1257           1 :     SizeVarSpeedCoil(state, ihp.SCDWHCoolCoilIndex, errFlag);
    1258           1 :     if (errFlag) {
    1259           0 :         ShowSevereError(state, format("SizeIHP: failed to size SCDWH cooling coil\"{}\"", ihp.SCDWHCoolCoilName));
    1260           0 :         ErrorsFound = true;
    1261             :     };
    1262             : 
    1263             :     // size SHDWH air coil
    1264           1 :     errFlag = false;
    1265           1 :     SizeVarSpeedCoil(state, ihp.SHDWHHeatCoilIndex, errFlag);
    1266           1 :     if (errFlag) {
    1267           0 :         ShowSevereError(state, format("SizeIHP: failed to size SHDWH heating coil\"{}\"", ihp.SHDWHHeatCoilName));
    1268           0 :         ErrorsFound = true;
    1269             :     };
    1270             : 
    1271             :     // size the water coils below
    1272             :     // size SCWH water coil
    1273           1 :     if (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).RatedCapWH == AutoSize) {
    1274           0 :         state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).RatedCapWH =
    1275           0 :             RatedCapacity / (1.0 - 1.0 / state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).RatedCOPHeat);
    1276             :     }
    1277             : 
    1278           1 :     errFlag = false;
    1279           1 :     SizeVarSpeedCoil(state, ihp.SCWHCoilIndex, errFlag);
    1280           1 :     if (errFlag) {
    1281           0 :         ShowSevereError(state, format("SizeIHP: failed to size SCWH coil\"{}\"", ihp.SCWHCoilName));
    1282           0 :         ErrorsFound = true;
    1283             :     };
    1284             : 
    1285             :     // size DWH water coil
    1286           1 :     if (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.DWHCoilIndex).RatedCapWH == AutoSize) {
    1287           0 :         state.dataVariableSpeedCoils->VarSpeedCoil(ihp.DWHCoilIndex).RatedCapWH = RatedCapacity;
    1288             :     }
    1289             : 
    1290           1 :     errFlag = false;
    1291           1 :     SizeVarSpeedCoil(state, ihp.DWHCoilIndex, errFlag);
    1292           1 :     if (errFlag) {
    1293           0 :         ShowSevereError(state, format("SizeIHP: failed to size DWH coil\"{}\"", ihp.DWHCoilName));
    1294           0 :         ErrorsFound = true;
    1295             :     };
    1296             : 
    1297             :     // size SCDWH water coil
    1298           1 :     if (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHWHCoilIndex).RatedCapWH == AutoSize) {
    1299           0 :         state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHWHCoilIndex).RatedCapWH = RatedCapacity * 0.13;
    1300             :     }
    1301             : 
    1302           1 :     errFlag = false;
    1303           1 :     SizeVarSpeedCoil(state, ihp.SCDWHWHCoilIndex, errFlag);
    1304           1 :     if (errFlag) {
    1305           0 :         ShowSevereError(state, format("SizeIHP: failed to size SCDWH water heating coil\"{}\"", ihp.SCDWHWHCoilName));
    1306           0 :         ErrorsFound = true;
    1307             :     };
    1308             : 
    1309             :     // size SHDWH water coil
    1310           1 :     if (state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).RatedCapWH == AutoSize) {
    1311           0 :         state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).RatedCapWH = RatedCapacity * 0.1;
    1312             :     }
    1313             : 
    1314           1 :     errFlag = false;
    1315           1 :     SizeVarSpeedCoil(state, ihp.SHDWHWHCoilIndex, errFlag);
    1316           1 :     if (errFlag) {
    1317           0 :         ShowSevereError(state, format("SizeIHP: failed to size SHDWH water heating coil\"{}\"", ihp.SHDWHWHCoilName));
    1318           0 :         ErrorsFound = true;
    1319             :     };
    1320             : 
    1321           1 :     if (ErrorsFound) {
    1322           0 :         ShowFatalError(state, "Program terminates due to preceding condition(s).");
    1323             :     }
    1324             : 
    1325           1 :     ihp.IHPCoilsSized = true;
    1326             : }
    1327             : 
    1328      263711 : void InitializeIHP(EnergyPlusData &state, int const DXCoilNum)
    1329             : {
    1330             :     // Obtains and Allocates AS-IHP related parameters from input file
    1331      263711 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    1332           0 :         GetIHPInput(state);
    1333           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    1334             :     }
    1335             : 
    1336      263711 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    1337           0 :         ShowFatalError(state,
    1338           0 :                        format("InitializeIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    1339             :                               DXCoilNum,
    1340           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    1341             :     }
    1342             : 
    1343      263711 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    1344             : 
    1345      263711 :     ihp.AirLoopFlowRate = 0.0;             // air loop mass flow rate [kg/s]
    1346      263711 :     ihp.TankSourceWaterMassFlowRate = 0.0; // water loop mass flow rate [kg/s]
    1347      263711 :     ihp.TotalCoolingRate = 0.0;            // total cooling rate [w]
    1348      263711 :     ihp.TotalWaterHeatingRate = 0.0;       // total water heating rate [w]
    1349      263711 :     ihp.TotalSpaceHeatingRate = 0.0;       // total space heating rate [w]
    1350      263711 :     ihp.TotalPower = 0.0;                  // total power consumption  [w]
    1351      263711 :     ihp.TotalLatentLoad = 0.0;             // total latent cooling rate [w]
    1352      263711 :     ihp.Qsource = 0.0;                     // source energy rate, [w]
    1353      263711 :     ihp.Energy = 0.0;                      // total electric energy consumption [J]
    1354      263711 :     ihp.EnergyLoadTotalCooling = 0.0;      // total cooling energy [J]
    1355      263711 :     ihp.EnergyLoadTotalHeating = 0.0;      // total heating energy [J]
    1356      263711 :     ihp.EnergyLoadTotalWaterHeating = 0.0; // total heating energy [J]
    1357      263711 :     ihp.EnergyLatent = 0.0;                // total latent energy [J]
    1358      263711 :     ihp.EnergySource = 0.0;                // total source energy
    1359      263711 :     ihp.TotalCOP = 0.0;
    1360      263711 : }
    1361             : 
    1362      263711 : void UpdateIHP(EnergyPlusData &state, int const DXCoilNum)
    1363             : {
    1364      263711 :     Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    1365             : 
    1366             :     // Obtains and Allocates AS-IHP related parameters from input file
    1367      263711 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    1368           0 :         GetIHPInput(state);
    1369           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    1370             :     }
    1371             : 
    1372      263711 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    1373           0 :         ShowFatalError(state,
    1374           0 :                        format("UpdateIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    1375             :                               DXCoilNum,
    1376           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    1377             :     }
    1378             : 
    1379      263711 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    1380             : 
    1381      263711 :     switch (ihp.CurMode) {
    1382       68656 :     case IHPOperationMode::SpaceClg:
    1383       68656 :         ihp.TotalCoolingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCCoilIndex).QLoadTotal; // total cooling rate [w]
    1384       68656 :         ihp.TotalWaterHeatingRate = 0.0;                                                               // total water heating rate [w]
    1385       68656 :         ihp.TotalSpaceHeatingRate = 0.0;                                                               // total space heating rate [w]
    1386       68656 :         ihp.TotalPower = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCCoilIndex).Power;            // total power consumption  [w]
    1387       68656 :         ihp.TotalLatentLoad = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCCoilIndex).QLatent;     // total latent cooling rate [w]
    1388       68656 :         ihp.Qsource = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCCoilIndex).QSource;             // source energy rate, [w]
    1389       68656 :         break;
    1390       74506 :     case IHPOperationMode::SpaceHtg:
    1391       74506 :         ihp.TotalCoolingRate = 0.0;                                                                         // total cooling rate [w]
    1392       74506 :         ihp.TotalWaterHeatingRate = 0.0;                                                                    // total water heating rate [w]
    1393       74506 :         ihp.TotalSpaceHeatingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHCoilIndex).QLoadTotal; // total space heating rate [w]
    1394       74506 :         ihp.TotalPower = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHCoilIndex).Power;                 // total power consumption  [w]
    1395       74506 :         ihp.TotalLatentLoad = 0.0;                                                                          // total latent cooling rate [w]
    1396       74506 :         ihp.Qsource = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHCoilIndex).QSource;                  // source energy rate, [w]
    1397       74506 :         break;
    1398        2336 :     case IHPOperationMode::DedicatedWaterHtg:
    1399        2336 :         ihp.TotalCoolingRate = 0.0;                                                                       // total cooling rate [w]
    1400        2336 :         ihp.TotalWaterHeatingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.DWHCoilIndex).QSource; // total water heating rate [w]
    1401        2336 :         ihp.TotalSpaceHeatingRate = 0.0;                                                                  // total space heating rate [w]
    1402        2336 :         ihp.TotalPower = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.DWHCoilIndex).Power;              // total power consumption  [w]
    1403        2336 :         ihp.TotalLatentLoad = 0.0;                                                                        // total latent cooling rate [w]
    1404        2336 :         ihp.Qsource = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.DWHCoilIndex).QLoadTotal;            // source energy rate, [w]
    1405        2336 :         break;
    1406        3472 :     case IHPOperationMode::SCWHMatchSC:
    1407             :     case IHPOperationMode::SCWHMatchWH:
    1408        3472 :         ihp.TotalCoolingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).QLoadTotal;   // total cooling rate [w]
    1409        3472 :         ihp.TotalWaterHeatingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).QSource; // total water heating rate [w]
    1410        3472 :         ihp.TotalSpaceHeatingRate = 0.0;                                                                   // total space heating rate [w]
    1411        3472 :         ihp.TotalPower = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).Power;              // total power consumption  [w]
    1412        3472 :         ihp.TotalLatentLoad = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).QLatent;       // total latent cooling rate [w]
    1413        3472 :         ihp.Qsource = 0.0;                                                                                 // source energy rate, [w]
    1414        3472 :         break;
    1415      102224 :     case IHPOperationMode::SpaceClgDedicatedWaterHtg:
    1416      102224 :         ihp.TotalCoolingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).QLoadTotal; // total cooling rate [w]
    1417      102224 :         ihp.TotalSpaceHeatingRate = 0.0;                                                                      // total space heating rate [w]
    1418      102224 :         ihp.TotalPower = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).Power;            // total power consumption  [w]
    1419      102224 :         ihp.TotalLatentLoad = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).QLatent;     // total latent cooling rate [w]
    1420      102224 :         ihp.Qsource = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).QSource;             // source energy rate, [w]
    1421             : 
    1422      102224 :         ihp.TotalWaterHeatingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHWHCoilIndex).QSource; // total water heating rate [w]
    1423             : 
    1424      102224 :         break;
    1425           0 :     case IHPOperationMode::SHDWHElecHeatOff:
    1426             :     case IHPOperationMode::SHDWHElecHeatOn:
    1427           0 :         ihp.TotalCoolingRate = 0.0;                                                                                // total cooling rate [w]
    1428           0 :         ihp.TotalSpaceHeatingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHHeatCoilIndex).QLoadTotal; // total space heating rate [w]
    1429           0 :         ihp.TotalPower = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHHeatCoilIndex).Power;                 // total power consumption  [w]
    1430           0 :         ihp.TotalLatentLoad = 0.0;                                                                                 // total latent cooling rate [w]
    1431           0 :         ihp.Qsource = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHHeatCoilIndex).QSource;                  // source energy rate, [w]
    1432             : 
    1433           0 :         ihp.TotalWaterHeatingRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).QSource; // total water heating rate [w]
    1434             : 
    1435           0 :         break;
    1436       12517 :     case IHPOperationMode::Idle:
    1437             :     default:
    1438       12517 :         break;
    1439             :     }
    1440             : 
    1441      263711 :     ihp.Energy = ihp.TotalPower * TimeStepSysSec;                                 // total electric energy consumption [J]
    1442      263711 :     ihp.EnergyLoadTotalCooling = ihp.TotalCoolingRate * TimeStepSysSec;           // total cooling energy [J]
    1443      263711 :     ihp.EnergyLoadTotalHeating = ihp.TotalSpaceHeatingRate * TimeStepSysSec;      // total heating energy [J]
    1444      263711 :     ihp.EnergyLoadTotalWaterHeating = ihp.TotalWaterHeatingRate * TimeStepSysSec; // total heating energy [J]
    1445      263711 :     ihp.EnergyLatent = ihp.TotalLatentLoad * TimeStepSysSec;                      // total latent energy [J]
    1446      263711 :     ihp.EnergySource = ihp.Qsource * TimeStepSysSec;                              // total source energy
    1447             : 
    1448      263711 :     if (ihp.TotalPower > 0.0) {
    1449      150770 :         Real64 TotalDelivery = ihp.TotalCoolingRate + ihp.TotalSpaceHeatingRate + ihp.TotalWaterHeatingRate;
    1450      150770 :         ihp.TotalCOP = TotalDelivery / ihp.TotalPower;
    1451             :     }
    1452      263711 : }
    1453             : 
    1454        5024 : void DecideWorkMode(EnergyPlusData &state,
    1455             :                     int const DXCoilNum,
    1456             :                     Real64 const SensLoad,  // Sensible demand load [W]
    1457             :                     Real64 const LatentLoad // Latent demand load [W]
    1458             :                     )                       // shall be called from a air loop parent
    1459             : {
    1460             :     //       AUTHOR         Bo Shen, ORNL
    1461             :     //       DATE WRITTEN   March 2016
    1462             :     //       RE-ENGINEERED  na
    1463             : 
    1464             :     // PURPOSE OF THIS SUBROUTINE:
    1465             :     // This subroutine determine the IHP working mode in the next time step,
    1466             :     // it should be called by an air loop parent object, when FirstHVACIteration == true
    1467             : 
    1468             :     // Using/Aliasing
    1469             :     using HVAC::SmallLoad;
    1470             :     using WaterThermalTanks::GetWaterThermalTankInput;
    1471             : 
    1472        5024 :     Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    1473             : 
    1474        5024 :     Real64 MyLoad(0.0);
    1475        5024 :     Real64 WHHeatTimeSav(0.0); // time accumulation for water heating
    1476        5024 :     Real64 WHHeatVolSave(0.0); // volume accumulation for water heating
    1477             : 
    1478             :     // Obtains and Allocates AS-IHP related parameters from input file
    1479        5024 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    1480           0 :         GetIHPInput(state);
    1481           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    1482             :     }
    1483             : 
    1484        5024 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    1485           0 :         ShowFatalError(state,
    1486           0 :                        format("DecideWorkMode: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    1487             :                               DXCoilNum,
    1488           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    1489             :     }
    1490             : 
    1491        5024 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    1492             : 
    1493        5024 :     if (ihp.IHPCoilsSized == false) SizeIHP(state, DXCoilNum);
    1494             : 
    1495             :     // decide working mode at the first moment
    1496             :     // check if there is a water heating call
    1497        5024 :     ihp.IsWHCallAvail = false;
    1498        5024 :     ihp.CheckWHCall = true; // set checking flag
    1499        5024 :     if (ihp.WHtankID == 0)  // not initialized yet
    1500             :     {
    1501           2 :         ihp.IsWHCallAvail = false;
    1502             :     } else {
    1503        5022 :         state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate = GetWaterVolFlowRateIHP(state, DXCoilNum, 1.0, 1.0) * WaterDensity;
    1504        5022 :         state.dataLoopNodes->Node(ihp.WaterOutletNodeNum).Temp = state.dataLoopNodes->Node(ihp.WaterInletNodeNum).Temp;
    1505             : 
    1506        5022 :         DataPlant::PlantEquipmentType tankType = ihp.WHtankType;
    1507             : 
    1508        5022 :         switch (tankType) {
    1509           0 :         case DataPlant::PlantEquipmentType::WtrHeaterMixed:
    1510             :         case DataPlant::PlantEquipmentType::WtrHeaterStratified:
    1511             :         case DataPlant::PlantEquipmentType::ChilledWaterTankMixed:
    1512             :         case DataPlant::PlantEquipmentType::ChilledWaterTankStratified:
    1513             : 
    1514             :         {
    1515           0 :             int tankIDX = WaterThermalTanks::getTankIDX(state, ihp.WHtankName, ihp.WHtankID);
    1516           0 :             auto &tank = state.dataWaterThermalTanks->WaterThermalTank(tankIDX);
    1517           0 :             tank.callerLoopNum = ihp.LoopNum;
    1518           0 :             PlantLocation A(0, DataPlant::LoopSideLocation::Invalid, 0, 0);
    1519           0 :             tank.simulate(state, A, true, MyLoad, true);
    1520           0 :             tank.callerLoopNum = 0;
    1521             : 
    1522           0 :             break;
    1523             :         }
    1524        5022 :         case DataPlant::PlantEquipmentType::HeatPumpWtrHeaterPumped:
    1525             :         case DataPlant::PlantEquipmentType::HeatPumpWtrHeaterWrapped:
    1526             : 
    1527             :         {
    1528        5022 :             int hpIDX = WaterThermalTanks::getHPTankIDX(state, ihp.WHtankName, ihp.WHtankID);
    1529        5022 :             auto &HPWH = state.dataWaterThermalTanks->HPWaterHeater(hpIDX);
    1530        5022 :             int tankIDX = HPWH.WaterHeaterTankNum;
    1531        5022 :             auto &tank = state.dataWaterThermalTanks->WaterThermalTank(tankIDX);
    1532        5022 :             tank.callerLoopNum = ihp.LoopNum;
    1533        5022 :             ihp.WHtankType = tankType;
    1534        5022 :             PlantLocation A(0, DataPlant::LoopSideLocation::Invalid, 0, 0);
    1535        5022 :             HPWH.simulate(state, A, true, MyLoad, true);
    1536        5022 :             tank.callerLoopNum = 0;
    1537        5022 :             break;
    1538             :         }
    1539           0 :         default:
    1540           0 :             break;
    1541             :         }
    1542             :     }
    1543        5024 :     ihp.CheckWHCall = false; // clear checking flag
    1544             : 
    1545             :     // keep the water heating time and volume history
    1546        5024 :     WHHeatTimeSav = ihp.SHDWHRunTime;
    1547        5024 :     if (IHPOperationMode::SpaceClgDedicatedWaterHtg == ihp.CurMode) {
    1548        2290 :         WHHeatVolSave = ihp.WaterFlowAccumVol +
    1549        1145 :                         state.dataLoopNodes->Node(ihp.WaterTankoutNod).MassFlowRate / 983.0 * TimeStepSysSec; // 983 - water density at 60 C
    1550             :     } else {
    1551        3879 :         WHHeatVolSave = 0.0;
    1552             :     }
    1553             : 
    1554             :     // clear the accumulation amount for other modes
    1555        5024 :     ihp.SHDWHRunTime = 0.0;
    1556        5024 :     ihp.WaterFlowAccumVol = 0.0;
    1557             : 
    1558        5024 :     if (!ihp.IsWHCallAvail) // no water heating call
    1559             :     {
    1560        3766 :         if ((SensLoad < (-1.0 * SmallLoad)) || (LatentLoad < (-1.0 * SmallLoad))) // space cooling mode
    1561             :         {
    1562         783 :             ihp.CurMode = IHPOperationMode::SpaceClg;
    1563        2983 :         } else if (SensLoad > SmallLoad) {
    1564        2322 :             if ((ihp.ControlledZoneTemp > ihp.TindoorOverCoolAllow) &&
    1565           0 :                 (state.dataEnvrn->OutDryBulbTemp > ihp.TambientOverCoolAllow)) // used for cooling season, avoid heating after SCWH mode
    1566           0 :                 ihp.CurMode = IHPOperationMode::Idle;
    1567             :             else
    1568        2322 :                 ihp.CurMode = IHPOperationMode::SpaceHtg;
    1569             :         } else {
    1570         661 :             ihp.CurMode = IHPOperationMode::Idle;
    1571             :         }
    1572             :     }
    1573             :     // below has water heating calls
    1574        1258 :     else if ((SensLoad < (-1.0 * SmallLoad)) || (LatentLoad < (-1.0 * SmallLoad))) // simultaneous SC and WH calls
    1575             :     {
    1576        1146 :         if (WHHeatVolSave < ihp.WaterVolSCDWH) // small water heating amount
    1577             :         {
    1578        1146 :             ihp.CurMode = IHPOperationMode::SpaceClgDedicatedWaterHtg;
    1579        1146 :             ihp.WaterFlowAccumVol = WHHeatVolSave;
    1580             :         } else {
    1581           0 :             if (1 == ihp.ModeMatchSCWH) // water heating priority
    1582           0 :                 ihp.CurMode = IHPOperationMode::SCWHMatchWH;
    1583             :             else // space cooling priority
    1584           0 :                 ihp.CurMode = IHPOperationMode::SCWHMatchSC;
    1585             :         };
    1586             : 
    1587         224 :     } else if ((ihp.ControlledZoneTemp > ihp.TindoorOverCoolAllow) &&
    1588         112 :                (state.dataEnvrn->OutDryBulbTemp > ihp.TambientOverCoolAllow)) // over-cooling allowed, water heating priority
    1589             :     {
    1590          56 :         ihp.CurMode = IHPOperationMode::SCWHMatchWH;
    1591         112 :     } else if ((ihp.ControlledZoneTemp > ihp.TindoorWHHighPriority) &&
    1592          56 :                (state.dataEnvrn->OutDryBulbTemp > ihp.TambientWHHighPriority)) // ignore space heating request
    1593             :     {
    1594          56 :         ihp.CurMode = IHPOperationMode::DedicatedWaterHtg;
    1595           0 :     } else if (SensLoad > SmallLoad) {
    1596           0 :         ihp.SHDWHRunTime = WHHeatTimeSav + TimeStepSysSec;
    1597             : 
    1598           0 :         if (WHHeatTimeSav > ihp.TimeLimitSHDWH) {
    1599           0 :             ihp.CurMode = IHPOperationMode::SHDWHElecHeatOn;
    1600             :         } else {
    1601           0 :             ihp.CurMode = IHPOperationMode::SHDWHElecHeatOff;
    1602             :         };
    1603             :     } else {
    1604           0 :         ihp.CurMode = IHPOperationMode::DedicatedWaterHtg;
    1605             :     }
    1606             : 
    1607             :     // clear up, important
    1608        5024 :     ClearCoils(state, DXCoilNum);
    1609        5024 : }
    1610             : 
    1611        7558 : void ClearCoils(EnergyPlusData &state, int const DXCoilNum)
    1612             : {
    1613             :     using VariableSpeedCoils::SimVariableSpeedCoils;
    1614             : 
    1615        7558 :     HVAC::FanOp fanOp = HVAC::FanOp::Cycling; // fan cycl manner place holder
    1616             : 
    1617             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    1618        7558 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    1619           0 :         GetIHPInput(state);
    1620           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    1621             :     }
    1622             : 
    1623        7558 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    1624           0 :         ShowFatalError(state,
    1625           0 :                        format("ClearCoils: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    1626             :                               DXCoilNum,
    1627           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    1628             :     }
    1629             : 
    1630        7558 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    1631             : 
    1632             :     // clear up
    1633        7558 :     SimVariableSpeedCoils(state, std::string(), ihp.SCDWHCoolCoilIndex, HVAC::FanOp::Cycling, HVAC::CompressorOp::On, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
    1634        7558 :     SimVariableSpeedCoils(state, std::string(), ihp.SCDWHWHCoilIndex, HVAC::FanOp::Cycling, HVAC::CompressorOp::On, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
    1635        7558 :     SimVariableSpeedCoils(state, std::string(), ihp.SHDWHHeatCoilIndex, HVAC::FanOp::Cycling, HVAC::CompressorOp::On, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
    1636        7558 :     SimVariableSpeedCoils(state, std::string(), ihp.SHDWHWHCoilIndex, HVAC::FanOp::Cycling, HVAC::CompressorOp::On, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
    1637        7558 :     SimVariableSpeedCoils(state, std::string(), ihp.SCWHCoilIndex, HVAC::FanOp::Cycling, HVAC::CompressorOp::On, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
    1638        7558 :     SimVariableSpeedCoils(state, std::string(), ihp.SCCoilIndex, HVAC::FanOp::Cycling, HVAC::CompressorOp::On, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
    1639        7558 :     SimVariableSpeedCoils(state, std::string(), ihp.SHCoilIndex, HVAC::FanOp::Cycling, HVAC::CompressorOp::On, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
    1640        7558 :     SimVariableSpeedCoils(state, std::string(), ihp.DWHCoilIndex, HVAC::FanOp::Cycling, HVAC::CompressorOp::On, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
    1641        7558 : }
    1642             : 
    1643       22657 : IHPOperationMode GetCurWorkMode(EnergyPlusData &state, int const DXCoilNum)
    1644             : {
    1645             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    1646       22657 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    1647           0 :         GetIHPInput(state);
    1648           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    1649             :     }
    1650             : 
    1651       22657 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    1652           0 :         ShowFatalError(state,
    1653           0 :                        format("GetCurWorkMode: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    1654             :                               DXCoilNum,
    1655           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    1656             :     }
    1657             : 
    1658       22657 :     if (state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum).IHPCoilsSized == false) SizeIHP(state, DXCoilNum);
    1659             : 
    1660       22657 :     return (state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum).CurMode);
    1661             : }
    1662             : 
    1663           7 : bool IHPInModel(EnergyPlusData &state)
    1664             : {
    1665           7 :     if (state.dataIntegratedHP->GetCoilsInputFlag) {
    1666           2 :         GetIHPInput(state);
    1667           2 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    1668             :     }
    1669           7 :     return !state.dataIntegratedHP->IntegratedHeatPumps.empty();
    1670             : }
    1671             : 
    1672           3 : int GetCoilIndexIHP(EnergyPlusData &state,
    1673             :                     std::string const &CoilType, // must match coil types in this module
    1674             :                     std::string const &CoilName, // must match coil names for the coil type
    1675             :                     bool &ErrorsFound            // set to true if problem
    1676             : )
    1677             : {
    1678             : 
    1679             :     // FUNCTION INFORMATION:
    1680             :     //       AUTHOR         Bo Shen
    1681             :     //       DATE WRITTEN   March 2016
    1682             :     //       MODIFIED       na
    1683             :     //       RE-ENGINEERED  na
    1684             : 
    1685             :     // PURPOSE OF THIS FUNCTION:
    1686             :     // This function looks up the coil index for the given coil and returns it.  If
    1687             :     // incorrect coil type or name is given, ErrorsFound is returned as true and index is returned
    1688             :     // as zero.
    1689             : 
    1690             :     // Return value
    1691             :     int IndexNum; // returned index of matched coil
    1692             : 
    1693             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    1694           3 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    1695           1 :         GetIHPInput(state);
    1696           1 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    1697             :     }
    1698             : 
    1699           3 :     IndexNum = Util::FindItemInList(CoilName, state.dataIntegratedHP->IntegratedHeatPumps);
    1700             : 
    1701           3 :     if (IndexNum == 0) {
    1702           0 :         ShowSevereError(state, format(R"(GetCoilIndexIHP: Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    1703           0 :         ErrorsFound = true;
    1704             :     }
    1705             : 
    1706           3 :     return IndexNum;
    1707             : }
    1708             : 
    1709           1 : int GetCoilInletNodeIHP(EnergyPlusData &state,
    1710             :                         std::string const &CoilType, // must match coil types in this module
    1711             :                         std::string const &CoilName, // must match coil names for the coil type
    1712             :                         bool &ErrorsFound            // set to true if problem
    1713             : )
    1714             : {
    1715             :     // FUNCTION INFORMATION:
    1716             :     //       AUTHOR         Bo Shen
    1717             :     //       DATE WRITTEN   March 2016
    1718             :     //       MODIFIED       na
    1719             :     //       RE-ENGINEERED  na
    1720             : 
    1721             :     // PURPOSE OF THIS FUNCTION:
    1722             :     // This function looks up the given coil and returns the inlet node.  If
    1723             :     // incorrect coil type or name is given, ErrorsFound is returned as true and value is returned
    1724             :     // as zero.
    1725             : 
    1726             :     // Return value
    1727           1 :     int NodeNumber(0); // returned outlet node of matched coil
    1728             : 
    1729             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
    1730             :     int WhichCoil;
    1731             : 
    1732             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    1733           1 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    1734           0 :         GetIHPInput(state);
    1735           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    1736             :     }
    1737             : 
    1738           1 :     WhichCoil = Util::FindItemInList(CoilName, state.dataIntegratedHP->IntegratedHeatPumps);
    1739           1 :     if (WhichCoil != 0) {
    1740           1 :         NodeNumber = state.dataIntegratedHP->IntegratedHeatPumps(WhichCoil).AirCoolInletNodeNum;
    1741             :     }
    1742             : 
    1743           1 :     if (WhichCoil == 0) {
    1744           0 :         ShowSevereError(state, format(R"(GetCoilInletNodeIHP: Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    1745           0 :         ErrorsFound = true;
    1746           0 :         NodeNumber = 0;
    1747             :     }
    1748             : 
    1749           1 :     return NodeNumber;
    1750             : }
    1751             : 
    1752           1 : int GetDWHCoilInletNodeIHP(EnergyPlusData &state,
    1753             :                            std::string const &CoilType, // must match coil types in this module
    1754             :                            std::string const &CoilName, // must match coil names for the coil type
    1755             :                            bool &ErrorsFound            // set to true if problem
    1756             : )
    1757             : {
    1758             :     // FUNCTION INFORMATION:
    1759             :     //       AUTHOR         Bo Shen
    1760             :     //       DATE WRITTEN   July 2016
    1761             :     //       MODIFIED       na
    1762             :     //       RE-ENGINEERED  na
    1763             : 
    1764             :     // PURPOSE OF THIS FUNCTION:
    1765             :     // This function looks up the given coil and returns the inlet node.  If
    1766             :     // incorrect coil type or name is given, ErrorsFound is returned as true and value is returned
    1767             :     // as zero.
    1768             : 
    1769             :     // Return value
    1770           1 :     int NodeNumber(0); // returned outlet node of matched coil
    1771             : 
    1772             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
    1773             :     int WhichCoil;
    1774             : 
    1775             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    1776           1 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    1777           0 :         GetIHPInput(state);
    1778           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    1779             :     }
    1780             : 
    1781           1 :     WhichCoil = Util::FindItemInList(CoilName, state.dataIntegratedHP->IntegratedHeatPumps);
    1782           1 :     if (WhichCoil != 0) {
    1783           1 :         NodeNumber = state.dataIntegratedHP->IntegratedHeatPumps(WhichCoil).ODAirInletNodeNum;
    1784             :     }
    1785             : 
    1786           1 :     if (WhichCoil == 0) {
    1787           0 :         ShowSevereError(state, format(R"(GetCoilInletNodeIHP: Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    1788           0 :         ErrorsFound = true;
    1789           0 :         NodeNumber = 0;
    1790             :     }
    1791             : 
    1792           1 :     return NodeNumber;
    1793             : }
    1794             : 
    1795           1 : int GetDWHCoilOutletNodeIHP(EnergyPlusData &state,
    1796             :                             std::string const &CoilType, // must match coil types in this module
    1797             :                             std::string const &CoilName, // must match coil names for the coil type
    1798             :                             bool &ErrorsFound            // set to true if problem
    1799             : )
    1800             : {
    1801             :     // FUNCTION INFORMATION:
    1802             :     //       AUTHOR         Bo Shen
    1803             :     //       DATE WRITTEN   July 2016
    1804             :     //       MODIFIED       na
    1805             :     //       RE-ENGINEERED  na
    1806             : 
    1807             :     // PURPOSE OF THIS FUNCTION:
    1808             :     // This function looks up the given coil and returns the outlet node.  If
    1809             :     // incorrect coil type or name is given, ErrorsFound is returned as true and value is returned
    1810             :     // as zero.
    1811             : 
    1812             :     // Return value
    1813           1 :     int NodeNumber(0); // returned outlet node of matched coil
    1814             : 
    1815             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
    1816             :     int WhichCoil;
    1817             : 
    1818             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    1819           1 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    1820           0 :         GetIHPInput(state);
    1821           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    1822             :     }
    1823             : 
    1824           1 :     WhichCoil = Util::FindItemInList(CoilName, state.dataIntegratedHP->IntegratedHeatPumps);
    1825           1 :     if (WhichCoil != 0) {
    1826           1 :         NodeNumber = state.dataIntegratedHP->IntegratedHeatPumps(WhichCoil).ODAirOutletNodeNum;
    1827             :     }
    1828             : 
    1829           1 :     if (WhichCoil == 0) {
    1830           0 :         ShowSevereError(state, format(R"(GetCoilInletNodeIHP: Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    1831           0 :         ErrorsFound = true;
    1832           0 :         NodeNumber = 0;
    1833             :     }
    1834             : 
    1835           1 :     return NodeNumber;
    1836             : }
    1837             : 
    1838           1 : int GetIHPDWHCoilPLFFPLR(EnergyPlusData &state,
    1839             :                          std::string const &CoilType,                  // must match coil types in this module
    1840             :                          std::string const &CoilName,                  // must match coil names for the coil type
    1841             :                          [[maybe_unused]] IHPOperationMode const Mode, // mode coil type
    1842             :                          bool &ErrorsFound                             // set to true if problem
    1843             : )
    1844             : {
    1845             :     // FUNCTION INFORMATION:
    1846             :     //       AUTHOR         Bo Shen
    1847             :     //       DATE WRITTEN   March, 2016
    1848             :     //       MODIFIED       na
    1849             :     //       RE-ENGINEERED  na
    1850             : 
    1851             :     // PURPOSE OF THIS FUNCTION:
    1852             :     // This function looks up the given coil and returns PLR curve index.  If
    1853             :     // incorrect coil type or name is given, ErrorsFound is returned as true and value is returned
    1854             :     // as zero.
    1855             : 
    1856             :     // Using/Aliasing
    1857             :     using VariableSpeedCoils::GetVSCoilPLFFPLR;
    1858             : 
    1859             :     // Return value
    1860           1 :     int PLRNumber(0); // returned outlet node of matched coil
    1861             : 
    1862             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    1863           1 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    1864           0 :         GetIHPInput(state);
    1865           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    1866             :     }
    1867             : 
    1868           1 :     int WhichCoil = Util::FindItemInList(CoilName, state.dataIntegratedHP->IntegratedHeatPumps);
    1869           1 :     if (WhichCoil != 0) {
    1870             : 
    1871           1 :         auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(WhichCoil);
    1872             : 
    1873             :         // this will be called by HPWH parent
    1874           1 :         if (ihp.DWHCoilIndex > 0)
    1875           1 :             PLRNumber = GetVSCoilPLFFPLR(state, ihp.DWHCoilType, ihp.DWHCoilName, ErrorsFound);
    1876             :         else
    1877           0 :             PLRNumber = GetVSCoilPLFFPLR(state, ihp.SCWHCoilType, ihp.SCWHCoilName, ErrorsFound);
    1878             :     } else {
    1879           0 :         WhichCoil = 0;
    1880             :     }
    1881             : 
    1882           1 :     if (WhichCoil == 0) {
    1883           0 :         ShowSevereError(state, format(R"(GetIHPDWHCoilPLFFPLR: Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    1884           0 :         ErrorsFound = true;
    1885           0 :         PLRNumber = 0;
    1886             :     }
    1887             : 
    1888           1 :     return PLRNumber;
    1889             : }
    1890             : 
    1891           1 : Real64 GetDWHCoilCapacityIHP(EnergyPlusData &state,
    1892             :                              std::string const &CoilType,                  // must match coil types in this module
    1893             :                              std::string const &CoilName,                  // must match coil names for the coil type
    1894             :                              [[maybe_unused]] IHPOperationMode const Mode, // mode coil type
    1895             :                              bool &ErrorsFound                             // set to true if problem
    1896             : )
    1897             : {
    1898             : 
    1899             :     // FUNCTION INFORMATION:
    1900             :     //       AUTHOR         Bo Shen
    1901             :     //       DATE WRITTEN   Jan 2016
    1902             :     //       MODIFIED       na
    1903             :     //       RE-ENGINEERED  na
    1904             : 
    1905             :     // PURPOSE OF THIS FUNCTION:
    1906             :     // This function looks up the rated coil capacity at the nominal speed level for the given coil and returns it.  If
    1907             :     // incorrect coil type or name is given, ErrorsFound is returned as true and capacity is returned
    1908             :     // as negative.
    1909             : 
    1910             :     // Using/Aliasing
    1911             :     using VariableSpeedCoils::GetCoilCapacityVariableSpeed;
    1912             : 
    1913             :     // Return value
    1914             :     Real64 CoilCapacity; // returned capacity of matched coil
    1915             : 
    1916             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    1917           1 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    1918           0 :         GetIHPInput(state);
    1919           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    1920             :     }
    1921             : 
    1922           1 :     int WhichCoil = Util::FindItemInList(CoilName, state.dataIntegratedHP->IntegratedHeatPumps);
    1923           1 :     if (WhichCoil != 0) {
    1924             : 
    1925           1 :         auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(WhichCoil);
    1926             : 
    1927           1 :         if (ihp.IHPCoilsSized == false) SizeIHP(state, WhichCoil);
    1928             : 
    1929           1 :         if (ihp.DWHCoilIndex > 0) {
    1930           1 :             CoilCapacity = GetCoilCapacityVariableSpeed(state, ihp.DWHCoilType, ihp.DWHCoilName, ErrorsFound);
    1931             :         } else {
    1932           0 :             CoilCapacity = GetCoilCapacityVariableSpeed(state, ihp.SCWHCoilType, ihp.SCWHCoilName, ErrorsFound);
    1933             :         }
    1934             :     } else {
    1935           0 :         WhichCoil = 0;
    1936             :     }
    1937             : 
    1938           1 :     if (WhichCoil == 0) {
    1939           0 :         ShowSevereError(state, format(R"(GetCoilCapacityVariableSpeed: Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    1940           0 :         ErrorsFound = true;
    1941           0 :         CoilCapacity = -1000.0;
    1942             :     }
    1943             : 
    1944           1 :     return CoilCapacity;
    1945             : }
    1946             : 
    1947        1531 : int GetLowSpeedNumIHP(EnergyPlusData &state, int const DXCoilNum)
    1948             : {
    1949        1531 :     int SpeedNum(0);
    1950             : 
    1951             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    1952        1531 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    1953           0 :         GetIHPInput(state);
    1954           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    1955             :     }
    1956             : 
    1957        1531 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    1958           0 :         ShowFatalError(state,
    1959           0 :                        format("GetLowSpeedNumIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    1960             :                               DXCoilNum,
    1961           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    1962             :     }
    1963             : 
    1964        1531 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    1965             : 
    1966        1531 :     switch (ihp.CurMode) {
    1967         161 :     case IHPOperationMode::Idle:
    1968             :     case IHPOperationMode::SpaceClg:
    1969             :     case IHPOperationMode::SpaceHtg:
    1970             :     case IHPOperationMode::DedicatedWaterHtg:
    1971         161 :         SpeedNum = 1;
    1972         161 :         break;
    1973         224 :     case IHPOperationMode::SCWHMatchSC:
    1974             :     case IHPOperationMode::SCWHMatchWH:
    1975         224 :         SpeedNum = ihp.MinSpedSCWH;
    1976         224 :         break;
    1977        1146 :     case IHPOperationMode::SpaceClgDedicatedWaterHtg:
    1978        1146 :         SpeedNum = ihp.MinSpedSCDWH;
    1979        1146 :         break;
    1980           0 :     case IHPOperationMode::SHDWHElecHeatOff:
    1981             :     case IHPOperationMode::SHDWHElecHeatOn:
    1982           0 :         SpeedNum = ihp.MinSpedSHDWH;
    1983           0 :         break;
    1984           0 :     default:
    1985           0 :         SpeedNum = 1;
    1986           0 :         break;
    1987             :     }
    1988             : 
    1989        1531 :     return (SpeedNum);
    1990             : }
    1991             : 
    1992       67912 : int GetMaxSpeedNumIHP(EnergyPlusData &state, int const DXCoilNum)
    1993             : {
    1994             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    1995       67912 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    1996           0 :         GetIHPInput(state);
    1997           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    1998             :     }
    1999             : 
    2000       67912 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    2001           0 :         ShowFatalError(state,
    2002           0 :                        format("GetMaxSpeedNumIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    2003             :                               DXCoilNum,
    2004           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    2005             :     }
    2006             : 
    2007       67912 :     int SpeedNum(0);
    2008       67912 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    2009             : 
    2010       67912 :     switch (ihp.CurMode) {
    2011       17944 :     case IHPOperationMode::Idle:
    2012             :     case IHPOperationMode::SpaceClg:
    2013       17944 :         SpeedNum = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCCoilIndex).NumOfSpeeds;
    2014       17944 :         break;
    2015       23270 :     case IHPOperationMode::SpaceHtg:
    2016       23270 :         SpeedNum = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHCoilIndex).NumOfSpeeds;
    2017       23270 :         break;
    2018         112 :     case IHPOperationMode::DedicatedWaterHtg:
    2019         112 :         SpeedNum = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.DWHCoilIndex).NumOfSpeeds;
    2020         112 :         break;
    2021         168 :     case IHPOperationMode::SCWHMatchSC:
    2022             :     case IHPOperationMode::SCWHMatchWH:
    2023         168 :         SpeedNum = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).NumOfSpeeds;
    2024         168 :         break;
    2025       26418 :     case IHPOperationMode::SpaceClgDedicatedWaterHtg:
    2026       26418 :         SpeedNum = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).NumOfSpeeds;
    2027       26418 :         break;
    2028           0 :     case IHPOperationMode::SHDWHElecHeatOff:
    2029             :     case IHPOperationMode::SHDWHElecHeatOn:
    2030           0 :         SpeedNum = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHHeatCoilIndex).NumOfSpeeds;
    2031           0 :         break;
    2032           0 :     default:
    2033           0 :         SpeedNum = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCCoilIndex).NumOfSpeeds;
    2034           0 :         break;
    2035             :     }
    2036             : 
    2037       67912 :     return (SpeedNum);
    2038             : }
    2039             : 
    2040       19412 : Real64 GetAirVolFlowRateIHP(EnergyPlusData &state,
    2041             :                             int const DXCoilNum,
    2042             :                             int const SpeedNum,
    2043             :                             Real64 const SpeedRatio,
    2044             :                             bool const IsCallbyWH // whether the call from the water heating loop or air loop, true = from water heating loop
    2045             : )
    2046             : {
    2047       19412 :     int IHPCoilIndex(0);
    2048       19412 :     Real64 AirVolFlowRate(0.0);
    2049       19412 :     Real64 FlowScale(1.0);
    2050       19412 :     bool IsResultFlow(false); // IsResultFlow = true, the air flow rate will be from a simultaneous mode, won't be re-calculated
    2051             : 
    2052             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    2053       19412 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2054           0 :         GetIHPInput(state);
    2055           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2056             :     }
    2057             : 
    2058       19412 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    2059           0 :         ShowFatalError(state,
    2060           0 :                        format("GetAirVolFlowRateIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    2061             :                               DXCoilNum,
    2062           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    2063             :     }
    2064             : 
    2065       19412 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    2066             : 
    2067       19412 :     if (!ihp.IHPCoilsSized) SizeIHP(state, DXCoilNum);
    2068             : 
    2069       19412 :     FlowScale = 0.0;
    2070       19412 :     switch (ihp.CurMode) {
    2071         818 :     case IHPOperationMode::Idle:
    2072         818 :         IHPCoilIndex = ihp.SCCoilIndex;
    2073         818 :         break;
    2074          16 :     case IHPOperationMode::SpaceClg:
    2075          16 :         IHPCoilIndex = ihp.SCCoilIndex;
    2076          16 :         if (!IsCallbyWH) // call from air loop
    2077             :         {
    2078           0 :             FlowScale = ihp.CoolVolFlowScale;
    2079             :         }
    2080             : 
    2081          16 :         break;
    2082        9286 :     case IHPOperationMode::SpaceHtg:
    2083        9286 :         IHPCoilIndex = ihp.SHCoilIndex;
    2084        9286 :         if (!IsCallbyWH) // call from air loop
    2085             :         {
    2086           0 :             FlowScale = ihp.HeatVolFlowScale;
    2087             :         }
    2088        9286 :         break;
    2089        1432 :     case IHPOperationMode::DedicatedWaterHtg:
    2090        1432 :         IHPCoilIndex = ihp.DWHCoilIndex;
    2091        1432 :         FlowScale = 1.0;
    2092        1432 :         break;
    2093           0 :     case IHPOperationMode::SCWHMatchSC:
    2094           0 :         IHPCoilIndex = ihp.SCWHCoilIndex;
    2095           0 :         FlowScale = ihp.CoolVolFlowScale;
    2096           0 :         if (IsCallbyWH) // call from water loop
    2097             :         {
    2098           0 :             IsResultFlow = true;
    2099           0 :             AirVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).AirVolFlowRate;
    2100             :         }
    2101           0 :         break;
    2102        3282 :     case IHPOperationMode::SCWHMatchWH:
    2103        3282 :         IHPCoilIndex = ihp.SCWHCoilIndex;
    2104        3282 :         FlowScale = ihp.CoolVolFlowScale;
    2105        3282 :         if (!IsCallbyWH) {
    2106           0 :             IsResultFlow = true;
    2107           0 :             AirVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCWHCoilIndex).AirVolFlowRate;
    2108             :         }
    2109        3282 :         break;
    2110        4578 :     case IHPOperationMode::SpaceClgDedicatedWaterHtg:
    2111        4578 :         IHPCoilIndex = ihp.SCDWHCoolCoilIndex;
    2112        4578 :         FlowScale = ihp.CoolVolFlowScale;
    2113        4578 :         if (IsCallbyWH) {
    2114        4578 :             IsResultFlow = true;
    2115        4578 :             AirVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SCDWHCoolCoilIndex).AirVolFlowRate;
    2116             :         }
    2117        4578 :         break;
    2118           0 :     case IHPOperationMode::SHDWHElecHeatOff:
    2119             :     case IHPOperationMode::SHDWHElecHeatOn:
    2120           0 :         IHPCoilIndex = ihp.SHDWHHeatCoilIndex;
    2121           0 :         FlowScale = ihp.HeatVolFlowScale;
    2122           0 :         if (IsCallbyWH) {
    2123           0 :             IsResultFlow = true;
    2124           0 :             AirVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHHeatCoilIndex).AirVolFlowRate;
    2125             :         }
    2126           0 :         break;
    2127           0 :     default:
    2128           0 :         IHPCoilIndex = ihp.SCCoilIndex;
    2129           0 :         FlowScale = 0.0;
    2130           0 :         break;
    2131             :     }
    2132             : 
    2133       19412 :     if (!IsResultFlow) {
    2134       14834 :         if (1 == SpeedNum)
    2135       11970 :             AirVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedAirVolFlowRate(SpeedNum);
    2136             :         else
    2137        2864 :             AirVolFlowRate = SpeedRatio * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedAirVolFlowRate(SpeedNum) +
    2138        2864 :                              (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedAirVolFlowRate(SpeedNum - 1);
    2139             : 
    2140       14834 :         AirVolFlowRate = AirVolFlowRate * FlowScale;
    2141             :     }
    2142             : 
    2143       19412 :     if (AirVolFlowRate > ihp.MaxCoolAirVolFlow) AirVolFlowRate = ihp.MaxCoolAirVolFlow;
    2144       19412 :     if (AirVolFlowRate > ihp.MaxHeatAirVolFlow) AirVolFlowRate = ihp.MaxHeatAirVolFlow;
    2145             : 
    2146       19412 :     return (AirVolFlowRate);
    2147             : }
    2148             : 
    2149      125508 : Real64 GetWaterVolFlowRateIHP(EnergyPlusData &state, int const DXCoilNum, int const SpeedNum, Real64 const SpeedRatio)
    2150             : {
    2151      125508 :     int IHPCoilIndex(0);
    2152      125508 :     Real64 WaterVolFlowRate(0.0);
    2153             : 
    2154             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    2155      125508 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2156           0 :         GetIHPInput(state);
    2157           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2158             :     }
    2159             : 
    2160      125508 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    2161           0 :         ShowFatalError(state,
    2162           0 :                        format("GetWaterVolFlowRateIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    2163             :                               DXCoilNum,
    2164           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    2165             :     }
    2166             : 
    2167      125508 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    2168             : 
    2169      125508 :     if (!ihp.IHPCoilsSized) SizeIHP(state, DXCoilNum);
    2170             : 
    2171      125508 :     switch (ihp.CurMode) {
    2172       13885 :     case IHPOperationMode::Idle:
    2173             :     case IHPOperationMode::SpaceClg:
    2174             :     case IHPOperationMode::SpaceHtg:
    2175       13885 :         WaterVolFlowRate = 0.0;
    2176       13885 :         break;
    2177        1488 :     case IHPOperationMode::DedicatedWaterHtg:
    2178        1488 :         IHPCoilIndex = ihp.DWHCoilIndex;
    2179        1488 :         if (1 == SpeedNum)
    2180         448 :             WaterVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum);
    2181             :         else
    2182        1040 :             WaterVolFlowRate = SpeedRatio * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum) +
    2183        1040 :                                (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum - 1);
    2184        1488 :         break;
    2185        3338 :     case IHPOperationMode::SCWHMatchSC:
    2186             :     case IHPOperationMode::SCWHMatchWH:
    2187        3338 :         IHPCoilIndex = ihp.SCWHCoilIndex;
    2188        3338 :         if (1 == SpeedNum)
    2189        1658 :             WaterVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum);
    2190             :         else
    2191        1680 :             WaterVolFlowRate = SpeedRatio * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum) +
    2192        1680 :                                (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum - 1);
    2193        3338 :         break;
    2194      106797 :     case IHPOperationMode::SpaceClgDedicatedWaterHtg:
    2195      106797 :         IHPCoilIndex = ihp.SCDWHWHCoilIndex;
    2196      106797 :         if (1 == SpeedNum)
    2197       40625 :             WaterVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum);
    2198             :         else
    2199       66172 :             WaterVolFlowRate = SpeedRatio * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum) +
    2200       66172 :                                (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum - 1);
    2201      106797 :         break;
    2202           0 :     case IHPOperationMode::SHDWHElecHeatOff:
    2203             :     case IHPOperationMode::SHDWHElecHeatOn:
    2204           0 :         IHPCoilIndex = ihp.SHDWHWHCoilIndex;
    2205           0 :         if (1 == SpeedNum)
    2206           0 :             WaterVolFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum);
    2207             :         else
    2208           0 :             WaterVolFlowRate = SpeedRatio * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum) +
    2209           0 :                                (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedWaterVolFlowRate(SpeedNum - 1);
    2210           0 :         break;
    2211           0 :     default:
    2212           0 :         WaterVolFlowRate = 0.0;
    2213           0 :         break;
    2214             :     }
    2215             : 
    2216      125508 :     return (WaterVolFlowRate);
    2217             : }
    2218             : 
    2219      256296 : Real64 GetAirMassFlowRateIHP(EnergyPlusData &state,
    2220             :                              int const DXCoilNum,
    2221             :                              int const SpeedNum,
    2222             :                              Real64 const SpeedRatio,
    2223             :                              bool const IsCallbyWH // whether the call from the water heating loop or air loop, true = from water heating loop
    2224             : )
    2225             : {
    2226      256296 :     int IHPCoilIndex(0);
    2227      256296 :     Real64 AirMassFlowRate(0.0);
    2228      256296 :     Real64 FlowScale(1.0);
    2229      256296 :     bool IsResultFlow(false); // IsResultFlow = true, the air flow rate will be from a simultaneous mode, won't be re-calculated
    2230             : 
    2231             :     // Obtains and Allocates WatertoAirHP related parameters from input file
    2232      256296 :     if (state.dataIntegratedHP->GetCoilsInputFlag) { // First time subroutine has been entered
    2233           0 :         GetIHPInput(state);
    2234           0 :         state.dataIntegratedHP->GetCoilsInputFlag = false;
    2235             :     }
    2236             : 
    2237      256296 :     if (DXCoilNum > static_cast<int>(state.dataIntegratedHP->IntegratedHeatPumps.size()) || DXCoilNum < 1) {
    2238           0 :         ShowFatalError(state,
    2239           0 :                        format("GetAirMassFlowRateIHP: Invalid CompIndex passed={}, Number of Integrated HPs={}, IHP name=AS-IHP",
    2240             :                               DXCoilNum,
    2241           0 :                               state.dataIntegratedHP->IntegratedHeatPumps.size()));
    2242             :     }
    2243             : 
    2244      256296 :     auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum);
    2245             : 
    2246      256296 :     if (!ihp.IHPCoilsSized) SizeIHP(state, DXCoilNum);
    2247             : 
    2248      256296 :     FlowScale = 0.0;
    2249      256296 :     switch (ihp.CurMode) {
    2250         818 :     case IHPOperationMode::Idle:
    2251         818 :         IHPCoilIndex = ihp.SCCoilIndex;
    2252         818 :         AirMassFlowRate = 0.0;
    2253         818 :         break;
    2254       65532 :     case IHPOperationMode::SpaceClg:
    2255       65532 :         IHPCoilIndex = ihp.SCCoilIndex;
    2256       65532 :         if (!IsCallbyWH) {
    2257       65516 :             FlowScale = ihp.CoolVolFlowScale;
    2258             :         } else {
    2259          16 :             IsResultFlow = true;
    2260          16 :             AirMassFlowRate = ihp.AirFlowSavInAirLoop;
    2261             :         }
    2262       65532 :         break;
    2263       83790 :     case IHPOperationMode::SpaceHtg:
    2264       83790 :         IHPCoilIndex = ihp.SHCoilIndex;
    2265       83790 :         if (!IsCallbyWH) {
    2266       74504 :             FlowScale = ihp.HeatVolFlowScale;
    2267             :         } else {
    2268        9286 :             IsResultFlow = true;
    2269        9286 :             AirMassFlowRate = ihp.AirFlowSavInAirLoop;
    2270             :         }
    2271       83790 :         break;
    2272        1464 :     case IHPOperationMode::DedicatedWaterHtg:
    2273        1464 :         IHPCoilIndex = ihp.DWHCoilIndex;
    2274        1464 :         FlowScale = 1.0;
    2275        1464 :         break;
    2276           0 :     case IHPOperationMode::SCWHMatchSC:
    2277           0 :         IHPCoilIndex = ihp.SCWHCoilIndex;
    2278           0 :         FlowScale = ihp.CoolVolFlowScale;
    2279           0 :         state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate = GetWaterVolFlowRateIHP(state, DXCoilNum, SpeedNum, SpeedRatio) * WaterDensity;
    2280           0 :         if (IsCallbyWH) {
    2281           0 :             IsResultFlow = true;
    2282           0 :             AirMassFlowRate = ihp.AirFlowSavInAirLoop;
    2283             :         }
    2284           0 :         break;
    2285        3618 :     case IHPOperationMode::SCWHMatchWH:
    2286        3618 :         IHPCoilIndex = ihp.SCWHCoilIndex;
    2287        3618 :         FlowScale = ihp.CoolVolFlowScale;
    2288        3618 :         if (!IsCallbyWH) {
    2289         336 :             IsResultFlow = true;
    2290         336 :             AirMassFlowRate = ihp.AirFlowSavInWaterLoop;
    2291             :         }
    2292        3618 :         break;
    2293      101074 :     case IHPOperationMode::SpaceClgDedicatedWaterHtg:
    2294      101074 :         IHPCoilIndex = ihp.SCDWHCoolCoilIndex;
    2295      101074 :         FlowScale = ihp.CoolVolFlowScale;
    2296      101074 :         state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate = GetWaterVolFlowRateIHP(state, DXCoilNum, SpeedNum, SpeedRatio) * WaterDensity;
    2297      101074 :         if (IsCallbyWH) {
    2298        4578 :             IsResultFlow = true;
    2299        4578 :             AirMassFlowRate = ihp.AirFlowSavInAirLoop;
    2300             :         }
    2301      101074 :         break;
    2302           0 :     case IHPOperationMode::SHDWHElecHeatOff:
    2303             :     case IHPOperationMode::SHDWHElecHeatOn:
    2304           0 :         IHPCoilIndex = ihp.SHDWHHeatCoilIndex;
    2305           0 :         FlowScale = ihp.HeatVolFlowScale;
    2306           0 :         state.dataLoopNodes->Node(ihp.WaterInletNodeNum).MassFlowRate = GetWaterVolFlowRateIHP(state, DXCoilNum, SpeedNum, SpeedRatio) * WaterDensity;
    2307           0 :         if (IsCallbyWH) {
    2308           0 :             IsResultFlow = true;
    2309           0 :             AirMassFlowRate = ihp.AirFlowSavInAirLoop;
    2310             :         }
    2311           0 :         break;
    2312           0 :     default:
    2313           0 :         IHPCoilIndex = ihp.SCCoilIndex;
    2314           0 :         FlowScale = 0.0;
    2315           0 :         break;
    2316             :     }
    2317             : 
    2318      256296 :     if (!IsResultFlow) {
    2319      242080 :         if (SpeedNum == 1) {
    2320       60556 :             AirMassFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedAirMassFlowRate(SpeedNum);
    2321             :         } else {
    2322      181524 :             AirMassFlowRate = SpeedRatio * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedAirMassFlowRate(SpeedNum) +
    2323      181524 :                               (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(IHPCoilIndex).MSRatedAirMassFlowRate(SpeedNum - 1);
    2324             :         }
    2325             : 
    2326      242080 :         AirMassFlowRate = AirMassFlowRate * FlowScale;
    2327             :     }
    2328             : 
    2329      256296 :     if (AirMassFlowRate > ihp.MaxCoolAirMassFlow) {
    2330           0 :         AirMassFlowRate = ihp.MaxCoolAirMassFlow;
    2331             :     }
    2332      256296 :     if (AirMassFlowRate > ihp.MaxHeatAirMassFlow) {
    2333           0 :         AirMassFlowRate = ihp.MaxHeatAirMassFlow;
    2334             :     }
    2335             : 
    2336             :     // set max air flow rate
    2337      256296 :     state.dataLoopNodes->Node(ihp.AirCoolInletNodeNum).MassFlowRateMax = AirMassFlowRate;
    2338      256296 :     state.dataLoopNodes->Node(ihp.AirHeatInletNodeNum).MassFlowRateMax = AirMassFlowRate;
    2339      256296 :     state.dataLoopNodes->Node(ihp.AirOutletNodeNum).MassFlowRateMax = AirMassFlowRate;
    2340             : 
    2341      256296 :     return AirMassFlowRate;
    2342             : }
    2343             : 
    2344             : } // namespace EnergyPlus::IntegratedHeatPump

Generated by: LCOV version 1.14