-
Notifications
You must be signed in to change notification settings - Fork 394
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
Fix Integrated Heat Pump Output Variable Setup #9249
Conversation
src/EnergyPlus/IntegratedHeatPump.cc
Outdated
if (ErrorsFound) { | ||
ShowFatalError(state, | ||
std::string{RoutineName} + "Errors found in getting " + CurrentModuleObject + | ||
" input. Preceding condition(s) causes termination."); | ||
} else { | ||
// set up output variables, not reported in the individual coil models | ||
SetupOutputVariable(state, |
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.
I moved this chunk into the for
loop. The rest is indentation formatting.
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 E+ will fatal out on the first IHP with an input error? i.e., ErrorsFound will be true for that IHP and the rest will not be read in. We typically loop through all instances of an equipment type to allow the warnings to print to the error file so the user can fix all at once instead of one at a time. It would be better to move this back and for loop inside the else to set up report vars for all IHPs.
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.
Thanks, @rraustad. I moved the fatal error call outside of the get input and SetupOutputVars now happens all at once after that.
…owFatal happens outside of reading inputs
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.
@Myoldmopar @rraustad @mjwitte I'd be interested to have your comments on this commit (4af38ce).
Sizing of the various variable speed coils in here was doing some weird stuff with showing an error message and then setting the error flag to false. I'm pretty sure most of the error messages in here were unreachable. I think I "fixed" it, although I'm pretty sure this is going to cause at least one unit test failure that will have to be handled if we keep this in.
The ErrorsFound flag (the king) is the getInput function flag for any errors found and should terminate the program after processing all objects. The local errFlag (the soldier) is used for the mining calls where some mining calls use to set errFlag false inside the mining function and then set back to true if an issue was found, I think we got rid of all those, so the King could get reset to false, part way through getInput, if it were used. So to be safe, a local errFlag is set to false before calling a mining function, because it could have been set to true from a previous mining call, and then if there is an error inside the mining function (i.e., errFlag = true for this call) then a warning is issued and ErrorsFound is set true. |
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.
The scope blew up well beyond the original issue, but this seems like a good set of cleanups.
Real64 constexpr WaterDensity(986.0); // standard water density at 60 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.
This was hardcoded into a couple of functions. I just pulled it up here and made it constexpr
state.dataIntegratedHP->GetCoilsInputFlag = false; | ||
} | ||
|
||
if (CompIndex == 0) { | ||
DXCoilNum = UtilityRoutines::FindItemInList(CompName, state.dataIntegratedHP->IntegratedHeatPumps); | ||
if (DXCoilNum == 0) { | ||
ShowFatalError(state, "Integrated Heat Pump not found=" + std::string{CompName}); | ||
ShowFatalError(state, format("Integrated Heat Pump not found={}", CompName)); |
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.
format
all the things.
@@ -138,21 +137,22 @@ void SimIHP(EnergyPlusData &state, | |||
} | |||
}; | |||
|
|||
if (!state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum).IHPCoilsSized) SizeIHP(state, DXCoilNum); | |||
auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum); |
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.
Using auto &iph = ...
everywhere to shorten lines.
int DXCoilNum; // No of IHP DX system | ||
int NumASIHPs; // Counter for air-source integrated heat pumps | ||
|
||
int NumAlphas; // Number of variables in String format | ||
int NumNums; // Number of variables in Numeric format | ||
int NumParams; // Total number of input fields | ||
int MaxNums(0); // Maximum number of numeric input fields | ||
int MaxAlphas(0); // Maximum number of alpha input fields | ||
std::string CoilName; // Name of the Coil | ||
std::string Coiltype; // type of coil | ||
std::string InNodeName; // Name of coil inlet node | ||
std::string OutNodeName; // Name of coil outlet node | ||
|
||
int NumAlphas; // Number of variables in String format | ||
int NumNums; // Number of variables in Numeric format | ||
int NumParams; // Total number of input fields | ||
int MaxNums(0); // Maximum number of numeric input fields | ||
int MaxAlphas(0); // Maximum number of alpha input fields | ||
std::string InNodeName; // Name of coil inlet node | ||
std::string OutNodeName; // Name of coil outlet node |
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.
Rescope or eliminate local vars where possible.
// why was this here | ||
// state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).AirInletNodeNum = InNode; | ||
// state.dataVariableSpeedCoils->VarSpeedCoil(ihp.SHDWHWHCoilIndex).AirOutletNodeNum = OutNode; | ||
|
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.
The coil inlet and outlet node nums were begin set here, but as far as I can tell they should have already been set elsewhere. I'm not seeing any diffs currently by leaving this out, but I left it commented out in case someone needs to do a forensics deep-dive on this code later.
IdleMode, | ||
SCMode, | ||
SHMode, | ||
DWHMode, | ||
SCWHMatchSCMode, | ||
SCWHMatchWHMode, | ||
SCDWHMode, | ||
SHDWHElecHeatOffMode, | ||
SHDWHElecHeatOnMode, | ||
Idle, | ||
SpaceClg, // Space Cooling | ||
SpaceHtg, // Space Heating | ||
DedicatedWaterHtg, // Dedicated Water Heating | ||
SCWHMatchSC, // Space Cooling Water Heating | ||
SCWHMatchWH, | ||
SpaceClgDedicatedWaterHtg, | ||
SHDWHElecHeatOff, | ||
SHDWHElecHeatOn, |
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.
Remove Mode
and rename so the values are somewhat intelligible.
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.
You should rename the remaining values to be somewhat intelligible too. I know SpaceHtgDedicatedWaterHtgElecHeatOff
is long, but it's still better than SHDWHElecHeatOff
. These long acronyms are crazy making.
ErrorsFound = false; | ||
SizeVarSpeedCoil(state, DXCoilNum, ErrorsFound); | ||
if (ErrorsFound) { | ||
ShowFatalError(state, format("{}: Failed to size variable speed coil.", RoutineName)); | ||
} |
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.
Better sizing error handling here.
ErrorsFound = false; | ||
SizeVarSpeedCoil(state, DXCoilNum, ErrorsFound); | ||
if (ErrorsFound) { | ||
ShowFatalError(state, format("{}: Failed to size variable speed coil.", RoutineName)); | ||
} |
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.
Same
@@ -4440,7 +4447,7 @@ namespace VariableSpeedCoils { | |||
state.dataHeatBal->HeatReclaimVS_DXCoil(DXCoilNum).AvailCapacity = 0.0; | |||
} | |||
|
|||
void SizeVarSpeedCoil(EnergyPlusData &state, int const DXCoilNum) | |||
void SizeVarSpeedCoil(EnergyPlusData &state, int const DXCoilNum, bool &ErrorsFound) |
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.
Let SizeVarSpeedCoil
propagate its errors back up to the caller.
if (this->WaterThermalTankType == DataPlant::PlantEquipmentType::WtrHeaterMixed) { | ||
switch (this->WaterThermalTankType) { | ||
case DataPlant::PlantEquipmentType::WtrHeaterMixed: | ||
this->CalcWaterThermalTankMixed(state); | ||
} else if (this->WaterThermalTankType == DataPlant::PlantEquipmentType::WtrHeaterStratified) { | ||
break; | ||
case DataPlant::PlantEquipmentType::WtrHeaterStratified: | ||
this->CalcWaterThermalTankStratified(state); | ||
} else { | ||
break; | ||
default: | ||
assert(false); | ||
} | ||
} |
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/else
to switch/case
here, and below.
The Windows build here looks like a fluke since it failed in the Transition project. I've built and run unit tests locally and it's looking just like the results from the other platforms. |
@mitchute so there seems to be something up with that failing unit test. I think it's the one that occasionally fails on Mac, but now it's failing across the board, so that's new. I remember talking with you about some of this PR, but I can't remember if that aspect was part of it. Let me know if you want me to run it to reproduce and/or find the issue so that I can get this in. Thanks! |
@Myoldmopar |
auto &ihp = state.dataIntegratedHP->IntegratedHeatPumps(CoilCounter); | ||
|
||
ihp.Name = AlphArray(1); | ||
ihp.IHPtype = "AIRSOURCE_IHP"; |
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.
Should be an enum
that can be converted to string for display purposes using a constexpr std::array<std::string_view>
.
state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum).SCCoilName = AlphArray(3); | ||
Coiltype = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum).SCCoilType; | ||
CoilName = state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum).SCCoilName; | ||
ihp.SCCoilType = "COIL:COOLING:DX:VARIABLESPEED"; |
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.
Is there a need to store this string? Will it ever be used other than in the ValidateComponent
call below?
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.
I'm working more on further propagating the component type enum around. These will eventually go away.
if (IsCallbyWH) // process when called from water loop | ||
{ | ||
SimVariableSpeedCoils(state, | ||
std::string(), | ||
state.dataIntegratedHP->IntegratedHeatPumps(DXCoilNum).SCDWHCoolCoilIndex, | ||
ihp.SCDWHCoolCoilIndex, |
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.
You may be able to make these into a loop using the enum OperationMode
as the index.
@mitchute Is this ready for final review? It's a ways behind develop, so please merge it up. |
@mjwitte @Myoldmopar done. There's one failing unit test - see here: #9249 (comment) IMO, that unit test has some deeper issues that this work exposed. So, we either hold this up and address that first or disable the unit test and figure it out after. |
Thanks @mitchute. I'm not a fan of disabling tests willy-nilly, but this fix needs to get in, and your work here just revealed that the test shouldn't have been passing. No big deal, sometime I'll get some energy to re-enable any disabled unit tests and figure out why they aren't working. Assuming this continues to be clean I'll merge it tonight. |
Tested with latest develop, no problems. Love these fast running unit test suites..... :) Anyway, all good here, thanks @mitchute , merging. |
@mitchute, I am making changes that impact the IDF snippets for the test disabled here. I am going to leave this alone for now, but I imagine we should make a new issue to make sure we don't lose track of re-enabling the test down the road. |
@nealkruis good idea. I don't remember the particulars here but feel free to make an issue so we don't lose track of it. |
@mitchute I don't really know the context here or why the test had to be disabled. I just noticed that there was an intention to follow up, but it might have been lost. I'll let you and @Myoldmopar sort out how to follow up on this. |
Pull request overview