GRINS-0.6.0
Functions
antioch_evaluator_regression.C File Reference
#include "grins_config.h"
#include <iomanip>
#include <limits>
#include <vector>
#include "grins/antioch_mixture.h"
#include "grins/antioch_evaluator.h"
#include "grins/cached_values.h"
#include "libmesh/getpot.h"
#include "antioch/cea_evaluator.h"
#include "antioch/stat_mech_thermo.h"
#include "boost/math/special_functions/fpclassify.hpp"
Include dependency graph for antioch_evaluator_regression.C:

Go to the source code of this file.

Functions

int test_generic (const libMesh::Real value, const libMesh::Real value_reg, const std::string &name)
 
template<typename Thermo >
int test_cp (const libMesh::Real cp)
 
template<typename Thermo >
int test_cv (const libMesh::Real cv)
 
template<typename Thermo >
int test_h_s (const libMesh::Real h_s)
 
template<>
int test_cp< Antioch::CEAEvaluator< libMesh::Real > > (const libMesh::Real cp)
 
template<>
int test_cv< Antioch::CEAEvaluator< libMesh::Real > > (const libMesh::Real cv)
 
template<>
int test_h_s< Antioch::CEAEvaluator< libMesh::Real > > (const libMesh::Real h_s)
 
template<>
int test_cp< Antioch::StatMechThermodynamics< libMesh::Real > > (const libMesh::Real cp)
 
template<>
int test_cv< Antioch::StatMechThermodynamics< libMesh::Real > > (const libMesh::Real cv)
 
template<>
int test_h_s< Antioch::StatMechThermodynamics< libMesh::Real > > (const libMesh::Real h_s)
 
template<typename Thermo >
int test_evaluator (const GRINS::AntiochMixture &antioch_mixture)
 
int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 255 of file antioch_evaluator_regression.C.

256 {
257  // Check command line count.
258  if( argc < 2 )
259  {
260  // TODO: Need more consistent error handling.
261  std::cerr << "Error: Must specify input file." << std::endl;
262  exit(1);
263  }
264 
265  GetPot input( argv[1] );
266 
267  GRINS::AntiochMixture antioch_mixture(input);
268 
269  int return_flag = 0;
270 
271  std::cout << "Running AntiochCEAThermo regression test." << std::endl;
272  return_flag = test_evaluator<Antioch::CEAEvaluator<libMesh::Real> >( antioch_mixture );
273 
274  std::cout << std::endl << "Running AntiochStatMechThermo regression test." << std::endl;
275  return_flag = test_evaluator<Antioch::StatMechThermodynamics<libMesh::Real> >( antioch_mixture );
276 
277  return return_flag;
278 }
Wrapper class for storing state for Antioch thermo and kinetics.
template<typename Thermo >
int test_cp ( const libMesh::Real  cp)
template<>
int test_cp< Antioch::CEAEvaluator< libMesh::Real > > ( const libMesh::Real  cp)

Definition at line 80 of file antioch_evaluator_regression.C.

References test_generic().

81 {
82  double cp_reg = 1.2361869971209990e+03;
83 
84  return test_generic(cp,cp_reg,"cp");
85 }
int test_generic(const libMesh::Real value, const libMesh::Real value_reg, const std::string &name)
template<>
int test_cp< Antioch::StatMechThermodynamics< libMesh::Real > > ( const libMesh::Real  cp)

Definition at line 104 of file antioch_evaluator_regression.C.

References test_generic().

105 {
106  double cp_reg = 1.2309250447693457e+03;
107 
108  return test_generic(cp,cp_reg,"cp");
109 }
int test_generic(const libMesh::Real value, const libMesh::Real value_reg, const std::string &name)
template<typename Thermo >
int test_cv ( const libMesh::Real  cv)
template<>
int test_cv< Antioch::CEAEvaluator< libMesh::Real > > ( const libMesh::Real  cv)

Definition at line 88 of file antioch_evaluator_regression.C.

References test_generic().

89 {
90  double cv_reg = 8.4681056933423179e+02;
91 
92  return test_generic(cv,cv_reg,"cv");
93 }
int test_generic(const libMesh::Real value, const libMesh::Real value_reg, const std::string &name)
template<>
int test_cv< Antioch::StatMechThermodynamics< libMesh::Real > > ( const libMesh::Real  cv)

