Skip to content

Commit

Permalink
add another check to remove the one additional Ncomp = Ncomp_new;
Browse files Browse the repository at this point in the history
assume the evaluation of conditions doesn't change code behavior

this evaluates to A(BA)*

    label:             <- the original code
        stuff A
    if (condition) {
        stuff B
        goto label
    }

this evaluates to (AB)+

    do {
        stuff A
        evaluate condition (in case stuff overwrites variables used in it)
        stuff B
    } while (condition)

This will lead to one more "B" than the original code

So change it to this

    do {
        stuff A
        evaluate condition (in case stuff overwrites variables used in it)
        if (condition) {
            stuff B
        }
    } while (condition)
  • Loading branch information
Yujie Xu committed May 23, 2024
1 parent f431bc6 commit ad28a57
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/EnergyPlus/HVACVariableRefrigerantFlow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11713,10 +11713,12 @@ void VRFCondenserEquipment::CalcVRFCondenser_FluidTCtrl(EnergyPlusData &state)
CompSpdActual,
Ncomp_new);

bool converged = !(std::abs(Ncomp_new - Ncomp) > (Tolerance * Ncomp));
Ncomp = Ncomp_new;
converged = (std::abs(Ncomp_new - Ncomp) <= (Tolerance * Ncomp)) || (Counter >= 30);
Counter = Counter + 1;
} while ((!converged) && (Counter < 30));
if (!converged) {
Ncomp = Ncomp_new;
}
} while (!converged);

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

5 comments on commit ad28a57

@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-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: OK (3604 of 3604 tests passed, 0 test warnings)

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-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-IntegrationCoverage-Debug: OK (791 of 791 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.