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

CppCheck expm1 log1p HeatRecovery #10880

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

rraustad
Copy link
Contributor

Pull request overview

  • Fixes expm1 and log1p suggestions
  • Use CppCheck as guide

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

@rraustad rraustad added the DoNotPublish Includes changes that shouldn't be reported in the changelog label Dec 25, 2024
Copy link

⚠️ Regressions detected on macos-14 for commit 394d5d7

Regression Summary
  • ESO Small Diffs: 2
  • MTR Small Diffs: 2
  • EIO: 1
  • Table Small Diffs: 1

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.

I've looked multiple times, and this does seem like the correct changes. It's annoying that this small tweak causes diffs, but it's fine. I may wait until a few more no diff PRs merge before dropping these PRs in together, but otherwise any thoughts anyone?

@@ -3133,7 +3133,7 @@ namespace HeatRecovery {
} break;
case HXConfiguration::CrossFlowBothUnmixed: { // CROSS FLOW BOTH UNMIXED
Temp = Z * std::pow(NTU, -0.22);
Eps = 1.0 - std::exp((std::exp(-NTU * Temp) - 1.0) / Temp);
Eps = 1.0 - std::exp(std::expm1(-NTU * Temp) / Temp);
Copy link
Member

@Myoldmopar Myoldmopar Jan 9, 2025

Choose a reason for hiding this comment

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

It's mildly confusing to me that

expm1(n) is the same as exp(n) - 1

but

log1p(n) is the same as log(n + 1).

I understand the difference, but at first glance I thought maybe that was the cause of diffs here.

Copy link
Contributor Author

@rraustad rraustad Jan 9, 2025

Choose a reason for hiding this comment

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

These are supposed to be more precise. So consider these improvements that could possibly change the answer slightly.

log1p(n) = log(1 + n)

I did these individually by module because there were diffs when I combined them all in 1 branch and I wanted to be sure which change caused which diffs.

Copy link
Member

Choose a reason for hiding this comment

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

Indeed it all makes sense. And it really can't be worth the time to investigate the diffs further. You've done a great job already, I feel comfortable merging the three log/exp branches, as it is crystal clear that they are just precision improvements.

@Myoldmopar
Copy link
Member

So we'll start with this one, and I'll look over the others and try to merge all three in short order.

@Myoldmopar Myoldmopar merged commit 1812659 into develop Jan 9, 2025
9 of 10 checks passed
@Myoldmopar Myoldmopar deleted the CppCheck-expm1-log1p-HeatRecovery branch January 9, 2025 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DoNotPublish Includes changes that shouldn't be reported in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants