From 76477454192bfd8e8c9d865e6f45bf1f6516e7f6 Mon Sep 17 00:00:00 2001 From: Yujie Xu Date: Fri, 30 Aug 2024 16:55:35 -0700 Subject: [PATCH] deal with b^2 - 4ac < 0 no root case --- src/EnergyPlus/HVACVariableRefrigerantFlow.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc index 6fa06b0f703..8263b4790cd 100644 --- a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc +++ b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc @@ -14274,9 +14274,13 @@ void VRFCondenserEquipment::VRFOU_CalcCompH( // Update SH and Pe to calculate Modification Factor, which is used to update rps to for N_comp calculations if (this->C3Te == 0) Modifi_SH = -(this->C1Te - Tfs + T_suction) / this->C2Te; - else - Modifi_SH = - (-this->C2Te + std::pow((pow_2(this->C2Te) - 4 * (this->C1Te - Tfs + T_suction) * this->C3Te), 0.5)) / (2 * this->C3Te); + else { + if ((pow_2(this->C2Te) - 4 * (this->C1Te - Tfs + T_suction) * this->C3Te) < 0.0) + Modifi_SH = this->C2Te / (-2 * (this->C1Te - Tfs + T_suction)); + else + Modifi_SH = + (-this->C2Te + std::pow((pow_2(this->C2Te) - 4 * (this->C1Te - Tfs + T_suction) * this->C3Te), 0.5)) / (2 * this->C3Te); + } Modifi_Pe = this->refrig->getSatPressure(state, T_suction, RoutineName);