GRINS-0.6.0
antioch_wilke_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 #include "grins_config.h"
27 
28 #ifdef GRINS_HAVE_ANTIOCH
29 
30 // C++
31 #include <iomanip>
32 #include <limits>
33 #include <vector>
34 
35 // GRINS
38 #include "grins/cached_values.h"
39 
40 // libMesh
41 #include "libmesh/getpot.h"
42 
43 int test_generic( const libMesh::Real value, const libMesh::Real value_reg, const std::string& name )
44 {
45  int return_flag = 0;
46 
47  const double tol = std::numeric_limits<double>::epsilon()*10;
48 
49  const double rel_error = std::fabs( (value - value_reg)/value_reg );
50 
51  if( rel_error > tol )
52  {
53  return_flag = 1;
54  std::cout << "Mismatch in "+name << std::endl
55  << name+" = " << value << std::endl
56  << name+"_reg = " << value_reg << std::endl
57  << "rel_error = " << rel_error << std::endl;
58  }
59 
60  return return_flag;
61 }
62 
63 
64 template<typename Viscosity>
65 int test_mu( const libMesh::Real mu );
66 
67 template<typename Thermo, typename Conductivity>
68 int test_k( const libMesh::Real k );
69 
70 template<typename Thermo, typename Viscosity, typename Conductivity, typename Diffusivity>
71 int test_D( const std::vector<libMesh::Real>& D );
72 
73 template<>
74 int test_mu<Antioch::MixtureViscosity<Antioch::BlottnerViscosity<libMesh::Real> > >( const libMesh::Real mu )
75 {
76  double mu_reg = 4.5123309407810213e-05;
77 
78  return test_generic(mu,mu_reg,"mu");
79 }
80 
81 template<>
82 int test_k<Antioch::StatMechThermodynamics<libMesh::Real>,
83  Antioch::EuckenThermalConductivity<Antioch::StatMechThermodynamics<libMesh::Real> > >( const libMesh::Real k )
84 {
85  double k_reg = 8.0102737519532258e-02;
86 
87  return test_generic(k,k_reg,"k");
88 }
89 
90 template<>
91 int test_D<Antioch::StatMechThermodynamics<libMesh::Real>,
92  Antioch::MixtureViscosity<Antioch::BlottnerViscosity<libMesh::Real> >,
93  Antioch::EuckenThermalConductivity<Antioch::StatMechThermodynamics<libMesh::Real> >,
94  Antioch::ConstantLewisDiffusivity<libMesh::Real> >( const std::vector<libMesh::Real>& D )
95 {
96  std::vector<libMesh::Real> D_reg(5);
97  D_reg[0] = 9.1105330096162743e-02;
98  D_reg[1] = D_reg[0];
99  D_reg[2] = D_reg[0];
100  D_reg[3] = D_reg[0];
101  D_reg[4] = D_reg[0];
102 
103  int return_flag_tmp = 0;
104  int return_flag = 0;
105  for( unsigned int s = 0; s < 5; s++ )
106  {
107  return_flag_tmp = test_generic(D[s],D_reg[s],"D_s");
108  if( return_flag_tmp != 0 ) return_flag = 1;
109  }
110 
111  return return_flag;
112 }
113 
114 template<typename Thermo, typename Viscosity, typename Conductivity, typename Diffusivity>
115 int test_evaluator( const GetPot& input )
116 {
118 
120 
121  const libMesh::Real T = 1000;
122 
123  const libMesh::Real rho = 1.0e-3;
124 
125  const unsigned int n_species = 5;
126 
127  std::vector<libMesh::Real> Y(n_species,0.2);
128 
129  GRINS::CachedValues cache;
130 
132  std::vector<double> Tqp(1,T);
134 
136  std::vector<double> rhoqp(1,rho);
138 
140  std::vector<std::vector<double> > Yqp(1,Y);
142 
143  libMesh::Real mu = evaluator.mu( cache, 0 );
144 
145  libMesh::Real k = evaluator.k( cache, 0 );
146 
147  libMesh::Real mu2 = 0.0;
148  libMesh::Real k2 = 0.0;
149 
150  evaluator.mu_and_k( cache, 0, mu2, k2 );
151 
152  std::vector<libMesh::Real> D(n_species,0.0);
153 
154  evaluator.D( cache, 0, D );
155 
156  std::cout << std::scientific << std::setprecision(16)
157  << "mu = " << mu << std::endl;
158 
159  std::cout << std::scientific << std::setprecision(16)
160  << "k = " << k << std::endl;
161 
162  for( unsigned int i = 0; i < n_species; i++ )
163  {
164  std::cout << std::scientific << std::setprecision(16)
165  << "D(" << mixture.species_name(i) << ") = " << D [i] << std::endl;
166  }
167 
168  int return_flag = 0;
169 
170  int return_flag_temp = 0;
171 
172  return_flag_temp = test_mu<Viscosity>( mu );
173  if( return_flag_temp != 0 ) return_flag = 1;
174 
175  return_flag_temp = test_k<Thermo,Conductivity>( k );
176  if( return_flag_temp != 0 ) return_flag = 1;
177 
178  return_flag_temp = test_mu<Viscosity>( mu2 );
179  if( return_flag_temp != 0 ) return_flag = 1;
180 
181  return_flag_temp = test_k<Thermo,Conductivity>( k2 );
182  if( return_flag_temp != 0 ) return_flag = 1;
183 
184  return_flag_temp = test_D<Thermo,Viscosity,Conductivity,Diffusivity>( D );
185  if( return_flag_temp != 0 ) return_flag = 1;
186 
187  return return_flag;
188 }
189 
190 
191 int main( int argc, char* argv[] )
192 {
193  // Check command line count.
194  if( argc < 2 )
195  {
196  // TODO: Need more consistent error handling.
197  std::cerr << "Error: Must specify input file." << std::endl;
198  exit(1);
199  }
200 
201  GetPot input( argv[1] );
202 
203  int return_flag = 0;
204 
205  std::cout << std::endl << "Running StatMesh, Blottner, Eucken, Constant Lewis regression test." << std::endl;
206  return_flag = test_evaluator<Antioch::StatMechThermodynamics<libMesh::Real>,
207  Antioch::MixtureViscosity<Antioch::BlottnerViscosity<libMesh::Real> >,
208  Antioch::EuckenThermalConductivity<Antioch::StatMechThermodynamics<libMesh::Real> >,
209  Antioch::ConstantLewisDiffusivity<libMesh::Real> >(input);
210 
211  return return_flag;
212 }
213 
214 #else //GRINS_HAVE_ANTIOCH
215 int main()
216 {
217  // automake expects 77 for a skipped test
218  return 77;
219 }
220 #endif
libMesh::Real mu(const CachedValues &cache, unsigned int qp)
void set_values(unsigned int quantity, std::vector< libMesh::Number > &values)
Definition: cached_values.C:72
void D(const CachedValues &cache, unsigned int qp, std::vector< libMesh::Real > &D)
int main(int argc, char *argv[])
int test_mu(const libMesh::Real mu)
int test_k(const libMesh::Real k)
std::string species_name(unsigned int species_index) const
void mu_and_k(const CachedValues &cache, unsigned int qp, libMesh::Real &mu, libMesh::Real &k)
int test_generic(const libMesh::Real value, const libMesh::Real value_reg, const std::string &name)
int test_D(const std::vector< libMesh::Real > &D)
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 k(const CachedValues &cache, unsigned int qp)
Wrapper class for storing state for computing Wilke transport properties using Antioch.
Wrapper class for evaluating Wilke transport properties using Antioch.
int test_evaluator(const GetPot &input)

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