Skip to content

Commit

Permalink
Merge pull request #10880 from NREL/CppCheck-expm1-log1p-HeatRecovery
Browse files Browse the repository at this point in the history
CppCheck expm1 log1p HeatRecovery
  • Loading branch information
Myoldmopar authored Jan 9, 2025
2 parents e2815c3 + 7450138 commit 1812659
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

0 comments on commit 1812659

Please sign in to comment.