Skip to content
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

Remove select_case_vars & enum cleanup #9413

Merged
merged 14 commits into from
May 6, 2022
Merged

Remove select_case_vars & enum cleanup #9413

merged 14 commits into from
May 6, 2022

Conversation

dareumnam
Copy link
Collaborator

Pull request overview

  • Remove select_case_vars in
    • HVACDXHeatPumpSystem.cc
    • HVACMultiSpeedHeatPump.cc
    • HVACUnitaryBypassVAV.cc
    • HVACVariableRefrigerantFlow.cc
    • LowTempRadiantSystem.cc
    • PackagedTerminalHeatPump.cc
    • PhotovoltaicThermalCollectors.cc
    • SimAirServingZones.cc
    • SolarShading.cc
    • ThermalISO15099Calc.cc
    • TranspiredCollector.cc
    • UnitarySystem.cc
  • enum cleanup

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.

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies

Reviewer

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

@dareumnam dareumnam added the Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring label May 5, 2022
@dareumnam dareumnam added this to the EnergyPlus 22.2 milestone May 5, 2022
@dareumnam dareumnam self-assigned this May 5, 2022
@dareumnam
Copy link
Collaborator Author

@Myoldmopar This is ready to get merged in.

@Myoldmopar
Copy link
Member

Wonderful! Looks clean on CI so far. I'll wait for final results,take a look at the changes, and do some quick local testing, but I expect it will merge soon. Thanks!

ShowFatalError(state, "SimDXCoolingSystem: Invalid DX Heating System/Coil=" + DXHeatPumpSystem(DXSystemNum).HeatPumpCoilType);
}
switch (DXHeatPumpSystem(DXSystemNum).HeatPumpCoilType_Num) {
case CoilDX_HeatingEmpirical: { // COIL:DX:COOLINGBYPASSFACTOREMPIRICAL
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it worth doing the auto & dxHeatPumpSys = state.dataDXHeatPumpSystem->DXHeatPumpSystem(DXSystemNum); thing here? Probably not at this point, but 📌.


if (SELECT_CASE_var == DataHVACGlobals::CoilDX_CoolingHXAssisted) {
switch (CBVAV(CBVAVNum).DXCoolCoilType_Num) {
case DataHVACGlobals::CoilDX_CoolingHXAssisted: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment about auto & cbVAV = state.dataHVACUnitaryBypassVAV->CBVAV(CBVAVNum);.

DataHVACGlobals::ContFanCycCoil,
HXUnitOn);
} else if (state.dataLoopNodes->Node(CBVAV(CBVAVNum).DXCoilOutletNode).Temp < CBVAV(CBVAVNum).CoilTempSetPoint) {
Par(1) = double(CBVAV(CBVAVNum).CoolCoilCompIndex);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This Par thing has to be the next pass, these things are killing me. 📌

Par(4) = double(CBVAVNum);
if (FirstHVACIteration) {
Par(5) = 1.0;
if (SolFla == -1 && !state.dataGlobal->WarmupFlag) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure what this SolFla == -1 and subsequent SolFla == -2 business is but I am sure I don't like it. Do these integers not have symbolic names somewhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

-1 means iteration limit exceeded, -2 means a solution could not be found within starting bounds. No, there are not any symbolic names for this but could easily be added because these (-1 or -2) always mean the same thing.

Copy link
Member

Choose a reason for hiding this comment

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

I actually don't recall seeing any symbolic names for these values, which is why they haven't popped up in any of the enum passes. The SolveRoot/Par/etc. pass is definitely going to be a great win.

PartLoadFrac =
max(0.0,
min(1.0,
(state.dataLoopNodes->Node(CBVAV(CBVAVNum).DXCoilInletNode).Temp - CBVAV(CBVAVNum).CoilTempSetPoint) /
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can/should do auto & inletNode, and auto & outletNode also.

PartLoadFrac,
PartLoadFrac);
ShowRecurringWarningErrorAtEnd(state,
CBVAV(CBVAVNum).DXCoolCoilType + " \"" + CBVAV(CBVAVNum).DXCoolCoilName +
Copy link
Collaborator

Choose a reason for hiding this comment

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

format

case Coil_HeatingGasOrOtherFuel:
case Coil_HeatingElectric: {
SimulateHeatingCoilComponents(state,
state.dataPTHP->PTUnit(PTUnitNum).SuppHeatCoilName,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The comment I always make for things like this.

SolFlag = 0;
state.dataPTHP->MinWaterFlow = 0.0;
CalcVarSpeedHeatPumpPar(1) = double(PTUnitNum);
if (FirstHVACIteration) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good lord, make this stop!

ScalableSM = "Design ";
}
switch (FinalSysSizing(AirLoopNum).ScaleCoolSAFMethod) {
case FlowPerFloorArea: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can probably be a std::array<std::string_view>. Does default ever actually happen?

} else if (SELECT_CASE_var == FlowPerCoolingCapacity) {
if (FinalSysSizing(AirLoopNum).CoolingCapMethod == FractionOfAutosizedCoolingCapacity) {
FractionOfAutosize = FinalSysSizing(AirLoopNum).ScaledCoolingCapacity;
switch (FinalSysSizing(AirLoopNum).ScaleCoolSAFMethod) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment I always make.

acoef = 2.86;
bexp = 0.617;
switch (ibc) {
case 0: { // ISO 15099
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do these things have symbolic names somewhere? Or are we just using a combination of integers and comments?

case 0: { // ISO 15099
hcout = 4.0 + 4.0 * ws;
} break;
case -1: { // old ASHRAE SPC142 correlation
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the fascination with using negative numbers for enumeration values in EnergyPlus?

Copy link
Member

Choose a reason for hiding this comment

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

I think it was just a trick to make it easier to inspect variables during debugging sessions. Because there was no type safety, they were all just integers and could be used all willy-nilly it was easier to spot when something was incorrectly assigned if it had a value of -6. Not saying it's right, that's just what I remember from debugging Fortran in CVF.

Copy link
Collaborator

Choose a reason for hiding this comment

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

At least you used integers and not floats.


if (SELECT_CASE_var == DataHVACGlobals::CoilDX_CoolingSingleSpeed) { // Coil:Cooling:DX:SingleSpeed

switch (this->m_CoolingCoilType_Num) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am just going to throw this out there. I am fine with using m_ to refer to member variables (it's a scope thing, not a type thing so technically not "Hungarian"). I am somewhat fine with using this-> to indicate reference to member variables. I am not sure what using this->m_ accomplishes. This is a member variable. Also, this is a member variable in case you didn't hear me the first time.

case DataHVACGlobals::Coil_HeatingGas_MultiStage: {
Par[1] = double(this->m_HeatingCoilIndex);
Par[2] = DesOutTemp;
Par[3] = double(this->m_UnitarySysNum);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lol.

@amirroth
Copy link
Collaborator

amirroth commented May 5, 2022

Thank you @dareumnam!

@Myoldmopar
Copy link
Member

Built and tested locally, all good. Some great comments to build on as we continue this path, but I think this particular chunk of changes is ready to go. Thanks @dareumnam !

@Myoldmopar Myoldmopar merged commit c64d257 into develop May 6, 2022
@Myoldmopar Myoldmopar deleted the enumTask9 branch May 6, 2022 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants