From 29c55487faba3bec389fcba74841489f97d2d39a Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Thu, 3 Apr 2025 19:55:48 -0400 Subject: [PATCH] Resolve some issues identified by XCode analysis [skipci] --- externals/msgpack-c | 2 +- src/Backends/Helmholtz/FlashRoutines.cpp | 4 ++-- src/Backends/PCSAFT/PCSAFTBackend.cpp | 7 +++---- src/CoolPropPlot.cpp | 4 ++-- src/HumidAirProp.cpp | 2 +- src/PolyMath.cpp | 5 +---- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/externals/msgpack-c b/externals/msgpack-c index f9f2917c..91990874 160000 --- a/externals/msgpack-c +++ b/externals/msgpack-c @@ -1 +1 @@ -Subproject commit f9f2917cc01ce6431dacf35986f53058e1857080 +Subproject commit 919908742b4fdbc575e77fe1a8657e70c9573c44 diff --git a/src/Backends/Helmholtz/FlashRoutines.cpp b/src/Backends/Helmholtz/FlashRoutines.cpp index c55f5b5a..6c16eb11 100644 --- a/src/Backends/Helmholtz/FlashRoutines.cpp +++ b/src/Backends/Helmholtz/FlashRoutines.cpp @@ -2048,10 +2048,10 @@ TEST_CASE("Stability testing", "[stability]") { HEOS->set_mole_fractions(z); HEOS->update(PQ_INPUTS, 101325, 0); - double TL = HEOS->T(), rhoL = HEOS->rhomolar(); + double TL = HEOS->T(); HEOS->update(PQ_INPUTS, 101325, 1); - double TV = HEOS->T(), rhoV = HEOS->rhomolar(); + double TV = HEOS->T(); SECTION("Liquid (feed is stable)") { StabilityRoutines::StabilityEvaluationClass stability_tester(*HEOS); diff --git a/src/Backends/PCSAFT/PCSAFTBackend.cpp b/src/Backends/PCSAFT/PCSAFTBackend.cpp index c33e2705..210df4f9 100644 --- a/src/Backends/PCSAFT/PCSAFTBackend.cpp +++ b/src/Backends/PCSAFT/PCSAFTBackend.cpp @@ -2771,18 +2771,18 @@ CoolPropDbl PCSAFTBackend::solver_rho_Tp(CoolPropDbl T, CoolPropDbl p, phases ph double x_lo_molar = 1e-8, x_hi_molar = 1e7; if (x_lo.size() == 1) { - rho_guess = reduced_to_molar((x_lo[0] + x_hi[0]) / 2., T); +// rho_guess = reduced_to_molar((x_lo[0] + x_hi[0]) / 2., T); x_lo_molar = reduced_to_molar(x_lo[0], T); x_hi_molar = reduced_to_molar(x_hi[0], T); rho = Brent(resid, x_lo_molar, x_hi_molar, DBL_EPSILON, 1e-8, 200); } else if (x_lo.size() <= 3 && !x_lo.empty()) { if ((phase == iphase_liquid) || (phase == iphase_supercritical_liquid)) { - rho_guess = reduced_to_molar((x_lo.back() + x_hi.back()) / 2., T); +// rho_guess = reduced_to_molar((x_lo.back() + x_hi.back()) / 2., T); x_lo_molar = reduced_to_molar(x_lo.back(), T); x_hi_molar = reduced_to_molar(x_hi.back(), T); rho = Brent(resid, x_lo_molar, x_hi_molar, DBL_EPSILON, 1e-8, 200); } else if ((phase == iphase_gas) || (phase == iphase_supercritical_gas) || (phase == iphase_supercritical)) { - rho_guess = reduced_to_molar((x_lo[0] + x_hi[0]) / 40., T); // starting with a lower guess often provides better results +// rho_guess = reduced_to_molar((x_lo[0] + x_hi[0]) / 40., T); // starting with a lower guess often provides better results x_lo_molar = reduced_to_molar(x_lo[0], T); x_hi_molar = reduced_to_molar(x_hi[0], T); rho = Brent(resid, x_lo_molar, x_hi_molar, DBL_EPSILON, 1e-8, 200); @@ -2791,7 +2791,6 @@ CoolPropDbl PCSAFTBackend::solver_rho_Tp(CoolPropDbl T, CoolPropDbl p, phases ph // if multiple roots to check, then find the one with the minimum gibbs energy. Reference: Privat R, Gani R, Jaubert JN. Are safe results obtained when the PC-SAFT equation of state is applied to ordinary pure chemicals?. Fluid Phase Equilibria. 2010 Aug 15;295(1):76-92. double g_min = 1e60; for (int i = 0; i < x_lo.size(); i++) { - rho_guess = reduced_to_molar((x_lo[i] + x_hi[i]) / 2., T); x_lo_molar = reduced_to_molar(x_lo[i], T); x_hi_molar = reduced_to_molar(x_hi[i], T); double rho_i = Brent(resid, x_lo_molar, x_hi_molar, DBL_EPSILON, 1e-8, 200); diff --git a/src/CoolPropPlot.cpp b/src/CoolPropPlot.cpp index cdbec0db..f8e44184 100644 --- a/src/CoolPropPlot.cpp +++ b/src/CoolPropPlot.cpp @@ -179,8 +179,8 @@ void Isoline::calc_sat_range(int count) { x[i] = state_->keyed_output(xkey_); y[i] = state_->keyed_output(ykey_); } catch (...) { - if (input_pair == CoolProp::QT_INPUTS && abs(two[i] - t_crit) < 1e0 - || input_pair == CoolProp::PQ_INPUTS && abs(one[i] - p_crit) < 1e2) { + if ((input_pair == CoolProp::QT_INPUTS && abs(two[i] - t_crit) < 1e0) + || (input_pair == CoolProp::PQ_INPUTS && abs(one[i] - p_crit) < 1e2)) { x[i] = x_crit; y[i] = y_crit; std::cerr << "ERROR near critical inputs" << std::endl; diff --git a/src/HumidAirProp.cpp b/src/HumidAirProp.cpp index eb586a63..ce0d7109 100644 --- a/src/HumidAirProp.cpp +++ b/src/HumidAirProp.cpp @@ -1256,7 +1256,7 @@ class WetBulbTminSolver : public CoolProp::FuncWrapper1D double call(double Ts) { //double RHS = HAPropsSI("H","T",Ts,"P",p,"R",1); - double psi_w, T; + double psi_w, T = Ts; //std::vector inp = { HumidAir::GIVEN_T, HumidAir::GIVEN_RH }; // C++11 std::vector inp(2); inp[0] = HumidAir::GIVEN_T; diff --git a/src/PolyMath.cpp b/src/PolyMath.cpp index fbfce7ff..d008041d 100644 --- a/src/PolyMath.cpp +++ b/src/PolyMath.cpp @@ -534,7 +534,7 @@ double Polynomial2DFrac::evaluate(const Eigen::MatrixXd& coefficients, const dou Eigen::MatrixXd tmpCoeffs(coefficients); Eigen::MatrixXd newCoeffs; - size_t r = tmpCoeffs.rows(); + size_t r; size_t c = tmpCoeffs.cols(); double negExp = 0; // First we treat the negative exponents double posExp = 0; // then the positive exponents @@ -1035,7 +1035,6 @@ TEST_CASE("Internal consistency checks and example use cases for PolyMath.cpp", CHECK(check_abs(c, d, acc)); } - c = 2.0; c = poly.solve(matrix, 0.0, d, 0)[0]; { CAPTURE(T); @@ -1044,7 +1043,6 @@ TEST_CASE("Internal consistency checks and example use cases for PolyMath.cpp", CHECK(check_abs(c, T, acc)); } - c = 2.0; c = poly.solve_limits(matrix, 0.0, d, -50, 750, 0); { CAPTURE(T); @@ -1053,7 +1051,6 @@ TEST_CASE("Internal consistency checks and example use cases for PolyMath.cpp", CHECK(check_abs(c, T, acc)); } - c = 2.0; c = poly.solve_guess(matrix, 0.0, d, 350, 0); { CAPTURE(T);