From 9ff2c9361530f1bf33aadb25b664d7c8636cc3a6 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 14 Dec 2011 05:55:29 +0000 Subject: [PATCH] Modified the cxx_ex tests to generate consistent output --- test_problems/cxx_ex/equil_example1.cpp | 7 - test_problems/cxx_ex/kinetics_example1.cpp | 11 +- test_problems/cxx_ex/kinetics_example2.cpp | 10 +- test_problems/cxx_ex/kinetics_example3.cpp | 10 +- test_problems/cxx_ex/output_blessed.txt | 135 ++++++++++++++++++++ test_problems/cxx_ex/rxnpath_example1.cpp | 7 +- test_problems/cxx_ex/transport_example1.cpp | 8 +- test_problems/cxx_ex/transport_example2.cpp | 8 +- 8 files changed, 141 insertions(+), 55 deletions(-) create mode 100644 test_problems/cxx_ex/output_blessed.txt diff --git a/test_problems/cxx_ex/equil_example1.cpp b/test_problems/cxx_ex/equil_example1.cpp index 1d812033d..94d349e76 100755 --- a/test_problems/cxx_ex/equil_example1.cpp +++ b/test_problems/cxx_ex/equil_example1.cpp @@ -17,7 +17,6 @@ #endif #include -#include #include "example_utils.h" #include @@ -84,7 +83,6 @@ int equil_example1(int job) { doublereal tlow = 500.0; doublereal dt = (thigh - tlow)/(ntemps); doublereal pres = 0.01*OneAtm; - clock_t t0 = clock(); for (int i = 0; i < ntemps; i++) { temp = tlow + dt*i; if (temp > gas.maxTemp()) break; @@ -97,7 +95,6 @@ int equil_example1(int job) { gas.getMoleFractions(&output(2,i)); } - clock_t t1 = clock(); // make a Tecplot data file and an Excel spreadsheet string plotTitle = "equilibrium example 1: " @@ -105,10 +102,6 @@ int equil_example1(int job) { plotEquilSoln("eq1.dat", "TEC", plotTitle, gas, output); plotEquilSoln("eq1.csv", "XL", plotTitle, gas, output); - // print timing data - doublereal tmm = 1.0*(t1 - t0)/CLOCKS_PER_SEC; - cout << " time = " << tmm << endl << endl; - cout << "Output files:" << endl << " eq1.csv (Excel CSV file)" << endl << " eq1.dat (Tecplot data file)" << endl; diff --git a/test_problems/cxx_ex/kinetics_example1.cpp b/test_problems/cxx_ex/kinetics_example1.cpp index 74500c287..65fd191bd 100755 --- a/test_problems/cxx_ex/kinetics_example1.cpp +++ b/test_problems/cxx_ex/kinetics_example1.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include "example_utils.h" using namespace Cantera; using namespace Cantera_CXX; @@ -101,29 +100,21 @@ int kinetics_example1(int job) { saveSoln(0, 0.0, gas, soln); // main loop - clock_t t0 = clock(); for (int i = 1; i <= nsteps; i++) { tm = i*dt; sim_ptr->advance(tm); saveSoln(tm, gas, soln); } - clock_t t1 = clock(); - // make a Tecplot data file and an Excel spreadsheet string plotTitle = "kinetics example 1: constant-pressure ignition"; plotSoln("kin1.dat", "TEC", plotTitle, gas, soln); plotSoln("kin1.csv", "XL", plotTitle, gas, soln); - - // print final temperature and timing data - doublereal tmm = 1.0*(t1 - t0)/CLOCKS_PER_SEC; + // print final temperature cout << " Tfinal = " << r.temperature() << endl; - cout << " time = " << tmm << endl; cout << " number of residual function evaluations = " << sim_ptr->integrator().nEvals() << endl; - cout << " time per evaluation = " << tmm/sim_ptr->integrator().nEvals() - << endl << endl; cout << "Output files:" << endl << " kin1.csv (Excel CSV file)" << endl << " kin1.dat (Tecplot data file)" << endl; diff --git a/test_problems/cxx_ex/kinetics_example2.cpp b/test_problems/cxx_ex/kinetics_example2.cpp index 391a7b7ea..29245cb18 100755 --- a/test_problems/cxx_ex/kinetics_example2.cpp +++ b/test_problems/cxx_ex/kinetics_example2.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include "example_utils.h" using namespace Cantera; @@ -91,14 +90,11 @@ int kinetics_example2(int job) { saveSoln(0, 0.0, gas, soln); // main loop - clock_t t0 = clock(); for (int i = 1; i <= nsteps; i++) { tm = i*dt; sim.advance(tm); saveSoln(tm, gas, soln); } - clock_t t1 = clock(); - // make a Tecplot data file and an Excel spreadsheet string plotTitle = "kinetics example 2: constant-pressure ignition"; @@ -106,14 +102,10 @@ int kinetics_example2(int job) { plotSoln("kin2.csv", "XL", plotTitle, gas, soln); - // print final temperature and timing data - doublereal tmm = 1.0*(t1 - t0)/CLOCKS_PER_SEC; + // print final temperature cout << " Tfinal = " << r.temperature() << endl; - cout << " time = " << tmm << endl; cout << " number of residual function evaluations = " << sim.integrator().nEvals() << endl; - cout << " time per evaluation = " << tmm/sim.integrator().nEvals() - << endl << endl; cout << "Output files:" << endl << " kin2.csv (Excel CSV file)" << endl diff --git a/test_problems/cxx_ex/kinetics_example3.cpp b/test_problems/cxx_ex/kinetics_example3.cpp index e2be7ff7b..6febff897 100644 --- a/test_problems/cxx_ex/kinetics_example3.cpp +++ b/test_problems/cxx_ex/kinetics_example3.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include "example_utils.h" using namespace Cantera; @@ -96,14 +95,11 @@ int kinetics_example3(int job) { saveSoln(0, 0.0, gas, soln); // main loop - clock_t t0 = clock(); for (int i = 1; i <= nsteps; i++) { tm = i*dt; sim.advance(tm); saveSoln(tm, gas, soln); } - clock_t t1 = clock(); - // make a Tecplot data file and an Excel spreadsheet string plotTitle = "kinetics example 3: constant-pressure ignition"; @@ -111,14 +107,10 @@ int kinetics_example3(int job) { plotSoln("kin3.csv", "XL", plotTitle, gas, soln); - // print final temperature and timing data - doublereal tmm = 1.0*(t1 - t0)/CLOCKS_PER_SEC; + // print final temperature cout << " Tfinal = " << r.temperature() << endl; - cout << " time = " << tmm << endl; cout << " number of residual function evaluations = " << sim.integrator().nEvals() << endl; - cout << " time per evaluation = " << tmm/sim.integrator().nEvals() - << endl << endl; cout << "Output files:" << endl << " kin3.csv (Excel CSV file)" << endl << " kin3.dat (Tecplot data file)" << endl; diff --git a/test_problems/cxx_ex/output_blessed.txt b/test_problems/cxx_ex/output_blessed.txt new file mode 100644 index 000000000..441509833 --- /dev/null +++ b/test_problems/cxx_ex/output_blessed.txt @@ -0,0 +1,135 @@ + +----------------------------------- + Cantera C++ examples +----------------------------------- + + + + +>>>>> example 1 + +Description: +Ignition simulation using class IdealGasMix with file gri30.cti. +Constant-pressure ignition of a hydrogen/oxygen/nitrogen mixture +beginning at T = 1001 K and P = 1 atm. + + Cantera version 1.8.x + Copyright California Institute of Technology, 2002. + http://www.cantera.org + + Tfinal = 2663.78 + number of residual function evaluations = 1876 +Output files: + kin1.csv (Excel CSV file) + kin1.dat (Tecplot data file) + + + + +>>>>> example 2 + +Description: +Ignition simulation using class GRI30. +Constant-pressure ignition of a hydrogen/oxygen/nitrogen mixture +beginning at T = 1001 K and P = 1 atm. + + Cantera version 1.8.x + Copyright California Institute of Technology, 2002. + http://www.cantera.org + + Tfinal = 2663.78 + number of residual function evaluations = 1970 +Output files: + kin2.csv (Excel CSV file) + kin2.dat (Tecplot data file) + + + + +>>>>> example 3 + +Description: +Ignition simulation using class IdealGasMix with file gri30.cti. +Constant-pressure ignition of a hydrogen/oxygen/nitrogen mixture +beginning at T = 1001 K and P = 1 atm. + + Cantera version 1.8.x + Copyright California Institute of Technology, 2002. + http://www.cantera.org + + Tfinal = 2663.78 + number of residual function evaluations = 1980 +Output files: + kin3.csv (Excel CSV file) + kin3.dat (Tecplot data file) + + + + +>>>>> example 4 + +Description: +Chemical equilibrium. +Equilibrium composition and pressure for a range of temperatures at constant density. + + Cantera version 1.8.x + Copyright California Institute of Technology, 2002. + http://www.cantera.org + + + +**** WARNING **** +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. + + +**** WARNING **** +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. + + +**** WARNING **** +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. +Output files: + eq1.csv (Excel CSV file) + eq1.dat (Tecplot data file) + + + + +>>>>> example 5 + +Description: +Mixture-averaged transport properties. +Viscosity, thermal conductivity, and mixture-averaged +diffusion coefficients at 2 atm for a range of temperatures + + Cantera version 1.8.x + Copyright California Institute of Technology, 2002. + http://www.cantera.org + +Output files: + tr1.csv (Excel CSV file) + tr1.dat (Tecplot data file) + + + + +>>>>> example 6 + +Description: +Multicomponent transport properties. +Viscosity, thermal conductivity, and thermal diffusion + coefficients at 2 atm for a range of temperatures + + Cantera version 1.8.x + Copyright California Institute of Technology, 2002. + http://www.cantera.org + +Output files: + tr2.csv (Excel CSV file) + tr2.dat (Tecplot data file) diff --git a/test_problems/cxx_ex/rxnpath_example1.cpp b/test_problems/cxx_ex/rxnpath_example1.cpp index 9a7756aad..4f264fae7 100755 --- a/test_problems/cxx_ex/rxnpath_example1.cpp +++ b/test_problems/cxx_ex/rxnpath_example1.cpp @@ -18,7 +18,6 @@ #include #include -#include #include "example_utils.h" #include #include @@ -142,17 +141,13 @@ int rxnpath_example1(int job) { b.init(rplog, gas); // initialize // main loop - clock_t t0 = clock(); for (int i = 1; i <= nsteps; i++) { tm = i*dt; sim.advance(tm); writeRxnPathDiagram(tm, b, gas, rplog, rplot); } - clock_t t1 = clock(); - // print final temperature and timing data - doublereal tmm = 1.0*(t1 - t0)/CLOCKS_PER_SEC; - cout << " time = " << tmm << endl; + // print final temperature cout << "Output files:" << endl << " rp1.log (log file)" << endl << " rp1.dot (input file for dot)" << endl; diff --git a/test_problems/cxx_ex/transport_example1.cpp b/test_problems/cxx_ex/transport_example1.cpp index 65fd37499..9e256e6b1 100755 --- a/test_problems/cxx_ex/transport_example1.cpp +++ b/test_problems/cxx_ex/transport_example1.cpp @@ -18,7 +18,6 @@ #include #include -#include #include "example_utils.h" #include @@ -81,7 +80,6 @@ int transport_example1(int job) { Array2D output(nsp+3, ntemps); // main loop - clock_t t0 = clock(); for (int i = 0; i < ntemps; i++) { temp = 500.0 + 100.0*i; gas.setState_TP(temp, pres); @@ -90,7 +88,6 @@ int transport_example1(int job) { output(2,i) = tr->thermalConductivity(); tr->getMixDiffCoeffs(&output(3,i)); } - clock_t t1 = clock(); // make a Tecplot data file and an Excel spreadsheet string plotTitle = "transport example 1: " @@ -98,10 +95,7 @@ int transport_example1(int job) { plotTransportSoln("tr1.dat", "TEC", plotTitle, gas, output); plotTransportSoln("tr1.csv", "XL", plotTitle, gas, output); - // print final temperature and timing data - doublereal tmm = 1.0*(t1 - t0)/CLOCKS_PER_SEC; - cout << " time = " << tmm << endl << endl; - + // print final temperature cout << "Output files:" << endl << " tr1.csv (Excel CSV file)" << endl << " tr1.dat (Tecplot data file)" << endl; diff --git a/test_problems/cxx_ex/transport_example2.cpp b/test_problems/cxx_ex/transport_example2.cpp index 83086651b..117e599e2 100755 --- a/test_problems/cxx_ex/transport_example2.cpp +++ b/test_problems/cxx_ex/transport_example2.cpp @@ -18,7 +18,6 @@ #include #include -#include #include "example_utils.h" #include #include @@ -83,7 +82,6 @@ int transport_example2(int job) { Array2D output(nsp+3, ntemps); // main loop - clock_t t0 = clock(); for (int i = 0; i < ntemps; i++) { temp = 500.0 + 100.0*i; gas.setState_TP(temp, pres); @@ -92,7 +90,6 @@ int transport_example2(int job) { output(2,i) = tr->thermalConductivity(); tr->getThermalDiffCoeffs(&output(3,i)); } - clock_t t1 = clock(); // make a Tecplot data file and an Excel spreadsheet string plotTitle = "transport example 2: " @@ -100,10 +97,7 @@ int transport_example2(int job) { plotTransportSoln("tr2.dat", "TEC", plotTitle, gas, output); plotTransportSoln("tr2.csv", "XL", plotTitle, gas, output); - // print final temperature and timing data - doublereal tmm = 1.0*(t1 - t0)/CLOCKS_PER_SEC; - cout << " time = " << tmm << endl << endl; - + // print final temperature cout << "Output files:" << endl << " tr2.csv (Excel CSV file)" << endl << " tr2.dat (Tecplot data file)" << endl;