Definition at line 112 of file antioch_evaluator_regression.C.

References test_generic().

113 {
114  double cv_reg = 8.4154861698257866e+02;
115 
116  return test_generic(cv,cv_reg,"cv");
117 }
int test_generic(const libMesh::Real value, const libMesh::Real value_reg, const std::string &name)
template<typename Thermo >
int test_evaluator ( const GRINS::AntiochMixture antioch_mixture)

Definition at line 129 of file antioch_evaluator_regression.C.

References GRINS::CachedValues::add_quantity(), GRINS::AntiochEvaluator< Thermo >::cp(), GRINS::AntiochEvaluator< Thermo >::cv(), GRINS::AntiochEvaluator< Thermo >::h_s(), GRINS::Cache::MASS_FRACTIONS, GRINS::Cache::MIXTURE_DENSITY, GRINS::Cache::MIXTURE_GAS_CONSTANT, GRINS::AntiochEvaluator< Thermo >::omega_dot(), GRINS::AntiochChemistry::R_mix(), GRINS::CachedValues::set_values(), GRINS::CachedValues::set_vector_values(), and GRINS::Cache::TEMPERATURE.

130 {
131  GRINS::AntiochEvaluator<Thermo> antioch_evaluator( antioch_mixture );
132 
133  libMesh::Real T = 1000;
134 
135  libMesh::Real rho = 1.0e-3;
136 
137  const unsigned int n_species = 5;
138 
139  std::vector<libMesh::Real> Y(n_species,0.2);
140 
141  libMesh::Real R_mix = antioch_mixture.R_mix(Y);
142 
143  GRINS::CachedValues cache;
144 
146  std::vector<double> Tqp(1,T);
148 
150  std::vector<double> rhoqp(1,rho);
152 
154  std::vector<double> Rqp(1,R_mix);
156 
158  std::vector<std::vector<double> > Yqp(1,Y);
160 
161  std::vector<libMesh::Real> omega_dot(n_species,0.0);
162 
163  libMesh::Real cp = antioch_evaluator.cp( cache, 0 );
164 
165  std::cout << std::scientific << std::setprecision(16)
166  << "cp = " << cp << std::endl;
167 
168  libMesh::Real cv = antioch_evaluator.cv( cache, 0 );
169 
170  std::cout << std::scientific << std::setprecision(16)
171  << "cv = " << cv << std::endl;
172 
173  libMesh::Real h_s = antioch_evaluator.h_s( cache, 0, 0 );
174 
175  std::cout << std::scientific << std::setprecision(16)
176  << "h_s = " << h_s << std::endl;
177 
178  int return_flag = 0;
179  int return_flag_temp = 0;
180 
181  return_flag_temp = test_cp<Thermo>( cp );
182  if( return_flag_temp != 0 ) return_flag = 1;
183 
184  return_flag_temp = test_cv<Thermo>( cv );
185  if( return_flag_temp != 0 ) return_flag = 1;
186 
187  return_flag_temp = test_h_s<Thermo>( h_s );
188  if( return_flag_temp != 0 ) return_flag = 1;
189 
190  antioch_evaluator.omega_dot( cache, 0, omega_dot );
191 
192  for( unsigned int i = 0; i < n_species; i++ )
193  {
194  std::cout << std::scientific << std::setprecision(16)
195  << "omega_dot(" << i << ") = " << omega_dot[i] << std::endl;
196  }
197 
198 
199  double tol = std::numeric_limits<double>::epsilon()*40;
200 
201  // Check that omega_dot sums to 1
202  libMesh::Real sum = 0.0;
203  for( unsigned int s = 0; s < n_species; s++ )
204  {
205  sum += omega_dot[s];
206  }
207 
208  if( std::fabs(sum) > tol )
209  {
210  std::cout << "Error: Sum of mass sources not equal to zero!" << std::endl
211  << "sum = " << sum << std::endl;
212  return_flag = 1;
213  }
214 
215  bool omega_is_nan = false;
216  for( unsigned int s = 0; s < n_species; s++ )
217  {
218  if( boost::math::isnan(omega_dot[s]) )
219  {
220  omega_is_nan = true;
221  return_flag = 1;
222  }
223  }
224 
225  if( omega_is_nan )
226  {
227  std::cerr << "Error: Detected NAN's for omega_dot!" << std::endl;
228  }
229 
230  // Now check against regression values
231  std::vector<libMesh::Real> omega_dot_reg(n_species,0.0);
232  omega_dot_reg[0] = 4.3561014567820650e-01;
233  omega_dot_reg[1] = -3.6797207156306633e+00;
234  omega_dot_reg[2] = 2.9970582875850726e+00;
235  omega_dot_reg[3] = -1.8346634812051223e+00;
236  omega_dot_reg[4] = 2.0817157635725065e+00;
237 
238  for( unsigned int s = 0; s < n_species; s++ )
239  {
240  if( std::fabs( (omega_dot[s] - omega_dot_reg[s])/omega_dot_reg[s] ) > tol )
241  {
242  std::cerr << "Error: Mismatch in omega_dot." << std::endl
243  << std::setprecision(16) << std::scientific
244  << "s = " << s << std::endl
245  << "omega_dot = " << omega_dot[s] << std::endl
246  << "omega_dot_reg = " << omega_dot_reg[s] << std::endl;
247  return_flag = 1;
248  }
249  }
250 
251  return return_flag;
252 }
Wrapper class for evaluating chemistry and thermo properties using Antioch.
libMesh::Real R_mix(const std::vector< libMesh::Real > &mass_fractions) const
Mixture gas constant, [J/kg-K].
void set_values(unsigned int quantity, std::vector< libMesh::Number > &values)
Definition: cached_values.C:72
void add_quantity(unsigned int quantity)
Definition: cached_values.C:40
void set_vector_values(unsigned int quantity, std::vector< std::vector< libMesh::Number > > &values)
Definition: cached_values.C:93
int test_generic ( const libMesh::Real  value,
const libMesh::Real  value_reg,
const std::string &  name 
)

Definition at line 50 of file antioch_evaluator_regression.C.

Referenced by test_cp< Antioch::CEAEvaluator< libMesh::Real > >(), test_cp< Antioch::StatMechThermodynamics< libMesh::Real > >(), test_cv< Antioch::CEAEvaluator< libMesh::Real > >(), test_cv< Antioch::StatMechThermodynamics< libMesh::Real > >(), test_h_s< Antioch::CEAEvaluator< libMesh::Real > >(), and test_h_s< Antioch::StatMechThermodynamics< libMesh::Real > >().

51 {
52  int return_flag = 0;
53 
54  const double tol = std::numeric_limits<double>::epsilon()*40;
55 
56  const double rel_error = std::fabs( (value - value_reg)/value_reg );
57 
58  if( rel_error > tol )
59  {
60  return_flag = 1;
61  std::cout << "Mismatch in "+name << std::endl
62  << name+" = " << value << std::endl
63  << name+"_reg = " << value_reg << std::endl
64  << "rel_error = " << rel_error << std::endl;
65  }
66 
67  return return_flag;
68 }
template<typename Thermo >
int test_h_s ( const libMesh::Real  h_s)
template<>
int test_h_s< Antioch::CEAEvaluator< libMesh::Real > > ( const libMesh::Real  h_s)

Definition at line 96 of file antioch_evaluator_regression.C.

References test_generic().

97 {
98  double h_s_reg = 7.6606764036494098e+05;
99 
100  return test_generic(h_s,h_s_reg,"h_s");
101 }
int test_generic(const libMesh::Real value, const libMesh::Real value_reg, const std::string &name)
template<>
int test_h_s< Antioch::StatMechThermodynamics< libMesh::Real > > ( const libMesh::Real  h_s)

Definition at line 120 of file antioch_evaluator_regression.C.

References test_generic().

121 {
122  double h_s_reg = 7.6397682090011111e+05;
123 
124  return test_generic(h_s,h_s_reg,"h_s");
125 }
int test_generic(const libMesh::Real value, const libMesh::Real value_reg, const std::string &name)

Generated on Mon Jun 22 2015 21:32:21 for GRINS-0.6.0 by  doxygen 1.8.9.1