diff --git a/include/cantera/base/global.h b/include/cantera/base/global.h index 1f2e70ec2..867bb8a64 100644 --- a/include/cantera/base/global.h +++ b/include/cantera/base/global.h @@ -194,13 +194,17 @@ void _warn_user(const std::string& method, const std::string& extra); * Print a user warning raised from *method*. * * @param method method name - * @param msg C format string for the following arguments - * @param args arguments used to interpolate the format string + * @param msg Python-style format string with the following arguments + * @param args arguments for the format string */ template void warn_user(const std::string& method, const std::string& msg, const Args&... args) { - _warn_user(method, fmt::format(msg, args...)); + if (sizeof...(args) == 0) { + _warn_user(method, msg); + } else { + _warn_user(method, fmt::format(msg, args...)); + } } //! @copydoc Application::make_deprecation_warnings_fatal diff --git a/src/base/application.cpp b/src/base/application.cpp index 24f5823d1..b0a62913c 100644 --- a/src/base/application.cpp +++ b/src/base/application.cpp @@ -170,14 +170,14 @@ void Application::warn_deprecated(const std::string& method, return; } warnings.insert(method); - writelog("DeprecationWarning: '" + method + "': " + extra); + writelog(fmt::format("DeprecationWarning: {}: {}", method, extra)); writelogendl(); } void Application::warn_user(const std::string& method, const std::string& extra) { - writelog("UserWarning: '" + method + "': " + extra); + writelog(fmt::format("CanteraWarning: {}: {}", method, extra)); writelogendl(); } diff --git a/src/kinetics/Falloff.cpp b/src/kinetics/Falloff.cpp index 3332bb1cc..3958e59ac 100644 --- a/src/kinetics/Falloff.cpp +++ b/src/kinetics/Falloff.cpp @@ -45,7 +45,13 @@ void Troe::init(const vector_fp& c) if (c.size() == 4) { if (std::abs(c[3]) < SmallNumber) { - warn_user("Troe::init", "Zero T2 value is suppressed."); + warn_user("Troe::init", + "Unexpected parameter value T2=0. Omitting exp(T2/T) term from " + "falloff expression. To suppress this warning, remove value " + "for T2 from the input file. In the unlikely case that the " + "exp(T2/T) term should be included with T2 effectively equal " + "to 0, set T2 to a sufficiently small value " + "(i.e. T2 < 1e-16)."); } m_t2 = c[3]; } diff --git a/src/thermo/PDSS_HKFT.cpp b/src/thermo/PDSS_HKFT.cpp index e724590ee..91845bc97 100644 --- a/src/thermo/PDSS_HKFT.cpp +++ b/src/thermo/PDSS_HKFT.cpp @@ -314,7 +314,7 @@ void PDSS_HKFT::initThermo() " not consistent with G and S: {} vs {} cal gmol-1", sname, Hcalc/toSI("cal/gmol"), m_deltaH_formation_tr_pr); } else { - warn_user("PDSS_HKFT::initThermo()", + warn_user("PDSS_HKFT::initThermo", "DHjmol for {} is not consistent with G and S: calculated {} " "vs input {} cal gmol-1; continuing with consistent DHjmol = {}", sname, Hcalc/toSI("cal/gmol"), m_deltaH_formation_tr_pr, diff --git a/src/transport/MMCollisionInt.cpp b/src/transport/MMCollisionInt.cpp index 5798aefb6..d285c8154 100644 --- a/src/transport/MMCollisionInt.cpp +++ b/src/transport/MMCollisionInt.cpp @@ -429,7 +429,7 @@ void MMCollisionInt::fit_omega22(int degree, doublereal deltastar, double rmserr = polyfit(n, degree, logT, values.data(), w.data(), o22); if (m_loglevel > 0 && rmserr > 0.01) { warn_user("MMCollisionInt::fit_omega22", - "RMS error = {:12.6g} in omega_22 fit" + "RMS error = {:12.6g} in omega_22 fit " "with delta* = {:12.6g}", rmserr, deltastar); } } diff --git a/test_problems/cxx_ex/output_blessed.txt b/test_problems/cxx_ex/output_blessed.txt index 5cdda4fe9..bdd9232b6 100644 --- a/test_problems/cxx_ex/output_blessed.txt +++ b/test_problems/cxx_ex/output_blessed.txt @@ -1,6 +1,6 @@ ----------------------------------- - Cantera C++ examples + Cantera C++ examples ----------------------------------- @@ -8,9 +8,9 @@ >>>>> example 1 -Description: +Description: Ignition simulation using class IdealGasPhase with file gri30.yaml. -Constant-pressure ignition of a hydrogen/oxygen/nitrogen mixture +Constant-pressure ignition of a hydrogen/oxygen/nitrogen mixture beginning at T = 1001 K and P = 1 atm. Tfinal = 2663.78 Output files: @@ -22,9 +22,9 @@ Output files: >>>>> example 2 -Description: +Description: Ignition simulation using class IdealGasPhase with file gri30.yaml. -Constant-pressure ignition of a hydrogen/oxygen/nitrogen mixture +Constant-pressure ignition of a hydrogen/oxygen/nitrogen mixture beginning at T = 1001 K and P = 1 atm. Tfinal = 2663.78 Output files: @@ -36,39 +36,39 @@ Output files: >>>>> example 3 -Description: +Description: Chemical equilibrium. Equilibrium composition and pressure for a range of temperatures at constant density. -UserWarning: 'NasaPoly2::validate': +CanteraWarning: NasaPoly2::validate: For species SI2H6, discontinuity in h/RT detected at Tmid = 1000 - Value computed using low-temperature polynomial: 19.8328 - Value computed using high-temperature polynomial: 19.9055 + Value computed using low-temperature polynomial: 19.8328 + Value computed using high-temperature polynomial: 19.9055 -UserWarning: 'NasaPoly2::validate': +CanteraWarning: NasaPoly2::validate: For species SI2H6, discontinuity in s/R detected at Tmid = 1000 - Value computed using low-temperature polynomial: 49.5493 - Value computed using high-temperature polynomial: 49.7214 + Value computed using low-temperature polynomial: 49.5493 + Value computed using high-temperature polynomial: 49.7214 -UserWarning: 'NasaPoly2::validate': +CanteraWarning: NasaPoly2::validate: For species SI3H8, discontinuity in h/RT detected at Tmid = 1000 - Value computed using low-temperature polynomial: 29.3028 - Value computed using high-temperature polynomial: 29.4297 + Value computed using low-temperature polynomial: 29.3028 + Value computed using high-temperature polynomial: 29.4297 -UserWarning: 'NasaPoly2::validate': +CanteraWarning: NasaPoly2::validate: For species SI3H8, discontinuity in s/R detected at Tmid = 1000 - Value computed using low-temperature polynomial: 65.9731 - Value computed using high-temperature polynomial: 66.2781 + Value computed using low-temperature polynomial: 65.9731 + Value computed using high-temperature polynomial: 66.2781 -UserWarning: 'NasaPoly2::validate': +CanteraWarning: NasaPoly2::validate: For species SI2, discontinuity in h/RT detected at Tmid = 1000 - Value computed using low-temperature polynomial: 74.0115 - Value computed using high-temperature polynomial: 74.0387 + Value computed using low-temperature polynomial: 74.0115 + Value computed using high-temperature polynomial: 74.0387 -UserWarning: 'NasaPoly2::validate': +CanteraWarning: NasaPoly2::validate: For species SI2, discontinuity in s/R detected at Tmid = 1000 - Value computed using low-temperature polynomial: 32.8813 - Value computed using high-temperature polynomial: 32.9489 + Value computed using low-temperature polynomial: 32.8813 + Value computed using high-temperature polynomial: 32.9489 Output files: eq1.csv (Excel CSV file) @@ -79,7 +79,7 @@ Output files: >>>>> example 4 -Description: +Description: Mixture-averaged transport properties. Viscosity, thermal conductivity, and mixture-averaged diffusion coefficients at 2 atm for a range of temperatures @@ -92,7 +92,7 @@ Output files: >>>>> example 5 -Description: +Description: Multicomponent transport properties. Viscosity, thermal conductivity, and thermal diffusion coefficients at 2 atm for a range of temperatures