GRINS-0.6.0
cantera_transport_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  std::vector<std::string> species(5);
52  species[0] = input( "Physics/Chemistry/species", "DIE!", 0 );
53  species[1] = input( "Physics/Chemistry/species", "DIE!", 1 );
54  species[2] = input( "Physics/Chemistry/species", "DIE!", 2 );
55  species[3] = input( "Physics/Chemistry/species", "DIE!", 3 );
56  species[4] = input( "Physics/Chemistry/species", "DIE!", 4 );
57 
58  GRINS::CanteraMixture cantera_mixture(input);
59 
60  GRINS::CanteraTransport cantera_trans(cantera_mixture);
61 
62  double T = 1000.0;
63 
64  double P = 100000.0;
65 
66  std::vector<double> Y(5,0.2);
67 
68  GRINS::CachedValues cache;
69 
73 
74  std::vector<double> Tqp(1,T);
75  std::vector<double> Pqp(1,P);
76  std::vector<std::vector<double> > Yqp(1,Y);
77 
81 
82  const double mu = cantera_trans.mu(cache,0);
83  const double k = cantera_trans.k(cache,0);
84 
85  std::vector<libMesh::Real> D(5,0.0);
86 
87  cantera_trans.D(cache, 0, D);
88 
89  int return_flag = 0;
90 
91  const double tol = 6.0e-15;
92 
93  const double mu_reg = 4.2134235819759682e-05;
94  const double k_reg = 5.7138665373733508e-02;
95  std::vector<libMesh::Real> D_reg(5,0.0);
96  D_reg[0] = 1.7611544183904180e-04;
97  D_reg[1] = 1.7169898621123060e-04;
98  D_reg[2] = 1.7379080956310527e-04;
99  D_reg[3] = 2.6991049091576078e-04;
100  D_reg[4] = 2.6488528311729070e-04;
101 
102  if( std::fabs( (mu_reg - mu)/mu ) > tol )
103  {
104  std::cerr << "Error: Mismatch in viscosity." << std::endl
105  << std::setprecision(16) << std::scientific
106  << "mu = " << mu << std::endl
107  << "mu_reg = " << mu_reg << std::endl;
108  return_flag = 1;
109  }
110 
111  if( std::fabs( (k_reg - k)/k ) > tol )
112  {
113  std::cerr << "Error: Mismatch in thermal conductivity." << std::endl
114  << std::setprecision(16) << std::scientific
115  << "k = " << k << std::endl
116  << "k_reg = " << k_reg << std::endl;
117  return_flag = 1;
118  }
119 
120  for( unsigned int i = 0; i < 5; i++ )
121  {
122  if( std::fabs( (D_reg[i] - D[i])/D[i] ) > tol )
123  {
124  std::cerr << "Error: Mismatch in diffusion coefficient." << std::endl
125  << std::setprecision(16) << std::scientific
126  << "i = " << i << std::endl
127  << "D = " << D[i] << std::endl
128  << "D_reg = " << D_reg[i] << std::endl;
129  return_flag = 1;
130  }
131  }
132  /*
133  std::cout << std::setprecision(16) << std::scientific
134  << "mu = " << mu << std::endl
135  << "k = " << k << std::endl;
136  for( unsigned int i = 0; i < 5; i++ )
137  {
138  std::cout << std::setprecision(16) << std::scientific
139  << "D[" << i << "] = " << D[i]
140  << std::endl;
141  }
142  */
143 
144  return return_flag;
145 }
146 #else //GRINS_HAVE_CANTERA
147 int main()
148 {
149  // automake expects 77 for a skipped test
150  return 77;
151 }
152 #endif
void D(const CachedValues &cache, unsigned int qp, std::vector< libMesh::Real > &D) const
void set_values(unsigned int quantity, std::vector< libMesh::Number > &values)
Definition: cached_values.C:72
int main(int argc, char *argv[])
libMesh::Real mu(const CachedValues &cache, unsigned int qp) const
libMesh::Real k(const CachedValues &cache, unsigned int qp) const
Wrapper class for storing state for computing thermochemistry and transport properties using Cantera...
void add_quantity(unsigned int quantity)
Definition: cached_values.C:40
Wrapper class for evaluating transport properties using Cantera.
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:20 for GRINS-0.6.0 by  doxygen 1.8.9.1