Skip to content

Commit

Permalink
goto to do-while for Label20 in physics-based VRF
Browse files Browse the repository at this point in the history
original:

    label:
        stuff A
    if (some condition) {
        stuff B
        goto label
    }

intermediate step:

    label:
        stuff A
        calculate condition before updating Ncomp
        stuff B
    if (some condition) {
        goto label
    }

final step:

    do {
        stuff A
        stuff B
    } while (condition)
  • Loading branch information
Yujie Xu committed May 15, 2024
1 parent 22053e4 commit ed744c2
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions src/EnergyPlus/HVACVariableRefrigerantFlow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11687,36 +11687,36 @@ void VRFCondenserEquipment::CalcVRFCondenser_FluidTCtrl(EnergyPlusData &state)

// Iteration_Ncomp: Perform iterations to calculate Ncomp (Label20)
Counter = 1;
Label20:;
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
this->VRFOU_CalcCompH(state,
TU_HeatingLoad,
this->EvaporatingTemp,
Tdischarge,
h_IU_cond_out_ave,
this->IUCondensingTemp,
CapMinTe,
Tfs,
Pipe_Q_h,
Q_c_OU,
CompSpdActual,
Ncomp_new);

if ((std::abs(Ncomp_new - Ncomp) > (Tolerance * Ncomp)) && (Counter < 30)) {
bool not_converged;
do {
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
this->VRFOU_CalcCompH(state,
TU_HeatingLoad,
this->EvaporatingTemp,
Tdischarge,
h_IU_cond_out_ave,
this->IUCondensingTemp,
CapMinTe,
Tfs,
Pipe_Q_h,
Q_c_OU,
CompSpdActual,
Ncomp_new);

bool not_converged = (std::abs(Ncomp_new - Ncomp) > (Tolerance * Ncomp));
Ncomp = Ncomp_new;
Counter = Counter + 1;
goto Label20;
}
} while (not_converged && (Counter < 30));

// Update h_comp_out in iteration Label23
P_comp_in = GetSatPressureRefrig(state, this->RefrigerantName, this->EvaporatingTemp, RefrigerantIndex, RoutineName);
Expand Down

5 comments on commit ed744c2

@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 (2774 of 2774 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 (3601 of 3603 tests passed, 1 test warnings)

Messages:\n

  • 2 tests had: Table big diffs.
  • 1 test had: ESO big diffs.
  • 1 test had: ESO small diffs.
  • 1 test had: MTR small diffs.
  • 1 test had: Table small diffs.

Failures:\n

regression Test Summary

  • Passed: 805
  • Failed: 2

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 (3560 of 3562 tests passed, 1 test warnings)

Messages:\n

  • 2 tests had: Table big diffs.
  • 1 test had: ESO big diffs.
  • 1 test had: ESO small diffs.
  • 1 test had: MTR small diffs.
  • 1 test had: Table small diffs.

Failures:\n

regression Test Summary

  • Passed: 785
  • 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 (1986 of 1986 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.