GRINS-0.6.0
Functions
cantera_evaluator_regression.C File Reference
#include <iomanip>
#include "grins_config.h"
#include "grins/cantera_mixture.h"
#include "grins/cantera_evaluator.h"
#include "grins/cached_values.h"
#include "libmesh/getpot.h"
Include dependency graph for cantera_evaluator_regression.C:

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 39 of file cantera_evaluator_regression.C.

References GRINS::CachedValues::add_quantity(), GRINS::CanteraEvaluator::cp(), GRINS::CanteraEvaluator::cv(), GRINS::CanteraEvaluator::D(), GRINS::CanteraEvaluator::h_s(), GRINS::CanteraEvaluator::k(), GRINS::Cache::MASS_FRACTIONS, GRINS::CanteraEvaluator::mu(), GRINS::CanteraEvaluator::omega_dot(), GRINS::CachedValues::set_values(), GRINS::CachedValues::set_vector_values(), GRINS::Cache::TEMPERATURE, and GRINS::Cache::THERMO_PRESSURE.

40 {
41  // Check command line count.
42  if( argc < 2 )
43  {
44  // TODO: Need more consistent error handling.
45  std::cerr << "Error: Must specify input file." << std::endl;
46  exit(1); // TODO: something more sophisticated for parallel runs?
47  }
48 
49  GetPot input( argv[1] );
50 
51  GRINS::CanteraMixture mixture( input );
52  GRINS::CanteraEvaluator gas(mixture);
53 
54  double T = 1500.0;
55 
56  double P = 100000.0;
57 
58  std::vector<double> Y(5,0.2);
59 
60  GRINS::CachedValues cache;
61 
65 
66  std::vector<double> Tqp(1,T);
67  std::vector<double> Pqp(1,P);
68  std::vector<std::vector<double> > Yqp(1,Y);
69 
73 
74  std::vector<double> omega_dot(5,0.0);
75 
76  gas.omega_dot( cache, 0, omega_dot );
77 
78  const double cv = gas.cv( cache, 0 );
79  const double cp = gas.cp( cache, 0 );
80 
81  const double mu = gas.mu( cache, 0 );
82  const double k = gas.k( cache, 0 );
83 
84  std::vector<libMesh::Real> D(5,0.0);
85 
86  gas.D( cache, 0, D );
87 
88  std::vector<double> h(5,0.0);
89  gas.h_s( cache, 0, h );
90 
91  int return_flag = 0;
92 
93  double tol = 1.0e-15;
94 
95  const double cv_reg = 8.8382964243437857e+02;
96  if( std::fabs( (cv - cv_reg)/cv_reg ) > tol )
97  {
98  std::cerr << "Error: Mismatch in internal energy." << std::endl
99  << std::setprecision(16) << std::scientific
100  << "cv = " << cv << std::endl
101  << "cv_reg = " << cv_reg << std::endl;
102  return_flag = 1;
103  }
104 
105  const double cp_reg = 1.2732313697364564e+03;
106  if( std::fabs( (cp - cp_reg)/cp_reg ) > tol )
107  {
108  std::cerr << "Error: Mismatch in internal energy." << std::endl
109  << std::setprecision(16) << std::scientific
110  << "cp = " << cp << std::endl
111  << "cp_reg = " << cp_reg << std::endl;
112  return_flag = 1;
113  }
114 
115  std::vector<double> od_reg(5,0.0);
116  /* Values before rescaling omega dot by molar mass
117  od_reg[0] = 3.3421893152544762e+03;
118  od_reg[1] = -1.0546740386620191e+04;
119  od_reg[2] = 8.6026851320309106e+03;
120  od_reg[3] = -1.5287063762539863e+04;
121  od_reg[4] = 1.2490795641209472e+04; */
122 
123  od_reg[0] = 9.3626353539094969e+04;
124  od_reg[1] = -3.3748303628338216e+05;
125  od_reg[2] = 2.5813337444763799e+05;
126  od_reg[3] = -2.1412192748531760e+05;
127  od_reg[4] = 1.9984523578196683e+05;
128 
129  for( unsigned int i = 0; i < 5; i++ )
130  {
131  if( std::fabs( (omega_dot[i] - od_reg[i])/od_reg[i] ) > tol )
132  {
133  std::cerr << "Error: Mismatch in internal energy." << std::endl
134  << std::setprecision(16) << std::scientific
135  << "i = " << i << std::endl
136  << "omega_dot = " << omega_dot[i] << std::endl
137  << "od_reg = " << od_reg[i] << std::endl;
138  return_flag = 1;
139  }
140  }
141 
142  const double mu_reg = 5.4816457619629627e-05;
143  const double k_reg = 9.2830809315384427e-02;
144  std::vector<libMesh::Real> D_reg(5,0.0);
145  D_reg[0] = 3.4493708884909694e-04;
146  D_reg[1] = 3.3630005706895442e-04;
147  D_reg[2] = 3.4039101336823794e-04;
148  D_reg[3] = 5.2738514208048540e-04;
149  D_reg[4] = 5.1755853748986337e-04;
150 
151  if( std::fabs( (mu_reg - mu)/mu ) > tol )
152  {
153  std::cerr << "Error: Mismatch in viscosity." << std::endl
154  << std::setprecision(16) << std::scientific
155  << "mu = " << mu << std::endl
156  << "mu_reg = " << mu_reg << std::endl;
157  return_flag = 1;
158  }
159 
160  for( unsigned int i = 0; i < 5; i++ )
161  {
162  if( std::fabs( (D_reg[i] - D[i])/D[i] ) > tol )
163  {
164  std::cerr << "Error: Mismatch in diffusion coefficient." << std::endl
165  << std::setprecision(16) << std::scientific
166  << "i = " << i << std::endl
167  << "D = " << D[i] << std::endl
168  << "D_reg = " << D_reg[i] << std::endl;
169  return_flag = 1;
170  }
171  }
172 
173  std::vector<double> h_reg(5,0.0);
174  h_reg[0] = 1.3709248272267890e+06;
175  h_reg[1] = 1.2692054328083945e+06;
176  h_reg[2] = 4.3659730250572553e+06;
177  h_reg[3] = 3.5529883128718123e+07;
178  h_reg[4] = 1.7154994250083648e+07;
179 
180  for( unsigned int i = 0; i < 5; i++ )
181  {
182  if( std::fabs( (h[i] - h_reg[i])/h_reg[i] ) > tol )
183  {
184  std::cerr << "Error: Mismatch in internal energy." << std::endl
185  << std::setprecision(16) << std::scientific
186  << "i = " << i << std::endl
187  << "h = " << h[i] << std::endl
188  << "h_reg = " << h_reg[i] << std::endl;
189  return_flag = 1;
190  }
191  }
192 
193  tol = 6.0e-15;
194 
195  if( std::fabs( (k_reg - k)/k ) > tol )
196  {
197  std::cerr << "Error: Mismatch in thermal conductivity." << std::endl
198  << std::setprecision(16) << std::scientific
199  << "k = " << k << std::endl
200  << "k_reg = " << k_reg << std::endl;
201  return_flag = 1;
202  }
203 
204  return return_flag;
205 }
void set_values(unsigned int quantity, std::vector< libMesh::Number > &values)
Definition: cached_values.C:72
Wrapper class for evaluating thermochemistry and transport properties using Cantera.
Wrapper class for storing state for computing thermochemistry and transport properties using Cantera...
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

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