Skip to content

Cleanout UtilityRoutines#11438

Merged
mitchute merged 11 commits intodevelopfrom
cleanout-utility-routines
Mar 9, 2026
Merged

Cleanout UtilityRoutines#11438
mitchute merged 11 commits intodevelopfrom
cleanout-utility-routines

Conversation

@mitchute
Copy link
Collaborator

Pull request overview

Reviewing PR #11411 prompted me to look at UtilityRoutines, where it appears we have a number of obsolete functions. This PR cleans these out in lieu of better approaches.

  • FindItemInSortedList was used in one place, and we have a number of other ways that are used more commonly to do this.
  • VerifyName was used in five places to verify object names are not duplicated or blank. I believe this is all now enforced through the IDD/epJSON schema validation methods, so I suspect this separate step is unnecessary and can be removed.
  • IsNameEmpty was used in about 110 places; however, like VerifyName I think nearly all of this is handled already by the epJSON schema, and whatever is left can be handled by the .empty() string method.

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
  • If adding/removing any output files (e.g., eplustbl.*)
    • Update ..\scripts\Epl-run.bat
    • Update ..\scripts\RunEPlus.bat
    • Update ..\src\EPLaunch\ MainModule.bas, epl-ui.frm, and epl.vbp (VersionComments)
    • Update ...github\workflows\energyplus.py

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 changed the title Cleanout utility routines Cleanout UtilityRoutines Feb 26, 2026
@mitchute mitchute added the Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring label Feb 26, 2026
@mitchute mitchute self-assigned this Feb 26, 2026
if (Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), state.dataHeatBalMgr->CurrentModuleObject, ErrorsFound)) {
if (state.dataIPShortCut->cAlphaArgs(1).empty()) {
continue;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't need this check because:

Zone,
  A1 , \field Name
       \required-field

This test:

Zone,
  ,                !- Name
  0,                       !- Direction of Relative North {deg}

gives this error from the InputProcessor:

** Severe  ** <root>[Zone] - Object name is required and cannot be blank or whitespace

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks. I'll remove this check.

if (Util::IsNameEmpty(state, cAlphas(1), CurrentModuleObject, localErrorsFound)) {
if (cAlphas(1).empty()) {
continue;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

NodeList,
  A1 , \field Name
       \required-field

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks. I'll remove this check.

if (Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound)) {
if (s_ipsc->cAlphaArgs(1).empty()) {
continue;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This one should be required (because it is checked as such) but it's not so this is OK. I suspect all object names should be required-field but there may be exceptions. i.e., be careful which one of these checks get deleted. I always check the idd when adding/removing input checks.

PhotovoltaicPerformance:Simple,
   A1 , \field Name
        \reference PVModules

Copy link
Collaborator

Choose a reason for hiding this comment

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

The next 2 are OK as-is (Name is not a required field).

@mitchute mitchute marked this pull request as draft March 2, 2026 22:42
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.

I checked all objects where these were used against the IDD. Every one except the PhotovoltaicPerformance objects that I noted are required in the IDD, so these checks should not be needed.

if (Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), state.dataHeatBalMgr->CurrentModuleObject, ErrorsFound)) {
if (state.dataIPShortCut->cAlphaArgs(1).empty()) {
continue;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks. I'll remove this check.

if (Util::IsNameEmpty(state, cAlphas(1), CurrentModuleObject, localErrorsFound)) {
if (cAlphas(1).empty()) {
continue;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks. I'll remove this check.


ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)};

if (Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adding \required-field for the PhotovoltaicPerformance:Simple name. OK to remove after that.

s_ipsc->cNumericFieldNames);

ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)};
if (Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

PhotovoltaicPerformance:EquivalentOne-Diode name should be required, right?

s_ipsc->lAlphaFieldBlanks,
s_ipsc->cAlphaFieldNames,
s_ipsc->cNumericFieldNames);
if (Util::IsNameEmpty(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

PhotovoltaicPerformance:Sandia name should be required, right?

@mitchute mitchute marked this pull request as ready for review March 4, 2026 15:56
\memo which surfaces convert incident solar radiation to electricity and need not specify
\memo arrays of specific modules.
A1 , \field Name
\required-field
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 went ahead and made these required since I can't see why they should not be.

if (Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), CurrentModuleObject, ErrorsFound)) {
if (state.dataIPShortCut->cAlphaArgs(1).empty()) {
continue;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

PlantEquipmentOperationSchemes,
   \min-fields 4
A1 , \field Name
    \required-field

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for looking this over @rraustad. I'll clean out these last few.

if (Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), CurrentModuleObject, ErrorsFound)) {
if (state.dataIPShortCut->cAlphaArgs(1).empty()) {
continue;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

CondenserEquipmentOperationSchemes,
   \min-fields 4
A1 , \field Name
   \required-field


if (Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound)) {
if (state.dataIPShortCut->cAlphaArgs(1).empty()) {
continue;
Copy link
Collaborator

Choose a reason for hiding this comment

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

ZoneThermalChimney,
   \min-fields 10
A1, \field Name
    \required-field

continue;
}
Alphas(1) = Alphas(1) + "--dup";
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder why a Branch name would be protected like this for a duplicate name?

Branch,
 A1,  \field Name
    \required-field

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fair question. I'll take another look at it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This could be a pre Input Processor unit test? But there is only 1 Branch in this unit test? The only concern I have is whether using the same branch name in different Branch objects is caught. I would suspect it is but can't find that in code or unit tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As far as I can tell, this was added about 10 years ago, by me...... #5575. No idea on why I did it or where I would have gotten that from. Unless we can point to some reason to keep it, I think it's safe to remove at this point.

@mitchute
Copy link
Collaborator Author

mitchute commented Mar 9, 2026

Thanks for the careful review @rraustad. This looks ready. Merging.

@mitchute mitchute merged commit d1725fe into develop Mar 9, 2026
8 checks passed
@mitchute mitchute deleted the cleanout-utility-routines branch March 9, 2026 23:56
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