GRINS-0.7.0
antioch_mixture_averaged_transport_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-2016 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"
40 #include "grins/physics_naming.h"
41 
42 // libMesh
43 #include "libmesh/getpot.h"
44 
45 int test_generic( const libMesh::Real value, const libMesh::Real value_reg, const std::string& name )
46 {
47  int return_flag = 0;
48 
49  const double tol = std::numeric_limits<double>::epsilon()*10;
50 
51  const double rel_error = std::fabs( (value - value_reg)/value_reg );
52 
53  if( rel_error > tol )
54  {
55  return_flag = 1;
56  std::cout << "Mismatch in "+name << std::endl
57  << name+" = " << value << std::endl
58  << name+"_reg = " << value_reg << std::endl
59  << "rel_error = " << rel_error << std::endl;
60  }
61 
62  return return_flag;
63 }
64 
65 
66 template<typename Viscosity>
67 int test_mu( const libMesh::Real mu );
68 
69 template<typename Thermo, typename Conductivity>
70 int test_k( const libMesh::Real k );
71 
72 template<typename Thermo, typename Viscosity, typename Conductivity, typename Diffusivity>
73 int test_D( const std::vector<libMesh::Real>& D );
74 
75 template<>
76 int test_mu<Antioch::BlottnerViscosity<libMesh::Real> >( const libMesh::Real mu )
77 {
78  double mu_reg = 4.5123309407810213e-05;
79 
80  return test_generic(mu,mu_reg,"mu");
81 }
82 
83 template<>
84 int test_k<Antioch::StatMechThermodynamics<libMesh::Real>,
85  Antioch::EuckenThermalConductivity<Antioch::StatMechThermodynamics<libMesh::Real> > >( const libMesh::Real k )
86 {
87  double k_reg = 8.0102737519532258e-02;
88 
89  return test_generic(k,k_reg,"k");
90 }
91 
92 template<>
93 int test_D<Antioch::StatMechThermodynamics<libMesh::Real>,
94  Antioch::BlottnerViscosity<libMesh::Real>,
95  Antioch::EuckenThermalConductivity<Antioch::StatMechThermodynamics<libMesh::Real> >,
96  Antioch::ConstantLewisDiffusivity<libMesh::Real> >( const std::vector<libMesh::Real>& D )
97 {
98  std::vector<libMesh::Real> D_reg(5);
99  D_reg[0] = 4.6482311273552429e-02;
100  D_reg[1] = D_reg[0];
101  D_reg[2] = D_reg[0];
102  D_reg[3] = D_reg[0];
103  D_reg[4] = D_reg[0];
104 
105  int return_flag_tmp = 0;
106  int return_flag = 0;
107  for( unsigned int s = 0; s < 5; s++ )
108  {
109  return_flag_tmp = test_generic(D[s],D_reg[s],"D_s");
110  if( return_flag_tmp != 0 ) return_flag = 1;
111  }
112 
113  return return_flag;
114 }
115 
116 template<typename Thermo, typename Viscosity, typename Conductivity, typename Diffusivity>
117 int test_evaluator( const GetPot& input )
118 {
120 
122 
123  const libMesh::Real T = 1000;
124 
125  const libMesh::Real rho = 1.0e-3;
126 
127  const unsigned int n_species = 5;
128 
129  std::vector<libMesh::Real> Y(n_species,0.2);
130 
131  libMesh::Real p0 = rho*T*evaluator.R_mix(Y);
132  libMesh::Real mu = 0.0;
133  libMesh::Real k = 0.0;
134  std::vector<libMesh::Real> D(n_species,0.0);
135 
136  evaluator.mu_and_k_and_D( T, rho, evaluator.cp(T,p0,Y), Y, mu, k, D );
137 
138  std::cout << std::scientific << std::setprecision(16)
139  << "mu = " << mu << std::endl;
140 
141  std::cout << std::scientific << std::setprecision(16)
142  << "k = " << k << std::endl;
143 
144  for( unsigned int i = 0; i < n_species; i++ )
145  {
146  std::cout << std::scientific << std::setprecision(16)
147  << "D(" << mixture.species_name(i) << ") = " << D [i] << std::endl;
148  }
149 
150  int return_flag = 0;
151 
152  int return_flag_temp = 0;
153 
154  return_flag_temp = test_mu<Viscosity>( mu );
155  if( return_flag_temp != 0 ) return_flag = 1;
156 
157  return_flag_temp = test_k<Thermo,Conductivity>( k );
158  if( return_flag_temp != 0 ) return_flag = 1;
159 
160  return_flag_temp = test_D<Thermo,Viscosity,Conductivity,Diffusivity>( D );
161  if( return_flag_temp != 0 ) return_flag = 1;
162 
163  return return_flag;
164 }
165 
166 
167 int main( int argc, char* argv[] )
168 {
169  // Check command line count.
170  if( argc < 2 )
171  {
172  // TODO: Need more consistent error handling.
173  std::cerr << "Error: Must specify input file." << std::endl;
174  exit(1);
175  }
176 
177  GetPot input( argv[1] );
178 
179  int return_flag = 0;
180 
181  std::cout << std::endl << "Running StatMesh, Blottner, Eucken, Constant Lewis regression test." << std::endl;
182  return_flag = test_evaluator<Antioch::StatMechThermodynamics<libMesh::Real>,
183  Antioch::BlottnerViscosity<libMesh::Real>,
184  Antioch::EuckenThermalConductivity<Antioch::StatMechThermodynamics<libMesh::Real> >,
185  Antioch::ConstantLewisDiffusivity<libMesh::Real> >(input);
186 
187  return return_flag;
188 }
189 
190 #else //GRINS_HAVE_ANTIOCH
191 int main()
192 {
193  // automake expects 77 for a skipped test
194  return 77;
195 }
196 #endif
libMesh::Real cp(const libMesh::Real &T, const libMesh::Real P, const std::vector< libMesh::Real > &Y)
int test_mu(const libMesh::Real mu)
int main(int argc, char *argv[])
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)
libMesh::Real R_mix(const std::vector< libMesh::Real > &mass_fractions) const
int test_k(const libMesh::Real k)
std::string species_name(unsigned int species_index) const
int test_D(const std::vector< libMesh::Real > &D)
int test_generic(const libMesh::Real value, const libMesh::Real value_reg, const std::string &name)
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)

Generated on Thu Jun 2 2016 21:52:28 for GRINS-0.7.0 by  doxygen 1.8.10