GRINS-0.8.0
nasa_thermo_test_base.h
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 #ifndef GRINS_NASA_THERMO_TEST_BASE_H
26 #define GRINS_NASA_THERMO_TEST_BASE_H
27 
28 #include "grins_config.h"
29 
30 #ifdef GRINS_HAVE_CPPUNIT
31 
32 #include <cppunit/extensions/HelperMacros.h>
33 
34 #include "species_test_base.h"
35 #include "thermochem_test_common.h"
36 #include "testing_utils.h"
37 
38 namespace GRINSTesting
39 {
41  {
42  public:
43 
44  virtual libMesh::Real cp_exact( unsigned int species_idx, libMesh::Real T ) = 0;
45 
46  virtual libMesh::Real h_exact( unsigned int species_idx, libMesh::Real T ) = 0;
47 
48  virtual libMesh::Real s_R_exact( unsigned int species_idx, libMesh::Real T ) = 0;
49 
50  virtual libMesh::Real h_RT_exact( unsigned int species_idx, libMesh::Real T ) = 0;
51 
52  template<typename ThermoMixture, typename ThermoEvaluator>
53  void test_cp_common( ThermoMixture& mixture, const std::vector<libMesh::Real>& Y, libMesh::Real rel_tol )
54  {
55  CPPUNIT_ASSERT_EQUAL(_active_species.size(), Y.size() );
56 
57  ThermoEvaluator evaluator( mixture );
58 
59  libMesh::Real R_mix = mixture.R_mix(Y);
60  libMesh::Real rho = 1.0e-3;
61 
62  libMesh::Real T = 300;
63  while( T <= 1000 )
64  {
65  libMesh::Real P = rho*R_mix*T;
66 
67  libMesh::Real cp_mix_computed = evaluator.cp( T, P, Y );
68 
69  std::vector<libMesh::Real> species_cp(_active_species.size(),0.0);
70  for( unsigned int s = 0; s < _active_species.size(); s++ )
71  species_cp[s] = this->cp_exact(_active_species[s], T);
72 
73  libMesh::Real cp_mix_exact =
75 
76  std::stringstream ss;
77  ss << T;
78  std::string message = "T = "+ss.str();
79 
80  libMesh::Real tol = TestingUtils::abs_tol_from_rel_tol( cp_mix_exact, rel_tol );
81 
82  CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( message, cp_mix_exact, cp_mix_computed, tol );
83 
84  T += 100.0;
85  }
86  }
87 
88  template<typename ThermoMixture, typename ThermoEvaluator>
89  void test_h_common( ThermoMixture& mixture, libMesh::Real rel_tol )
90  {
91  ThermoEvaluator evaluator( mixture );
92 
93  libMesh::Real tol;
94 
95  libMesh::Real T = 300;
96  while( T <= 1000 )
97  {
98  std::stringstream ss;
99  ss << T;
100  std::string message = "T = "+ss.str();
101 
102  for( unsigned int s = 0; s < _active_species.size(); s++ )
103  {
104  libMesh::Real h_exact = this->h_exact(_active_species[s], T);
105 
106  libMesh::Real h_computed = evaluator.h_s( T, _active_species[s] );
107  tol = TestingUtils::abs_tol_from_rel_tol( h_exact, rel_tol );
108 
109  CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( message,
110  h_exact,
111  h_computed,
112  tol );
113  }
114 
115  T += 100.0;
116  }
117  }
118 
119  protected:
120 
121  const std::vector<libMesh::Real>& nasa_coeffs( unsigned int idx )
122  {
123  if(idx == _N2_idx)
124  return _N2_200_1000_coeffs;
125 
126  else if( idx == _O2_idx)
127  return _O2_200_1000_coeffs;
128 
129  else if( idx == _NO_idx)
130  return _NO_200_1000_coeffs;
131 
132  else if(idx == _O_idx)
133  return _O_200_1000_coeffs;
134 
135  else if(idx == _N_idx)
136  return _N_200_1000_coeffs;
137 
138  else
139  CPPUNIT_FAIL("Invalid idx for nasa_coeffs");
140 
141  // dummy to avoid warning
142  return _N2_200_1000_coeffs;
143  }
144 
145  std::vector<libMesh::Real> _N2_200_1000_coeffs;
146  std::vector<libMesh::Real> _O2_200_1000_coeffs;
147  std::vector<libMesh::Real> _O_200_1000_coeffs;
148  std::vector<libMesh::Real> _NO_200_1000_coeffs;
149  std::vector<libMesh::Real> _N_200_1000_coeffs;
150 
151  };
152 
154  {
155  public:
156 
158  {
159  this->init_N2_coeffs();
160  this->init_O2_coeffs();
161  this->init_O_coeffs();
162  this->init_NO_coeffs();
163  this->init_N_coeffs();
164  }
165 
166  virtual libMesh::Real cp_exact( unsigned int species_idx, libMesh::Real T )
167  {
168  const std::vector<libMesh::Real> coeffs = this->nasa_coeffs(species_idx);
170  coeffs[0],
171  coeffs[1],
172  coeffs[2],
173  coeffs[3],
174  coeffs[4])*this->R_species(species_idx);
175  }
176 
177  virtual libMesh::Real h_exact( unsigned int species_idx, libMesh::Real T )
178  {
179  const std::vector<libMesh::Real> coeffs = this->nasa_coeffs(species_idx);
181  coeffs[0],
182  coeffs[1],
183  coeffs[2],
184  coeffs[3],
185  coeffs[4],
186  coeffs[5])*this->R_species(species_idx)*T;
187  }
188 
189  virtual libMesh::Real s_R_exact( unsigned int species_idx, libMesh::Real T )
190  {
191  const std::vector<libMesh::Real> coeffs = this->nasa_coeffs(species_idx);
193  coeffs[0],
194  coeffs[1],
195  coeffs[2],
196  coeffs[3],
197  coeffs[4],
198  coeffs[6]);
199  }
200 
201  virtual libMesh::Real h_RT_exact( unsigned int species_idx, libMesh::Real T )
202  {
203  const std::vector<libMesh::Real> coeffs = this->nasa_coeffs(species_idx);
205  coeffs[0],
206  coeffs[1],
207  coeffs[2],
208  coeffs[3],
209  coeffs[4],
210  coeffs[5]);
211  }
212 
213  private:
214 
216  {
217  _N2_200_1000_coeffs.resize(7);
218 
219  _N2_200_1000_coeffs[0] = 3.53100528E+00;
220  _N2_200_1000_coeffs[1] = -1.23660987E-04;
221  _N2_200_1000_coeffs[2] = -5.02999437E-07;
222  _N2_200_1000_coeffs[3] = 2.43530612E-09;
223  _N2_200_1000_coeffs[4] = -1.40881235E-12;
224  _N2_200_1000_coeffs[5] = -1.04697628E+03;
225  _N2_200_1000_coeffs[6] = 2.96747468E+00;
226  }
227 
229  {
230  _O2_200_1000_coeffs.resize(7);
231 
232  _O2_200_1000_coeffs[0] = 3.78245636E+00;
233  _O2_200_1000_coeffs[1] = -2.99673415E-03;
234  _O2_200_1000_coeffs[2] = 9.84730200E-06;
235  _O2_200_1000_coeffs[3] = -9.68129508E-09;
236  _O2_200_1000_coeffs[4] = 3.24372836E-12;
237  _O2_200_1000_coeffs[5] = -1.06394356E+03;
238  _O2_200_1000_coeffs[6] = 3.65767573E+00;
239  }
240 
242  {
243  _O_200_1000_coeffs.resize(7);
244 
245  _O_200_1000_coeffs[0] = 3.16826710E+00;
246  _O_200_1000_coeffs[1] = -3.27931884E-03;
247  _O_200_1000_coeffs[2] = 6.64306396E-06;
248  _O_200_1000_coeffs[3] = -6.12806624E-09;
249  _O_200_1000_coeffs[4] = 2.11265971E-12;
250  _O_200_1000_coeffs[5] = 2.91222592E+04;
251  _O_200_1000_coeffs[6] = 2.05193346E+00;
252  }
253 
255  {
256  _NO_200_1000_coeffs.resize(7);
257 
258  _NO_200_1000_coeffs[0] = 4.21859896E+00;
259  _NO_200_1000_coeffs[1] = -4.63988124E-03;
260  _NO_200_1000_coeffs[2] = 1.10443049E-05;
261  _NO_200_1000_coeffs[3] = -9.34055507E-09;
262  _NO_200_1000_coeffs[4] = 2.80554874E-12;
263  _NO_200_1000_coeffs[5] = 9.84509964E+03;
264  _NO_200_1000_coeffs[6] = 2.28061001E+00;
265  }
266 
268  {
269  _N_200_1000_coeffs.resize(7);
270 
271  _N_200_1000_coeffs[0] = 2.50000000E+00;
272  _N_200_1000_coeffs[1] = 0.0;
273  _N_200_1000_coeffs[2] = 0.0;
274  _N_200_1000_coeffs[3] = 0.0;
275  _N_200_1000_coeffs[4] = 0.0;
276  _N_200_1000_coeffs[5] = 5.61046378E+04;
277  _N_200_1000_coeffs[6] = 4.19390932E+00;
278  }
279 
280  };
281 
283  {
284  public:
285 
287  {
288  this->init_N2_coeffs();
289  this->init_O2_coeffs();
290  this->init_O_coeffs();
291  this->init_NO_coeffs();
292  this->init_N_coeffs();
293  }
294 
295  virtual libMesh::Real cp_exact( unsigned int species_idx, libMesh::Real T )
296  {
297  const std::vector<libMesh::Real> coeffs = this->nasa_coeffs(species_idx);
299  coeffs[0],
300  coeffs[1],
301  coeffs[2],
302  coeffs[3],
303  coeffs[4],
304  coeffs[5],
305  coeffs[6])*this->R_species(species_idx);
306  }
307 
308  virtual libMesh::Real h_exact( unsigned int species_idx, libMesh::Real T )
309  {
310  const std::vector<libMesh::Real> coeffs = this->nasa_coeffs(species_idx);
312  coeffs[0],
313  coeffs[1],
314  coeffs[2],
315  coeffs[3],
316  coeffs[4],
317  coeffs[5],
318  coeffs[6],
319  coeffs[7])*this->R_species(species_idx)*T;
320  }
321 
322  virtual libMesh::Real s_R_exact( unsigned int species_idx, libMesh::Real T )
323  {
324  const std::vector<libMesh::Real> coeffs = this->nasa_coeffs(species_idx);
326  coeffs[0],
327  coeffs[1],
328  coeffs[2],
329  coeffs[3],
330  coeffs[4],
331  coeffs[5],
332  coeffs[6],
333  coeffs[8]);
334  }
335 
336  virtual libMesh::Real h_RT_exact( unsigned int species_idx, libMesh::Real T )
337  {
338  const std::vector<libMesh::Real> coeffs = this->nasa_coeffs(species_idx);
340  coeffs[0],
341  coeffs[1],
342  coeffs[2],
343  coeffs[3],
344  coeffs[4],
345  coeffs[5],
346  coeffs[6],
347  coeffs[7]);
348  }
349 
350  private:
351 
353  {
354  _N2_200_1000_coeffs.resize(9);
355 
356  _N2_200_1000_coeffs[0] = 2.21037122e+04;
357  _N2_200_1000_coeffs[1] = -3.81846145e+02;
358  _N2_200_1000_coeffs[2] = 6.08273815e+00;
359  _N2_200_1000_coeffs[3] = -8.53091381e-03;
360  _N2_200_1000_coeffs[4] = 1.38464610e-05;
361  _N2_200_1000_coeffs[5] = -9.62579293e-09;
362  _N2_200_1000_coeffs[6] = 2.51970560e-12;
363  _N2_200_1000_coeffs[7] = 7.10845911e+02;
364  _N2_200_1000_coeffs[8] = -1.07600320e+01;
365  }
366 
368  {
369  _O2_200_1000_coeffs.resize(9);
370 
371  _O2_200_1000_coeffs[0] = -3.42556269e+04;
372  _O2_200_1000_coeffs[1] = 4.84699986e+02;
373  _O2_200_1000_coeffs[2] = 1.11901159e+00;
374  _O2_200_1000_coeffs[3] = 4.29388743e-03;
375  _O2_200_1000_coeffs[4] = -6.83627313e-07;
376  _O2_200_1000_coeffs[5] = -2.02337478e-09;
377  _O2_200_1000_coeffs[6] = 1.03904064e-12;
378  _O2_200_1000_coeffs[7] = -3.39145434e+03;
379  _O2_200_1000_coeffs[8] = 1.84969912e+01;
380  }
381 
383  {
384  _O_200_1000_coeffs.resize(9);
385 
386  _O_200_1000_coeffs[0] = -7.95361130e+03;
387  _O_200_1000_coeffs[1] = 1.60717779e+02;
388  _O_200_1000_coeffs[2] = 1.96622644e+00;
389  _O_200_1000_coeffs[3] = 1.01367031e-03;
390  _O_200_1000_coeffs[4] = -1.11041542e-06;
391  _O_200_1000_coeffs[5] = 6.51750750e-10;
392  _O_200_1000_coeffs[6] = -1.58477925e-13;
393  _O_200_1000_coeffs[7] = 2.84036244e+04;
394  _O_200_1000_coeffs[8] = 8.40424182e+00;
395  }
396 
398  {
399  _NO_200_1000_coeffs.resize(9);
400 
401  _NO_200_1000_coeffs[0] = -1.14391658e+04;
402  _NO_200_1000_coeffs[1] = 1.53646774e+02;
403  _NO_200_1000_coeffs[2] = 3.43146865e+00;
404  _NO_200_1000_coeffs[3] = -2.66859213e-03;
405  _NO_200_1000_coeffs[4] = 8.48139877e-06;
406  _NO_200_1000_coeffs[5] = -7.68511079e-09;
407  _NO_200_1000_coeffs[6] = 2.38679758e-12;
408  _NO_200_1000_coeffs[7] = 9.09794974e+03;
409  _NO_200_1000_coeffs[8] = 6.72872795e+00;
410  }
411 
413  {
414  _N_200_1000_coeffs.resize(9);
415 
416  _N_200_1000_coeffs[0] = 0.0;
417  _N_200_1000_coeffs[1] = 0.0;
418  _N_200_1000_coeffs[2] = 2.5;
419  _N_200_1000_coeffs[3] = 0.0;
420  _N_200_1000_coeffs[4] = 0.0;
421  _N_200_1000_coeffs[5] = 0.0;
422  _N_200_1000_coeffs[6] = 0.0;
423  _N_200_1000_coeffs[7] = 5.61046378e+04;
424  _N_200_1000_coeffs[8] = 4.19390932e+00;
425  }
426 
427  };
428 
429 } // end namespace GRINSTesting
430 
431 #endif // GRINS_HAVE_CPPUNIT
432 
433 #endif // GRINS_NASA_THERMO_TEST_BASE_H
const std::vector< libMesh::Real > & nasa_coeffs(unsigned int idx)
virtual libMesh::Real s_R_exact(unsigned int species_idx, libMesh::Real T)=0
virtual libMesh::Real cp_exact(unsigned int species_idx, libMesh::Real T)
std::vector< libMesh::Real > _NO_200_1000_coeffs
virtual libMesh::Real h_RT_exact(unsigned int species_idx, libMesh::Real T)
static libMesh::Real nasa7_cp_R_exact(libMesh::Real T, libMesh::Real a0, libMesh::Real a1, libMesh::Real a2, libMesh::Real a3, libMesh::Real a4)
virtual libMesh::Real h_exact(unsigned int species_idx, libMesh::Real T)
static libMesh::Real nasa9_s_R_exact(libMesh::Real T, libMesh::Real a0, libMesh::Real a1, libMesh::Real a2, libMesh::Real a3, libMesh::Real a4, libMesh::Real a5, libMesh::Real a6, libMesh::Real a8)
std::vector< libMesh::Real > _N2_200_1000_coeffs
virtual libMesh::Real h_exact(unsigned int species_idx, libMesh::Real T)
std::vector< libMesh::Real > _N_200_1000_coeffs
static libMesh::Real nasa9_cp_R_exact(libMesh::Real T, libMesh::Real a0, libMesh::Real a1, libMesh::Real a2, libMesh::Real a3, libMesh::Real a4, libMesh::Real a5, libMesh::Real a6)
static libMesh::Real nasa7_s_R_exact(libMesh::Real T, libMesh::Real a0, libMesh::Real a1, libMesh::Real a2, libMesh::Real a3, libMesh::Real a4, libMesh::Real a6)
virtual libMesh::Real cp_exact(unsigned int species_idx, libMesh::Real T)
virtual libMesh::Real h_RT_exact(unsigned int species_idx, libMesh::Real T)
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
void test_h_common(ThermoMixture &mixture, libMesh::Real rel_tol)
virtual libMesh::Real h_RT_exact(unsigned int species_idx, libMesh::Real T)=0
virtual libMesh::Real h_exact(unsigned int species_idx, libMesh::Real T)=0
std::vector< libMesh::Real > _O2_200_1000_coeffs
virtual libMesh::Real cp_exact(unsigned int species_idx, libMesh::Real T)=0
static libMesh::Real nasa7_h_RT_exact(libMesh::Real T, libMesh::Real a0, libMesh::Real a1, libMesh::Real a2, libMesh::Real a3, libMesh::Real a4, libMesh::Real a5)
std::vector< unsigned int > _active_species
virtual libMesh::Real s_R_exact(unsigned int species_idx, libMesh::Real T)
static libMesh::Real compute_mass_frac_mixture_prop(const std::vector< libMesh::Real > &properties, const std::vector< libMesh::Real > &mass_fracs)
virtual libMesh::Real s_R_exact(unsigned int species_idx, libMesh::Real T)
std::vector< libMesh::Real > _O_200_1000_coeffs
static libMesh::Real nasa9_h_RT_exact(libMesh::Real T, libMesh::Real a0, libMesh::Real a1, libMesh::Real a2, libMesh::Real a3, libMesh::Real a4, libMesh::Real a5, libMesh::Real a6, libMesh::Real a7)
libMesh::Real R_species(unsigned int idx)
void test_cp_common(ThermoMixture &mixture, const std::vector< libMesh::Real > &Y, libMesh::Real rel_tol)

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