diff --git a/samples/cxx/NASA_coeffs/NASA_coeffs.cpp b/samples/cxx/NASA_coeffs/NASA_coeffs.cpp index b6f37f2640..8c89ca56e0 100644 --- a/samples/cxx/NASA_coeffs/NASA_coeffs.cpp +++ b/samples/cxx/NASA_coeffs/NASA_coeffs.cpp @@ -9,7 +9,7 @@ using namespace Cantera; void demoprog() { - printf("\n\n**** Testing modifying NASA polynomial coefficients ****\n\n"); + writelog("\n**** Testing modifying NASA polynomial coefficients ****\n"); IdealGasMix gas("h2o2.cti","ohmech"); int nsp = gas.nSpecies(); @@ -27,46 +27,44 @@ void demoprog() // cofficient array c. The c array contains Tmid in the first // location, followed by the 7 low-temperature coefficients, then // the seven high-temperature ones. - const int LOW_A6 = 6; - for (n = 0; n < nsp; n++) { - printf("\n\n %s (original):", gas.speciesName(n).c_str()); + writelog("\n\n {} (original):", gas.speciesName(n)); // get the NASA coefficients in array c sp.reportParams(n, type, c, minTemp, maxTemp, refPressure); // print the unmodified NASA coefficients - printf("\n "); + writelog("\n "); for (j = 1; j < 8; j++) { - printf(" A%d ", j); + writelog(" A{} ", j); } - printf("\n low:"); + writelog("\n low:"); for (j = 1; j < 8; j++) { - printf(" %10.4E ", c[j]); + writelog(" {:10.4E} ", c[j]); } - printf("\n high:"); + writelog("\n high:"); for (j = 8; j < 15; j++) { - printf(" %10.4E ", c[j]); + writelog(" {:10.4E} ", c[j]); } - printf("\n "); + writelog("\n "); // print the modified NASA coefficients - printf("\n\n %s (modified):", gas.speciesName(n).c_str()); - printf("\n "); + writelog("\n\n {} (modified):", gas.speciesName(n).c_str()); + writelog("\n "); for (j = 1; j < 8; j++) { - printf(" A%d ", j); + writelog(" A{} ", j); } - printf("\n low:"); + writelog("\n low:"); for (j = 1; j < 8; j++) { - printf(" %10.4E ", c[j]); + writelog(" {:10.4E} ", c[j]); } - printf("\n high:"); + writelog("\n high:"); for (j = 8; j < 15; j++) { - printf(" %10.4E ", c[j]); + writelog(" {:10.4E} ", c[j]); } - printf("\n "); + writelog("\n"); } } diff --git a/samples/cxx/demo.cpp b/samples/cxx/demo.cpp index 7a23b4e818..f11992fb7e 100644 --- a/samples/cxx/demo.cpp +++ b/samples/cxx/demo.cpp @@ -25,7 +25,7 @@ using namespace Cantera; void demoprog() { - printf("\n\n**** C++ Test Program ****\n\n"); + writelog("\n**** C++ Test Program ****\n"); IdealGasMix gas("h2o2.cti","ohmech"); double temp = 1200.0; @@ -35,14 +35,14 @@ void demoprog() // Thermodynamic properties - printf("\n\nInitial state:\n\n"); - printf( - "Temperature: %14.5g K\n" - "Pressure: %14.5g Pa\n" - "Density: %14.5g kg/m3\n" - "Molar Enthalpy: %14.5g J/kmol\n" - "Molar Entropy: %14.5g J/kmol-K\n" - "Molar cp: %14.5g J/kmol-K\n", + writelog("\n\nInitial state:\n\n"); + writelog( + "Temperature: {:14.5g} K\n" + "Pressure: {:14.5g} Pa\n" + "Density: {:14.5g} kg/m3\n" + "Molar Enthalpy: {:14.5g} J/kmol\n" + "Molar Entropy: {:14.5g} J/kmol-K\n" + "Molar cp: {:14.5g} J/kmol-K\n", gas.temperature(), gas.pressure(), gas.density(), gas.enthalpy_mole(), gas.entropy_mole(), gas.cp_mole()); @@ -50,14 +50,14 @@ void demoprog() // enthalpy and pressure gas.equilibrate("HP"); - printf("\n\nEquilibrium state:\n\n"); - printf( - "Temperature: %14.5g K\n" - "Pressure: %14.5g Pa\n" - "Density: %14.5g kg/m3\n" - "Molar Enthalpy: %14.5g J/kmol\n" - "Molar Entropy: %14.5g J/kmol-K\n" - "Molar cp: %14.5g J/kmol-K\n", + writelog("\n\nEquilibrium state:\n\n"); + writelog( + "Temperature: {:14.5g} K\n" + "Pressure: {:14.5g} Pa\n" + "Density: {:14.5g} kg/m3\n" + "Molar Enthalpy: {:14.5g} J/kmol\n" + "Molar Entropy: {:14.5g} J/kmol-K\n" + "Molar cp: {:14.5g} J/kmol-K\n", gas.temperature(), gas.pressure(), gas.density(), gas.enthalpy_mole(), gas.entropy_mole(), gas.cp_mole()); @@ -76,10 +76,10 @@ void demoprog() gas.getRevRatesOfProgress(&qr[0]); gas.getNetRatesOfProgress(&q[0]); - printf("\n\n"); + writelog("\n\n"); for (int i = 0; i < irxns; i++) { - printf("%30s %14.5g %14.5g %14.5g kmol/m3/s\n", - gas.reactionString(i).c_str(), qf[i], qr[i], q[i]); + writelog("{:30s} {:14.5g} {:14.5g} {:14.5g} kmol/m3/s\n", + gas.reactionString(i), qf[i], qr[i], q[i]); } @@ -87,20 +87,20 @@ void demoprog() // create a transport manager for the gas that computes // mixture-averaged properties - std::unique_ptr tr(newTransportMgr("Mix", &gas, 1)); + std::unique_ptr tr(newTransportMgr("Mix", &gas, 0)); // print the viscosity, thermal conductivity, and diffusion // coefficients - printf("\n\nViscosity: %14.5g Pa-s\n", tr->viscosity()); - printf("Thermal conductivity: %14.5g W/m/K\n", tr->thermalConductivity()); + writelog("\n\nViscosity: {:14.5g} Pa-s\n", tr->viscosity()); + writelog("Thermal conductivity: {:14.5g} W/m/K\n", tr->thermalConductivity()); int nsp = gas.nSpecies(); vector_fp diff(nsp); tr->getMixDiffCoeffs(&diff[0]); int k; - printf("\n\n%20s %26s\n", "Species","Diffusion Coefficient"); + writelog("\n\n{:20s} {:26s}\n", "Species", "Diffusion Coefficient"); for (k = 0; k < nsp; k++) { - printf("%20s %14.5g m2/s \n", gas.speciesName(k).c_str(), diff[k]); + writelog("{:20s} {:14.5g} m2/s \n", gas.speciesName(k), diff[k]); } } diff --git a/samples/cxx/rankine/rankine.cpp b/samples/cxx/rankine/rankine.cpp index 695834db93..e564ed8be0 100644 --- a/samples/cxx/rankine/rankine.cpp +++ b/samples/cxx/rankine/rankine.cpp @@ -21,13 +21,11 @@ void saveState(F& fluid, std::string name) void printStates() { - std::string name; - int n; int nStates = states.size(); - for (n = 0; n < nStates; n++) { - name = states[n]; - printf(" %5s %10.6g %10.6g %12.6g %12.6g %5.2g \n", - name.c_str(), T[name], P[name], h[name], s[name], x[name]); + for (int n = 0; n < nStates; n++) { + std::string name = states[n]; + writelog(" {:5s} {:10.6g} {:10.6g} {:12.6g} {:12.6g} {:5.2g}\n", + name, T[name], P[name], h[name], s[name], x[name]); } } @@ -71,8 +69,6 @@ int openRankine(int np, void* p) return 0; } - -#ifndef CXX_DEMO int main() { try { @@ -82,4 +78,3 @@ int main() return -1; } } -#endif