-
Notifications
You must be signed in to change notification settings - Fork 396
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 ZoneEquipmentManager #10705
Conversation
@@ -1758,7 +1757,7 @@ void updateZoneSizingEndDay(DataSizing::ZoneSizingData &zsCalcSizing, | |||
// save heat peak conditions when there is no design heating load or design heating volume flow rate, i.e., when | |||
// zone temperature is always greater than the zone heating thermostat temperature | |||
if (zsCalcFinalSizing.DesHeatLoad == 0) { | |||
bool FirstIteration = true; | |||
bool FirstIteration = true; // declare as static to save for next iteration? but needs to be space/zone specific? |
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.
Move to struct to get expected result? It seems the intent is to set these sizing data on a first pass but is not working as intended.
[src/EnergyPlus/ZoneEquipmentManager.cc:1791]:(style),[unreadVariable],Variable 'FirstIteration' is assigned a value that is never used.
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.
If I'm following correctly, this is being used locally here to initialize the peak data to the first timestep values, then let the < (or >) comparisons take over for the remaining timesteps in the loop. So, this really is very local, and it is used in the IF, so not sure why cppCheck thinks it isn't used. The name is misleading, could be firstTimeStep
or just delete it and put || TimeStepIndex = 1
in the if
.
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.
Looking at this again. This is in EndDay calcs so it seems each of these blocks should be executed at least once. That does not appear to be happening for the later blocks where a previous block was executed and the later block doesn't set bool FirstIteration = true;
. I think the || TimeStepIndex == 1
is the better approach. I expect diffs so will target this section in a new branch. I have seen hour of peak = 24 (usually a heating design day) in the past so wondering if TimeStepIndex ==1 or numTimeStepInDay (with condition to not overwrite if set on TimeStepIndex < numTimeStepInDay) is better? If there is no load or flow the entire day maybe it doesn't matter so will try with TimeStepIndex ==1 to see what happens.
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.
Oh, and CppCheck thinks FirstIteration = false;
at line 1791 is never used.
bool heatDDNumAllSame = true; | ||
bool coolDDNumAllSame = true; | ||
int priorHeatDDNum = 0; | ||
int priorCoolDDNum = 0; |
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.
[src/EnergyPlus/ZoneEquipmentManager.cc:1989]:(style),[unreadVariable],Variable 'heatDDNumAllSame' is assigned a value that is never used.
[src/EnergyPlus/ZoneEquipmentManager.cc:1990]:(style),[unreadVariable],Variable 'coolDDNumAllSame' is assigned a value that is never used.
[src/EnergyPlus/ZoneEquipmentManager.cc:1991]:(style),[unreadVariable],Variable 'priorHeatDDNum' is assigned a value that is never used.
[src/EnergyPlus/ZoneEquipmentManager.cc:1992]:(style),[unreadVariable],Variable 'priorCoolDDNum' is assigned a value that is never used.
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.
Hmm, oh these were left over from plan A, but changed to plan B. Ok.
@@ -1004,7 +1004,6 @@ void SetUpZoneSizingArrays(EnergyPlusData &state) | |||
// If this is a DesignSpecification:OutdoorAir:SpaceList check to make sure spaces are valid and belong to this zone | |||
if (thisOAReq.numDSOA > 0) { | |||
for (int spaceCounter = 1; spaceCounter <= thisOAReq.numDSOA; ++spaceCounter) { | |||
std::string thisSpaceName = thisOAReq.dsoaSpaceNames(spaceCounter); |
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.
[src/EnergyPlus/ZoneEquipmentManager.cc:1007]:(style),[unreadVariable],Variable 'thisSpaceName' is assigned a value that is never used.
@@ -315,8 +315,6 @@ void sizeZoneSpaceEquipmentPart1(EnergyPlusData &state, | |||
: state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).NonAirSystemResponse; | |||
auto &sysDepZoneLoads = (spaceNum > 0) ? state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).SysDepZoneLoads | |||
: state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).SysDepZoneLoads; | |||
auto &zoneLatentGain = (spaceNum > 0) ? state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).latentGain | |||
: state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).latentGain; |
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.
[src/EnergyPlus/ZoneEquipmentManager.cc:318]:(style),[variableScope],The scope of the variable 'zoneLatentGain' can be reduced.
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.
@mjwitte this is 1 thing causing a conflict in this branch. It looks like you did something different with zoneLatentGain maybe? I'm hesitant to smash in a conflict resolution when there may be side effects.
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.
This can go all the way at the bottom of the function inside this:
if (zsCalcSizing.zoneLatentSizing) {
int ZoneMult = zoneOrSpace.Multiplier * zoneOrSpace.ListMultiplier;
auto &zoneLatentGain = (spaceNum > 0) ? state.dataZoneTempPredictorCorrector>spaceHeatBalance(spaceNum).latentGain
: state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).latentGain;
zoneLatentGain += (LatOutputProvided * HgAir) / ZoneMult;
}
@@ -558,13 +556,15 @@ void sizeZoneSpaceEquipmentPart1(EnergyPlusData &state, | |||
} else { | |||
nonAirSystemResponse = SysOutputProvided; | |||
if (state.dataHeatBal->doSpaceHeatBalance) { | |||
for (int spaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) { | |||
for (int spaceNumLoop : state.dataHeatBal->Zone(zoneNum).spaceIndexes) { |
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.
[src/EnergyPlus/ZoneEquipmentManager.cc:561]:(style),[shadowArgument],Local variable 'spaceNum' shadows outer argument
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.
This is the other thing causing a conflict. Obviously this is minor, and it looks like you also changed this to be spaceNum2 or something.
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.
Yes, you can keep either one spaceNum2
or spaceNumLoop
. I'll look at the other conflict.
for (std::size_t i = 0; i < state.dataSize->FinalSpaceSizing.size(); ++i) { | ||
updateZoneSizingEndZoneSizingCalc5(state.dataSize->FinalSpaceSizing[i], state.dataSize->CalcFinalSpaceSizing[i]); | ||
for (std::size_t j = 0; j < state.dataSize->FinalSpaceSizing.size(); ++j) { | ||
updateZoneSizingEndZoneSizingCalc5(state.dataSize->FinalSpaceSizing[j], state.dataSize->CalcFinalSpaceSizing[j]); |
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.
[src/EnergyPlus/ZoneEquipmentManager.cc:3324]:(style),[shadowVariable],Local variable 'i' shadows outer variable
[src/EnergyPlus/ZoneEquipmentManager.cc:3333]:(style),[shadowVariable],Local variable 'i' shadows outer variable
const Real64 heatLoadRatio = thisZEqList.SequentialHeatingFraction(state, equipNum); | ||
const Real64 coolLoadRatio = thisZEqList.SequentialCoolingFraction(state, equipNum); | ||
heatLoadRatio = thisZEqList.SequentialHeatingFraction(state, equipNum); | ||
coolLoadRatio = thisZEqList.SequentialCoolingFraction(state, equipNum); |
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.
[src/EnergyPlus/ZoneEquipmentManager.cc:4272]:(style),[shadowVariable],Local variable 'heatLoadRatio' shadows outer variable
[src/EnergyPlus/ZoneEquipmentManager.cc:4273]:(style),[shadowVariable],Local variable 'coolLoadRatio' shadows outer variable
The conflicts here are ever so slightly more complex than I want to deal with right now. If I need to do it later, I can, but I'll want to grok things more deeply than I would like this morning. |
These are a little tricky. I started last night just accepting the develop version and running CppCheck again to see what style suggestions remain. Obviously that did not go well with WindowManager. So don't waste anymore time on these. I'll either fix them or punt and do them over. |
…Check-ZoneEquipmentManager
Thanks for resolving things @rraustad. This looks good up here. I'll pull and test. |
Still clean with develop, thanks @rraustad |
Pull request overview
NOTE: ENHANCEMENTS MUST FOLLOW A SUBMISSION PROCESS INCLUDING A FEATURE PROPOSAL AND DESIGN DOCUMENT PRIOR TO SUBMITTING CODE
Pull Request Author
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
Reviewer
This will not be exhaustively relevant to every PR.