GRINS-0.8.0
List of all members | Public Member Functions | Protected Attributes | Private Member Functions
GRINSTesting::KineticsTestBase Class Reference

#include <kinetics_test_base.h>

Inheritance diagram for GRINSTesting::KineticsTestBase:
Inheritance graph
[legend]
Collaboration diagram for GRINSTesting::KineticsTestBase:
Collaboration graph
[legend]

Public Member Functions

template<typename ThermoMixture , typename ThermoEvaluator >
void test_omega_dot_common (ThermoMixture &mixture, NASAThermoTestBase &thermo_funcs, const std::vector< libMesh::Real > &Y, libMesh::Real rel_tol)
 
- Public Member Functions inherited from GRINSTesting::SpeciesTestBase
 SpeciesTestBase ()
 
libMesh::Real molar_mass (unsigned int idx)
 
libMesh::Real R_species (unsigned int idx)
 

Protected Attributes

unsigned int _n_reactions
 
std::vector< libMesh::Real > _Ea_coeffs
 
std::vector< libMesh::Real > _preexp_coeffs
 
std::vector< libMesh::Real > _temp_exp_coeffs
 
std::vector< std::vector< libMesh::Real > > _three_body_coeffs
 
std::vector< bool > _is_three_body_rxn
 
std::vector< std::vector< libMesh::Real > > _reactant_stoich_coeffs
 
std::vector< std::vector< libMesh::Real > > _product_stoich_coeffs
 
- Protected Attributes inherited from GRINSTesting::SpeciesTestBase
unsigned int _N2_idx
 
unsigned int _O2_idx
 
unsigned int _O_idx
 
unsigned int _N_idx
 
unsigned int _NO_idx
 
std::vector< unsigned int > _active_species
 

Private Member Functions

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)
 
libMesh::Real eq_constant (libMesh::Real T, std::vector< libMesh::Real > &reactant_stoich_coeffs, std::vector< libMesh::Real > &product_stoich_coeffs, NASAThermoTestBase &thermo_funcs)
 

Detailed Description

Definition at line 42 of file kinetics_test_base.h.

Member Function Documentation

void GRINSTesting::KineticsTestBase::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 
)
inlineprivate

Definition at line 126 of file kinetics_test_base.h.

References GRINSTesting::SpeciesTestBase::_active_species, _n_reactions, GRINSTesting::ThermochemTestCommon::arrhenius_rate(), GRINSTesting::ThermochemTestCommon::compute_third_body_molar_density(), and eq_constant().

Referenced by test_omega_dot_common().

131  {
132  forward_rates.resize(_n_reactions,1.0);
133  backward_rates.resize(_n_reactions,1.0);
134 
135  for( unsigned int r = 0; r < _n_reactions; r++ )
136  {
137  libMesh::Real fwd_rate_coeff = ThermochemTestCommon::arrhenius_rate( _preexp_coeffs[r],
138  _temp_exp_coeffs[r],
139  _Ea_coeffs[r],
140  T );
141 
142  libMesh::Real Keq = this->eq_constant(T,
145  thermo_funcs);
146 
147  libMesh::Real bkwd_rate_coeff = fwd_rate_coeff/Keq;
148 
149  forward_rates[r] *= fwd_rate_coeff;
150  backward_rates[r] *= bkwd_rate_coeff;
151 
152  for( unsigned int s = 0; s < _active_species.size(); s++ )
153  {
154  forward_rates[r] *= std::pow(molar_densities[s],_reactant_stoich_coeffs[r][s]);
155 
156  backward_rates[r] *= std::pow(molar_densities[s],_product_stoich_coeffs[r][s]);
157  }
158 
159  if( _is_three_body_rxn[r] )
160  {
161  libMesh::Real M = ThermochemTestCommon::compute_third_body_molar_density( molar_densities,
162  _three_body_coeffs[r] );
163  forward_rates[r] *= M;
164  backward_rates[r] *= M;
165  }
166  }
167  }
libMesh::Real eq_constant(libMesh::Real T, std::vector< libMesh::Real > &reactant_stoich_coeffs, std::vector< libMesh::Real > &product_stoich_coeffs, NASAThermoTestBase &thermo_funcs)
std::vector< std::vector< libMesh::Real > > _product_stoich_coeffs
std::vector< libMesh::Real > _temp_exp_coeffs
static libMesh::Real compute_third_body_molar_density(const std::vector< libMesh::Real > &molar_densities, const std::vector< libMesh::Real > &three_body_efficiencies)
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
std::vector< std::vector< libMesh::Real > > _reactant_stoich_coeffs
std::vector< unsigned int > _active_species
std::vector< bool > _is_three_body_rxn
std::vector< libMesh::Real > _Ea_coeffs
libMesh::Real GRINSTesting::KineticsTestBase::eq_constant ( libMesh::Real  T,
std::vector< libMesh::Real > &  reactant_stoich_coeffs,
std::vector< libMesh::Real > &  product_stoich_coeffs,
NASAThermoTestBase thermo_funcs 
)
inlineprivate

Definition at line 169 of file kinetics_test_base.h.

References GRINSTesting::NASAThermoTestBase::h_RT_exact(), GRINS::Constants::R_universal, and GRINSTesting::NASAThermoTestBase::s_R_exact().

Referenced by compute_reaction_rates().

