diff --git a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc index 737d62cef48..3caa350548a 100644 --- a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc +++ b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc @@ -11330,19 +11330,25 @@ void VRFCondenserEquipment::CalcVRFCondenser_FluidTCtrl(EnergyPlusData &state, c C_cap_operation = this->VRFOU_CapModFactor( state, h_comp_in, h_IU_evap_in, max(min(Psuction, RefPHigh), RefPLow), Tsuction + SH_Comp, Tsuction + 8, CapMinTc - 5); - // Iteration_Ncomp: Perform iterations to calculate Ncomp (Label10) - Counter = 1; + // Perform iterations to calculate Ncomp + Counter = 0; Ncomp = TU_CoolingLoad / this->CoolingCOP; Ncomp_new = Ncomp; - bool converged_10; + + bool ncompConverged = false; + bool iterationLimitReached = false; + do { - Q_h_OU = Q_c_TU_PL + Ncomp_new; // Ncomp_new may be updated during Iteration_Ncomp Label10 + ++Counter; + + Q_h_OU = Q_c_TU_PL + Ncomp_new; - // *VRF OU TeTc calculations m_air = this->OUAirFlowRate * RhoAir; SC_OU = this->SC; + this->VRFOU_TeTc( state, HXOpMode::CondMode, Q_h_OU, SC_OU, m_air, OutdoorDryBulb, OutdoorHumRat, OutdoorPressure, Tfs, this->CondensingTemp); + this->CondensingTemp = min(CapMaxTc, this->CondensingTemp); this->SC = SC_OU; @@ -11362,11 +11368,23 @@ void VRFCondenserEquipment::CalcVRFCondenser_FluidTCtrl(EnergyPlusData &state, c Ncomp, CyclingRatio); - converged_10 = (std::abs(Ncomp - Ncomp_new) <= (Tolerance * Ncomp_new)) || (Counter >= 30); - if (!converged_10) { + ncompConverged = std::abs(Ncomp - Ncomp_new) <= (Tolerance * std::abs(Ncomp_new)); + + iterationLimitReached = Counter >= 30; + + if (!ncompConverged && !iterationLimitReached) { Ncomp_new = Ncomp; } - } while (!converged_10); + + } while (!ncompConverged && !iterationLimitReached); + + if (iterationLimitReached && !ncompConverged) { + ShowWarningMessage(state, EnergyPlus::format("{} \"{}\":", cVRFTypes(VRF_HeatPump), this->Name)); + ShowContinueError( + state, + EnergyPlus::format( + "...{}: Iteration limit exceeded calculating cooling mode compressor power, maximum iterations = {}", RoutineName, Counter)); + } // Update h_IU_evap_in in iterations Label12 h_IU_evap_in_new = this->refrig->getSatEnthalpy(state, this->CondensingTemp - this->SC, 0.0, RoutineName); @@ -11552,18 +11570,25 @@ void VRFCondenserEquipment::CalcVRFCondenser_FluidTCtrl(EnergyPlusData &state, c } // CompEvaporatingCAPSpdMin < (Q_c_OU * C_cap_operation) <= CompEvaporatingCAPSpdMaxCurrentTsuc + CompEvaporatingPWRSpdMaxCurrentTsuc // Required heating load is greater than or equal to the min heating capacity - // Iteration_Ncomp: Perform iterations to calculate Ncomp (Label20) - Counter = 1; - bool converged_20; + // Iteration_Ncomp: Perform iterations to calculate Ncomp + Counter = 0; + + bool ncompConverged = false; + bool iterationLimitReached = false; + do { + ++Counter; + Ncomp_new = Ncomp; Q_c_OU = max(0.0, Q_h_TU_PL - Ncomp); // *VRF OU Te calculations m_air = this->OUAirFlowRate * RhoAir; SH_OU = this->SH; + this->VRFOU_TeTc( state, HXOpMode::EvapMode, Q_c_OU, SH_OU, m_air, OutdoorDryBulb, OutdoorHumRat, OutdoorPressure, Tfs, this->EvaporatingTemp); + this->SH = SH_OU; // *VRF OU Compressor Simulation at heating mode: Specify the compressor speed and power consumption @@ -11581,12 +11606,23 @@ void VRFCondenserEquipment::CalcVRFCondenser_FluidTCtrl(EnergyPlusData &state, c Ncomp_new, CyclingRatio); - converged_20 = (std::abs(Ncomp_new - Ncomp) <= (Tolerance * Ncomp)) || (Counter >= 30); - Counter = Counter + 1; - if (!converged_20) { + ncompConverged = std::abs(Ncomp_new - Ncomp) <= (Tolerance * std::abs(Ncomp)); + + iterationLimitReached = Counter >= 30; + + if (!ncompConverged && !iterationLimitReached) { Ncomp = Ncomp_new; } - } while (!converged_20); + + } while (!ncompConverged && !iterationLimitReached); + + if (iterationLimitReached && !ncompConverged) { + ShowWarningMessage(state, EnergyPlus::format("{} \"{}\":", cVRFTypes(VRF_HeatPump), this->Name)); + ShowContinueError( + state, + EnergyPlus::format( + "...{}: Iteration limit exceeded calculating heating mode compressor power, maximum iterations = {}", RoutineName, Counter)); + } // Update h_comp_out in iteration Label23 P_comp_in = this->refrig->getSatPressure(state, this->EvaporatingTemp, RoutineName);