diff --git a/CMakeLists.txt b/CMakeLists.txt index f397e0a9..7c2ca2d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -322,7 +322,7 @@ list(APPEND APP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/externals/fmtlib" if (MSVC) # fmtlib requires that the utf-8 support be compiled in # TODO: add the fmt target from fmtlib directly which does this - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 -D_CRT_SECURE_NO_WARNINGS") endif() list(APPEND APP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include") list(APPEND APP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") diff --git a/include/Configuration.h b/include/Configuration.h index cf57503b..b1e6e1ae 100644 --- a/include/Configuration.h +++ b/include/Configuration.h @@ -1,7 +1,6 @@ #ifndef COOLPROP_CONFIGURATION #define COOLPROP_CONFIGURATION -#define _CRT_SECURE_NO_WARNINGS #include "Exceptions.h" #include "CoolPropTools.h" #include diff --git a/include/Solvers.h b/include/Solvers.h index 8e62a1b6..73c485de 100644 --- a/include/Solvers.h +++ b/include/Solvers.h @@ -21,7 +21,7 @@ class FuncWrapper1D std::string errstring; Dictionary options; int iter; - FuncWrapper1D() : errcode(0), errstring(""){}; + FuncWrapper1D() : errcode(0), errstring(""), iter(0) {}; virtual ~FuncWrapper1D(){}; virtual double call(double) = 0; /** diff --git a/src/Backends/Cubics/CubicsLibrary.cpp b/src/Backends/Cubics/CubicsLibrary.cpp index 0d9db0f6..f0bd0afc 100644 --- a/src/Backends/Cubics/CubicsLibrary.cpp +++ b/src/Backends/Cubics/CubicsLibrary.cpp @@ -154,7 +154,7 @@ void add_fluids_as_JSON(const std::string& JSON) { } else { try { library.add_many(dd); - } catch (std::exception& e) { + } catch (std::exception& /* e */) { throw ValueError(format("Unable to load cubics library with error: %s", errstr.c_str())); } } diff --git a/src/Backends/Cubics/UNIFAC.cpp b/src/Backends/Cubics/UNIFAC.cpp index 142a9259..dcf624dd 100644 --- a/src/Backends/Cubics/UNIFAC.cpp +++ b/src/Backends/Cubics/UNIFAC.cpp @@ -35,7 +35,7 @@ void UNIFAC::UNIFACMixture::set_interaction_parameter(const std::size_t mgi1, co } } double UNIFAC::UNIFACMixture::get_interaction_parameter(const std::size_t mgi1, const std::size_t mgi2, const std::string& parameter) { - std::map, UNIFACLibrary::InteractionParameters>::iterator it = this->interaction.find(std::pair(mgi1, mgi2)); + std::map, UNIFACLibrary::InteractionParameters>::iterator it = this->interaction.find(std::pair(static_cast(mgi1), static_cast(mgi2))); if (it == this->interaction.end()) { throw CoolProp::ValueError(format("Unable to match mgi-mgi pair: [%d,%d]", static_cast(mgi1), static_cast(mgi1))); } else { diff --git a/src/Backends/PCSAFT/PCSAFTBackend.cpp b/src/Backends/PCSAFT/PCSAFTBackend.cpp index 210df4f9..35d5575a 100644 --- a/src/Backends/PCSAFT/PCSAFTBackend.cpp +++ b/src/Backends/PCSAFT/PCSAFTBackend.cpp @@ -437,12 +437,12 @@ CoolPropDbl PCSAFTBackend::calc_alphar(void) { // these indices are necessary because we are only using 1D vectors vector XA (num_sites, 0); vector delta_ij(num_sites * num_sites, 0); - auto idxa = 0UL; - auto idxi = 0UL; // index for the ii-th compound - auto idxj = 0UL; // index for the jj-th compound - for (auto i = 0UL; i < num_sites; i++) { + auto idxa = 0ULL; + auto idxi = 0ULL; // index for the ii-th compound + auto idxj = 0ULL; // index for the jj-th compound + for (auto i = 0; i < num_sites; i++) { idxi = iA[i]*ncomp+iA[i]; - for (int j = 0UL; j < num_sites; j++) { + for (int j = 0; j < num_sites; j++) { idxj = iA[j]*ncomp+iA[j]; if (assoc_matrix[idxa] != 0) { double eABij = (components[iA[i]].getUAB()+components[iA[j]].getUAB())/2.; @@ -754,12 +754,12 @@ CoolPropDbl PCSAFTBackend::calc_dadt(void) { vector XA (num_sites, 0); vector delta_ij(num_sites * num_sites, 0); vector ddelta_dt(num_sites * num_sites, 0); - auto idxa = 0UL; - auto idxi = 0UL; // index for the ii-th compound - auto idxj = 0UL; // index for the jj-th compound - for (auto i = 0UL; i < num_sites; i++) { + std::size_t idxa = 0UL; + std::size_t idxi = 0UL; // index for the ii-th compound + std::size_t idxj = 0UL; // index for the jj-th compound + for (auto i = 0; i < num_sites; i++) { idxi = iA[i]*ncomp+iA[i]; - for (auto j = 0UL; j < num_sites; j++) { + for (auto j = 0; j < num_sites; j++) { idxj = iA[j]*ncomp+iA[j]; if (assoc_matrix[idxa] != 0) { double eABij = (components[iA[i]].getUAB()+components[iA[j]].getUAB())/2.; @@ -1211,12 +1211,12 @@ vector PCSAFTBackend::calc_fugacity_coefficients(void) { // these indices are necessary because we are only using 1D vectors vector XA (num_sites, 0); vector delta_ij(num_sites * num_sites, 0); - auto idxa = 0UL; - auto idxi = 0UL; // index for the ii-th compound - auto idxj = 0UL; // index for the jj-th compound - for (auto i = 0UL; i < num_sites; i++) { + std::size_t idxa = 0UL; + std::size_t idxi = 0UL; // index for the ii-th compound + std::size_t idxj = 0UL; // index for the jj-th compound + for (auto i = 0UL; i < static_cast(num_sites); i++) { idxi = iA[i]*ncomp+iA[i]; - for (auto j = 0UL; j < num_sites; j++) { + for (auto j = 0UL; j < static_cast(num_sites); j++) { idxj = iA[j]*ncomp+iA[j]; if (assoc_matrix[idxa] != 0) { double eABij = (components[iA[i]].getUAB()+components[iA[j]].getUAB())/2.; @@ -1235,12 +1235,12 @@ vector PCSAFTBackend::calc_fugacity_coefficients(void) { vector ddelta_dx(num_sites * num_sites * ncomp, 0); int idx_ddelta = 0; for (int k = 0; k < ncomp; k++) { - auto idxi = 0UL; // index for the ii-th compound - auto idxj = 0UL; // index for the jj-th compound + std::size_t idxi = 0UL; // index for the ii-th compound + std::size_t idxj = 0UL; // index for the jj-th compound idxa = 0; - for (auto i = 0UL; i < num_sites; i++) { + for (auto i = 0UL; i < static_cast(num_sites); i++) { idxi = iA[i]*ncomp+iA[i]; - for (auto j = 0UL; j < num_sites; j++) { + for (auto j = 0UL; j < static_cast(num_sites); j++) { idxj = iA[j]*ncomp+iA[j]; if (assoc_matrix[idxa] != 0) { double eABij = (components[iA[i]].getUAB()+components[iA[j]].getUAB())/2.; @@ -1565,12 +1565,12 @@ CoolPropDbl PCSAFTBackend::calc_compressibility_factor(void) { // these indices are necessary because we are only using 1D vectors vector XA (num_sites, 0); vector delta_ij(num_sites * num_sites, 0); - auto idxa = 0UL; - auto idxi = 0UL; // index for the ii-th compound - auto idxj = 0UL; // index for the jj-th compound - for (auto i = 0UL; i < num_sites; i++) { + std::size_t idxa = 0UL; + std::size_t idxi = 0UL; // index for the ii-th compound + std::size_t idxj = 0UL; // index for the jj-th compound + for (auto i = 0UL; i < static_cast(num_sites); i++) { idxi = iA[i]*ncomp+iA[i]; - for (auto j = 0UL; j < num_sites; j++) { + for (auto j = 0UL; j < static_cast(num_sites); j++) { idxj = iA[j]*ncomp+iA[j]; if (assoc_matrix[idxa] != 0) { double eABij = (components[iA[i]].getUAB()+components[iA[j]].getUAB())/2.; @@ -1589,12 +1589,12 @@ CoolPropDbl PCSAFTBackend::calc_compressibility_factor(void) { vector ddelta_dx(num_sites * num_sites * ncomp, 0); int idx_ddelta = 0; for (int k = 0; k < ncomp; k++) { - auto idxi = 0UL; // index for the ii-th compound - auto idxj = 0UL; // index for the jj-th compound + std::size_t idxi = 0UL; // index for the ii-th compound + std::size_t idxj = 0UL; // index for the jj-th compound idxa = 0; - for (auto i = 0UL; i < num_sites; i++) { + for (auto i = 0UL; i < static_cast(num_sites); i++) { idxi = iA[i]*ncomp+iA[i]; - for (auto j = 0UL; j < num_sites; j++) { + for (auto j = 0UL; j < static_cast(num_sites); j++) { idxj = iA[j]*ncomp+iA[j]; if (assoc_matrix[idxa] != 0) { double eABij = (components[iA[i]].getUAB()+components[iA[j]].getUAB())/2.; @@ -1874,8 +1874,7 @@ phases PCSAFTBackend::calc_phase_internal(CoolProp::input_pairs input_pair) { SatL->_T = _T; SatV->_T = _T; try { flash_QT(*this); - } - catch (const SolutionError& ex) { + } catch (const SolutionError& /* ex */) { phase = iphase_supercritical; break; } @@ -1916,7 +1915,7 @@ phases PCSAFTBackend::calc_phase_internal(CoolProp::input_pairs input_pair) { SatV->_T = _T; try { flash_QT(*this); - } catch (const SolutionError& ex) { + } catch (const SolutionError& /* ex */) { phase = iphase_supercritical; break; } @@ -1964,9 +1963,9 @@ void PCSAFTBackend::flash_QT(PCSAFTBackend &PCSAFT) { p_guess = estimate_flash_p(PCSAFT); p = outerTQ(p_guess, PCSAFT); solution_found = true; + } catch (const SolutionError& /* ex */) { + } catch (const ValueError& /* ex */) { } - catch (const SolutionError& ex) {} - catch (const ValueError& ex) {} // if solution hasn't been found, try cycling through a range of pressures if (!solution_found) { @@ -1978,9 +1977,9 @@ void PCSAFTBackend::flash_QT(PCSAFTBackend &PCSAFT) { try { p = outerTQ(pow(10, p_guess), PCSAFT); solution_found = true; - } catch (const SolutionError& ex) { + } catch (const SolutionError& /* ex */) { p_guess += p_step; - } catch (const ValueError& ex) { + } catch (const ValueError& /* ex */) { p_guess += p_step; } } @@ -2005,9 +2004,9 @@ void PCSAFTBackend::flash_PQ(PCSAFTBackend &PCSAFT) { t_guess = estimate_flash_t(PCSAFT); t = outerPQ(t_guess, PCSAFT); solution_found = true; + } catch (const SolutionError& /* ex */) { + } catch (const ValueError& /* ex */) { } - catch (const SolutionError& ex) {} - catch (const ValueError& ex) {} // if solution hasn't been found, try calling the flash function directly with a range of initial temperatures if (!solution_found) { @@ -2023,9 +2022,9 @@ void PCSAFTBackend::flash_PQ(PCSAFTBackend &PCSAFT) { try { t = outerPQ(t_guess, PCSAFT); solution_found = true; - } catch (const SolutionError& ex) { + } catch (const SolutionError& /* ex */) { t_guess -= t_step; - } catch (const ValueError& ex) { + } catch (const ValueError& /* ex */) { t_guess -= t_step; } } @@ -2046,7 +2045,7 @@ double PCSAFTBackend::outerPQ(double t_guess, PCSAFTBackend &PCSAFT) { // Based on the algorithm proposed in H. A. J. Watson, M. Vikse, T. Gundersen, and P. I. Barton, “Reliable Flash Calculations: Part 1. Nonsmooth Inside-Out Algorithms,” Ind. Eng. Chem. Res., vol. 56, no. 4, pp. 960–973, Feb. 2017, doi: 10.1021/acs.iecr.6b03956. auto ncomp = N; // number of components double TOL = 1e-8; - double MAXITER = 200; + int MAXITER = 200; // Define the residual to be driven to zero class SolverInnerResid : public FuncWrapper1D @@ -2308,7 +2307,7 @@ double PCSAFTBackend::outerTQ(double p_guess, PCSAFTBackend &PCSAFT) { // Based on the algorithm proposed in H. A. J. Watson, M. Vikse, T. Gundersen, and P. I. Barton, “Reliable Flash Calculations: Part 1. Nonsmooth Inside-Out Algorithms,” Ind. Eng. Chem. Res., vol. 56, no. 4, pp. 960–973, Feb. 2017, doi: 10.1021/acs.iecr.6b03956. auto ncomp = N; // number of components double TOL = 1e-8; - double MAXITER = 200; + int MAXITER = 200; // Define the residual to be driven to zero class SolverInnerResid : public FuncWrapper1D @@ -2590,7 +2589,7 @@ double PCSAFTBackend::estimate_flash_t(PCSAFTBackend &PCSAFT) { double intercept = std::log10(p1) - slope * (1/t); t_guess = slope / (std::log10(PCSAFT._p) - intercept); guess_found = true; - } catch (const SolutionError& ex) { + } catch (const SolutionError& /* ex */) { t_start -= t_step; } } diff --git a/src/HumidAirProp.cpp b/src/HumidAirProp.cpp index 9ab716a3..bcfd565a 100644 --- a/src/HumidAirProp.cpp +++ b/src/HumidAirProp.cpp @@ -403,7 +403,7 @@ static double Secant_Tdb_at_saturated_W(double psi_w, double p, double T_guess) if (!ValidNumber(T)) { throw CoolProp::ValueError("Intermediate value for Tdb is invalid"); } - } catch (std::exception& e) { + } catch (std::exception& /* e */) { T = CoolProp::Brent(Resids, 100, 640, 1e-15, 1e-10, 100); }