GRINS-0.8.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-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 
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"
35 #include "grins/physics_naming.h"
36 
37 // libMesh
38 #include "libmesh/getpot.h"
39 
40 #ifdef GRINS_HAVE_CANTERA
41 int main(int argc, char* argv[])
42 {
43  // Check command line count.
44  if( argc < 2 )
45  {
46  // TODO: Need more consistent error handling.
47  std::cerr << "Error: Must specify input file." << std::endl;
48  exit(1); // TODO: something more sophisticated for parallel runs?
49  }
50 
51  GetPot input( argv[1] );
52 
53  std::vector<std::string> species(5);
54  species[0] = input( "Materials/TestMaterial/GasMixture/species", "DIE!", 0 );
55  species[1] = input( "Materials/TestMaterial/GasMixture/species", "DIE!", 1 );
56  species[2] = input( "Materials/TestMaterial/GasMixture/species", "DIE!", 2 );
57  species[3] = input( "Materials/TestMaterial/GasMixture/species", "DIE!", 3 );
58  species[4] = input( "Materials/TestMaterial/GasMixture/species", "DIE!", 4 );
59 
60  GRINS::CanteraMixture cantera_mixture(input,"TestMaterial");
61 
62  GRINS::CanteraTransport cantera_trans(cantera_mixture);
63 
64  double T = 1000.0;
65 
66  double P = 100000.0;
67 
68  std::vector<double> Y(5,0.2);
69 
70  double rho = P/T/cantera_mixture.R_mix(Y);
71 
72  GRINS::CachedValues cache;
73 
77 
78  std::vector<double> Tqp(1,T);
79  std::vector<double> Pqp(1,P);
80  std::vector<std::vector<double> > Yqp(1,Y);
81 
85 
86  double mu, k;
87  std::vector<libMesh::Real> D(5,0.0);
88 
89  double dummy = 0.0;
90 
91  cantera_trans.mu_and_k_and_D( T, rho, dummy, Y, mu, k, D );
92 
93  int return_flag = 0;
94 
95  const double tol = 6.0e-15;
96 
97  const double mu_reg = 4.2134235819759682e-05;
98  const double k_reg = 5.7138665373733508e-02;
99  std::vector<libMesh::Real> D_reg(5,0.0);
100  D_reg[0] = 1.7611544183904180e-04;
101  D_reg[1] = 1.7169898621123060e-04;
102  D_reg[2] = 1.7379080956310527e-04;
103  D_reg[3] = 2.6991049091576078e-04;
104  D_reg[4] = 2.6488528311729070e-04;
105 
106  if( std::fabs( (mu_reg - mu)/mu ) > tol )
107  {
108  std::cerr << "Error: Mismatch in viscosity." << std::endl
109  << std::setprecision(16) << std::scientific
110  << "mu = " << mu << std::endl
111  << "mu_reg = " << mu_reg << std::endl;
112  return_flag = 1;
113  }
114 
115  if( std::fabs( (k_reg - k)/k ) > tol )
116  {
117  std::cerr << "Error: Mismatch in thermal conductivity." << std::endl
118  << std::setprecision(16) << std::scientific
119  << "k = " << k << std::endl
120  << "k_reg = " << k_reg << std::endl;
121  return_flag = 1;
122  }
123 
124  for( unsigned int i = 0; i < 5; i++ )
125  {
126  if( std::fabs( (D_reg[i] - D[i])/D[i] ) > tol )
127  {
128  std::cerr << "Error: Mismatch in diffusion coefficient." << std::endl
129  << std::setprecision(16) << std::scientific
130  << "i = " << i << std::endl
131  << "D = " << D[i] << std::endl
132  << "D_reg = " << D_reg[i] << std::endl;
133  return_flag = 1;
134  }
135  }
136  /*
137  std::cout << std::setprecision(16) << std::scientific
138  << "mu = " << mu << std::endl
139  << "k = " << k << std::endl;
140  for( unsigned int i = 0; i < 5; i++ )
141  {
142  std::cout << std::setprecision(16) << std::scientific
143  << "D[" << i << "] = " << D[i]
144  << std::endl;
145  }
146  */
147 
148  return return_flag;
149 }
150 #else //GRINS_HAVE_CANTERA
151 int main()
152 {
153  // automake expects 77 for a skipped test
154  return 77;
155 }
156 #endif
void set_values(unsigned int quantity, std::vector< libMesh::Number > &values)
Definition: cached_values.C:72
int main(int argc, char *argv[])
libMesh::Real R_mix(const std::vector< libMesh::Real > &mass_fractions) const
Wrapper class for storing state for computing thermochemistry and transport properties using Cantera...
void mu_and_k_and_D(const libMesh::Real T, const libMesh::Real rho, const libMesh::Real cp, const std::vector< libMesh::Real > &Y, libMesh::Real &mu, libMesh::Real &k, std::vector< libMesh::Real > &D)
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 Tue Dec 19 2017 12:47:29 for GRINS-0.8.0 by  doxygen 1.8.9.1