37 #include "libmesh/getpot.h"
39 #ifdef GRINS_HAVE_CANTERA
40 int main(
int argc,
char* argv[] )
46 std::cerr <<
"Error: Must specify input file." << std::endl;
50 GetPot input( argv[1] );
56 std::vector<double> mass_fractions( 5, 0.2 );
58 const double M_N2 = 14.00674*2;
59 const double M_O2 = 15.9994*2;
60 const double M_N = 14.00674;
61 const double M_O = 15.9994;
62 const double M_NO = (14.00674+15.9994);
64 double R_exact = Cantera::GasConstant*( mass_fractions[0]/M_N2
65 + mass_fractions[1]/M_O2
66 + mass_fractions[3]/M_N
67 + mass_fractions[4]/M_O
68 + mass_fractions[2]/M_NO );
70 double M_exact = 1.0/( mass_fractions[0]/M_N2
71 + mass_fractions[1]/M_O2
72 + mass_fractions[3]/M_N
73 + mass_fractions[4]/M_O
74 + mass_fractions[2]/M_NO );
76 std::vector<double> X_exact(5, 0.0);
77 X_exact[0] = mass_fractions[0]*M_exact/M_N2;
78 X_exact[1] = mass_fractions[1]*M_exact/M_O2;
79 X_exact[3] = mass_fractions[3]*M_exact/M_N;
80 X_exact[4] = mass_fractions[4]*M_exact/M_O;
81 X_exact[2] = mass_fractions[2]*M_exact/M_NO;
85 const double tol = std::numeric_limits<double>::epsilon()*10;
87 if( std::fabs( (cantera.
R_mix(mass_fractions) - R_exact)/R_exact) > tol )
89 std::cerr <<
"Error: Mismatch in mixture gas constant." << std::endl
90 << std::setprecision(16) << std::scientific
91 <<
"R = " << cantera.
R_mix(mass_fractions) << std::endl
92 <<
"R_exact = " << R_exact << std::endl;
96 if( std::fabs( (cantera.
M_mix(mass_fractions) - M_exact)/M_exact ) > tol )
98 std::cerr <<
"Error: Mismatch in mixture molar mass." << std::endl
99 << std::setprecision(16) << std::scientific
100 <<
"M = " << cantera.
M_mix(mass_fractions) << std::endl
101 <<
"M_exact = " << M_exact << std::endl;
105 std::vector<double> X(5);
106 cantera.
X( cantera.
M_mix(mass_fractions), mass_fractions, X );
107 for(
unsigned int s = 0; s < 5; s++ )
109 if( std::fabs( (X[s] - X_exact[s])/X_exact[s]) > tol )
111 std::cerr <<
"Error: Mismatch in mole fraction for species " << s << std::endl
112 << std::setprecision(16) << std::scientific
113 <<
"X = " << X[s] << std::endl
114 <<
"X_exact = " << X_exact[s] << std::endl;
121 #else //GRINS_HAVE_CANTERA
libMesh::Real X(unsigned int species, libMesh::Real M, libMesh::Real mass_fraction) const
int main(int argc, char *argv[])
libMesh::Real M_mix(const std::vector< libMesh::Real > &mass_fractions) const
libMesh::Real R_mix(const std::vector< libMesh::Real > &mass_fractions) const
Wrapper class for storing state for computing thermochemistry and transport properties using Cantera...