35 #include "libmesh/getpot.h"
37 #ifdef GRINS_HAVE_CANTERA
38 int main(
int argc,
char* argv[] )
44 std::cerr <<
"Error: Must specify input file." << std::endl;
48 GetPot input( argv[1] );
54 std::vector<double> mass_fractions( 5, 0.2 );
56 const double M_N2 = 14.00674*2;
57 const double M_O2 = 15.9994*2;
58 const double M_N = 14.00674;
59 const double M_O = 15.9994;
60 const double M_NO = (14.00674+15.9994);
62 double R_exact = Cantera::GasConstant*( mass_fractions[0]/M_N2
63 + mass_fractions[1]/M_O2
64 + mass_fractions[3]/M_N
65 + mass_fractions[4]/M_O
66 + mass_fractions[2]/M_NO );
68 double M_exact = 1.0/( mass_fractions[0]/M_N2
69 + mass_fractions[1]/M_O2
70 + mass_fractions[3]/M_N
71 + mass_fractions[4]/M_O
72 + mass_fractions[2]/M_NO );
74 std::vector<double> X_exact(5, 0.0);
75 X_exact[0] = mass_fractions[0]*M_exact/M_N2;
76 X_exact[1] = mass_fractions[1]*M_exact/M_O2;
77 X_exact[3] = mass_fractions[3]*M_exact/M_N;
78 X_exact[4] = mass_fractions[4]*M_exact/M_O;
79 X_exact[2] = mass_fractions[2]*M_exact/M_NO;
83 const double tol = std::numeric_limits<double>::epsilon()*10;
85 if( std::fabs( (cantera.
R_mix(mass_fractions) - R_exact)/R_exact) > tol )
87 std::cerr <<
"Error: Mismatch in mixture gas constant." << std::endl
88 << std::setprecision(16) << std::scientific
89 <<
"R = " << cantera.
R_mix(mass_fractions) << std::endl
90 <<
"R_exact = " << R_exact << std::endl;
94 if( std::fabs( (cantera.
M_mix(mass_fractions) - M_exact)/M_exact ) > tol )
96 std::cerr <<
"Error: Mismatch in mixture molar mass." << std::endl
97 << std::setprecision(16) << std::scientific
98 <<
"M = " << cantera.
M_mix(mass_fractions) << std::endl
99 <<
"M_exact = " << M_exact << std::endl;
103 std::vector<double> X(5);
104 cantera.
X( cantera.
M_mix(mass_fractions), mass_fractions, X );
105 for(
unsigned int s = 0; s < 5; s++ )
107 if( std::fabs( (X[s] - X_exact[s])/X_exact[s]) > tol )
109 std::cerr <<
"Error: Mismatch in mole fraction for species " << s << std::endl
110 << std::setprecision(16) << std::scientific
111 <<
"X = " << X[s] << std::endl
112 <<
"X_exact = " << X_exact[s] << std::endl;
119 #else //GRINS_HAVE_CANTERA
libMesh::Real X(unsigned int species, libMesh::Real M, libMesh::Real mass_fraction) const
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...
int main(int argc, char *argv[])