diff --git a/doc/doxygen/bindings.txt b/doc/doxygen/bindings.txt index 3a2b31fd5..7228bff40 100644 --- a/doc/doxygen/bindings.txt +++ b/doc/doxygen/bindings.txt @@ -21,7 +21,7 @@ For example, %Cantera classes that represent phases of matter have a method call \verbatim ThermoPhase* gas = importPhase("gas.cti"); ... - int nsp = gas.nSpecies(); + int nsp = gas.nSpecies(); double x[nsp]; gas.getMoleFractions(x); \endverbatim @@ -66,13 +66,13 @@ namespace DropletNamespace { const double Tboil = 489.5; // const double molWt = 170.337; const double hfg = 2.56e5; // J/kg - const double rho_vapor = 0.4267; - const double rho_liquid = 749.0; + const double rho_vapor = 0.4267; + const double rho_liquid = 749.0; class Droplet { public: - Droplet(double D=-1.0, double T=300.0) : m_diam(D), + Droplet(double D=-1.0, double T=300.0) : m_diam(D), m_temp(T), m_yinf(0.0) {} virtual ~Droplet() {} @@ -94,11 +94,11 @@ namespace DropletNamespace { return 4.0*Pi*rho_vapor*Dab()*log(1.0+B()); } - double B() const { + double B() const { double ys = surfaceMassFraction(); return (ys - m_yinf)/(1.0 - ys); } - double surfaceMassFraction() const { + double surfaceMassFraction() const { double ps = Psat(); return ps*molWt/(ps*molWt + (OneAtm - ps)*28.014); } @@ -109,10 +109,10 @@ namespace DropletNamespace { double lifetime() const { return m_diam*m_diam/evapConstant();} protected: - + double Dab() { return Dab_0*pow(800.0/399.0, 1.5); } - double m_diam, m_temp, m_yinf; + double m_diam, m_temp, m_yinf; }; } diff --git a/doc/doxygen/cxx-headers.txt b/doc/doxygen/cxx-headers.txt index 8722db80e..47c3aa184 100644 --- a/doc/doxygen/cxx-headers.txt +++ b/doc/doxygen/cxx-headers.txt @@ -11,8 +11,8 @@ header files from the kernel needed to do equilibrium calculations These headers are designed for use in C++ application programs, and are not included by the Cantera kernel. The headers and their functions are: -These are: -- equilibrium.h +These are: +- equilibrium.h - Chemical equilibrium. - GRI30.h - Provides class GRI30. diff --git a/doc/doxygen/demo.cpp b/doc/doxygen/demo.cpp deleted file mode 100644 index 6fdb49b6f..000000000 --- a/doc/doxygen/demo.cpp +++ /dev/null @@ -1,100 +0,0 @@ - -#include -#include // defines class IdealGasMix -#include // chemical equilibrium -#include // transport properties - -void demoprog() -{ - - IdealGasMix gas("h2o2.cti","ohmech"); - double temp = 1200.0; - double pres = OneAtm; - gas.setState_TPX(temp, pres, "H2:1, O2:1, AR:2"); - - // 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", - gas.temperature(), gas.pressure(), gas.density(), - gas.enthalpy_mole(), gas.entropy_mole(), gas.cp_mole()); - - // set the gas to the equilibrium state with the same specific - // enthalpy and pressure - equilibrate(gas,"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", - gas.temperature(), gas.pressure(), gas.density(), - gas.enthalpy_mole(), gas.entropy_mole(), gas.cp_mole()); - - - // Reaction information - - int irxns = gas.nReactions(); - double* qf = new double[irxns]; - double* qr = new double[irxns]; - double* q = new double[irxns]; - - // since the gas has been set to an equilibrium state, the forward - // and reverse rates of progress should be equal for all - // reversible reactions, and the net rates should be zero. - gas.getFwdRatesOfProgress(qf); - gas.getRevRatesOfProgress(qr); - gas.getNetRatesOfProgress(q); - - printf("\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]); - } - - - // transport properties - - Transport* tr = newTransportMgr("Mix", &gas, 1); - - printf("\n\nViscosity: %14.5g Pa-s\n", tr->viscosity()); - printf("Thermal conductivity: %14.5g W/m/K\n", tr->thermalConductivity()); - - int nsp = gas.nSpecies(); - double* diff = new double[nsp]; - tr->getMixDiffCoeffs(diff); - int k; - printf("\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]); - } - - // clean up - delete qf; - delete qr; - delete q; - delete diff; - delete tr; -} - - - -int main() -{ - - try { - demoprog(); - } catch (CanteraError) { - showErrors(cout); - } -} - diff --git a/doc/doxygen/demo1.cpp b/doc/doxygen/demo1.cpp index 2d4a53e58..24e5f9b37 100644 --- a/doc/doxygen/demo1.cpp +++ b/doc/doxygen/demo1.cpp @@ -2,6 +2,8 @@ #include // chemical equilibrium #include // transport properties +using namespace Cantera; + void demoprog() { @@ -100,7 +102,7 @@ int main() try { demoprog(); } catch (CanteraError) { - showErrors(cout); + showErrors(std::cout); } } diff --git a/doc/doxygen/demo1a.cpp b/doc/doxygen/demo1a.cpp index 2830df2d1..a67ef08a9 100644 --- a/doc/doxygen/demo1a.cpp +++ b/doc/doxygen/demo1a.cpp @@ -1,5 +1,6 @@ #include +using namespace Cantera; // The actual code is put into a function that // can be called from the main program. @@ -16,7 +17,7 @@ void simple_demo() gas->setState_TPX(500.0, 2.0*OneAtm, "H2O:1.0, H2:8.0, AR:1.0"); // Print a summary report of the state of the gas - cout << report(*gas) << endl; + std::cout << report(*gas) << std::endl; // Clean up delete gas; diff --git a/doc/doxygen/demoequil.cpp b/doc/doxygen/demoequil.cpp index 5f6b6e6b8..a10a634ab 100644 --- a/doc/doxygen/demoequil.cpp +++ b/doc/doxygen/demoequil.cpp @@ -1,12 +1,14 @@ #include #include +using namespace Cantera; + void equil_demo() { ThermoPhase* gas = newPhase("h2o2.cti","ohmech"); gas->setState_TPX(1500.0, 2.0*OneAtm, "O2:1.0, H2:3.0, AR:1.0"); equilibrate(*gas, "TP"); - cout << report(*gas) << endl; + std::cout << report(*gas) << std::endl; } int main() diff --git a/doc/doxygen/edemo.cpp b/doc/doxygen/edemo.cpp index 1125d5e56..e52042b1f 100644 --- a/doc/doxygen/edemo.cpp +++ b/doc/doxygen/edemo.cpp @@ -5,12 +5,13 @@ void demoprog() // Calls Cantera } -int main() +int main(int argc, char** argv) { try { demoprog(); - } catch (CanteraError) { - showErrors(cout); + } catch (Cantera::CanteraError) { + Cantera::showErrors(std::cout); + return 1; } + return 0; } - diff --git a/doc/doxygen/ex1.cpp b/doc/doxygen/ex1.cpp index a671b549f..24d3a1feb 100644 --- a/doc/doxygen/ex1.cpp +++ b/doc/doxygen/ex1.cpp @@ -1,9 +1,9 @@ #include "cantera/thermo.h" #include -int main() +int main(int argc, char** argv) { - ThermoPhase* gas = newPhase("h2o2.cti","ohmech"); - cout << gas->temperature() << endl; + Cantera::ThermoPhase* gas = Cantera::newPhase("h2o2.cti","ohmech"); + std::cout << gas->temperature() << std::endl; return 0; } diff --git a/doc/doxygen/except.cpp b/doc/doxygen/except.cpp index 329c20d31..30036e4fd 100644 --- a/doc/doxygen/except.cpp +++ b/doc/doxygen/except.cpp @@ -2,6 +2,9 @@ // // artifical example of throwing and catching a CanteraError exception. // + +using namespace Cantera; + void mycode() { ThermoPhase* gas = newPhase("h2o2.cti","ohmech"); diff --git a/doc/doxygen/introcxx.txt b/doc/doxygen/introcxx.txt index ef393f32f..65be2d7ca 100644 --- a/doc/doxygen/introcxx.txt +++ b/doc/doxygen/introcxx.txt @@ -28,16 +28,16 @@ This program produces the output below: heat capacity c_p 3919.29 2.904e+04 J/K heat capacity c_v 2797.09 2.072e+04 J/K - X Y Chem. Pot. / RT + X Y Chem. Pot. / RT ------------- ------------ ------------ H2 0.8 0.217667 -15.6441 - H 0 0 - O 0 0 - O2 0 0 - OH 0 0 + H 0 0 + O 0 0 + O2 0 0 + OH 0 0 H2O 0.1 0.243153 -82.9531 - HO2 0 0 - H2O2 0 0 + HO2 0 0 + H2O2 0 0 AR 0.1 0.53918 -20.5027 \endverbatim diff --git a/doc/doxygen/thermodemo.cpp b/doc/doxygen/thermodemo.cpp index 5e3541dc0..5a6eefaf5 100644 --- a/doc/doxygen/thermodemo.cpp +++ b/doc/doxygen/thermodemo.cpp @@ -1,41 +1,42 @@ #include "cantera/thermo.h" +using namespace Cantera; -void thermo_demo(string file, string phase) +void thermo_demo(std::string file, std::string phase) { ThermoPhase* gas = newPhase(file, phase); gas->setState_TPX(1500.0, 2.0*OneAtm, "O2:1.0, H2:3.0, AR:1.0"); // temperature, pressure, and density - cout << gas->temperature() << endl; - cout << gas->pressure() << endl; - cout << gas->density() << endl; + std::cout << gas->temperature() << std::endl; + std::cout << gas->pressure() << std::endl; + std::cout << gas->density() << std::endl; // molar thermodynamic properties - cout << gas->enthalpy_mole() << endl; - cout << gas->entropy_mole() << endl; + std::cout << gas->enthalpy_mole() << std::endl; + std::cout << gas->entropy_mole() << std::endl; // specific (per unit mass) thermodynamic properties - cout << gas->enthalpy_mass() << endl; - cout << gas->entropy_mass() << endl; + std::cout << gas->enthalpy_mass() << std::endl; + std::cout << gas->entropy_mass() << std::endl; // chemical potentials of the species int numSpecies = gas->nSpecies(); vector_fp mu(numSpecies); - gas->getChemPotentials(mu.begin()); + gas->getChemPotentials(&mu[0]); int n; for (n = 0; n < numSpecies; n++) { - cout << gas->speciesName(n) << " " << mu[n] << endl; + std::cout << gas->speciesName(n) << " " << mu[n] << std::endl; } } -int main() +int main(int argc, char** argv) { - try { thermo_demo("h2o2.cti","ohmech"); } catch (CanteraError) { showErrors(); + return 1; } + return 0; } - diff --git a/samples/cxx/NASA_coeffs/NASA_coeffs.cpp b/samples/cxx/NASA_coeffs/NASA_coeffs.cpp index c1f2295f6..6440c6329 100644 --- a/samples/cxx/NASA_coeffs/NASA_coeffs.cpp +++ b/samples/cxx/NASA_coeffs/NASA_coeffs.cpp @@ -10,8 +10,6 @@ using namespace std; using namespace Cantera; -using namespace Cantera_CXX; - // The program is put into a function so that error handling code can // be conveniently put around the whole thing. See main() below. diff --git a/samples/cxx/bvp/BoundaryValueProblem.h b/samples/cxx/bvp/BoundaryValueProblem.h index 415829f16..c06189ffb 100644 --- a/samples/cxx/bvp/BoundaryValueProblem.h +++ b/samples/cxx/bvp/BoundaryValueProblem.h @@ -1,6 +1,7 @@ /// @file BoundaryValueProblem.h /// Simplified interface to the capabilities provided by Cantera to /// solve boundary value problems. +/// @todo This example cannot currently be compiled #ifndef BVP_H #define BVP_H diff --git a/samples/cxx/combustor/combustor.cpp b/samples/cxx/combustor/combustor.cpp index 5ca6502ee..5aa62897f 100644 --- a/samples/cxx/combustor/combustor.cpp +++ b/samples/cxx/combustor/combustor.cpp @@ -105,7 +105,7 @@ void runexample() double tres; int k; - ofstream f("combustor_cxx.csv"); + std::ofstream f("combustor_cxx.csv"); while (tnow < tfinal) { tnow = sim.step(tfinal); @@ -117,7 +117,7 @@ void runexample() for (k = 0; k < nsp; k++) { f << c.moleFraction(k) << ", "; } - f << endl; + f << std::endl; } f.close(); } @@ -131,8 +131,8 @@ int main() } // handle exceptions thrown by Cantera catch (CanteraError) { - showErrors(cout); - cout << " terminating... " << endl; + showErrors(std::cout); + std::cout << " terminating... " << std::endl; appdelete(); return 1; } diff --git a/samples/cxx/demo.cpp b/samples/cxx/demo.cpp index a46615ec4..eb79e7af6 100644 --- a/samples/cxx/demo.cpp +++ b/samples/cxx/demo.cpp @@ -120,7 +120,7 @@ int main() try { demoprog(); } catch (CanteraError) { - showErrors(cout); + showErrors(std::cout); } } diff --git a/samples/cxx/flamespeed/flamespeed.cpp b/samples/cxx/flamespeed/flamespeed.cpp index c80a84dde..4404d5ca2 100644 --- a/samples/cxx/flamespeed/flamespeed.cpp +++ b/samples/cxx/flamespeed/flamespeed.cpp @@ -1,9 +1,20 @@ -#include +/*! + * @file flamespeed.cpp + * C++ demo program to compute flame speeds using GRI-Mech. + * + * @todo This demo compiles but does not run correctly. + */ + +#include "cantera/oneD/Sim1D.h" +#include "cantera/oneD/Inlet1D.h" +#include "cantera/oneD/StFlow.h" #include #include #include using namespace Cantera; +using std::cout; +using std::endl; int flamespeed(int np, void* p) { @@ -27,7 +38,7 @@ int flamespeed(int np, void* p) } if (phi == 0.0) { cout << "Enter phi: "; - cin >> phi; + std::cin >> phi; } doublereal C_atoms=1.0; @@ -116,7 +127,7 @@ int flamespeed(int np, void* p) //=================== create the container and insert the domains ===== - vector domains; + std::vector domains; domains.push_back(&inlet); domains.push_back(&flow); domains.push_back(&outlet); @@ -216,7 +227,7 @@ int flamespeed(int np, void* p) flame.value(flowdomain,flow.componentIndex("u"),0) << " m/s" << endl; int np=flow.nPoints(); - vector zvec,Tvec,COvec,CO2vec,Uvec; + std::vector zvec,Tvec,COvec,CO2vec,Uvec; printf("\n%9s\t%8s\t%5s\t%7s\n","z (m)", "T (K)", "U (m/s)", "Y(CO)"); for (int n=0; n #include "example_utils.h" +using namespace Cantera; +using std::cout; +using std::endl; int kinetics1(int np, void* p) { @@ -85,7 +88,7 @@ int kinetics1(int np, void* p) // make a Tecplot data file and an Excel spreadsheet - string plotTitle = "kinetics example 1: constant-pressure ignition"; + std::string plotTitle = "kinetics example 1: constant-pressure ignition"; plotSoln("kin1.dat", "TEC", plotTitle, gas, soln); plotSoln("kin1.csv", "XL", plotTitle, gas, soln);