25 #ifndef GRINS_KINETICS_TEST_BASE_H
26 #define GRINS_KINETICS_TEST_BASE_H
28 #include "grins_config.h"
30 #ifdef GRINS_HAVE_CPPUNIT
32 #include <cppunit/extensions/HelperMacros.h>
38 #include "libmesh/libmesh_common.h"
46 template<
typename ThermoMixture,
typename ThermoEvaluator>
48 const std::vector<libMesh::Real>& Y, libMesh::Real rel_tol )
52 ThermoEvaluator evaluator( mixture );
54 libMesh::Real rho = 1.0e-3;
58 molar_densities[s] = rho*Y[s]/this->
molar_mass(s);
60 libMesh::Real T = 300;
63 std::vector<libMesh::Real> forward_rates, backward_rates;
66 std::vector<libMesh::Real> omega_dot_exact(
_active_species.size(), 0.0);
69 evaluator.omega_dot( T, rho, Y, omega_dot_computed );
77 omega_dot_exact[s] += this->
molar_mass(species)*stoich*( forward_rates[r] - backward_rates[r] );
86 std::string message =
"T = "+ss.str();
88 ss.str(std::string());
90 message +=
", species = "+mixture.species_name(species);
100 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( message,
102 omega_dot_computed[s],
127 const std::vector<libMesh::Real>& molar_densities,
129 std::vector<libMesh::Real>& forward_rates,
130 std::vector<libMesh::Real>& backward_rates )
132 forward_rates.resize(_n_reactions,1.0);
133 backward_rates.resize(_n_reactions,1.0);
143 _reactant_stoich_coeffs[r],
144 _product_stoich_coeffs[r],
147 libMesh::Real bkwd_rate_coeff = fwd_rate_coeff/Keq;
149 forward_rates[r] *= fwd_rate_coeff;
150 backward_rates[r] *= bkwd_rate_coeff;
154 forward_rates[r] *= std::pow(molar_densities[s],_reactant_stoich_coeffs[r][s]);
156 backward_rates[r] *= std::pow(molar_densities[s],_product_stoich_coeffs[r][s]);
159 if( _is_three_body_rxn[r] )
162 _three_body_coeffs[r] );
163 forward_rates[r] *= M;
164 backward_rates[r] *= M;
170 std::vector<libMesh::Real>& reactant_stoich_coeffs,
171 std::vector<libMesh::Real>& product_stoich_coeffs,
174 CPPUNIT_ASSERT_EQUAL( reactant_stoich_coeffs.size(), product_stoich_coeffs.size() );
176 libMesh::Real coeff_sum = 0.0;
177 libMesh::Real exp_sum = 0.0;
179 for(
unsigned int s = 0; s < reactant_stoich_coeffs.size(); s++ )
181 libMesh::Real stoich = (product_stoich_coeffs[s] - reactant_stoich_coeffs[s]);
189 return std::pow(P_RT,coeff_sum)*std::exp(-exp_sum);
196 #endif // GRINS_HAVE_CPPUNIT
198 #endif // GRINS_KINETICS_TEST_BASE_H
libMesh::Real eq_constant(libMesh::Real T, std::vector< libMesh::Real > &reactant_stoich_coeffs, std::vector< libMesh::Real > &product_stoich_coeffs, NASAThermoTestBase &thermo_funcs)
virtual libMesh::Real s_R_exact(unsigned int species_idx, libMesh::Real T)=0
std::vector< std::vector< libMesh::Real > > _product_stoich_coeffs
const libMesh::Real R_universal
Universal Gas Constant, R, [J/(kmol-K)].
std::vector< libMesh::Real > _temp_exp_coeffs
libMesh::Real molar_mass(unsigned int idx)
static libMesh::Real compute_third_body_molar_density(const std::vector< libMesh::Real > &molar_densities, const std::vector< libMesh::Real > &three_body_efficiencies)
void test_omega_dot_common(ThermoMixture &mixture, NASAThermoTestBase &thermo_funcs, const std::vector< libMesh::Real > &Y, libMesh::Real rel_tol)
static libMesh::Real arrhenius_rate(libMesh::Real A, libMesh::Real b, libMesh::Real Ea, libMesh::Real T)
std::vector< libMesh::Real > _preexp_coeffs
std::vector< std::vector< libMesh::Real > > _three_body_coeffs
static libMesh::Real abs_tol_from_rel_tol(libMesh::Real exact, libMesh::Real rel_tol)
Get absolute tolerance from input relative tol.
std::vector< std::vector< libMesh::Real > > _reactant_stoich_coeffs
virtual libMesh::Real h_RT_exact(unsigned int species_idx, libMesh::Real T)=0
std::vector< unsigned int > _active_species
std::vector< bool > _is_three_body_rxn
void compute_reaction_rates(libMesh::Real T, const std::vector< libMesh::Real > &molar_densities, NASAThermoTestBase &thermo_funcs, std::vector< libMesh::Real > &forward_rates, std::vector< libMesh::Real > &backward_rates)
std::vector< libMesh::Real > _Ea_coeffs
unsigned int _n_reactions