Skip to content

AirLoopHVAC Cleanups#11281

Merged
mitchute merged 6 commits intodevelopfrom
airloop-hvac-cleanups
Oct 25, 2025
Merged

AirLoopHVAC Cleanups#11281
mitchute merged 6 commits intodevelopfrom
airloop-hvac-cleanups

Conversation

@mitchute
Copy link
Collaborator

@mitchute mitchute commented Oct 17, 2025

Pull request overview

I spent a little time looking at clang-tidy as a possible way to do some automated code refactoring. This was mostly a learning exercise for me, but I made a few cleanups (and maybe fixes) along the way, so I figured I'd commit them here.

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

@mitchute mitchute requested a review from mjwitte October 17, 2025 17:31
@mitchute mitchute self-assigned this Oct 17, 2025
@mitchute mitchute added the Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring label Oct 17, 2025
Copy link
Collaborator Author

@mitchute mitchute left a comment

Choose a reason for hiding this comment

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

Code walk through.

Comment on lines -190 to +191
AirLoopMixer *AirLoopMixer::factory(EnergyPlusData &state, int object_num, std::string const &objectName)
AirLoopMixer *AirLoopMixer::factory(EnergyPlusData &state, const int objectNum, const std::string &objectName)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added const and unified the arg names between the function declaration and implementation.

Comment on lines +249 to +250
std::string const name = Util::makeUPPER(NodeDOASName.at("inlet_node_name").get<std::string>());
int const NodeNum = NodeInputManager::GetOnlySingleNode(state,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I played with using clang-tidy to automatically detect where const could be added. I'm sure the compiler is likely smart enough to figure all this out.

for (const auto &thisAirLoopMixerObject : state.dataAirLoopHVACDOAS->airloopMixer) {
if (Util::SameString(objectName, thisAirLoopMixerObject.name)) {
index = static_cast<int>(loop);
return index;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Range-based loop conversion.

Comment on lines +482 to +487
ShowSevereError(state,
format("{}, \"{}\", {} not found: {}\n", cCurrentModuleObject, thisDOAS.Name, cFieldName, thisDOAS.OASystemName));
ShowSevereError(
state, format(R"({}, "{}", {} not found: {}\n)", cCurrentModuleObject, thisDOAS.Name, cFieldName, thisDOAS.OASystemName));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe these are more readable? I'm not sure whether the \n at the end is needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think I have ever seen a new line used in Show messages. void ShowErrorMessage() already includes the new line.

Comment on lines 871 to +874
if (Util::SameString(state.dataAirLoop->OutsideAirSys(OASysNum).ControllerListName, "")) {
if (state.dataAirLoop->OutsideAirSys(OASysNum).AirLoopDOASNum == -1) {
ShowSevereError(state,
format("AirLoopHVAC:OutdoorAirSystem = \"{}\" invalid Controller List Name = \" not found.",
format(R"(AirLoopHVAC:OutdoorAirSystem = "{}" invalid Controller List Name = " not found.)",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This error message looks odd.

Copy link
Collaborator

@rraustad rraustad Oct 17, 2025

Choose a reason for hiding this comment

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

Also, if there is no coil in the OA system (e.g., just the OA Mixer) then you don't need, and can't even specify (because the sensor node and actuator node are required-fields), a Controller:WaterCoil object. Not sure if a DOAS should ever not have a cooling coil but that cooling coil could be in an AirLoopHVACUnitarySystem or CoilSystemCoolingDX which do not require a controller. I think this should be checking if a controller type coil (heating or cooling) is present before posting this error. Also, the IDD note says the controller list should be blank? and line 872 checks that it's NOT a DOAS (the -1)? Shouldn't this be checking only for controllers for a coil in the DOAS system? in the AirloopHVACDOAS source? Maybe this check got moved here when DOAS was added and this is somehow checking the non-DOAS OA systems but I still think the controller list is optional and only needed if water coils are present. I'm not a DOAS expert but this does look odd in more ways than one.

AirLoopHVAC:OutdoorAirSystem,
   \memo Outdoor air subsystem for an AirLoopHVAC. Includes an outdoor air mixing box and
   \memo optional outdoor air conditioning equipment such as heat recovery, preheat, and precool
   \memo coils. From the perspective of the primary air loop the outdoor air system is treated
   \memo as a single component.
   \min-fields 3
A1, \field Name
   \required-field
   \type alpha
   \reference-class-name validBranchEquipmentTypes
   \reference validBranchEquipmentNames
A2, \field Controller List Name
   \note Enter the name of an AirLoopHVAC:ControllerList object or blank if this object is used in
   \note AirLoopHVAC:DedicatedOutdoorAirSystem.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tagging issue #11291 to keep track of this.

Comment on lines -1098 to +1102
ShowRecurringWarningErrorAtEnd(state,
loop.Name + "\": The max difference of node temperatures exceeding 1.0e-6 continues...",
loop.ConveIndex,
maxDiff,
maxDiff);
ShowRecurringWarningErrorAtEnd(
state,
format(R"("{}": The max difference of node temperatures exceeding 1.0e-6 continues...)", loop.Name),
loop.ConveIndex,
maxDiff,
maxDiff);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Another odd looking error message. I think I cleaned it up to what was intended.

Comment on lines 75 to +81
@@ -81,14 +78,14 @@ namespace AirLoopHVACDOAS {
std::vector<int> InletNodeNum;
Real64 OutletTemp = 0.0;

static AirLoopMixer *factory(EnergyPlusData &state, int objectNum, std::string const &objectName);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just grouping the functions together, and unifying the arg names.

} // namespace AirLoopHVACDOAS

struct AirLoopHVACDOASData : BaseGlobalStruct
struct AirLoopHVACDOASData final : BaseGlobalStruct
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does this do? final?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It just signals that this struct won't be inherited.

@mitchute mitchute added DoNotPublish Includes changes that shouldn't be reported in the changelog and removed DoNotPublish Includes changes that shouldn't be reported in the changelog labels Oct 22, 2025
ValidEquipListType foundType = static_cast<ValidEquipListType>(getEnumValue(validEquipNamesUC, typeNameUC));

switch (foundType) {
switch (static_cast<ValidEquipListType>(getEnumValue(validEquipNamesUC, typeNameUC))) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Smart enough to make this substitution but uses auto in range based loops?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this was me doing stuff manually.

@mitchute mitchute merged commit 1da8f83 into develop Oct 25, 2025
11 checks passed
@mitchute mitchute deleted the airloop-hvac-cleanups branch October 25, 2025 19:53
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.

5 participants