Skip to content

GHE Refactoring Work#11152

Merged
Myoldmopar merged 23 commits intodevelopfrom
GHEWorkFor252
Sep 4, 2025
Merged

GHE Refactoring Work#11152
Myoldmopar merged 23 commits intodevelopfrom
GHEWorkFor252

Conversation

@Myoldmopar
Copy link
Member

Pull request overview

This takes the huge GroundHeatExchangers hh and cc files and breaks them into meaningful pieces. The next steps on this include updating the physics model and including GHEDesigner for GLHE auto sizing. I've got the GHEDesigner stuff underway, but I'm running into an issue with the results, so I want to get this big changeset merged in with (I believe) no diffs. Then it will be easier to feel confident in the model changes, since they may have some small numeric diffs.

Description of the purpose of this PR

Pull Request Author

  • 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

  • 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

Copy link
Member Author

@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.

Should be an effectively non-functioning change, isolated to the GLHE codebase. Assuming no diffs, I'd like to merge this right in and continue on the functional changes.


# expecting one command line argument - the path to the python_lib folder to place the pip package
pkgs = {'energyplus_launch': '3.7.4', 'energyplus_transition_tools': '2.1.4'}
pkgs = {'energyplus_launch': '3.7.4', 'energyplus_transition_tools': '2.1.4', 'ghedesigner': '1.5'}
Copy link
Member Author

Choose a reason for hiding this comment

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

This will be more meaningful in the next PR. I could remove it from here if anyone thinks it is necessary.


void ShowFatalError(EnergyPlusData &state, std::string const &ErrorMessage, OptionalOutputFileRef OutUnit1, OptionalOutputFileRef OutUnit2)
[[noreturn]] void
ShowFatalError(EnergyPlusData &state, std::string const &ErrorMessage, OptionalOutputFileRef OutUnit1, OptionalOutputFileRef OutUnit2)
Copy link
Member Author

Choose a reason for hiding this comment

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

Marking it [[noreturn]] is really nice because that tells compilers that once you call this function, it's over. And that way you don't have to have workarounds of unused code after calls to ShowFatalError.

@Myoldmopar Myoldmopar added the Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring label Aug 14, 2025
@Myoldmopar
Copy link
Member Author

Code Integrity failed because the GitHub Action script for Clang Format didn't like that I removed a file. In the calculation of changed files, it was including the deleted files as modified files to check. But those files don't exist anymore. I think adding --diff-filter=AM should be a sufficient addition to fix that. I'll do it in a later commit as needed.

@github-actions
Copy link

⚠️ Regressions detected on macos-14 for commit 6ecce78

Regression Summary
  • EIO: 2
  • ERR: 2
  • ESO Big Diffs: 2
  • Table Small Diffs: 2
  • Table String Diffs: 2

@github-actions
Copy link

⚠️ Regressions detected on macos-14 for commit 978ac96

Regression Summary
  • EIO: 2
  • ERR: 2
  • ESO Big Diffs: 2
  • Table Small Diffs: 2
  • Table String Diffs: 2

@github-actions
Copy link

github-actions bot commented Sep 2, 2025

⚠️ Regressions detected on macos-14 for commit 015e4d7

Regression Summary
  • EIO: 2
  • ERR: 2
  • ESO Big Diffs: 2
  • Table Small Diffs: 2
  • Table String Diffs: 2

Copy link
Member Author

@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.

I laid out a bunch of comments, though the TODO's should all be done now with my latest commit.

-DBUILD_PACKAGE:BOOL=OFF
-DDOCUMENTATION_BUILD:STRING=DoNotBuild
-DENABLE_OPENMP:BOOL=OFF
-DUSE_OpenMP:BOOL=OFF
Copy link
Member Author

Choose a reason for hiding this comment

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

USE_OpenMP was only here for the CpGFunction library. There is still a separate ENABLE_OPENMP from other third party code.


begin_group "Run clang-format for changes files"
# Using \0 as a terminator in case we'd ever have files with spaces
git diff -z --name-only HEAD^ HEAD src/ tst/ \
Copy link
Member Author

Choose a reason for hiding this comment

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

These --diff-filter=AM changes are so that Git doesn't list "removed" files. Removed files should not be checked in the subsequent steps.

