cantera/test_problems/NASA9poly_test/NASA9poly_test.cpp
Ray Speth 54efbaa320 Rewrote exception handling to be more general and more explicit
CanteraError inerits from std:exception, so now it has a what() method
that is used to print a message describing the exception. Adding an
exception to the Cantera error stack now requires explicitly calling
the .save() method.
2012-03-05 20:45:56 +00:00

96 lines
2.6 KiB
C++

/**
* @file NASA9poly_test
* test problem for NASA 9 coefficient formulation
*/
#include <iostream>
#include <string>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
/*****************************************************************/
/*****************************************************************/
#include "cantera/transport.h"
#include "cantera/IdealGasMix.h"
#include "cantera/transport/TransportFactory.h"
using namespace Cantera;
void printDbl(double val)
{
if (fabs(val) < 5.0E-17) {
cout << " nil";
} else {
cout << val;
}
}
int main(int argc, char** argv)
{
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
try {
//throw ArraySizeError("MadeUpFunction", 12, 22);
IdealGasMix g("gasNASA9.xml", "gri30_mix");
int nsp = g.nSpecies();
double pres = 1.0E5;
vector_fp Xset(nsp, 0.0);
Xset[0] = 0.5 ;
Xset[1] = 0.5;
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
vector_fp cp_R(nsp, 0.0);
g.getCp_R(DATA_PTR(cp_R));
vector_fp Gvalues(nsp, 0.0);
printf("Comparisons of H2 calculated via several equivalent classes:\n");
printf("1500 K and 1 atm:\n");
printf(" NasaThermo Nasa9 Nasa9_4reg \n");
printf(" cp/R: %11.6g %11.6g %11.6g\n", cp_R[0], cp_R[1], cp_R[2]);
vector_fp H_RT(nsp, 0.0);
g.getEnthalpy_RT(DATA_PTR(H_RT));
printf(" H/RT: %11.6g %11.6g %11.6g\n", H_RT[0], H_RT[1], H_RT[2]);
vector_fp S_R(nsp, 0.0);
g.getEntropy_R(DATA_PTR(S_R));
printf(" S/R: %11.6g %11.6g %11.6g\n", S_R[0], S_R[1], S_R[2]);
Transport* tran = newTransportMgr("Mix", &g);
// MultiTransport * tranMix = dynamic_cast<MultiTransport *>(tran);
printf("Viscoscity and thermal Cond vs. T\n");
for (int k = 0; k < 40; k++) {
double T1 = 400. + 200. * k;
g.setState_TPX(T1, pres, DATA_PTR(Xset));
g.getPureGibbs(DATA_PTR(Gvalues));
//printf(" -- %13g %13.5g %13.5g %13.5g %13.5g \n",
// Gvalues[0], Gvalues[1], Gvalues[2],
// Gvalues[3], Gvalues[4]);
double visc = tran->viscosity();
double cond = tran->thermalConductivity();
printf(" %13g %13.5g %13.5g\n", T1, visc, cond);
}
} catch (CanteraError& err) {
err.save();
// cout << err.what() << endl;
showErrors(cout);
return 1;
}
return 0;
}
/***********************************************************/