-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CppCheck ZoneContaminantPredictorCorrector #10706
Changes from all commits
f860a93
32cd650
3340203
05bb46d
79c422a
c075bbb
dcf5109
31d58de
14053bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1504,7 +1504,6 @@ void InitZoneContSetPoints(EnergyPlusData &state) | |
Real64 Pi; // Pressue at zone i | ||
Real64 Pj; // Pressue at zone j | ||
Real64 Sch; // Schedule value | ||
bool ErrorsFound(false); | ||
|
||
if (state.dataContaminantBalance->Contaminant.CO2Simulation) { | ||
state.dataContaminantBalance->OutdoorCO2 = | ||
|
@@ -1707,6 +1706,7 @@ void InitZoneContSetPoints(EnergyPlusData &state) | |
} | ||
|
||
if (allocated(state.dataZoneEquip->ZoneEquipConfig) && state.dataZoneContaminantPredictorCorrector->MyConfigOneTimeFlag) { | ||
bool ErrorsFound = false; | ||
for (int ContZoneNum = 1; ContZoneNum <= (int)state.dataContaminantBalance->ContaminantControlledZone.size(); ++ContZoneNum) { | ||
int ZoneNum = state.dataContaminantBalance->ContaminantControlledZone(ContZoneNum).ActualZoneNum; | ||
for (int zoneInNode = 1; zoneInNode <= state.dataZoneEquip->ZoneEquipConfig(ZoneNum).NumInletNodes; ++zoneInNode) { | ||
|
@@ -1817,13 +1817,13 @@ void InitZoneContSetPoints(EnergyPlusData &state) | |
|
||
// From decay model | ||
for (auto &con : state.dataContaminantBalance->ZoneContamGenericDecay) { | ||
int Sch = ScheduleManager::GetCurrentScheduleValue(state, con.GCEmiRateSchedPtr); | ||
if (Sch == 0.0 || state.dataGlobal->BeginEnvrnFlag || state.dataGlobal->WarmupFlag) { | ||
int intSch = ScheduleManager::GetCurrentScheduleValue(state, con.GCEmiRateSchedPtr); | ||
if (intSch == 0.0 || state.dataGlobal->BeginEnvrnFlag || state.dataGlobal->WarmupFlag) { | ||
con.GCTime = 0.0; | ||
} else { | ||
con.GCTime += state.dataGlobal->TimeStepZoneSec; | ||
} | ||
GCGain = con.GCInitEmiRate * Sch * std::exp(-con.GCTime / con.GCDelayTime); | ||
GCGain = con.GCInitEmiRate * intSch * std::exp(-con.GCTime / con.GCDelayTime); | ||
con.GCGenRate = GCGain; | ||
} | ||
|
||
|
@@ -2051,7 +2051,6 @@ void PredictZoneContaminants(EnergyPlusData &state, | |
// Calculate the coefficients for the 3rd Order derivative for final | ||
// zone CO2. The A, B, C coefficients are analogous to the CO2 balance. | ||
// Assume that the system will have flow | ||
auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum); | ||
if (state.afn->multizone_always_simulated || | ||
(state.afn->simulation_control.type == AirflowNetwork::ControlType::MultizoneWithDistributionOnlyDuringFanOperation && | ||
state.afn->AirflowNetworkFanActivated)) { | ||
|
@@ -2165,7 +2164,6 @@ void PredictZoneContaminants(EnergyPlusData &state, | |
// Calculate the coefficients for the 3rd Order derivative for final | ||
// zone GC. The A, B, C coefficients are analogous to the GC balance. | ||
// Assume that the system will have flow | ||
auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum); | ||
if (state.afn->multizone_always_simulated || | ||
(state.afn->simulation_control.type == AirflowNetwork::ControlType::MultizoneWithDistributionOnlyDuringFanOperation && | ||
state.afn->AirflowNetworkFanActivated)) { | ||
|
@@ -2334,12 +2332,12 @@ void RevertZoneTimestepHistories(EnergyPlusData &state) | |
} | ||
|
||
void InverseModelCO2(EnergyPlusData &state, | ||
int const ZoneNum, // Zone number | ||
Real64 &CO2Gain, // Zone total CO2 gain | ||
Real64 &CO2GainExceptPeople, // ZOne total CO2 gain from sources except for people | ||
Real64 &ZoneMassFlowRate, // Zone air mass flow rate | ||
Real64 &CO2MassFlowRate, // Zone air CO2 mass flow rate | ||
Real64 &RhoAir // Air density | ||
int const ZoneNum, // Zone number | ||
Real64 const CO2Gain, // Zone total CO2 gain | ||
Real64 const CO2GainExceptPeople, // ZOne total CO2 gain from sources except for people | ||
Real64 const ZoneMassFlowRate, // Zone air mass flow rate | ||
Real64 const CO2MassFlowRate, // Zone air CO2 mass flow rate | ||
Real64 const RhoAir // Air density | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [src/EnergyPlus/ZoneContaminantPredictorCorrector.cc:2338]:(style),[constParameter],Parameter 'CO2Gain' can be declared as reference to const |
||
) | ||
{ | ||
// SUBROUTINE INFORMATION: | ||
|
@@ -2363,7 +2361,7 @@ void InverseModelCO2(EnergyPlusData &state, | |
state.dataEnvrn->DayOfYear <= state.dataHybridModel->HybridModelZone(ZoneNum).HybridEndDayOfYear) { | ||
state.dataContaminantBalance->ZoneAirCO2(ZoneNum) = state.dataHeatBal->Zone(ZoneNum).ZoneMeasuredCO2Concentration; | ||
|
||
auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum); | ||
auto const &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum); | ||
if (state.dataHybridModel->HybridModelZone(ZoneNum).InfiltrationCalc_C && state.dataHVACGlobal->UseZoneTimeStepHistory) { | ||
static constexpr std::string_view RoutineNameInfiltration("CalcAirFlowSimple:Infiltration"); | ||
// Conditionally calculate the CO2-dependent and CO2-independent terms. | ||
|
@@ -2575,7 +2573,7 @@ void CorrectZoneContaminants(EnergyPlusData &state, | |
|
||
// Calculate moisture flow rate into each zone | ||
for (int NodeNum = 1; NodeNum <= state.dataZoneEquip->ZoneEquipConfig(ZoneNum).NumInletNodes; ++NodeNum) { | ||
auto &node = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ZoneNum).InletNode(NodeNum)); | ||
auto const &node = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ZoneNum).InletNode(NodeNum)); | ||
if (state.dataContaminantBalance->Contaminant.CO2Simulation) { | ||
CO2MassFlowRate += (node.MassFlowRate * node.CO2) / ZoneMult; | ||
} | ||
|
@@ -2588,7 +2586,7 @@ void CorrectZoneContaminants(EnergyPlusData &state, | |
// Do the calculations for the plenum zone | ||
} else if (ZoneRetPlenumAirFlag) { | ||
for (int NodeNum = 1; NodeNum <= state.dataZonePlenum->ZoneRetPlenCond(ZoneRetPlenumNum).NumInletNodes; ++NodeNum) { | ||
auto &node = state.dataLoopNodes->Node(state.dataZonePlenum->ZoneRetPlenCond(ZoneRetPlenumNum).InletNode(NodeNum)); | ||
auto const &node = state.dataLoopNodes->Node(state.dataZonePlenum->ZoneRetPlenCond(ZoneRetPlenumNum).InletNode(NodeNum)); | ||
if (state.dataContaminantBalance->Contaminant.CO2Simulation) { | ||
CO2MassFlowRate += (node.MassFlowRate * node.CO2) / ZoneMult; | ||
} | ||
|
@@ -2602,7 +2600,7 @@ void CorrectZoneContaminants(EnergyPlusData &state, | |
int ADUNum = state.dataZonePlenum->ZoneRetPlenCond(ZoneRetPlenumNum).ADUIndex(ADUListIndex); | ||
if (state.dataDefineEquipment->AirDistUnit(ADUNum).UpStreamLeak) { | ||
auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(ADUNum); | ||
auto &node = state.dataLoopNodes->Node(airDistUnit.InletNodeNum); | ||
auto const &node = state.dataLoopNodes->Node(airDistUnit.InletNodeNum); | ||
if (state.dataContaminantBalance->Contaminant.CO2Simulation) { | ||
CO2MassFlowRate += (airDistUnit.MassFlowRateUpStrLk * node.CO2) / ZoneMult; | ||
} | ||
|
@@ -2613,7 +2611,7 @@ void CorrectZoneContaminants(EnergyPlusData &state, | |
} | ||
if (state.dataDefineEquipment->AirDistUnit(ADUNum).DownStreamLeak) { | ||
auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(ADUNum); | ||
auto &node = state.dataLoopNodes->Node(airDistUnit.OutletNodeNum); | ||
auto const &node = state.dataLoopNodes->Node(airDistUnit.OutletNodeNum); | ||
if (state.dataContaminantBalance->Contaminant.CO2Simulation) { | ||
CO2MassFlowRate += (airDistUnit.MassFlowRateDnStrLk * node.CO2) / ZoneMult; | ||
} | ||
|
@@ -2625,7 +2623,7 @@ void CorrectZoneContaminants(EnergyPlusData &state, | |
} | ||
|
||
} else if (ZoneSupPlenumAirFlag) { | ||
auto &node = state.dataLoopNodes->Node(state.dataZonePlenum->ZoneSupPlenCond(ZoneSupPlenumNum).InletNode); | ||
auto const &node = state.dataLoopNodes->Node(state.dataZonePlenum->ZoneSupPlenCond(ZoneSupPlenumNum).InletNode); | ||
if (state.dataContaminantBalance->Contaminant.CO2Simulation) { | ||
CO2MassFlowRate += (node.MassFlowRate * node.CO2) / ZoneMult; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -749,7 +749,6 @@ namespace ZoneDehumidifier { | |
Real64 AirMassFlowRate; // Air mass flow rate through this dehumidifier (kg/s) | ||
Real64 Cp; // Heat capacity of inlet air (J/kg-C) | ||
int AirInletNodeNum(0); // Node number for the inlet air to the dehumidifier | ||
int AirOutletNodeNum(0); // Node number for the outlet air from the dehumidifier | ||
|
||
SensibleOutput = 0.0; | ||
LatentOutput = 0.0; | ||
|
@@ -763,7 +762,6 @@ namespace ZoneDehumidifier { | |
ElectricPowerOnCycle = 0.0; | ||
|
||
AirInletNodeNum = state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumNum).AirInletNodeNum; | ||
AirOutletNodeNum = state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumNum).AirOutletNodeNum; | ||
|
||
InletAirTemp = state.dataLoopNodes->Node(AirInletNodeNum).Temp; | ||
InletAirHumRat = state.dataLoopNodes->Node(AirInletNodeNum).HumRat; | ||
|
@@ -1105,7 +1103,6 @@ namespace ZoneDehumidifier { | |
Real64 RhoWater; // Density of condensate (water) being removed (kg/m3) | ||
Real64 InletAirTemp; // Dry-bulb temperature of air entering the dehumidifier (C) | ||
Real64 OutletAirTemp; // Dry-bulb temperature of air leaving the dehumidifier (C) | ||
int AirInletNodeNum; // Node number corresponding to the air entering dehumidifier | ||
|
||
state.dataZoneDehumidifier->ZoneDehumid(DehumidNum).SensHeatingEnergy = | ||
state.dataZoneDehumidifier->ZoneDehumid(DehumidNum).SensHeatingRate * TimeStepSysSec; | ||
|
@@ -1121,7 +1118,7 @@ namespace ZoneDehumidifier { | |
// Calculate and report condensation rate (how much water extracted from the air stream) | ||
// Volumetric flow of water in m3/s for water system interactions | ||
|
||
AirInletNodeNum = state.dataZoneDehumidifier->ZoneDehumid(DehumidNum).AirInletNodeNum; | ||
int AirInletNodeNum = state.dataZoneDehumidifier->ZoneDehumid(DehumidNum).AirInletNodeNum; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [src/EnergyPlus/ZoneDehumidifier.cc:1108]:(style),[variableScope],The scope of the variable 'AirInletNodeNum' can be reduced. |
||
InletAirTemp = state.dataLoopNodes->Node(AirInletNodeNum).Temp; | ||
OutletAirTemp = max((InletAirTemp - 11.0), 1.0); // Assume coil outlet air is 11C (20F) lower than inlet air temp | ||
RhoWater = RhoH2O(OutletAirTemp); // Density of water, minimum temp = 1.0 C | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So here, Sch shadows an outer REAL variable. So what was the intent? I think it was to convert a Real64 0 - 1 to either 0 or 1 given the text in the idd. Instead of changing this to read the schedule into a real I chose to int that data just like it was done before. It does seem like this was the intent, except that the idd says if it's 1 it will be set to 0 and here if it's 0 it's set to 0.
[src/EnergyPlus/ZoneContaminantPredictorCorrector.cc:1820]:(style),[shadowVariable],Local variable 'Sch' shadows outer variable