Skip to content

Commit

Permalink
convert label 19, can directly convert to do-while
Browse files Browse the repository at this point in the history
there's only a counter increase inside the if condition in goto
  • Loading branch information
Yujie Xu committed May 23, 2024
1 parent 76edf3a commit de28187
Showing 1 changed file with 45 additions and 44 deletions.
89 changes: 45 additions & 44 deletions src/EnergyPlus/HVACVariableRefrigerantFlow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14386,58 +14386,59 @@ void VRFCondenserEquipment::VRFOU_CalcCompH(
// Low Load Modifications

NumIteCcap = 1;
Label19:;
Q_evap_req = max(0.0, TU_load + Pipe_Q - Ncomp);
bool converged_19;
// triggered in VariableRefrigerantFlow_FluidTCtrl_HR_5Zone.idf
do {
Q_evap_req = max(0.0, TU_load + Pipe_Q - Ncomp);

// Update Te'( SmallLoadTe ) to meet the required evaporator capacity
CompSpdActual = this->CompressorSpeed(1);
Real64 CondHeat = Q_evap_req * C_cap_operation / this->RatedEvapCapacity;
int CAPFT = this->OUCoolingCAPFT(CounterCompSpdTemp);
// Update Te'( SmallLoadTe ) to meet the required evaporator capacity
CompSpdActual = this->CompressorSpeed(1);
Real64 CondHeat = Q_evap_req * C_cap_operation / this->RatedEvapCapacity;
int CAPFT = this->OUCoolingCAPFT(CounterCompSpdTemp);

auto f = [&state, T_discharge, CondHeat, CAPFT](Real64 const T_suc) {
return CompResidual_FluidTCtrl(state, T_discharge, CondHeat, CAPFT, T_suc);
};
auto f = [&state, T_discharge, CondHeat, CAPFT](Real64 const T_suc) {
return CompResidual_FluidTCtrl(state, T_discharge, CondHeat, CAPFT, T_suc);
};

General::SolveRoot(state, 1.0e-3, MaxIter, SolFla, SmallLoadTe, f, MinOutdoorUnitTe, T_suction);
if (SolFla < 0) SmallLoadTe = MinOutdoorUnitTe;
General::SolveRoot(state, 1.0e-3, MaxIter, SolFla, SmallLoadTe, f, MinOutdoorUnitTe, T_suction);
if (SolFla < 0) SmallLoadTe = MinOutdoorUnitTe;

T_suction = SmallLoadTe;
T_suction = SmallLoadTe;

// 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);

Modifi_Pe = GetSatPressureRefrig(state, this->RefrigerantName, T_suction, RefrigerantIndex, RoutineName);

// Calculate capacity modification factor
RefTSat =
GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Modifi_Pe, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
Pipe_h_comp_in = GetSupHeatEnthalpyRefrig(state,
this->RefrigerantName,
max(RefTSat, T_suction + Modifi_SH),
max(min(Modifi_Pe, RefPHigh), RefPLow),
RefrigerantIndex,
RoutineName);
C_cap_operation = this->VRFOU_CapModFactor(state,
Pipe_h_comp_in,
Pipe_h_out_ave,
max(min(Modifi_Pe, RefPHigh), RefPLow),
T_suction + Modifi_SH,
T_suction + 8,
IUMaxCondTemp - 5);
// 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);

Cap_Eva0 = Q_evap_req * C_cap_operation;
Cap_Eva1 =
this->CoffEvapCap * this->RatedEvapCapacity * CurveValue(state, this->OUCoolingCAPFT(CounterCompSpdTemp), T_discharge, T_suction);
CapDiff = std::abs(Cap_Eva1 - Cap_Eva0);
Modifi_Pe = GetSatPressureRefrig(state, this->RefrigerantName, T_suction, RefrigerantIndex, RoutineName);

if ((CapDiff > (Tolerance * Cap_Eva0)) && (NumIteCcap < 30)) {
// Calculate capacity modification factor
RefTSat =
GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Modifi_Pe, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
Pipe_h_comp_in = GetSupHeatEnthalpyRefrig(state,
this->RefrigerantName,
max(RefTSat, T_suction + Modifi_SH),
max(min(Modifi_Pe, RefPHigh), RefPLow),
RefrigerantIndex,
RoutineName);
C_cap_operation = this->VRFOU_CapModFactor(state,
Pipe_h_comp_in,
Pipe_h_out_ave,
max(min(Modifi_Pe, RefPHigh), RefPLow),
T_suction + Modifi_SH,
T_suction + 8,
IUMaxCondTemp - 5);

Cap_Eva0 = Q_evap_req * C_cap_operation;
Cap_Eva1 = this->CoffEvapCap * this->RatedEvapCapacity *
CurveValue(state, this->OUCoolingCAPFT(CounterCompSpdTemp), T_discharge, T_suction);
CapDiff = std::abs(Cap_Eva1 - Cap_Eva0);

converged_19 = (CapDiff <= (Tolerance * Cap_Eva0)) || (NumIteCcap >= 30);
NumIteCcap = NumIteCcap + 1;
goto Label19;
}
} while (!converged_19);
if (CapDiff > (Tolerance * Cap_Eva0)) NumIteCcap = 999;

Ncomp = this->RatedCompPower * CurveValue(state, this->OUCoolingPWRFT(CounterCompSpdTemp), T_discharge, T_suction);
Expand Down

5 comments on commit de28187

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactorGOTO (Unknown) - Win64-Windows-10-VisualStudio-16: OK (2775 of 2775 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactorGOTO (Unknown) - x86_64-MacOS-10.18-clang-15.0.0: OK (3563 of 3563 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactorGOTO (Unknown) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (3602 of 3604 tests passed, 1 test warnings)

Messages:\n

  • 3 tests had: AUD diffs.
  • 3 tests had: EIO diffs.
  • 3 tests had: ERR diffs.
  • 2 tests had: EDD diffs.
  • 2 tests had: Table big diffs.

Failures:\n

regression Test Summary

  • Passed: 805
  • Failed: 2

Build Badge Test Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactorGOTO (Unknown) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (1987 of 1987 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactorGOTO (Unknown) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (791 of 791 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.