Skip to content

Commit

Permalink
all scope vars
Browse files Browse the repository at this point in the history
  • Loading branch information
rraustad committed Aug 22, 2024
1 parent 8a1be36 commit ae23d5e
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions src/EnergyPlus/Humidifiers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ namespace Humidifiers {

auto &Humidifier = state.dataHumidifiers->Humidifier;

This comment has been minimized.

Copy link
@amirroth

amirroth Aug 22, 2024

Collaborator

All of these are examples of poor use of reference shortcuts. Array. Scalar. Array.

int NumHumidifiers = state.dataHumidifiers->NumHumidifiers;
auto &CheckEquipName = state.dataHumidifiers->CheckEquipName;

if (state.dataHumidifiers->GetInputFlag) {
GetHumidifierInput(state);
Expand All @@ -150,6 +149,7 @@ namespace Humidifiers {
state,
format("SimHumidifier: Invalid CompIndex passed={}, Number of Units={}, Entered Unit name={}", HumNum, NumHumidifiers, CompName));
}
auto &CheckEquipName = state.dataHumidifiers->CheckEquipName;

This comment has been minimized.

Copy link
@amirroth

amirroth Aug 22, 2024

Collaborator

This is one type of shortcut you are not supposed to use. A shortcut to an array. The other type is a shortcut to a scalar. I understand you are just moving this rather than creating it, but I thought I would remind.

This comment has been minimized.

Copy link
@rraustad

rraustad Aug 22, 2024

Author Contributor

Actually a good reminder. I was focused on the CppCheck warnings and not paying attention to other code issues.

if (CheckEquipName(HumNum)) {
if (CompName != Humidifier(HumNum).Name) {
ShowFatalError(state,
Expand Down Expand Up @@ -742,31 +742,27 @@ namespace Humidifiers {
// na

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
std::string ModuleObjectType; // for ease in getting objects
int RefrigerantIndex; // refrigerant index
int WaterIndex; // fluid type index
Real64 NominalPower; // Nominal power input to humidifier, W
Real64 WaterSpecHeatAvg; // specific heat of water, J/kgK
Real64 SteamSatEnthalpy; // enthalpy of saturated steam at 100C, J/kg
Real64 WaterSatEnthalpy; // enthalpy of saturated water at 100C, J/kg
bool IsAutoSize; // Indicator to autosize
bool HardSizeNoDesRun; // Indicator to a hard-sized field with no design sizing data
bool ErrorsFound(false); // TRUE if errors detected in input
Real64 NomPowerDes; // Autosized nominal power for reporting
Real64 NomPowerUser; // Hardsized nominal power for reporting
Real64 MassFlowDes; // Design air mass flow rate
Real64 InletHumRatDes; // Design inlet humidity ratio
Real64 OutletHumRatDes; // Design outlet humidity ratio
Real64 NomCapVolDes; // Autosized Nominal capacity volume for reporting
Real64 NomCapVolUser; // HardSized nominal capacity volume for reporting
Real64 AirVolFlow; // Design air volume flow rate
Real64 AirDensity; // Density of air
Real64 NominalPower; // Nominal power input to humidifier, W
Real64 WaterSpecHeatAvg; // specific heat of water, J/kgK
Real64 SteamSatEnthalpy; // enthalpy of saturated steam at 100C, J/kg
Real64 WaterSatEnthalpy; // enthalpy of saturated water at 100C, J/kg
bool ErrorsFound(false); // TRUE if errors detected in input
Real64 NomPowerDes; // Autosized nominal power for reporting
Real64 NomPowerUser; // Hardsized nominal power for reporting
Real64 MassFlowDes; // Design air mass flow rate
Real64 InletHumRatDes; // Design inlet humidity ratio
Real64 OutletHumRatDes; // Design outlet humidity ratio
Real64 NomCapVolDes; // Autosized Nominal capacity volume for reporting
Real64 NomCapVolUser; // HardSized nominal capacity volume for reporting
Real64 AirVolFlow; // Design air volume flow rate
Real64 AirDensity; // Density of air

if (HumType == HumidType::Electric || HumType == HumidType::Gas) {
IsAutoSize = false;
HardSizeNoDesRun = false;
bool IsAutoSize = false;
bool HardSizeNoDesRun = false;
NomPowerDes = 0.0;
NomPowerUser = 0.0;
std::string ModuleObjectType; // for ease in getting objects

if (HumType == HumidType::Electric) {
ModuleObjectType = "electric";
Expand Down Expand Up @@ -878,8 +874,8 @@ namespace Humidifiers {
}

NomCap = RhoH2O(Constant::InitConvTemp) * NomCapVol;
RefrigerantIndex = FluidProperties::GetRefrigNum(state, format(fluidNameSteam));
WaterIndex = FluidProperties::GetGlycolNum(state, format(fluidNameWater));
int RefrigerantIndex = FluidProperties::GetRefrigNum(state, format(fluidNameSteam));
int WaterIndex = FluidProperties::GetGlycolNum(state, format(fluidNameWater));
SteamSatEnthalpy = GetSatEnthalpyRefrig(state, format(fluidNameSteam), TSteam, 1.0, RefrigerantIndex, CalledFrom);
WaterSatEnthalpy = GetSatEnthalpyRefrig(state, format(fluidNameSteam), TSteam, 0.0, RefrigerantIndex, CalledFrom);
WaterSpecHeatAvg = 0.5 * (GetSpecificHeatGlycol(state, format(fluidNameWater), TSteam, WaterIndex, CalledFrom) +
Expand Down Expand Up @@ -1189,8 +1185,6 @@ namespace Humidifiers {
Real64 SteamSatEnthalpy; // enthalpy of saturated steam at 100C [J/kg]
Real64 WaterSatEnthalpy; // enthalpy of saturated water at 100C [J/kg]
Real64 Tref; // humidifier entering water temperature [C]
int RefrigerantIndex; // refiferant index
int WaterIndex; // fluid type index

HumRatSatIn = PsyWFnTdbRhPb(state, AirInTemp, 1.0, state.dataEnvrn->OutBaroPress, RoutineName);
HumRatSatOut = 0.0;
Expand Down Expand Up @@ -1252,8 +1246,8 @@ namespace Humidifiers {
CurMakeupWaterTemp = state.dataEnvrn->WaterMainsTemp;
}
Tref = CurMakeupWaterTemp;
RefrigerantIndex = FluidProperties::GetRefrigNum(state, format(fluidNameSteam));
WaterIndex = FluidProperties::GetGlycolNum(state, format(fluidNameWater));
int RefrigerantIndex = FluidProperties::GetRefrigNum(state, format(fluidNameSteam));
int WaterIndex = FluidProperties::GetGlycolNum(state, format(fluidNameWater));
SteamSatEnthalpy = GetSatEnthalpyRefrig(state, format(fluidNameSteam), TSteam, 1.0, RefrigerantIndex, RoutineName);
WaterSatEnthalpy = GetSatEnthalpyRefrig(state, format(fluidNameSteam), TSteam, 0.0, RefrigerantIndex, RoutineName);
WaterSpecHeatAvg = 0.5 * (GetSpecificHeatGlycol(state, format(fluidNameWater), TSteam, WaterIndex, RoutineName) +
Expand Down

4 comments on commit ae23d5e

@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.

CppCheck-StandardRatings (rraustad) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (3706 of 3706 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

CppCheck-StandardRatings (rraustad) - Win64-Windows-10-VisualStudio-16: OK (2871 of 2871 tests passed, 0 test warnings)

Build Badge Test 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.

CppCheck-StandardRatings (rraustad) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (2077 of 2077 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.

CppCheck-StandardRatings (rraustad) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (797 of 797 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.