Skip to content

Commit

Permalink
CppCheck expm1 log1p HeatRecovery
Browse files Browse the repository at this point in the history
  • Loading branch information
rraustad committed Dec 25, 2024
1 parent aa39f9f commit 7450138
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/EnergyPlus/HeatRecovery.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
} break;
case HXConfiguration::CrossFlowOther: { // CROSS FLOW, Cmax MIXED, Cmin UNMIXED
Eps = (1.0 - std::exp(-Z * (1.0 - std::exp(-NTU)))) / Z;
Expand Down Expand Up @@ -3221,13 +3221,13 @@ namespace HeatRecovery {
}
} break;
case HXConfiguration::ParallelFlow: { // PARALLEL FLOW
NTU = -std::log(-Eps - Eps * Z + 1.0) / (Z + 1.0);
NTU = -std::log1p(-Eps - Eps * Z) / (Z + 1.0);
} break;
case HXConfiguration::CrossFlowBothUnmixed: { // CROSS FLOW BOTH UNMIXED
NTU = GetNTUforCrossFlowBothUnmixed(state, Eps, Z);
} break;
case HXConfiguration::CrossFlowOther: { // CROSS FLOW, Cmax MIXED, Cmin UNMIXED
NTU = -std::log(1.0 + std::log(1.0 - Eps * Z) / Z);
NTU = -std::log1p(std::log(1.0 - Eps * Z) / Z);
} break;
default: {
ShowFatalError(state, format("HeatRecovery: Illegal flow arrangement in CalculateNTUfromEpsAndZ, Value={}", FlowArr));
Expand Down Expand Up @@ -3273,7 +3273,7 @@ namespace HeatRecovery {
int SolFla; // Flag of solver
Real64 constexpr NTU0(0.0); // lower bound for NTU
Real64 constexpr NTU1(50.0); // upper bound for NTU
auto f = [Eps, Z](Real64 const NTU) { return 1.0 - std::exp((std::exp(-std::pow(NTU, 0.78) * Z) - 1.0) / Z * std::pow(NTU, 0.22)) - Eps; };
auto f = [Eps, Z](Real64 const NTU) { return 1.0 - std::exp(std::expm1(-std::pow(NTU, 0.78) * Z) / Z * std::pow(NTU, 0.22)) - Eps; };
General::SolveRoot(state, Acc, MaxIte, SolFla, NTU, f, NTU0, NTU1);

if (SolFla == -2) {
Expand Down

3 comments on commit 7450138

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

CppCheck-expm1-log1p-HeatRecovery (rraustad) - x86_64-Linux-Ubuntu-24.04-gcc-13.3: OK (2918 of 2918 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

CppCheck-expm1-log1p-HeatRecovery (rraustad) - x86_64-Linux-Ubuntu-24.04-gcc-13.3-UnitTestsCoverage-RelWithDebInfo: OK (2100 of 2100 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

CppCheck-expm1-log1p-HeatRecovery (rraustad) - x86_64-Linux-Ubuntu-24.04-gcc-13.3-IntegrationCoverage-RelWithDebInfo: OK (801 of 801 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.