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

Code Restructuring in ChillerHeater Model (intermediate step) #10601

Merged
merged 9 commits into from
Jul 11, 2024

Conversation

RKStrand
Copy link
Contributor

Pull request overview

  • Initial Work for CentralHeatPumpSystem / ChillerHeater Misbehavior #10065
  • Defect CentralHeatPumpSystem / ChillerHeater Misbehavior #10065 requires the addition of code to address a gap in the logic. Currently, the code always assumes that the evaporator is at full load during heating mode. This is clearly not the case. This is one of the issues that is being addressed in the process of resolving this defect. To make the implementation of a model to deal with the gap more straightforward and to avoid additional duplication of code, various portions of the existing model for both heating and cooling modes in the ChillerHeater model have been separated out into subroutines/functions. This PR is simply doing the groundwork for the eventual solution to the defect. The changes here should be code neutral and not result in any changes in the output. This PR is an intermediate step to get these changes in the code so that it is clearer what is actually getting changed in the algorithm to address the actual defect.

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
  • [no] Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair (unit test will be added at the next stage)
  • 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

Created a new subroutine that avoids duplicate code and simplifies slightly the ChillerHeater subroutine.
Forgot the clang formatting for these changes.
Next step: more simplification of the code, this time dealing with the handling of the condenser water temperature.  Decision now based on enum and handled by a Real64 function.
More restructuring for the ChillerHeater module, this time the calculation of CapFT and error checks are made into a stand-alone Real64 function.
Created a new routine that is used by both the chiller and chillerheater in this model.  This is again to improve clarity in the routines and prepare for the changes that will be needed to solve the actual defect which is that the evaporator and compressor energy never get updated when heating is the predominant mode (modes 2 and 5).
Moved repetitive code from the chiller and heater models of the chiller-heater component.  This code focuses on the calculation of part load ratio and the cycling fraction (when PLR is below the minimum).
@RKStrand RKStrand added the Defect Includes code to repair a defect in EnergyPlus label Jul 10, 2024
@RKStrand RKStrand added this to the EnergyPlus 24.2 milestone Jul 10, 2024
@RKStrand RKStrand self-assigned this Jul 10, 2024
@Myoldmopar
Copy link
Member

As expected, CI is completely clean, this is great @RKStrand . I'll look over the refactors.

Copy link
Member

@Myoldmopar Myoldmopar left a comment

Choose a reason for hiding this comment

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

Looks like a nice preliminary cleanup pass. Breaking the functionality into small worker methods is a great way to identify responsibility, and eventually add clear, targeted, testing.

setChillerHeaterCondTemp = condLeavingTemp;
}
return setChillerHeaterCondTemp;
}
Copy link
Member

Choose a reason for hiding this comment

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

Could simplify this further...

if (this->ChillerHeater(numChillerHeater).CondMode == CondenserModeTemperature::EnteringCondenser) {
    return condEnteringTemp;
} else { // by default, if not EnteringCondenser, then this can only be LeavingCondenser
    return condLeavingTemp;
}

or further...

if (this->ChillerHeater(numChillerHeater).CondMode == CondenserModeTemperature::EnteringCondenser) {
    return condEnteringTemp;
}
return condLeavingTemp;

And because I think @amirroth enjoys ternaries, I suppose you could also

return this->ChillerHeater(numChillerHeater).CondMode == CondenserModeTemperature::EnteringCondenser ? condEnteringTemp : condLeavingTemp;

@Myoldmopar
Copy link
Member

CI is all clean, code cleanup looks good, no reason to hold this up. I'll merge this and you can immediately carry on to the functional changes which may cause diffs, etc. Good luck!

@Myoldmopar Myoldmopar merged commit 5e4cb34 into develop Jul 11, 2024
15 checks passed
@Myoldmopar Myoldmopar deleted the 10065ChillerHeaterMisbehavin branch July 11, 2024 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Defect Includes code to repair a defect in EnergyPlus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants