Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/EnergyPlus/ChillerExhaustAbsorption.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ void GetExhaustAbsorberInput(EnergyPlusData &state)

auto &thisChiller = state.dataChillerExhaustAbsorption->ExhaustAbsorber(AbsorberNum);
thisChiller.Name = s_ipsc->cAlphaArgs(1);
std::string ChillerName = fmt::format("{} Named {}", cCurrentModuleObject, thisChiller.Name);

// Assign capacities
thisChiller.NomCoolingCap = s_ipsc->rNumericArgs(1);
Expand Down
1 change: 0 additions & 1 deletion src/EnergyPlus/ChillerGasAbsorption.cc
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ void GetGasAbsorberInput(EnergyPlusData &state)

auto &thisChiller = state.dataChillerGasAbsorption->GasAbsorber(AbsorberNum);
thisChiller.Name = s_ipsc->cAlphaArgs(1);
std::string ChillerName = s_ipsc->cCurrentModuleObject + " Named " + thisChiller.Name;

// Assign capacities
thisChiller.NomCoolingCap = s_ipsc->rNumericArgs(1);
Expand Down
6 changes: 3 additions & 3 deletions src/EnergyPlus/DuctLoss.cc
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ namespace DuctLoss {
if (!airLoopFound) {
ShowSevereError(state, "Multiple AirLoopHVAC names are found. A single AirLoopHVAC is required");
errorsFound = true;
if (errorsFound) {
ShowFatalError(state, "GetDuctLossMakeupAirInput: Previous errors cause termination.");
}
}
state.dataDuctLoss->SplitterNum = 1;
state.dataDuctLoss->MixerNum = 1;
Expand Down Expand Up @@ -833,9 +836,6 @@ namespace DuctLoss {
thisDuctLoss.LossSubType = DuctLossSubType::SupLeakTrunk;
state.dataDuctLoss->SubTypeSimuFlag(int(DuctLossSubType::SupLeakTrunk) + 1) = true;
}
} else {
// DO we need nodenum=0?
NodeNum1 = 0;
}
if (Util::SameString(state.afn->DisSysNodeData(AFNNodeNum1).EPlusType, "Zone") ||
Util::SameString(state.afn->DisSysNodeData(AFNNodeNum1).EPlusType, "OutdoorAir:NodeList") ||
Expand Down
1 change: 0 additions & 1 deletion src/EnergyPlus/Furnaces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,6 @@ namespace Furnaces {
if (errorFound) {
ShowSevereError(state, format("The index of \"{}\" is not found", thisFurnace.SuppHeatCoilName));
ShowContinueError(state, format("...occurs for {}", thisFurnace.Name));
errorFound = false;
}
state.dataAirLoop->AirLoopAFNInfo(AirLoopNum).AFNLoopHeatingCoilMaxRTF =
max(refAFNLoopHeatingCoilMaxRTF, heatingCoilRTF, suppHeatingCoilRTF);
Expand Down
4 changes: 0 additions & 4 deletions src/EnergyPlus/GroundHeatExchangers/Vertical.cc
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,6 @@ fs::path GLHEVert::runGHEDesigner(EnergyPlusData &state, nlohmann::json const &i
void GLHEVert::performBoreholeFieldDesignAndSizingWithGHEDesigner(EnergyPlusData &state, std::vector<Real64> const &hourlyLoads) const
{
nlohmann::json gheDesignerInputs = this->getCommonGHEDesignerInputs(state);
std::string const p = fmt::format("[GHEDesigner Calculation for GHE Named: {}] ", this->name);

// grab thermal and borehole properties
nlohmann::json grout = {{"conductivity", this->grout.k}, {"rho_cp", this->grout.rhoCp}};
Expand Down Expand Up @@ -868,7 +867,6 @@ void GLHEVert::performBoreholeFieldDesignAndSizingWithGHEDesigner(EnergyPlusData
nlohmann::json data = nlohmann::json::parse(file3);
std::vector<double> t = data["log_time"];
std::vector<double> g = data["g_values"];
std::vector<double> gbhw = data["g_bhw_values"];
this->myRespFactors->time = t;
this->myRespFactors->LNTTS = t;
this->myRespFactors->GFNC = g;
Expand Down Expand Up @@ -1287,8 +1285,6 @@ void GLHEVert::calcShortTimestepGFunctions(EnergyPlusData &state)
for (auto const val : GFNC_shortTimestep) {
g << val << '\n';
}
std::string l2 = l.str();
std::string g2 = g.str();
}

Real64 GLHEVert::calcBHAverageResistance(EnergyPlusData &state)
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/HVACManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2983,7 +2983,7 @@ void SetHeatToReturnAirFlag(EnergyPlusData &state)
void UpdateZoneInletConvergenceLog(EnergyPlusData &state)
{

std::array<Real64, DataConvergParams::ConvergLogStackDepth> tmpRealARR = {};
std::array<Real64, DataConvergParams::ConvergLogStackDepth> tmpRealARR;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Remove the zero-initialization of tmpRealARR. It is always overwritten before being read, so the initialization was redundant and triggered a cppcheck warning.


for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {

Expand Down
3 changes: 0 additions & 3 deletions src/EnergyPlus/HVACVariableRefrigerantFlow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11299,8 +11299,6 @@ void VRFCondenserEquipment::CalcVRFCondenser_FluidTCtrl(EnergyPlusData &state, c
NumTUInCoolingMode = 0;
NumTUInHeatingMode = 0;
Tolerance = 0.05;
Counter = 1;
NumIteHIUIn = 1;
this->ElecCoolingPower = 0.0;
this->ElecHeatingPower = 0.0;
this->CrankCaseHeaterPower = 0.0;
Expand Down Expand Up @@ -13761,7 +13759,6 @@ void VRFCondenserEquipment::VRFOU_TeModification(
} while (!converged_11);

if (std::abs(Tsuction - Te_low) > 0.5) {
NumTeIte = 999;
Tsuction = Te_low;
Pipe_SH_merged = 3.0;
Te_update = Te_low + 1;
Expand Down
1 change: 0 additions & 1 deletion src/EnergyPlus/HybridEvapCoolingModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,6 @@ namespace HybridEvapCoolingModel {
if (OutletMassFlowRate > 0) {
averageOSAF = SupplyVentilationAir / OutletMassFlowRate;
} else {
std::string ObjectID = Name.c_str();
if (CoolingRequested || HeatingRequested) {
ShowSevereError(
state,
Expand Down
7 changes: 2 additions & 5 deletions src/EnergyPlus/InputProcessing/InputProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@ int InputProcessor::getIntFieldValue(json const &ep_object, json const &schema_o

auto const &schema_field_obj = schema_obj_props[fieldName];
assert(!schema_field_obj.empty()); // Check that field name exists in the schema for this object type
bool isDefaulted = false;
int value = 0;
Real64 defaultValue = 0.0;
auto it = ep_object.find(fieldName);
Expand All @@ -702,14 +701,12 @@ int InputProcessor::getIntFieldValue(json const &ep_object, json const &schema_o
// really is an int then the input processor will have forced it to be an integer.
assert(!field_value.is_number());
} else if (field_value.get<std::string>().empty()) {
isDefaulted = findDefault(defaultValue, schema_field_obj);
if (isDefaulted) {
if (findDefault(defaultValue, schema_field_obj)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Remove the temporary isDefaulted variable and use findDefault() directly in the condition to remove cppcheck error as it was redundant and only stored an intermediate result.

value = static_cast<int>(defaultValue);
}
}
} else {
isDefaulted = findDefault(defaultValue, schema_field_obj);
if (isDefaulted) {
if (findDefault(defaultValue, schema_field_obj)) {
value = static_cast<int>(defaultValue);
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/EnergyPlus/MicroCHPElectricGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ void GetMicroCHPGeneratorInput(EnergyPlusData &state)

auto &microCHPParams = state.dataCHPElectGen->MicroCHPParamInput(CHPParamNum);

std::string ObjMSGName = s_ipsc->cCurrentModuleObject + " Named " + AlphArray(1);

microCHPParams.Name = AlphArray(1); // A1 name
microCHPParams.MaxElecPower = NumArray(1); // N1 Maximum Electric Power [W]
microCHPParams.MinElecPower = NumArray(2); // N2 Minimum Electric Power [W]
Expand Down
1 change: 0 additions & 1 deletion src/EnergyPlus/PCMThermalStorage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ namespace PCMStorage {
int NumPCMObjs = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "ThermalStorage:PCM");
if (NumPCMObjs != 1) {
ShowSevereError(state, "Exactly one ThermalStorage:PCM object is required.");
ErrorsFound = true;
return;
}

Expand Down
12 changes: 2 additions & 10 deletions src/EnergyPlus/PlantLoopHeatPumpEIR.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2707,13 +2707,10 @@ void HeatPumpAirToWater::oneTimeInit(EnergyPlusData &state)
return;
}
EIRPlantLoopHeatPump::oneTimeInit(state);
std::string suffix;
std::string mode_keyword;
if (this->EIRHPType == DataPlant::PlantEquipmentType::HeatPumpAirToWaterHeating) {
suffix = " in Heating Mode";
mode_keyword = "Heating";
} else if (this->EIRHPType == DataPlant::PlantEquipmentType::HeatPumpAirToWaterCooling) {
suffix = " in Cooling Mode";
mode_keyword = "Cooling";
}
if (this->EIRHPType == DataPlant::PlantEquipmentType::HeatPumpAirToWaterHeating ||
Expand Down Expand Up @@ -4261,11 +4258,8 @@ void EIRPlantLoopHeatPump::setUpEMS(EnergyPlusData &)

void HeatPumpAirToWater::setUpEMS(EnergyPlusData &state)
{

std::string mode_keyword;
if (this->EIRHPType == DataPlant::PlantEquipmentType::HeatPumpAirToWaterHeating) {
// defrost related actuators
mode_keyword = "Heating";
SetupEMSActuator(
state, "HeatPump:AirToWater", this->name, "Defrost Flag", "[]", this->DefrosstFlagEMSOverrideOn, this->DefrosstFlagEMSOverrideValue);
SetupEMSActuator(state,
Expand All @@ -4282,8 +4276,6 @@ void HeatPumpAirToWater::setUpEMS(EnergyPlusData &state)
"[C]",
this->LeavingTempEMSOverrideOn,
this->LeavingTempEMSOverrideValue);
} else {
mode_keyword = "Cooling";
}
SetupEMSActuator(
state, "HeatPump:AirToWater", this->name, "Operating Mode", "[ ]", this->OperationModeEMSOverrideOn, this->OperationModeEMSOverrideValue);
Expand Down Expand Up @@ -4609,8 +4601,8 @@ void HeatPumpAirToWater::calcOpMode(EnergyPlus::EnergyPlusData &state, Real64 cu
}
int numCoolingUnit = 0;
int numHeatingUnit = 0;
int numCoolingUnitNeeded = 0;
int numHeatingUnitNeeded = 0;
int numCoolingUnitNeeded;
int numHeatingUnitNeeded;
if (modeCalcMethod == OperatingModeControlOptionMultipleUnit::CoolingPriority) {
// prioritize satisfy cooling need
numCoolingUnit = int(ceil(coolingLoad / coolCapacity));
Expand Down
1 change: 0 additions & 1 deletion src/EnergyPlus/PluginManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ void PluginManager::setupOutputVariables([[maybe_unused]] EnergyPlusData &state)
for (auto instance = instancesValue.begin(); instance != instancesValue.end(); ++instance) {
auto const &fields = instance.value();
std::string const &thisObjectName = instance.key();
std::string const objNameUC = Util::makeUPPER(thisObjectName);
// no need to validate name, the JSON will validate that.
state.dataInputProcessing->inputProcessor->markObjectAsUsed(sOutputVariable, thisObjectName);
std::string varName = fields.at("python_plugin_variable_name").get<std::string>();
Expand Down
6 changes: 2 additions & 4 deletions src/EnergyPlus/RefrigeratedCase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16295,8 +16295,6 @@ void ZeroHVACValues(EnergyPlusData &state)
// to zero when called on zone timestep. Otherwise, values may be held over when
// no HVAC load calls module during that zone time step.

int DemandARRID = 0; // Index to water tank Demand used for evap condenser

if (state.dataRefrigCase->HaveRefrigRacks) {
// HaveRefrigRacks is TRUE when NumRefrigeratedRAcks > 0
// RefrigRack ALLOCATED to NumRefrigeratedRacks
Expand All @@ -16309,7 +16307,7 @@ void ZeroHVACValues(EnergyPlusData &state)
}
if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
if (RefrigRack(RackNum).EvapWaterSupplyMode == WaterSupply::FromTank) {
DemandARRID = RefrigRack(RackNum).EvapWaterTankDemandARRID;
int DemandARRID = RefrigRack(RackNum).EvapWaterTankDemandARRID;
int TankID = RefrigRack(RackNum).EvapWaterSupTankID;
state.dataWaterData->WaterStorage(TankID).VdotRequestDemand(DemandARRID) = 0.0;
}
Expand All @@ -16328,7 +16326,7 @@ void ZeroHVACValues(EnergyPlusData &state)
}
if (Condenser(CondID).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
if (Condenser(CondID).EvapWaterSupplyMode == WaterSupply::FromTank) {
DemandARRID = Condenser(CondID).EvapWaterTankDemandARRID;
int DemandARRID = Condenser(CondID).EvapWaterTankDemandARRID;
int TankID = Condenser(CondID).EvapWaterSupTankID;
state.dataWaterData->WaterStorage(TankID).VdotRequestDemand(DemandARRID) = 0.0;
}
Expand Down
5 changes: 0 additions & 5 deletions src/EnergyPlus/RoomAirModelAirflowNetwork.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@ namespace RoomAir {
if (!afnZoneInfo.IsUsed) {
continue;
}
int NumSurfs = 0; // NumSurfs isn't used anywhere?
for (int spaceNum : state.dataHeatBal->Zone(iZone).spaceIndexes) {
auto const &thisSpace = state.dataHeatBal->space(spaceNum);
NumSurfs += thisSpace.HTSurfaceLast - thisSpace.HTSurfaceFirst + 1;
}

for (auto &afnNode : afnZoneInfo.Node) {
// calculate volume of air in node's control volume
Expand Down
13 changes: 2 additions & 11 deletions src/EnergyPlus/SimAirServingZones.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2381,10 +2381,8 @@ void ConnectReturnNodes(EnergyPlusData &state)
continue;
}
for (int zoneOutNum = 1; zoneOutNum <= thisZoneEquip.NumReturnNodes; ++zoneOutNum) {
bool returnFound = false;
if (thisZoneEquip.ReturnNode(zoneOutNum) == zeqReturnNodeNum) {
thisZoneEquip.ReturnNodeAirLoopNum(zoneOutNum) = airLoopNum;
returnFound = true;
// Find matching inlet node connected to the same air loop
for (int inletNum = 1; inletNum <= thisZoneEquip.NumInletNodes; ++inletNum) {
if (thisZoneEquip.InletNodeAirLoopNum(inletNum) == airLoopNum) {
Expand All @@ -2394,9 +2392,6 @@ void ConnectReturnNodes(EnergyPlusData &state)
}
break; // leave zone return node loop
}
if (returnFound) {
break; // leave controlled zone loop
}
}
}
}
Expand Down Expand Up @@ -3742,8 +3737,6 @@ void UpdateBranchConnections(EnergyPlusData &state,

int InletNodeNum; // node number of splitter inlet node
int OutletNodeNum; // node number of a splitter outlet node
int RABNodeNum; // splitter outlet RAB node
int NonRABNodeNum; // splitter outlet nonRAB node
Real64 MassFlowRateSetSum; // sum of mass flow rate setpoints for splitter outlet nodes
Real64 MassFlowRateOut; // outlet mass flow rate of mixer
Real64 MassFlowRateMinAvailOut; // outlet minimum available mass flow rate
Expand All @@ -3758,8 +3751,6 @@ void UpdateBranchConnections(EnergyPlusData &state,
OutletHumRat = 0.0;
OutletEnthalpy = 0.0;
OutletPress = 0.0;
RABNodeNum = 0;
NonRABNodeNum = 0;
OutletCO2 = 0.0;
OutletGC = 0.0;

Expand Down Expand Up @@ -3803,8 +3794,8 @@ void UpdateBranchConnections(EnergyPlusData &state,
}
} else { // set the RAB flow rates
auto &AirLoopControlInfo = state.dataAirLoop->AirLoopControlInfo;
RABNodeNum = PrimaryAirSystems(AirLoopNum).RABSplitOutNode;
NonRABNodeNum = PrimaryAirSystems(AirLoopNum).OtherSplitOutNode;
int RABNodeNum = PrimaryAirSystems(AirLoopNum).RABSplitOutNode; // splitter outlet RAB node
int NonRABNodeNum = PrimaryAirSystems(AirLoopNum).OtherSplitOutNode; // splitter outlet nonRAB node
if (AirLoopControlInfo(AirLoopNum).EconoActive) {
state.dataLoopNodes->Node(RABNodeNum).MassFlowRate = 0.0;
state.dataLoopNodes->Node(NonRABNodeNum).MassFlowRate = state.dataLoopNodes->Node(InletNodeNum).MassFlowRate;
Expand Down
5 changes: 2 additions & 3 deletions src/EnergyPlus/SolarShading.cc
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ void processShadowingInput(EnergyPlusData &state)
for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; SurfNum++) {
if (state.dataSurface->Surface(SurfNum).ExtBoundCond == 0) { // Loop through all exterior surfaces
int SurfZoneGroup = 0;
int CurZoneGroup = 0;
int CurZoneGroup;
// Check the shading zone group of each exterior surface
for (int ZoneGroupLoop = 1; ZoneGroupLoop <= NumOfShadingGroups; ZoneGroupLoop++) { // Loop through all defined shading groups
CurZoneGroup = DisableSelfShadingGroups(ZoneGroupLoop);
Expand Down Expand Up @@ -8235,7 +8235,6 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state)

int ConstrNumBack = s_surf->Surface(BackSurfNum).Construction;
auto const &constrBack = state.dataConstruction->Construct(ConstrNumBack);
int NBackGlass = constrBack.TotGlassLayers;
// Irradiated (overlap) area for this back surface, projected onto window plane
// (includes effect of shadowing on exterior window)

Expand Down Expand Up @@ -8292,7 +8291,7 @@ void CalcInteriorSolarDistribution(EnergyPlusData &state)
}

// determine the number of glass layers
NBackGlass = 0;
int NBackGlass = 0;
for (int Lay = 1; Lay <= CFS(EQLNum).NL; ++Lay) {
if (CFS(EQLNum).L(Lay).LTYPE != LayerType::GLAZE) {
continue;
Expand Down
7 changes: 2 additions & 5 deletions src/EnergyPlus/ThermalComfort.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,6 @@ namespace ThermalComfort {
state.dataThermalComforts->ThermalComfortData.allocate(state.dataHeatBal->TotPeople);

for (Loop = 1; Loop <= state.dataHeatBal->TotPeople; ++Loop) {

std::string CurrentGroupName = state.dataHeatBal->People(Loop).Name;

// CurrentModuleObject='People'
// MJW MRT ToDo: Rename most Zone Thermal Comfort output variables to People Thermal Comfort ('cause they're keyed by People name)
if (state.dataHeatBal->People(Loop).Fanger) {
Expand Down Expand Up @@ -2791,7 +2788,7 @@ namespace ThermalComfort {
std::string epwLine;
auto epwFile = state.files.inputWeatherFilePath.open(state, "CalcThermalComfortAdaptiveASH55");
for (i = 1; i <= 8; ++i) { // Headers
epwLine = epwFile.readLine().data;
epwFile.readLine();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I updated the code to call readLine() without assigning the result to epwLine, since the code stored each skipped line into epwLine and immediately overwrote it in the next iteration without ever reading it. This removes the dead assignments flagged by cppcheck and makes the intent clearer, with no change in behavior. I made the same change below.

}
int jStartDay = state.dataEnvrn->DayOfYear - 1;
int calcStartDay = jStartDay - 30;
Expand Down Expand Up @@ -2837,7 +2834,7 @@ namespace ThermalComfort {
state.dataThermalComforts->DailyAveOutTemp(i + 30 - calcEndDay) = state.dataThermalComforts->avgDryBulbASH;
}
for (i = calcEndHr + 1; i <= calcStartHr - 1; ++i) {
epwLine = epwFile.readLine().data;
epwFile.readLine();
}
for (i = 1; i <= 30 - calcEndDay; ++i) {
state.dataThermalComforts->avgDryBulbASH = 0.0;
Expand Down
4 changes: 1 addition & 3 deletions src/EnergyPlus/UtilityRoutines.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,13 @@ namespace Util {
int Probe = 0;
int LBnd = 0;
int UBnd = NumItems + 1;
bool Found = false;
while ((!Found) || (Probe != 0)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Found is always false, so (!Found) is a redundant condition.

while (true) {
Probe = (UBnd - LBnd) / 2;
if (Probe == 0) {
break;
}
Probe += LBnd;
if (equali(String, ListOfItems(Probe))) {
Found = true;
break;
}
if (lessthani(String, ListOfItems(Probe))) {
Expand Down
Loading
Loading