GRINS-0.8.0
air_5sp.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2017 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #include "grins_config.h"
26 
27 #ifdef GRINS_HAVE_CPPUNIT
28 
29 #include <cppunit/extensions/HelperMacros.h>
30 #include <cppunit/TestCase.h>
31 
32 #include "grins_test_paths.h"
33 #include "nasa_thermo_test_base.h"
34 #include "kinetics_test_base.h"
35 #include "antioch_test_base.h"
36 #include "cantera_test_base.h"
37 
38 // GRINS
41 
42 namespace GRINSTesting
43 {
45  {
46  public:
47 
48  void init_air_test( unsigned int& N2_idx, unsigned int& O2_idx,
49  unsigned int& N_idx, unsigned int& O_idx,
50  unsigned int& NO_idx,
51  std::vector<unsigned int>& active_species )
52  {
53  N2_idx = 0;
54  O2_idx = 1;
55  O_idx = 4;
56  N_idx = 3;
57  NO_idx = 2;
58 
59  active_species.resize(5);
60  active_species[0] = N2_idx;
61  active_species[1] = O2_idx;
62  active_species[2] = NO_idx;
63  active_species[3] = N_idx;
64  active_species[4] = O_idx;
65  }
66 
67  };
68 
69  class AirNASA9Thermo : public AirTestBase,
70  public NASA9ThermoTestBase
71  {
72  public:
73 
75  {
78  }
79 
80  };
81 
83  public AirTestBase
84  {
85  public:
86 
88  {
91 
92  _n_reactions = 5;
93 
94  unsigned int n_species = _active_species.size();
95 
96  // All in cal/mol
97  _Ea_coeffs.resize(_n_reactions);
98  _Ea_coeffs[0] = 224801.3;
99  _Ea_coeffs[1] = 117881.7;
100  _Ea_coeffs[2] = 149943.0;
101  _Ea_coeffs[3] = 85269.6;
102  _Ea_coeffs[4] = 38526.0;
103 
104  // Convert to J/kmol (since this is what GRINS::Constants::R_universal is in)
105  for( unsigned int r = 0; r < _n_reactions; r++ )
106  _Ea_coeffs[r] *= 1000.0*4.1868;
107 
108  // m^3/kmol
109  _preexp_coeffs.resize(_n_reactions);
110  _preexp_coeffs[0] = 7.e+18;
111  _preexp_coeffs[1] = 2.e+18;
112  _preexp_coeffs[2] = 5.e+12;
113  _preexp_coeffs[3] = 5.7e+9;
114  _preexp_coeffs[4] = 8.4e+09;
115 
116  _temp_exp_coeffs.resize(_n_reactions);
117  _temp_exp_coeffs[0] = -1.6;
118  _temp_exp_coeffs[1] = -1.5;
119  _temp_exp_coeffs[2] = 0.0;
120  _temp_exp_coeffs[3] = 0.42;
121  _temp_exp_coeffs[4] = 0.0;
122 
123  _three_body_coeffs.resize(_n_reactions);
124  _is_three_body_rxn.resize(_n_reactions,false);
125  _is_three_body_rxn[0] = true;
126  _three_body_coeffs[0].resize(n_species, 1.0);
127  _three_body_coeffs[0][_N_idx] = 4.2857;
128  _three_body_coeffs[0][_O_idx] = 4.2857;
129 
130  _is_three_body_rxn[1] = true;
131  _three_body_coeffs[1].resize(n_species, 1.0);
132  _three_body_coeffs[1][_N_idx] = 5.0;
133  _three_body_coeffs[1][_O_idx] = 5.0;
134 
135  _is_three_body_rxn[2] = true;
136  _three_body_coeffs[2].resize(n_species, 1.0);
137  _three_body_coeffs[2][_N_idx] = 22.0;
138  _three_body_coeffs[2][_O_idx] = 22.0;
139  _three_body_coeffs[2][_NO_idx] = 22.0;
140 
141  _reactant_stoich_coeffs.resize(_n_reactions);
142  _product_stoich_coeffs.resize(_n_reactions);
143 
144  // N_2 + M <=> 2N + M
145  _reactant_stoich_coeffs[0].resize(n_species, 0.0);
146  _product_stoich_coeffs[0].resize(n_species, 0.0);
148  _product_stoich_coeffs[0][_N_idx] = 2.0;
149 
150  // O_2 + M <=> 2O + M
151  _reactant_stoich_coeffs[1].resize(n_species, 0.0);
152  _product_stoich_coeffs[1].resize(n_species, 0.0);
154  _product_stoich_coeffs[1][_O_idx] = 2.0;
155 
156  // NO + M <=> N + O + M
157  _reactant_stoich_coeffs[2].resize(n_species, 0.0);
158  _product_stoich_coeffs[2].resize(n_species, 0.0);
160  _product_stoich_coeffs[2][_O_idx] = 1.0;
161  _product_stoich_coeffs[2][_N_idx] = 1.0;
162 
163  // N2 + 0 <=> NO + N
164  _reactant_stoich_coeffs[3].resize(n_species, 0.0);
165  _product_stoich_coeffs[3].resize(n_species, 0.0);
169  _product_stoich_coeffs[3][_N_idx] = 1.0;
170 
171  // NO + 0 <=> O2 + N
172  _reactant_stoich_coeffs[4].resize(n_species, 0.0);
173  _product_stoich_coeffs[4].resize(n_species, 0.0);
177  _product_stoich_coeffs[4][_N_idx] = 1.0;
178  }
179 
180  };
181 
182 
183 #ifdef GRINS_HAVE_ANTIOCH
184 
185  class AntiochAirNASA9ThermoTest : public CppUnit::TestCase,
186  public AntiochTestBase,
187  public AirTestBase,
188  public NASA9ThermoTestBase
189  {
190  public:
192 
195 
197 
198  public:
199 
200  void setUp()
201  {
202  std::string input_file = std::string(GRINS_TEST_SRCDIR)+"/input_files/antioch.in";
203  this->init_antioch(input_file, "TestMaterial");
204 
206  _active_species );
207 
208  //this->check_indices(*_antioch_mixture);
209  }
210 
211  void test_cp()
212  {
213  std::vector<libMesh::Real> Y(5);
214  Y[_N2_idx] = 0.15;
215  Y[_O2_idx] = 0.35;
216  Y[_NO_idx] = 0.25;
217  Y[_O_idx] = 0.2;
218  Y[_N_idx] = 0.05;
219 
220  this->test_cp_common<GRINS::AntiochMixture<Antioch::CEACurveFit<libMesh::Real> >,GRINS::AntiochEvaluator<Antioch::CEACurveFit<libMesh::Real>,Antioch::IdealGasMicroThermo<Antioch::NASAEvaluator<libMesh::Real,Antioch::CEACurveFit<libMesh::Real> >, libMesh::Real> > >
222  }
223 
224  void test_hs()
225  {
226  this->test_h_common<GRINS::AntiochMixture<Antioch::CEACurveFit<libMesh::Real> >,GRINS::AntiochEvaluator<Antioch::CEACurveFit<libMesh::Real>,Antioch::IdealGasMicroThermo<Antioch::NASAEvaluator<libMesh::Real,Antioch::CEACurveFit<libMesh::Real> >, libMesh::Real> > >
228  }
229  };
230 
231  class AntiochAirNASA9KineticsTest : public CppUnit::TestCase,
232  public AntiochTestBase,
233  public AirKineticsTestBase
234  {
235  public:
237 
239 
241 
242  public:
243 
244  void setUp()
245  {
246  std::string input_file = std::string(GRINS_TEST_SRCDIR)+"/input_files/antioch.in";
247  this->init_antioch(input_file, "TestMaterial");
248 
249  this->init_air_kinetics();
250 
251  //this->check_indices(*_antioch_mixture);
252  }
253 
255  {
256  std::vector<libMesh::Real> Y(5);
257  Y[_N2_idx] = 0.15;
258  Y[_O2_idx] = 0.35;
259  Y[_NO_idx] = 0.25;
260  Y[_O_idx] = 0.2;
261  Y[_N_idx] = 0.05;
262 
263  AirNASA9Thermo thermo;
264 
265  this->test_omega_dot_common<GRINS::AntiochMixture<Antioch::CEACurveFit<libMesh::Real> >,GRINS::AntiochEvaluator<Antioch::CEACurveFit<libMesh::Real>,Antioch::IdealGasMicroThermo<Antioch::NASAEvaluator<libMesh::Real,Antioch::CEACurveFit<libMesh::Real> >, libMesh::Real> > >
266  ( *_antioch_mixture, thermo, Y, TestingUtils::epsilon()*1e3 );
267  }
268  };
269 
270  CPPUNIT_TEST_SUITE_REGISTRATION( AntiochAirNASA9ThermoTest );
271  CPPUNIT_TEST_SUITE_REGISTRATION( AntiochAirNASA9KineticsTest );
272 
273 #endif // GRINS_HAVE_ANTIOCH
274 
275 
276 #ifdef GRINS_HAVE_CANTERA
277 
278  class CanteraAirNASA9ThermoTest : public CppUnit::TestCase,
279  public CanteraTestBase,
280  public AirTestBase,
281  public NASA9ThermoTestBase
282  {
283  public:
285 
288 
290 
291  public:
292 
293  void setUp()
294  {
295  std::string input_file = std::string(GRINS_TEST_SRCDIR)+"/input_files/cantera_chem_thermo.in";
296  this->init_cantera(input_file, "TestMaterial");
297 
299  _active_species );
300 
301  //this->check_indices(*_antioch_mixture);
302  }
303 
304  void test_cp()
305  {
306  std::vector<libMesh::Real> Y(5);
307  Y[_N2_idx] = 0.15;
308  Y[_O2_idx] = 0.35;
309  Y[_NO_idx] = 0.25;
310  Y[_O_idx] = 0.2;
311  Y[_N_idx] = 0.05;
312 
313  this->test_cp_common<GRINS::CanteraMixture,GRINS::CanteraEvaluator>
314  ( *_cantera_mixture, Y, 1.0e-4 );
315  }
316 
317  void test_hs()
318  {
319  this->test_h_common<GRINS::CanteraMixture,GRINS::CanteraEvaluator>
320  ( *_cantera_mixture, 1.0e-4 );
321  }
322  };
323 
324  class CanteraAirNASA9KineticsTest : public CppUnit::TestCase,
325  public CanteraTestBase,
326  public AirKineticsTestBase
327  {
328  public:
330 
332 
334 
335  public:
336 
337  void setUp()
338  {
339  std::string input_file = std::string(GRINS_TEST_SRCDIR)+"/input_files/cantera_chem_thermo.in";
340  this->init_cantera(input_file, "TestMaterial");
341 
342  this->init_air_kinetics();
343 
344  //this->check_indices(*_antioch_mixture);
345  }
346 
348  {
349  std::cout << "Running Cantera test_omega_dot()" << std::endl;
350 
351  std::vector<libMesh::Real> Y(5);
352  Y[_N2_idx] = 0.15;
353  Y[_O2_idx] = 0.35;
354  Y[_NO_idx] = 0.25;
355  Y[_O_idx] = 0.2;
356  Y[_N_idx] = 0.05;
357 
358  AirNASA9Thermo thermo;
359 
360  this->test_omega_dot_common<GRINS::CanteraMixture,GRINS::CanteraEvaluator>
361  ( *_cantera_mixture, thermo, Y, 3.0e-1 );
362  }
363  };
364 
365  CPPUNIT_TEST_SUITE_REGISTRATION( CanteraAirNASA9ThermoTest );
366  CPPUNIT_TEST_SUITE_REGISTRATION( CanteraAirNASA9KineticsTest );
367 
368 #endif // GRINS_HAVE_CANTERA
369 
370 } // end namespace GRINSTesting
371 
372 #endif // GRINS_HAVE_CPPUNIT
libMesh::UniquePtr< GRINS::CanteraMixture > _cantera_mixture
void init_antioch(const std::string &input_file, const std::string &material_name)
CPPUNIT_TEST_SUITE(CanteraAirNASA9KineticsTest)
Wrapper class for evaluating chemistry and thermo properties using Antioch.
CPPUNIT_TEST_SUITE_REGISTRATION(AntiochAirNASA9ThermoTest)
CPPUNIT_TEST_SUITE(AntiochAirNASA9KineticsTest)
CPPUNIT_TEST_SUITE(CanteraAirNASA9ThermoTest)
std::vector< std::vector< libMesh::Real > > _product_stoich_coeffs
void init_air_test(unsigned int &N2_idx, unsigned int &O2_idx, unsigned int &N_idx, unsigned int &O_idx, unsigned int &NO_idx, std::vector< unsigned int > &active_species)
Definition: air_5sp.C:48
std::vector< libMesh::Real > _temp_exp_coeffs
static libMesh::Real epsilon()
Convenience function.
Definition: testing_utils.h:50
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
CPPUNIT_TEST_SUITE(AntiochAirNASA9ThermoTest)
std::vector< bool > _is_three_body_rxn
void init_cantera(const std::string &input_file, const std::string &material_name)
libMesh::UniquePtr< GRINS::AntiochMixture< Antioch::CEACurveFit< libMesh::Real > > > _antioch_mixture
std::vector< libMesh::Real > _Ea_coeffs

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