diff --git a/src/ConvertInputFormat/main.cpp b/src/ConvertInputFormat/main.cpp index f8c37a45b44..fa83f514e03 100644 --- a/src/ConvertInputFormat/main.cpp +++ b/src/ConvertInputFormat/main.cpp @@ -569,7 +569,6 @@ Select one (case insensitive): #else if (number_of_threads > 1) { displayMessage("ConvertInputFormat is not compiled with OpenMP. Only running on 1 thread, not requested {} threads.", number_of_threads); - number_of_threads = 1; } for (auto const &file : files) { diff --git a/src/EnergyPlus/AirflowNetwork/src/Solver.cpp b/src/EnergyPlus/AirflowNetwork/src/Solver.cpp index 7cea86e24d7..12f753b8445 100644 --- a/src/EnergyPlus/AirflowNetwork/src/Solver.cpp +++ b/src/EnergyPlus/AirflowNetwork/src/Solver.cpp @@ -5041,12 +5041,12 @@ namespace AirflowNetwork { if (simulation_control.DuctLoss) { // Assign node num based on Distribution node for (int i = 1; i <= AirflowNetworkNumOfLinks; ++i) { - for (int k = 1; k <= DisSysNumOfNodes; ++k) { - if (Util::SameString(AirflowNetworkLinkageData(i).NodeNames[0], DisSysNodeData(k).Name)) { - AirflowNetworkLinkageData(i).NodeNums[0] = k; + for (int l = 1; l <= DisSysNumOfNodes; ++l) { + if (Util::SameString(AirflowNetworkLinkageData(i).NodeNames[0], DisSysNodeData(l).Name)) { + AirflowNetworkLinkageData(i).NodeNums[0] = l; } - if (Util::SameString(AirflowNetworkLinkageData(i).NodeNames[1], DisSysNodeData(k).Name)) { - AirflowNetworkLinkageData(i).NodeNums[1] = k; + if (Util::SameString(AirflowNetworkLinkageData(i).NodeNames[1], DisSysNodeData(l).Name)) { + AirflowNetworkLinkageData(i).NodeNums[1] = l; } } if (AirflowNetworkLinkageData(i).NodeNums[0] == 0) { diff --git a/src/EnergyPlus/BaseboardRadiator.cc b/src/EnergyPlus/BaseboardRadiator.cc index 1e7141d2519..06d0010e10d 100644 --- a/src/EnergyPlus/BaseboardRadiator.cc +++ b/src/EnergyPlus/BaseboardRadiator.cc @@ -248,8 +248,8 @@ namespace BaseboardRadiator { static constexpr std::string_view availabilityScheduleFieldName = "Availability Schedule Name"; static constexpr std::string_view heatingDesignCapacityMethodFieldName = "Heating Design Capacity Method"; - int ConvHWBaseboardNum = 0; if (baseboardObjects != inputProcessor->epJSON.end()) { + int ConvHWBaseboardNum = 0; for (auto const &baseboardInstance : baseboardObjects.value().items()) { auto const &baseboardFields = baseboardInstance.value(); auto const baseboardName = Util::makeUPPER(baseboardInstance.key()); diff --git a/src/EnergyPlus/BoilerSteam.cc b/src/EnergyPlus/BoilerSteam.cc index 146891c381e..f4fa2681413 100644 --- a/src/EnergyPlus/BoilerSteam.cc +++ b/src/EnergyPlus/BoilerSteam.cc @@ -171,8 +171,8 @@ namespace BoilerSteam { auto const &boilerSchemaProps = inputProcessor->getObjectSchemaProps(state, state.dataIPShortCut->cCurrentModuleObject); auto const boilerObjects = inputProcessor->epJSON.find(state.dataIPShortCut->cCurrentModuleObject); - int BoilerNum = 1; if (boilerObjects != inputProcessor->epJSON.end()) { + int BoilerNum = 1; for (auto const &boilerInstance : boilerObjects.value().items()) { auto const &boilerFields = boilerInstance.value(); auto const boilerName = Util::makeUPPER(boilerInstance.key()); diff --git a/src/EnergyPlus/EMSManager.cc b/src/EnergyPlus/EMSManager.cc index be760cca6df..b371c3e5ff7 100644 --- a/src/EnergyPlus/EMSManager.cc +++ b/src/EnergyPlus/EMSManager.cc @@ -325,7 +325,7 @@ namespace EMSManager { state.dataRuntimeLang->NumExternalInterfaceFunctionalMockupUnitImportActuatorsUsed + state.dataRuntimeLang->NumExternalInterfaceFunctionalMockupUnitExportActuatorsUsed; ++ActuatorUsedLoop) { - auto &thisActuatorUsed = state.dataRuntimeLang->EMSActuatorUsed(ActuatorUsedLoop); + auto const &thisActuatorUsed = state.dataRuntimeLang->EMSActuatorUsed(ActuatorUsedLoop); int ErlVariableNum = thisActuatorUsed.ErlVariableNum; if (ErlVariableNum <= 0) { diff --git a/src/EnergyPlus/ElectricBaseboardRadiator.cc b/src/EnergyPlus/ElectricBaseboardRadiator.cc index b438abd3374..7e264ad9626 100644 --- a/src/EnergyPlus/ElectricBaseboardRadiator.cc +++ b/src/EnergyPlus/ElectricBaseboardRadiator.cc @@ -212,8 +212,8 @@ namespace ElectricBaseboardRadiator { static constexpr std::string_view radiantSurfaceFractionFieldName = "Fraction of Radiant Energy to Surface"; auto const &surfaceFractionSchemaProps = elecBaseboardSchemaProps.at("surface_fractions").at("items").at("properties"); - int BaseboardNum = 0; if (elecBaseboardObjects != inputProcessor->epJSON.end()) { + int BaseboardNum = 0; for (auto const &elecBaseboardInstance : elecBaseboardObjects.value().items()) { auto const &elecBaseboardFields = elecBaseboardInstance.value(); auto const elecBaseboardName = Util::makeUPPER(elecBaseboardInstance.key()); diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc index ac38440ed93..cf29b380734 100644 --- a/src/EnergyPlus/FileSystem.cc +++ b/src/EnergyPlus/FileSystem.cc @@ -207,7 +207,7 @@ namespace FileSystem { // * // * To resolve symlinks, wrap this call in getAbsolutePath(). // */ - char executableRelativePath[1024]; + char executableRelativePath[1024] = {'\0'}; #ifdef __APPLE__ uint32_t pathSize = sizeof(executableRelativePath); diff --git a/src/EnergyPlus/Furnaces.cc b/src/EnergyPlus/Furnaces.cc index ecc3ab595bc..a596487bf52 100644 --- a/src/EnergyPlus/Furnaces.cc +++ b/src/EnergyPlus/Furnaces.cc @@ -706,7 +706,6 @@ namespace Furnaces { if (errorFound) { ShowSevereError(state, EnergyPlus::format("The index of \"{}\" is not found", thisFurnace.SuppHeatCoilName)); ShowContinueError(state, EnergyPlus::format("...occurs for {}", thisFurnace.Name)); - errorFound = false; } state.dataAirLoop->AirLoopAFNInfo(AirLoopNum).AFNLoopHeatingCoilMaxRTF = max(refAFNLoopHeatingCoilMaxRTF, heatingCoilRTF, suppHeatingCoilRTF); diff --git a/src/EnergyPlus/HVACDXHeatPumpSystem.cc b/src/EnergyPlus/HVACDXHeatPumpSystem.cc index ab1f3672ae7..ca34ef0a2c2 100644 --- a/src/EnergyPlus/HVACDXHeatPumpSystem.cc +++ b/src/EnergyPlus/HVACDXHeatPumpSystem.cc @@ -1116,7 +1116,7 @@ namespace HVACDXHeatPumpSystem { if (state.dataHVACDXHeatPumpSys->NumDXHeatPumpSystems > 0) { int DXHeatSysNum = Util::FindItemInList(DXHeatCoilSysName, state.dataHVACDXHeatPumpSys->DXHeatPumpSystem); if (DXHeatSysNum > 0 && DXHeatSysNum <= state.dataHVACDXHeatPumpSys->NumDXHeatPumpSystems) { - auto &dxhpSystem = state.dataHVACDXHeatPumpSys->DXHeatPumpSystem(DXHeatSysNum); + auto const &dxhpSystem = state.dataHVACDXHeatPumpSys->DXHeatPumpSystem(DXHeatSysNum); NodeNum = dxhpSystem.DXHeatPumpCoilInletNodeNum; } } diff --git a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc index 4307a88be4b..87b0aeda00f 100644 --- a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc +++ b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc @@ -7326,7 +7326,7 @@ void SetCompFlowRate(EnergyPlusData &state, int const VRFTUNum, int const VRFCon int IndexToTUInTUList; // - index to TU in specific list for this VRF system int TUListIndex; // index to TU list for this VRF system - auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum); + auto const &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum); IndexToTUInTUList = vrfTU.IndexToTUInTUList; TUListIndex = vrfTU.TUListIndex; @@ -8272,9 +8272,9 @@ void SizeVRF(EnergyPlusData &state, int const VRFTUNum) auto &vrfTUList = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum); for (int NumTU = 1; NumTU <= vrfTUList.NumTUInList; ++NumTU) { int TUIndex = vrfTUList.ZoneTUPtr(NumTU); - auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(TUIndex); - if (vrfTU.CoolCoilIndex > 0) { - DXCoilCap = DXCoils::GetCoilCapacityByIndexType(state, vrfTU.CoolCoilIndex, vrfTU.coolCoilType, errFlag); + auto &vrfTUobj = state.dataHVACVarRefFlow->VRFTU(TUIndex); + if (vrfTUobj.CoolCoilIndex > 0) { + DXCoilCap = DXCoils::GetCoilCapacityByIndexType(state, vrfTUobj.CoolCoilIndex, vrfTUobj.coolCoilType, errFlag); TUCoolingCapacity += DXCoilCap; if (DXCoilCap == AutoSize) { FoundAll = false; @@ -8282,8 +8282,8 @@ void SizeVRF(EnergyPlusData &state, int const VRFTUNum) } } - if (vrfTU.HeatCoilIndex > 0) { - DXCoilCap = DXCoils::GetCoilCapacityByIndexType(state, vrfTU.HeatCoilIndex, vrfTU.heatCoilType, errFlag); + if (vrfTUobj.HeatCoilIndex > 0) { + DXCoilCap = DXCoils::GetCoilCapacityByIndexType(state, vrfTUobj.HeatCoilIndex, vrfTUobj.heatCoilType, errFlag); TUHeatingCapacity += DXCoilCap; if (DXCoilCap == AutoSize) { FoundAll = false; @@ -10455,7 +10455,7 @@ int GetVRFTUOutAirNode(EnergyPlusData &state, int const VRFTUNum) } if (VRFTUNum > 0 && VRFTUNum <= state.dataHVACVarRefFlow->NumVRFTU) { - auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum); + auto const &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum); return vrfTU.VRFTUOAMixerOANodeNum; } return 0; @@ -10479,7 +10479,7 @@ int GetVRFTUZoneInletAirNode(EnergyPlusData &state, int const VRFTUNum) } if (VRFTUNum > 0 && VRFTUNum <= state.dataHVACVarRefFlow->NumVRFTU) { - auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum); + auto const &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum); return vrfTU.VRFTUOutletNodeNum; } return 0; @@ -10547,7 +10547,7 @@ int GetVRFTUMixedAirNode(EnergyPlusData &state, int const VRFTUNum) } if (VRFTUNum > 0 && VRFTUNum <= state.dataHVACVarRefFlow->NumVRFTU) { - auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum); + auto const &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum); return vrfTU.VRFTUOAMixerOANodeNum; } return 0; @@ -10571,7 +10571,7 @@ int GetVRFTUReturnAirNode(EnergyPlusData &state, int const VRFTUNum) } if (VRFTUNum > 0 && VRFTUNum <= state.dataHVACVarRefFlow->NumVRFTU) { - auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum); + auto const &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum); return vrfTU.VRFTUOAMixerRetNodeNum; } return 0; @@ -14936,7 +14936,7 @@ void VRFCondenserEquipment::VRFOU_PipeLossC( NumIUActivated = 0; for (int NumTU = 1; NumTU <= NumTUInList; ++NumTU) { int TUIndex = vrfTUList.ZoneTUPtr(NumTU); - auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(TUIndex); + auto const &vrfTU = state.dataHVACVarRefFlow->VRFTU(TUIndex); int CoilIndex = vrfTU.CoolCoilIndex; if (state.dataDXCoils->DXCoil(CoilIndex).TotalCoolingEnergyRate > 0.0) { @@ -15096,7 +15096,7 @@ void VRFCondenserEquipment::VRFOU_PipeLossH( NumIUActivated = 0; for (int NumTU = 1; NumTU <= NumTUInList; ++NumTU) { int TUIndex = vrfTUList.ZoneTUPtr(NumTU); - auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(TUIndex); + auto const &vrfTU = state.dataHVACVarRefFlow->VRFTU(TUIndex); int CoilIndex = vrfTU.HeatCoilIndex; if (state.dataDXCoils->DXCoil(CoilIndex).TotalHeatingEnergyRate > 0.0) { diff --git a/src/EnergyPlus/HeatBalanceKivaManager.cc b/src/EnergyPlus/HeatBalanceKivaManager.cc index f61bde1d295..52f826d75b4 100644 --- a/src/EnergyPlus/HeatBalanceKivaManager.cc +++ b/src/EnergyPlus/HeatBalanceKivaManager.cc @@ -78,6 +78,7 @@ namespace EnergyPlus::HeatBalanceKivaManager { +// cppcheck-suppress passedByValueCallback void kivaErrorCallback(const int messageType, const std::string message, void *contextPtr) { if (contextPtr == nullptr) { diff --git a/src/EnergyPlus/HeatBalanceSurfaceManager.cc b/src/EnergyPlus/HeatBalanceSurfaceManager.cc index 359e326da53..16b84f0421e 100644 --- a/src/EnergyPlus/HeatBalanceSurfaceManager.cc +++ b/src/EnergyPlus/HeatBalanceSurfaceManager.cc @@ -5310,10 +5310,8 @@ void UpdateThermalHistories(EnergyPlusData &state) SurfOutsideTempCurr * construct.CTFTUserOut[0] + state.dataHeatBalSurf->SurfTempIn(SurfNum) * construct.CTFTUserIn[0] + state.dataHeatBalSurf->SurfQsrcHist(SurfNum, 1) * construct.CTFTUserSource[0] + state.dataHeatBalFanSys->CTFTuserConstPart(SurfNum); - } - // Set current outside flux: - if (construct.SourceSinkPresent) { + // Set current outside flux: state.dataHeatBalSurf->SurfOutsideFluxHist(1)(SurfNum) = SurfOutsideTempCurr * construct.CTFOutside[0] - state.dataHeatBalSurf->SurfTempIn(SurfNum) * construct.CTFCross[0] + state.dataHeatBalSurf->SurfQsrcHist(SurfNum, 1) * construct.CTFSourceOut[0] + @@ -9936,7 +9934,7 @@ void InitSurfacePropertyViewFactors(EnergyPlusData &state) } if (Surface.IsSurfPropertyGndSurfacesDefined) { GndSurfsNum = Surface.SurfPropertyGndSurfIndex; - auto &GrndSurfsProperty = state.dataSurface->GroundSurfsProperty(GndSurfsNum); + auto const &GrndSurfsProperty = state.dataSurface->GroundSurfsProperty(GndSurfsNum); GroundSurfsViewFactor = GrndSurfsProperty.SurfsViewFactorSum; IsGroundViewFactorSet = GrndSurfsProperty.IsGroundViewFactorSet; SrdSurfsViewFactor += GroundSurfsViewFactor; diff --git a/src/EnergyPlus/IndoorGreen.cc b/src/EnergyPlus/IndoorGreen.cc index 7a07f0eec66..b58f3f3bde6 100644 --- a/src/EnergyPlus/IndoorGreen.cc +++ b/src/EnergyPlus/IndoorGreen.cc @@ -542,7 +542,8 @@ namespace IndoorGreen { Real64 rhoair = Psychrometrics::PsyRhoAirFnPbTdbW(state, OutPb * 1000, ZonePreTemp, ZonePreHum); // kg/m3 Real64 ETRate; // mm/s; kg/(m2s) Real64 rs = 60 * (1500 + ZonePPFD) / (200 + ZonePPFD); // stomatal resistance s/m - Real64 ra = 350 * std::pow((0.1 / 0.1), 0.5) * (1 / (LAI + 1e-10)); // aerodynamic resistance s/m + // cppcheck-suppress duplicateExpression -- room air velocity is assumed to be 0.1 m/s & mean leaf diameter is assumed to be 0.1 m + Real64 ra = 350 * std::pow((0.1 / 0.1), 0.5) * (1 / (LAI + 1e-10)); // aerodynamic resistance s/m ETRate = (1 / hfg) * (slopepat * (In - G) + (SwitchF * rhoair * CpAir * ZoneVPD) / ra) / (slopepat + psyconst * (1 + rs / ra)); // Penman-Monteith ET model return ETRate; // mm/s; kg/(m2s) diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index f91cc1847af..889b10d5383 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -13879,7 +13879,7 @@ void WriteHeatEmissionTable(EnergyPlusData &state) if (state.dataOutRptTab->displayHeatEmissionsSummary) { - for (auto ¤tStyle : ort->tabularReportPasses) { + for (auto const ¤tStyle : ort->tabularReportPasses) { if (currentStyle.produceTabular) { WriteReportHeaders(state, "Annual Heat Emissions Report", "Entire Facility", OutputProcessor::StoreType::Average); @@ -14964,7 +14964,7 @@ void ComputeLoadComponentDecayCurve(EnergyPlusData &state) int coolDesSelected = state.dataSize->CalcFinalZoneSizing(zoneNum).CoolDDNum; // loop over timesteps after pulse occurred if (coolDesSelected != 0) { - auto &surfCLClDay = ort->surfCompLoads[coolDesSelected - 1]; + auto const &surfCLClDay = ort->surfCompLoads[coolDesSelected - 1]; int timeOfPulse = ort->radiantPulseTimestep(coolDesSelected, zoneNum); // if the CoolDesSelected time is on a different day than // when the pulse occurred, need to scan back and find when @@ -14992,7 +14992,7 @@ void ComputeLoadComponentDecayCurve(EnergyPlusData &state) } int const heatDesSelected = state.dataSize->CalcFinalZoneSizing(zoneNum).HeatDDNum; if (heatDesSelected != 0) { - auto &surfCLHtDay = ort->surfCompLoads[heatDesSelected - 1]; + auto const &surfCLHtDay = ort->surfCompLoads[heatDesSelected - 1]; int timeOfPulse = ort->radiantPulseTimestep(heatDesSelected, zoneNum); // scan back to the day that the heating pulse occurs, if necessary if (timeOfPulse == 0) { diff --git a/src/EnergyPlus/PlantCentralGSHP.cc b/src/EnergyPlus/PlantCentralGSHP.cc index b571a76fc17..a3dcb3de04a 100644 --- a/src/EnergyPlus/PlantCentralGSHP.cc +++ b/src/EnergyPlus/PlantCentralGSHP.cc @@ -133,7 +133,7 @@ void WrapperSpecs::getDesignCapacities( if (calledFromLocation.loopNum == this->CWPlantLoc.loopNum) { // Chilled water loop if (this->ControlMode == CondenserType::SmartMixing) { // control mode is SmartMixing for (int NumChillerHeater = 1; NumChillerHeater <= this->ChillerHeaterNums; ++NumChillerHeater) { - auto &chillerHeater = this->ChillerHeater(NumChillerHeater); + auto const &chillerHeater = this->ChillerHeater(NumChillerHeater); MaxLoad += chillerHeater.RefCapCooling * chillerHeater.MaxPartLoadRatCooling; OptLoad += chillerHeater.RefCapCooling * chillerHeater.OptPartLoadRatCooling; MinLoad += chillerHeater.RefCapCooling * chillerHeater.MinPartLoadRatCooling; @@ -142,7 +142,7 @@ void WrapperSpecs::getDesignCapacities( } else if (calledFromLocation.loopNum == this->HWPlantLoc.loopNum) { // Hot water loop if (this->ControlMode == CondenserType::SmartMixing) { // control mode is SmartMixing for (int NumChillerHeater = 1; NumChillerHeater <= this->ChillerHeaterNums; ++NumChillerHeater) { - auto &chillerHeater = this->ChillerHeater(NumChillerHeater); + auto const &chillerHeater = this->ChillerHeater(NumChillerHeater); MaxLoad += chillerHeater.RefCapClgHtg * chillerHeater.MaxPartLoadRatClgHtg; OptLoad += chillerHeater.RefCapClgHtg * chillerHeater.OptPartLoadRatClgHtg; MinLoad += chillerHeater.RefCapClgHtg * chillerHeater.MinPartLoadRatClgHtg; @@ -517,7 +517,7 @@ void WrapperSpecs::SizeWrapper(EnergyPlusData &state) Real64 TotalCondVolFlowRate = 0.0; Real64 TotalHotWaterVolFlowRate = 0.0; for (int NumChillerHeater = 1; NumChillerHeater <= this->ChillerHeaterNums; ++NumChillerHeater) { - auto &chillerHeater = this->ChillerHeater(NumChillerHeater); + auto const &chillerHeater = this->ChillerHeater(NumChillerHeater); TotalEvapVolFlowRate += chillerHeater.tmpEvapVolFlowRate; TotalCondVolFlowRate += chillerHeater.tmpCondVolFlowRate; TotalHotWaterVolFlowRate += chillerHeater.DesignHotWaterVolFlowRate; @@ -2794,7 +2794,7 @@ void WrapperSpecs::CalcWrapperModel(EnergyPlusData &state, Real64 &MyLoad, int c GLHEOutletMassFlowRate = 0.0; for (int ChillerHeaterNum = 1; ChillerHeaterNum <= this->ChillerHeaterNums; ++ChillerHeaterNum) { - auto &chillerHeater = this->ChillerHeater(ChillerHeaterNum); + auto const &chillerHeater = this->ChillerHeater(ChillerHeaterNum); // Calculated mass flow rate used by individual chiller heater and bypasses CHWOutletMassFlowRate += chillerHeater.Report.Evapmdot; @@ -2954,7 +2954,7 @@ void WrapperSpecs::CalcWrapperModel(EnergyPlusData &state, Real64 &MyLoad, int c if (this->SimulHtgDominant || this->SimulClgDominant) { if (this->SimulClgDominant) { for (int ChillerHeaterNum = 1; ChillerHeaterNum <= this->ChillerHeaterNums; ++ChillerHeaterNum) { - auto &chillerHeater = this->ChillerHeater(ChillerHeaterNum); + auto const &chillerHeater = this->ChillerHeater(ChillerHeaterNum); int CurrentMode = chillerHeater.Report.CurrentMode; CHWInletTemp = this->Report.CHWInletTempSimul; GLHEInletTemp = this->Report.GLHEInletTempSimul; @@ -2974,8 +2974,8 @@ void WrapperSpecs::CalcWrapperModel(EnergyPlusData &state, Real64 &MyLoad, int c HWOutletTemp = HWInletTemp; } } else { // Mode 4. Cooling-only mode with other heat recovery units. Condenser flows. - CHWOutletMassFlowRate += this->ChillerHeater(ChillerHeaterNum) - .Report.EvapmdotSimul; // Wrapper evaporator side to plant chilled water loop + CHWOutletMassFlowRate += + chillerHeater.Report.EvapmdotSimul; // Wrapper evaporator side to plant chilled water loop // Sum condenser node mass flow rates and mass weighed temperatures if (GLHEInletMassFlowRate > 0.0) { GLHEOutletMassFlowRate += chillerHeater.Report.CondmdotSimul; @@ -3076,8 +3076,8 @@ void WrapperSpecs::CalcWrapperModel(EnergyPlusData &state, Real64 &MyLoad, int c if (CurrentMode != 0) { // This chiller heater unit is on if (CurrentMode == 3) { // Heat recovery mode. Both chilled water and hot water connections - CHWOutletMassFlowRate += this->ChillerHeater(ChillerHeaterNum) - .Report.EvapmdotSimul; // Wrapper evaporator side to plant chilled water loop + CHWOutletMassFlowRate += + chillerHeater.Report.EvapmdotSimul; // Wrapper evaporator side to plant chilled water loop HWOutletMassFlowRate += chillerHeater.Report.Condmdot; // Wrapper condenser side to plant hot water loop if (CHWInletMassFlowRate > 0.0) { CHWOutletTemp += chillerHeater.Report.EvapOutletTempSimul * @@ -3184,7 +3184,7 @@ void WrapperSpecs::CalcWrapperModel(EnergyPlusData &state, Real64 &MyLoad, int c } else { // Heating only mode (mode 2) for (int ChillerHeaterNum = 1; ChillerHeaterNum <= this->ChillerHeaterNums; ++ChillerHeaterNum) { - auto &chillerHeater = this->ChillerHeater(ChillerHeaterNum); + auto const &chillerHeater = this->ChillerHeater(ChillerHeaterNum); HWOutletMassFlowRate += chillerHeater.Report.Condmdot; HWOutletTemp += chillerHeater.Report.CondOutletTemp * chillerHeater.Report.Condmdot / HWInletMassFlowRate; WrapperElecPowerHeat += chillerHeater.Report.HeatingPower; diff --git a/src/EnergyPlus/Psychrometrics.cc b/src/EnergyPlus/Psychrometrics.cc index 131570cf1c1..867f4dfff10 100644 --- a/src/EnergyPlus/Psychrometrics.cc +++ b/src/EnergyPlus/Psychrometrics.cc @@ -311,12 +311,12 @@ namespace Psychrometrics { std::uint64_t hash = (Tdb_tag ^ (W_tag ^ Pb_tag)) & std::uint64_t(twbcache_size - 1); - auto &twb_Cache = state.dataPsychCache->cached_Twb; + auto &cachedTwb = state.dataPsychCache->cached_Twb; - if (twb_Cache[hash].iTdb != Tdb_tag || twb_Cache[hash].iW != W_tag || twb_Cache[hash].iPb != Pb_tag) { - twb_Cache[hash].iTdb = Tdb_tag; - twb_Cache[hash].iW = W_tag; - twb_Cache[hash].iPb = Pb_tag; + if (cachedTwb[hash].iTdb != Tdb_tag || cachedTwb[hash].iW != W_tag || cachedTwb[hash].iPb != Pb_tag) { + cachedTwb[hash].iTdb = Tdb_tag; + cachedTwb[hash].iW = W_tag; + cachedTwb[hash].iPb = Pb_tag; DISABLE_WARNING_PUSH DISABLE_WARNING_STRICT_ALIASING @@ -330,10 +330,10 @@ namespace Psychrometrics { Real64 Pb_tag_r = *reinterpret_cast(&Pb_tag); DISABLE_WARNING_POP - twb_Cache[hash].Twb = PsyTwbFnTdbWPb_raw(state, Tdb_tag_r, W_tag_r, Pb_tag_r, CalledFrom); + cachedTwb[hash].Twb = PsyTwbFnTdbWPb_raw(state, Tdb_tag_r, W_tag_r, Pb_tag_r, CalledFrom); } - return twb_Cache[hash].Twb; + return cachedTwb[hash].Twb; } Real64 PsyTwbFnTdbWPb_raw(EnergyPlusData &state, diff --git a/src/EnergyPlus/PythonEngine.cc b/src/EnergyPlus/PythonEngine.cc index 1df6e1138a9..02f7ecefd79 100644 --- a/src/EnergyPlus/PythonEngine.cc +++ b/src/EnergyPlus/PythonEngine.cc @@ -404,10 +404,10 @@ sys.argv.append("energyplus") for (auto &p : std::filesystem::directory_iterator(pathToPythonPackages)) { if (p.is_directory()) { std::string dirName = p.path().filename().string(); - if (dirName.starts_with("tcl") && dirName.find('.', 0) > 0) { + if (dirName.starts_with("tcl") && dirName.find('.') != std::string::npos) { tclConfigDir = dirName; } - if (dirName.starts_with("tk") && dirName.find('.', 0) > 0) { + if (dirName.starts_with("tk") && dirName.find('.') != std::string::npos) { tkConfigDir = dirName; } if (!tclConfigDir.empty() && !tkConfigDir.empty()) { diff --git a/src/EnergyPlus/RefrigeratedCase.cc b/src/EnergyPlus/RefrigeratedCase.cc index 0e890a84eee..9b6b614e338 100644 --- a/src/EnergyPlus/RefrigeratedCase.cc +++ b/src/EnergyPlus/RefrigeratedCase.cc @@ -15204,7 +15204,6 @@ void SecondaryLoopData::CalculateSecondary(EnergyPlusData &state, int const Seco Real64 constexpr ErrorTol(0.001); // Iterative solution tolerance bool AtPartLoad; // Whether or not need to iterate on pump power - bool DeRate; // If true, need to derate aircoils because don't carry over unmet energy Real64 CpBrine; // Specific heat (W/kg) Real64 DensityBrine; // Density (kg/m3) Real64 DiffTemp; // (C) @@ -15424,10 +15423,7 @@ void SecondaryLoopData::CalculateSecondary(EnergyPlusData &state, int const Seco } //>my large number } else { // air coils on secondary loop, no "unmet" energy accounting, just reduce amount of cooling provided to zone by coils - DeRate = false; - if (TotalLoad > this->MaxLoad) { - DeRate = true; - } + bool DeRate = (TotalLoad > this->MaxLoad); // If true, need to derate aircoils because don't carry over unmet energy FinalRateCoils( state, DeRate, SourceType::SecondarySystem, SecondaryNum, TotalLoad, this->MaxLoad); // assign case credits for coils on this loop // Bug TotalCoolingLoad not set but used below diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index e8a0bd0464f..defd566313c 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -4172,8 +4172,8 @@ void CLIPRECT(EnergyPlusData &state, int const NS2, int const NV1, int &NV3) // Re-populate XTEMP/YTEMP if (NV3 > 1) { int LastEdgeIndex = -1, incr = 0; - double cornerXs[4] = {minX, minX, maxX, maxX}; - double cornerYs[4] = {minY, maxY, maxY, minY}; + const double cornerXs[4] = {minX, minX, maxX, maxX}; + const double cornerYs[4] = {minY, maxY, maxY, minY}; Real64 edges[4] = {minX, maxY, maxX, minY}; Real64 LastEdgeX, LastEdgeY; for (int i = 0; i <= arrc; i++) { @@ -4284,8 +4284,8 @@ void CLIPRECT(EnergyPlusData &state, int const NS2, int const NV1, int &NV3) state.dataSolarShading->YTEMP[0] = arry[0]; } if (NV3 == 0) { - double cornerXs[4] = {minX, minX, maxX, maxX}; - double cornerYs[4] = {minY, maxY, maxY, minY}; + const double cornerXs[4] = {minX, minX, maxX, maxX}; + const double cornerYs[4] = {minY, maxY, maxY, minY}; Real64 cornerX = cornerXs[0]; Real64 cornerY = cornerYs[0]; bool insideFlag = true; diff --git a/src/EnergyPlus/SteamCoils.cc b/src/EnergyPlus/SteamCoils.cc index 5b781b2dffb..690dd67d9c7 100644 --- a/src/EnergyPlus/SteamCoils.cc +++ b/src/EnergyPlus/SteamCoils.cc @@ -1315,7 +1315,7 @@ namespace SteamCoils { int AirOutletNode; int SteamOutletNode; - auto &steamCoil = state.dataSteamCoils->SteamCoil(CoilNum); + auto const &steamCoil = state.dataSteamCoils->SteamCoil(CoilNum); AirInletNode = steamCoil.AirInletNodeNum; SteamInletNode = steamCoil.SteamInletNodeNum; diff --git a/src/EnergyPlus/SurfaceGeometry.cc b/src/EnergyPlus/SurfaceGeometry.cc index c71ca54a5c9..a97660d766d 100644 --- a/src/EnergyPlus/SurfaceGeometry.cc +++ b/src/EnergyPlus/SurfaceGeometry.cc @@ -7403,8 +7403,6 @@ namespace SurfaceGeometry { int Dummy; // argument for call to GetObjectDefMaxArgs int IOStatus; // Used in GetObjectItem int Found; - int AlphaOffset; // local temp var - std::string Roughness; int ThisSurf; // do loop counter Real64 AvgAzimuth; // temp for error checking Real64 AvgTilt; // temp for error checking @@ -7467,7 +7465,7 @@ namespace SurfaceGeometry { } state.dataHeatBal->ExtVentedCavity(Item).OSCMPtr = Found; - Roughness = s_ipsc->cAlphaArgs(3); + std::string Roughness = s_ipsc->cAlphaArgs(3); // Select the correct Number for the associated ascii name for the roughness type if (Util::SameString(Roughness, "VerySmooth")) { state.dataHeatBal->ExtVentedCavity(Item).BaffleRoughness = Material::SurfaceRoughness::VerySmooth; @@ -7494,7 +7492,7 @@ namespace SurfaceGeometry { ErrorsFound = true; } - AlphaOffset = 3; + constexpr int AlphaOffset = 3; // local temp var state.dataHeatBal->ExtVentedCavity(Item).NumSurfs = NumAlphas - AlphaOffset; if (state.dataHeatBal->ExtVentedCavity(Item).NumSurfs == 0) { ShowSevereError(state, @@ -9635,13 +9633,10 @@ namespace SurfaceGeometry { int ControlNumAlpha; // Number of control alpha names being passed int ControlNumProp; // Number of control properties being passed int ControlNum; // DO loop counter/index for window shading control number - int IShadedConst; // Construction number of shaded construction - int IShadingDevice; // Material number of shading device int NLayers; // Layers in shaded construction int Loop; bool BGShadeBlindError; // True if problem with construction that is supposed to have between-glass // shade or blind - int Found; auto &s_mat = state.dataMaterial; auto &s_ipsc = state.dataIPShortCut; @@ -9715,7 +9710,7 @@ namespace SurfaceGeometry { } // Check for illegal shading type name - Found = Util::FindItemInList(s_ipsc->cAlphaArgs(3), cValidShadingTypes, NumValidShadingTypes); + int Found = Util::FindItemInList(s_ipsc->cAlphaArgs(3), cValidShadingTypes, NumValidShadingTypes); if (Found <= 1) { ErrorsFound = true; ShowSevereError(state, @@ -9895,8 +9890,8 @@ namespace SurfaceGeometry { } DataSurfaces::WinShadingType ShTyp = windowShadingControl.ShadingType; - IShadedConst = windowShadingControl.getInputShadedConstruction; - IShadingDevice = windowShadingControl.ShadingDevice; + int IShadedConst = windowShadingControl.getInputShadedConstruction; // Construction number of shaded construction + int IShadingDevice = windowShadingControl.ShadingDevice; // Material number of shading device if (IShadedConst == 0 && IShadingDevice == 0) { ShowSevereError(state, diff --git a/src/EnergyPlus/UnitarySystem.cc b/src/EnergyPlus/UnitarySystem.cc index 7644b8d1f16..76eccac6306 100644 --- a/src/EnergyPlus/UnitarySystem.cc +++ b/src/EnergyPlus/UnitarySystem.cc @@ -4901,7 +4901,7 @@ namespace UnitarySystems { if (this->m_heatCoilType == HVAC::CoilType::HeatingDXVariableSpeed || this->m_heatCoilType == HVAC::CoilType::HeatingDXMultiSpeed || this->m_heatCoilType == HVAC::CoilType::HeatingDXSingleSpeed) { - auto &newCoil = state.dataCoilCoolingDX->coilCoolingDXs[this->m_CoolingCoilIndex]; + auto const &newCoil = state.dataCoilCoolingDX->coilCoolingDXs[this->m_CoolingCoilIndex]; newCoil.performance->ReportCoolingCoilCrankcasePower = false; } } diff --git a/src/EnergyPlus/UtilityRoutines.hh b/src/EnergyPlus/UtilityRoutines.hh index c0ebc6a8d12..567dacb93b3 100644 --- a/src/EnergyPlus/UtilityRoutines.hh +++ b/src/EnergyPlus/UtilityRoutines.hh @@ -473,8 +473,10 @@ namespace Util { template ::value>::type> // Container needs operator[i] and value_type - inline int - FindItemInList(std::string_view const String, Container const &ListOfItems, std::string Container::value_type::*const name_p, int const NumItems) + inline int FindItemInList(std::string_view const String, + Container const &ListOfItems, + const std::string Container::value_type::*const name_p, + int const NumItems) { for (typename Container::size_type i = 0, e = NumItems; i < e; ++i) { if (String == ListOfItems[i].*name_p) { diff --git a/src/EnergyPlus/WaterManager.cc b/src/EnergyPlus/WaterManager.cc index 372d98ccdf7..89bcfa5a8d3 100644 --- a/src/EnergyPlus/WaterManager.cc +++ b/src/EnergyPlus/WaterManager.cc @@ -199,7 +199,6 @@ namespace WaterManager { Array1D_bool lAlphaFieldBlanks; Array1D_string cAlphaArgs; Array1D rNumericArgs; - std::string cCurrentModuleObject; if ((state.dataWaterManager->MyOneTimeFlag) && (!(state.dataWaterData->WaterSystemGetInputCalled))) { // big block for entire subroutine @@ -216,7 +215,7 @@ namespace WaterManager { // initialize rainfall model state.dataWaterData->RainFall.ModeID = RainfallMode::None; - cCurrentModuleObject = "WaterUse:Storage"; + std::string cCurrentModuleObject = "WaterUse:Storage"; state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, cCurrentModuleObject, TotalArgs, NumAlphas, NumNumbers); MaxNumNumbers = NumNumbers; MaxNumAlphas = NumAlphas; diff --git a/src/EnergyPlus/WeatherManager.cc b/src/EnergyPlus/WeatherManager.cc index b284f1981c8..12712fbb7d0 100644 --- a/src/EnergyPlus/WeatherManager.cc +++ b/src/EnergyPlus/WeatherManager.cc @@ -5384,8 +5384,6 @@ namespace Weather { if (runPerInput1.dayOfWeek != 0 && !ErrorsFound) { SetupWeekDaysByMonth(state, runPerInput1.startMonth, runPerInput1.startDay, runPerInput1.dayOfWeek, runPerInput1.monWeekDay); } - } else { - nRunPeriods = 1; } } diff --git a/src/EnergyPlus/WindowAC.cc b/src/EnergyPlus/WindowAC.cc index d3c60d182dc..45600fc3ea4 100644 --- a/src/EnergyPlus/WindowAC.cc +++ b/src/EnergyPlus/WindowAC.cc @@ -1429,7 +1429,7 @@ namespace WindowAC { state.dataWindowAC->GetWindowACInputFlag = false; } - auto &windAC = state.dataWindowAC->WindAC(WindACNum); + auto const &windAC = state.dataWindowAC->WindAC(WindACNum); return windAC.AirOutNode; } @@ -1448,7 +1448,7 @@ namespace WindowAC { state.dataWindowAC->GetWindowACInputFlag = false; } - auto &windAC = state.dataWindowAC->WindAC(WindACNum); + auto const &windAC = state.dataWindowAC->WindAC(WindACNum); return windAC.OutsideAirNode; } diff --git a/src/EnergyPlus/WindowComplexManager.cc b/src/EnergyPlus/WindowComplexManager.cc index 0637eca341c..3b5c0e8b09a 100644 --- a/src/EnergyPlus/WindowComplexManager.cc +++ b/src/EnergyPlus/WindowComplexManager.cc @@ -3205,6 +3205,7 @@ namespace WindowComplexManager { edgeGlCorrFac); // process results from TARCOG + // cppcheck-suppress knownConditionTrueFalse -- nperr is initialized to 0 but gets modified inside TARCOG90() via reference if ((nperr > 0) && (nperr < 1000)) { // process error signal from tarcog ShowSevereError(state, "Window tarcog returned an error"); diff --git a/src/EnergyPlus/WindowEquivalentLayer.cc b/src/EnergyPlus/WindowEquivalentLayer.cc index 0b23a20dc09..1016a82e6f2 100644 --- a/src/EnergyPlus/WindowEquivalentLayer.cc +++ b/src/EnergyPlus/WindowEquivalentLayer.cc @@ -3685,7 +3685,7 @@ void VB_SOL46_CURVE(EnergyPlusData const &state, int CORR; DE = 0.0; // INITIALIZE DE - CORR = 1; + CORR = 1; // TODO: make this a parameter if no-correction path is needed // limit slat angle to +/- 90 deg PHI = max(-Constant::DegToRad * 90.0, min(Constant::DegToRad * 90.0, PHIx)); diff --git a/src/EnergyPlus/WindowManager.cc b/src/EnergyPlus/WindowManager.cc index adf98f7ec56..0546151542b 100644 --- a/src/EnergyPlus/WindowManager.cc +++ b/src/EnergyPlus/WindowManager.cc @@ -4572,16 +4572,15 @@ namespace Window { Real64 constexpr gaslaw(8314.51); // Molar gas constant (J/kMol-K) Real64 const two_sqrt_2(2.0 * std::sqrt(2.0)); - int NMix; // Number of gases in a mixture - Real64 molmix; // Molecular weight of mixture - std::array mukpdwn; // Denominator term - Real64 mumix; // For accumulating viscosity of gas mixture - Real64 phimup; // Numerator factor - Real64 downer; // Denominator factor - Real64 rhomix; // Density of gas mixture (kg/m3) - std::array frct; // Fraction of each gas in a mixture - std::array fvis; // Viscosity of each gas in a mixture (g/m-s) - std::array fdens; // Density of each gas in a mixture (kg/m3) + int NMix; // Number of gases in a mixture + Real64 molmix; // Molecular weight of mixture + Real64 mumix; // For accumulating viscosity of gas mixture + Real64 phimup; // Numerator factor + Real64 downer; // Denominator factor + Real64 rhomix; // Density of gas mixture (kg/m3) + std::array frct; // Fraction of each gas in a mixture + std::array fvis; // Viscosity of each gas in a mixture (g/m-s) + std::array fdens; // Density of each gas in a mixture (kg/m3) auto const &wm = state.dataWindowManager; @@ -4604,6 +4603,8 @@ namespace Window { // Initialize summations for eqns 60-66 mumix = 0.0; + + std::array mukpdwn; // Denominator term mukpdwn[0] = 1.0; // Calculate properties of mixture constituents @@ -4664,8 +4665,7 @@ namespace Window { constexpr Real64 hrad(5.3); // Typical radiative conductance (W/m2-K) constexpr Real64 resgap(0.21); // Typical gap resistance (m2-K/W) - WinShadingType ShadeFlag; // Shading flag - std::array rguess; // Combined radiative/convective resistance (m2-K/W) of + WinShadingType ShadeFlag; // Shading flag // inside or outside air film, or gap Real64 restot; // Total window resistance including outside // and inside air films (m2-K/W) @@ -4691,6 +4691,7 @@ namespace Window { // Interaction with shade or blind, if one of these is present, is ignored. See below for // separate calculation of shade/blind temperature. + std::array rguess; // Combined radiative/convective resistance (m2-K/W) of rguess[0] = 1.0 / (wm->hcout + hrad); rguess[wm->nglface] = 1.0 / (wm->hcin + hrad); @@ -6431,11 +6432,9 @@ namespace Window { Real64 hcinprev; // Value of hcin from previous iteration int d; // +1 if number of row interchanges is even, // -1 if odd (in LU decomposition) - std::array indx; // Vector of row permutations in LU decomposition - std::array, maxArraySize> Aface; // Coefficient in equation Aface*thetas = Bface - std::array Bface; // Coefficient in equation Aface*thetas = Bface - int iter; // Iteration number - Real64 errtemp; // Absolute value of sum of face temperature differences + std::array indx; // Vector of row permutations in LU decomposition + int iter; // Iteration number + Real64 errtemp; // Absolute value of sum of face temperature differences // between iterations, divided by number of faces Real64 TmeanFilm; // mean film temperature Real64 TmeanFilmKelvin; // mean film temperature for property evaluation @@ -6470,8 +6469,8 @@ namespace Window { //! fw 3/4/03 if ( iter >= 1 ) hr(i) = 0.5*(hrprev(i)+hr(i)) } - Aface = {{0.0}}; - Bface = {0.0}; + std::array, maxArraySize> Aface = {{0.0}}; // Coefficient in equation Aface*thetas = Bface + std::array Bface = {0.0}; // Coefficient in equation Aface*thetas = Bface // Inside convective film conductance for vertical window if (iter >= 1) { @@ -7997,7 +7996,6 @@ namespace Window { std::array, maxArraySize> X; // X*J = Q std::array, maxArraySize> Xinv; // J = Xinv*Q - std::array indx; // Indices for LU decomposition Real64 fEdge; // Slat edge correction factor Real64 fEdge1; @@ -8067,7 +8065,7 @@ namespace Window { ++X[k][k]; } - indx = {0}; + std::array indx = {0}; // Indices for LU decomposition // In the following, note that InvertMatrix changes X InvertMatrix(state, X, Xinv, indx, 4); diff --git a/src/EnergyPlus/WindowsGuiLauncher.cc b/src/EnergyPlus/WindowsGuiLauncher.cc index dd530d52121..ff2cbd682da 100644 --- a/src/EnergyPlus/WindowsGuiLauncher.cc +++ b/src/EnergyPlus/WindowsGuiLauncher.cc @@ -61,7 +61,7 @@ int wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int std::wstring directory(path); size_t pos = directory.find_last_of(L"\\/"); if (pos != std::wstring::npos) { - directory = directory.substr(0, pos); // Extract just the directory path + directory.resize(pos); // Extract just the directory path } // Construct the target application path (assuming it's in the same directory) diff --git a/src/EnergyPlus/api/datatransfer.cc b/src/EnergyPlus/api/datatransfer.cc index e5f39d092af..9372d8e3c5d 100644 --- a/src/EnergyPlus/api/datatransfer.cc +++ b/src/EnergyPlus/api/datatransfer.cc @@ -604,7 +604,7 @@ Real64 getInternalVariableValue(EnergyPlusState state, int handle) int getEMSGlobalVariableHandle(EnergyPlusState state, const char *name) { - auto *thisState = static_cast(state); + auto const *thisState = static_cast(state); int index = 0; for (auto const &erlVar : thisState->dataRuntimeLang->ErlVariable) { index++;