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

Generated on Tue Dec 19 2017 12:47:29 for GRINS-0.8.0 by  doxygen 1.8.9.1