# Otherwise, if either cpgfunctionEP (yes by default) or kiva (no by default) **actually** linked to OpenMP, we need to ship the libs
if (NOT ${CMAKE_INSTALL_OPENMP_LIBRARIES} AND (${USE_OpenMP} OR ${ENABLE_OPENMP}))
# Otherwise, if kiva (no by default) **actually** linked to OpenMP, we need to ship the libs
if (NOT ${CMAKE_INSTALL_OPENMP_LIBRARIES} AND (${ENABLE_OPENMP}))
Copy link
Member Author

Choose a reason for hiding this comment

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

No more USE_OpenMP, so cleans this logic up.


# expecting one command line argument - the path to the python_lib folder to place the pip package
pkgs = {'energyplus_launch': '3.7.4', 'energyplus_transition_tools': '2.1.4'}
pkgs = {'energyplus_launch': '3.7.4', 'energyplus_transition_tools': '2.1.4', 'ghedesigner': '2.0'}
Copy link
Member Author

Choose a reason for hiding this comment

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

Add in the ghedesigner 2.0 release!

\begin{enumerate}
\item Use the \hyperref[groundheatexchangerverticalarray]{GroundHeatExchanger:Vertical:Array} object to define a rectangular borehole field. EnergyPlus will compute and cache the g-functions for reuse again in future simulations.
\item Use one or more \hyperref[groundheatexchangerverticalsingle]{GroundHeatExchanger:Vertical:Single} objects to define a vertical borehole field with the boreholes located arbitrarily. EnergyPlus will compute and cache the g-functions for reuse again in future simulations.
\item Use the \hyperref[groundheatexchangerverticalarray]{GroundHeatExchanger:Vertical:Array} object to define a rectangular borehole field.
Copy link
Member Author

Choose a reason for hiding this comment

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

OK, so the g function caching would be incredibly problematic.

  • In the "current" state of things, the g-function depended on the GLHE physical properties. So it was very easy to develop a unique cache key based on the input fields for the GLHE.
  • But as we are going to be developing GLHE field designs based on plant loads, the field could be different for literally any input that affects the building or systems. The GLHE caching was simply not worth having anymore because every different run would result in a changed g-function. So we have removed g-function caching, which has cleaned up a whole bunch of code.

Copy link
Member Author

Choose a reason for hiding this comment

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

This file captures as much of the common GLHE base class functionality as possible.

}
}

} // namespace EnergyPlus::GroundHeatExchangers No newline at end of file
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: Missing newline.

ShowFatalError(state, "Preceding errors cause program termination");
}

} // namespace EnergyPlus::GroundHeatExchangers No newline at end of file
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: Missing newline.

ShowFatalError(state, "Preceding errors cause program termination");
}

} // namespace EnergyPlus::GroundHeatExchangers No newline at end of file
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: Missing newline...how are these happening?

@github-actions
Copy link

github-actions bot commented Sep 3, 2025

⚠️ Regressions detected on macos-14 for commit f0aa8a5

Regression Summary
  • EIO: 2
  • ERR: 2
  • ESO Big Diffs: 2
  • Table Small Diffs: 2
  • Table String Diffs: 2

@Myoldmopar
Copy link
Member Author

There are two diff files. I ran the GSHP-GLHE-CalcGFunctions-cpg.idf file in annual mode, reporting things hourly. Here's the borehole temperature response over the year. Noisy plot but take a look at the difference range on the right side y axis:

GSHP-GLHE-CalcGFunctions-cpg

Over the course of the whole year, the temperature difference peaks at about 0.2 degrees. This appears to simply be because of the slightly different g-function calculated by GHEDesigner compared to CpGFunction, because when I tested this earlier and hardcoded the original CpGFunction-calcualted-g-function, I got no diffs.

I believe this is ready to merge in, so that I can immediately create a new branch that takes this further to allow GHE borefield design. If anyone has thoughts, please let me know soon.

@Myoldmopar
Copy link
Member Author

Alright, I'm merging this. I don't anticipate any issue on Windows, but I'll resolve them quickly if anything pops up that wasn't caught here.

@Myoldmopar Myoldmopar merged commit 21a264b into develop Sep 4, 2025
9 checks passed
@Myoldmopar Myoldmopar deleted the GHEWorkFor252 branch September 4, 2025 00:08
@jmarrec jmarrec mentioned this pull request Sep 5, 2025
20 tasks
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.

3 participants