int main( int argc, char* argv[] ) { #ifdef GRINS_HAVE_ANTIOCH // Check command line count. if( argc < 2 ) { // TODO: Need more consistent error handling. std::cerr << "Error: Must specify input file." << std::endl; exit(1); } GetPot input( argv[1] ); GRINS::AntiochMixture antioch(input); std::vector<double> mass_fractions( 5, 0.2 ); const double M_N2 = 14.00800*2; const double M_O2 = 16.0000*2; const double M_N = 14.00800; const double M_O = 16.0000; const double M_NO = 30.00800; double R_exact = Antioch::Constants::R_universal<double>()*( mass_fractions[0]/M_N2 + mass_fractions[1]/M_O2 + mass_fractions[3]/M_N + mass_fractions[4]/M_O + mass_fractions[2]/M_NO ); double M_exact = 1.0/( mass_fractions[0]/M_N2 + mass_fractions[1]/M_O2 + mass_fractions[3]/M_N + mass_fractions[4]/M_O + mass_fractions[2]/M_NO ); std::vector<double> X_exact(5, 0.0); X_exact[0] = mass_fractions[0]*M_exact/M_N2; X_exact[1] = mass_fractions[1]*M_exact/M_O2; X_exact[3] = mass_fractions[3]*M_exact/M_N; X_exact[4] = mass_fractions[4]*M_exact/M_O; X_exact[2] = mass_fractions[2]*M_exact/M_NO; int return_flag = 0; const double tol = std::numeric_limits<double>::epsilon()*10; if( std::fabs( (antioch.R_mix(mass_fractions) - R_exact)/R_exact) > tol ) { std::cerr << "Error: Mismatch in mixture gas constant." << std::endl << std::setprecision(16) << std::scientific << "R = " << antioch.R_mix(mass_fractions) << std::endl << "R_exact = " << R_exact << std::endl; return_flag = 1; } if( std::fabs( (antioch.M_mix(mass_fractions) - M_exact)/M_exact ) > tol ) { std::cerr << "Error: Mismatch in mixture molar mass." << std::endl << std::setprecision(16) << std::scientific << "M = " << antioch.M_mix(mass_fractions) << std::endl << "M_exact = " << M_exact << std::endl; return_flag = 1; } std::vector<double> X(5); antioch.X( antioch.M_mix(mass_fractions), mass_fractions, X ); for( unsigned int s = 0; s < 5; s++ ) { if( std::fabs( (X[s] - X_exact[s])/X_exact[s]) > tol ) { std::cerr << "Error: Mismatch in mole fraction for species " << s << std::endl << std::setprecision(16) << std::scientific << "X = " << X[s] << std::endl << "X_exact = " << X_exact[s] << std::endl; return_flag = 1; } } #else //GRINS_HAVE_ANTIOCH // automake expects 77 for a skipped test int return_flag = 77; #endif return return_flag; }
bool GasRecombinationCatalyticWall<Chemistry>::eval_flux( bool compute_jacobian, AssemblyContext& context, libMesh::Real sign, bool is_axisymmetric ) { libMesh::FEGenericBase<libMesh::Real>* side_fe = NULL; context.get_side_fe( _reactant_var_idx, side_fe ); // The number of local degrees of freedom in each variable. const unsigned int n_var_dofs = context.get_dof_indices(_reactant_var_idx).size(); libmesh_assert_equal_to( n_var_dofs, context.get_dof_indices(_product_var_idx).size() ); // Element Jacobian * quadrature weight for side integration. const std::vector<libMesh::Real> &JxW_side = side_fe->get_JxW(); // The var shape functions at side quadrature points. const std::vector<std::vector<libMesh::Real> >& var_phi_side = side_fe->get_phi(); // Physical location of the quadrature points const std::vector<libMesh::Point>& var_qpoint = side_fe->get_xyz(); // reactant residual libMesh::DenseSubVector<libMesh::Number> &F_r_var = context.get_elem_residual(_reactant_var_idx); // product residual libMesh::DenseSubVector<libMesh::Number> &F_p_var = context.get_elem_residual(_product_var_idx); unsigned int n_qpoints = context.get_side_qrule().n_points(); for (unsigned int qp=0; qp != n_qpoints; qp++) { libMesh::Real jac = JxW_side[qp]; if(is_axisymmetric) { const libMesh::Number r = var_qpoint[qp](0); jac *= r; } std::vector<libMesh::Real> mass_fractions(this->_chem_ptr->n_species()); for( unsigned int s = 0; s < this->_chem_ptr->n_species(); s++ ) mass_fractions[s] = context.side_value(this->_species_vars[s], qp); libMesh::Real Y_r = mass_fractions[this->_reactant_species_idx]; libMesh::Real T = context.side_value(this->_T_var, qp); libMesh::Real R_mix = this->_chem_ptr->R_mix(mass_fractions); libMesh::Real rho = this->rho( T, this->_p0, R_mix ); const libMesh::Real r_value = this->compute_reactant_mass_flux(rho, Y_r, T); const libMesh::Real p_value = -r_value; for (unsigned int i=0; i != n_var_dofs; i++) { F_r_var(i) += sign*r_value*var_phi_side[i][qp]*jac; F_p_var(i) += sign*p_value*var_phi_side[i][qp]*jac; if( compute_jacobian ) libmesh_not_implemented(); } } // We're not computing the Jacobian yet return false; }
int main( int argc, char* argv[] ) { // Check command line count. if( argc < 2 ) { // TODO: Need more consistent error handling. std::cerr << "Error: Must specify input file." << std::endl; exit(1); } GetPot input( argv[1] ); GRINS::CanteraMixture cantera(input,"TestMaterial"); std::vector<double> mass_fractions( 5, 0.2 ); const double M_N2 = 14.00674*2; const double M_O2 = 15.9994*2; const double M_N = 14.00674; const double M_O = 15.9994; const double M_NO = (14.00674+15.9994); double R_exact = Cantera::GasConstant*( mass_fractions[0]/M_N2 + mass_fractions[1]/M_O2 + mass_fractions[3]/M_N + mass_fractions[4]/M_O + mass_fractions[2]/M_NO ); double M_exact = 1.0/( mass_fractions[0]/M_N2 + mass_fractions[1]/M_O2 + mass_fractions[3]/M_N + mass_fractions[4]/M_O + mass_fractions[2]/M_NO ); std::vector<double> X_exact(5, 0.0); X_exact[0] = mass_fractions[0]*M_exact/M_N2; X_exact[1] = mass_fractions[1]*M_exact/M_O2; X_exact[3] = mass_fractions[3]*M_exact/M_N; X_exact[4] = mass_fractions[4]*M_exact/M_O; X_exact[2] = mass_fractions[2]*M_exact/M_NO; int return_flag = 0; const double tol = std::numeric_limits<double>::epsilon()*10; if( std::fabs( (cantera.R_mix(mass_fractions) - R_exact)/R_exact) > tol ) { std::cerr << "Error: Mismatch in mixture gas constant." << std::endl << std::setprecision(16) << std::scientific << "R = " << cantera.R_mix(mass_fractions) << std::endl << "R_exact = " << R_exact << std::endl; return_flag = 1; } if( std::fabs( (cantera.M_mix(mass_fractions) - M_exact)/M_exact ) > tol ) { std::cerr << "Error: Mismatch in mixture molar mass." << std::endl << std::setprecision(16) << std::scientific << "M = " << cantera.M_mix(mass_fractions) << std::endl << "M_exact = " << M_exact << std::endl; return_flag = 1; } std::vector<double> X(5); cantera.X( cantera.M_mix(mass_fractions), mass_fractions, X ); for( unsigned int s = 0; s < 5; s++ ) { if( std::fabs( (X[s] - X_exact[s])/X_exact[s]) > tol ) { std::cerr << "Error: Mismatch in mole fraction for species " << s << std::endl << std::setprecision(16) << std::scientific << "X = " << X[s] << std::endl << "X_exact = " << X_exact[s] << std::endl; return_flag = 1; } } return return_flag; }