173  {
174  CPPUNIT_ASSERT_EQUAL( reactant_stoich_coeffs.size(), product_stoich_coeffs.size() );
175 
176  libMesh::Real coeff_sum = 0.0;
177  libMesh::Real exp_sum = 0.0;
178 
179  for( unsigned int s = 0; s < reactant_stoich_coeffs.size(); s++ )
180  {
181  libMesh::Real stoich = (product_stoich_coeffs[s] - reactant_stoich_coeffs[s]);
182 
183  coeff_sum += stoich;
184  exp_sum += stoich*( thermo_funcs.h_RT_exact(s,T) - thermo_funcs.s_R_exact(s,T) );
185  }
186 
187  libMesh::Real P_RT = 1e5/(GRINS::Constants::R_universal*T);
188 
189  return std::pow(P_RT,coeff_sum)*std::exp(-exp_sum);
190  }
const libMesh::Real R_universal
Universal Gas Constant, R, [J/(kmol-K)].
template<typename ThermoMixture , typename ThermoEvaluator >
void GRINSTesting::KineticsTestBase::test_omega_dot_common ( ThermoMixture &  mixture,
NASAThermoTestBase thermo_funcs,
const std::vector< libMesh::Real > &  Y,
libMesh::Real  rel_tol 
)
inline

Definition at line 47 of file kinetics_test_base.h.

References GRINSTesting::SpeciesTestBase::_active_species, _n_reactions, _product_stoich_coeffs, _reactant_stoich_coeffs, GRINSTesting::TestingUtils::abs_tol_from_rel_tol(), compute_reaction_rates(), and GRINSTesting::SpeciesTestBase::molar_mass().

49  {
50  CPPUNIT_ASSERT_EQUAL(_active_species.size(), Y.size() );
51 
52  ThermoEvaluator evaluator( mixture );
53 
54  libMesh::Real rho = 1.0e-3;
55 
56  std::vector<libMesh::Real> molar_densities(_active_species.size(),0.0);
57  for( unsigned int s = 0; s < _active_species.size(); s++ )
58  molar_densities[s] = rho*Y[s]/this->molar_mass(s);
59 
60  libMesh::Real T = 300;
61  while( T <= 1000 )
62  {
63  std::vector<libMesh::Real> forward_rates, backward_rates;
64  this->compute_reaction_rates( T, molar_densities, thermo_funcs, forward_rates, backward_rates );
65 
66  std::vector<libMesh::Real> omega_dot_exact(_active_species.size(), 0.0);
67  std::vector<libMesh::Real> omega_dot_computed(_active_species.size());
68 
69  evaluator.omega_dot( T, rho, Y, omega_dot_computed );
70 
71  for( unsigned int s = 0; s < _active_species.size(); s++ )
72  for( unsigned int r = 0; r < _n_reactions; r++ )
73  {
74  unsigned int species = _active_species[s];
75  libMesh::Real stoich = _product_stoich_coeffs[r][species] - _reactant_stoich_coeffs[r][species];
76 
77  omega_dot_exact[s] += this->molar_mass(species)*stoich*( forward_rates[r] - backward_rates[r] );
78  }
79 
80  for( unsigned int s = 0; s < _active_species.size(); s++ )
81  {
82  unsigned int species = _active_species[s];
83 
84  std::stringstream ss;
85  ss << T;
86  std::string message = "T = "+ss.str();
87 
88  ss.str(std::string());
89  ss << s;
90  message += ", species = "+mixture.species_name(species);
91 
92  /*
93  std::cout << message
94  << ", omega_dot_exact = " << omega_dot_exact[s]
95  << ", omega_dot_computed = " << omega_dot_computed[s]
96  << std::endl;
97  */
98 
99  libMesh::Real tol = TestingUtils::abs_tol_from_rel_tol( omega_dot_exact[s], rel_tol );
100  CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( message,
101  omega_dot_exact[s],
102  omega_dot_computed[s],
103  tol );
104  }
105 
106  T += 100.0;
107  }
108  }
std::vector< std::vector< libMesh::Real > > _product_stoich_coeffs
libMesh::Real molar_mass(unsigned int idx)
static libMesh::Real abs_tol_from_rel_tol(libMesh::Real exact, libMesh::Real rel_tol)
Get absolute tolerance from input relative tol.
Definition: testing_utils.h:44
std::vector< std::vector< libMesh::Real > > _reactant_stoich_coeffs
std::vector< unsigned int > _active_species
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)

Member Data Documentation

std::vector<libMesh::Real> GRINSTesting::KineticsTestBase::_Ea_coeffs
protected
std::vector<bool> GRINSTesting::KineticsTestBase::_is_three_body_rxn
protected
unsigned int GRINSTesting::KineticsTestBase::_n_reactions
protected
std::vector<libMesh::Real> GRINSTesting::KineticsTestBase::_preexp_coeffs
protected
std::vector<std::vector<libMesh::Real> > GRINSTesting::KineticsTestBase::_product_stoich_coeffs
protected
std::vector<std::vector<libMesh::Real> > GRINSTesting::KineticsTestBase::_reactant_stoich_coeffs
protected
std::vector<libMesh::Real> GRINSTesting::KineticsTestBase::_temp_exp_coeffs
protected
std::vector<std::vector<libMesh::Real> > GRINSTesting::KineticsTestBase::_three_body_coeffs
protected

The documentation for this class was generated from the following file:

Generated on Tue Dec 19 2017 12:47:32 for GRINS-0.8.0 by  doxygen 1.8.9.1