GRINS-0.6.0
cantera_evaluator_regression.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2015 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 
26 //C++
27 #include <iomanip>
28 
29 // GRINS
30 #include "grins_config.h"
31 #include "grins/cantera_mixture.h"
33 #include "grins/cached_values.h"
34 
35 // libMesh
36 #include "libmesh/getpot.h"
37 
38 #ifdef GRINS_HAVE_CANTERA
39 int main(int argc, char* argv[])
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 }
206 #else //GRINS_HAVE_CANTERA
207 int main()
208 {
209  // automake expects 77 for a skipped test
210  return 77;
211 }
212 #endif
213 
libMesh::Real h_s(const CachedValues &cache, unsigned int qp, unsigned int species) const
void set_values(unsigned int quantity, std::vector< libMesh::Number > &values)
Definition: cached_values.C:72
libMesh::Real cv(const CachedValues &cache, unsigned int qp) const
libMesh::Real mu(const CachedValues &cache, unsigned int qp) const
void omega_dot(const CachedValues &cache, unsigned int qp, std::vector< libMesh::Real > &omega_dot) const
libMesh::Real k(const CachedValues &cache, unsigned int qp) const
void D(const CachedValues &cache, unsigned int qp, std::vector< libMesh::Real > &D) const
int main(int argc, char *argv[])
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
libMesh::Real cp(const CachedValues &cache, unsigned int qp) const

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