antioch-0.4.0
mixture_conductivity_regression.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // Antioch - A Gas Dynamics Thermochemistry Library
5 //
6 // Copyright (C) 2014-2016 Paul T. Bauman, Benjamin S. Kirk,
7 // Sylvain Plessis, Roy H. Stonger
8 //
9 // Copyright (C) 2013 The PECOS Development Team
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the Version 2.1 GNU Lesser General
13 // Public License as published by the Free Software Foundation.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
23 // Boston, MA 02110-1301 USA
24 //
25 //-----------------------------------------------------------------------el-
26 
27 // Antioch
28 #include "antioch_config.h"
31 
32 
36 
41 #include "antioch/vector_utils.h"
42 
43 
47 
49 
50 template<typename Scalar>
51 bool test_val( Scalar value, Scalar gold, Scalar tol, std::string test )
52 {
53  bool test_passed = true;
54 
55  Scalar error = std::abs( value - gold );
56  if( error > tol )
57  {
58  test_passed = false;
59  std::cerr << "Test "+test+" failed!" << std::endl
60  << "value = " << value << std::endl
61  << "gold = " << gold << std::endl
62  << "error = " << error << std::endl
63  << "tol = " << tol << std::endl;
64  }
65 
66  return test_passed;
67 }
68 
69 template <typename Scalar>
70 int tester()
71 {
72  std::vector<std::string> species_str_list;
73 
74  // Test hard coded to 1 species right now. If we ever
75  // add more here, be aware that the regression test on
76  // the values is targeted at the N2 values, so if you
77  // change the species order, update the N2_species index
78  // accordingly.
79  const unsigned int n_species = 1;
80  species_str_list.reserve(n_species);
81  species_str_list.push_back( "N2" );
82  unsigned int N2_species = 0;
83 
84  Antioch::ChemicalMixture<Scalar> chem_mixture( species_str_list );
85 
86  typedef Antioch::StatMechThermodynamics<Scalar> MicroThermo;
87  MicroThermo thermo_stat( chem_mixture );
88 
89  Antioch::TransportMixture<Scalar> tran_mixture( chem_mixture );
90 
92  e_k_mixture(tran_mixture);
93 
94  Antioch::build_eucken_thermal_conductivity<MicroThermo,Scalar>(e_k_mixture, thermo_stat);
95 
97  s_mu_mixture(tran_mixture);
98 
100  b_mu_mixture(tran_mixture);
101 
102 #ifdef ANTIOCH_HAVE_GSL
104  k_mu_mixture(tran_mixture);
105 #endif // ANTIOCH_HAVE_GSL
106 
107  Antioch::read_sutherland_data_ascii<Scalar>( s_mu_mixture, Antioch::DefaultFilename::sutherland_data() );
108  Antioch::read_blottner_data_ascii<Scalar>( b_mu_mixture, Antioch::DefaultFilename::blottner_data() );
109 
110 #ifdef ANTIOCH_HAVE_GSL
111  Antioch::build_kinetics_theory_viscosity<Scalar>(k_mu_mixture);
112 #endif // ANTIOCH_HAVE_GSL
113 
114  const Scalar T = 1500.1;
115 
116  // Gold values were generated with long double version of test
117  // Eucken, Sutherland gold
118  Scalar k_e_s_N2_gold = 8.1294319021704618392660e-02L;
119  Scalar k_e_s_N2_value = 0.0; // init
120 
121  // Eucken, Blottner gold
122  Scalar k_e_b_N2_gold = 8.3906393746814049491975e-02L;
123  Scalar k_e_b_N2_value = 0.0; // init
124 
125  // Eucken KineticsTheory gold
126 #ifdef ANTIOCH_HAVE_GSL
127  Scalar k_e_kt_N2_gold = 8.6774379182691310526782e-02L;
128  Scalar k_e_kt_N2_value = 0.0; // init
129 #endif // ANTIOCH_HAVE_GSL
130 
131  std::cout << "Eucken (with SutherlandViscosity):" << std::endl;
132  for( unsigned int s = 0; s < n_species; s++ )
133  {
134  Scalar mu = s_mu_mixture(s,T);
135  Scalar value = e_k_mixture.conductivity_without_diffusion(s, T, mu);
136  if( s == N2_species )
137  k_e_s_N2_value = value;
138 
139  std::cout << "k(" << species_str_list[s] << ") = " << value << std::endl;
140  }
141 
142  std::cout << "Eucken (with BlottnerViscosity):" << std::endl;
143  for( unsigned int s = 0; s < n_species; s++ )
144  {
145  Scalar mu = b_mu_mixture(s,T);
146  Scalar value = e_k_mixture.conductivity_without_diffusion(s, T, mu);
147  if( s == N2_species )
148  k_e_b_N2_value = value;
149 
150  std::cout << "k(" << species_str_list[s] << ") = " << value << std::endl;
151  }
152 
153 #ifdef ANTIOCH_HAVE_GSL
154  std::cout << "Eucken (with KineticsTheoryViscosity):" << std::endl;
155  for( unsigned int s = 0; s < n_species; s++ )
156  {
157  Scalar mu = k_mu_mixture(s,T);
158  Scalar value = e_k_mixture.conductivity_without_diffusion(s, T, mu);
159  if( s == N2_species )
160  k_e_kt_N2_value = value;
161 
162  std::cout << "k(" << species_str_list[s] << ") = " << value << std::endl;
163  }
164 #endif // ANTIOCH_HAVE_GSL
165 
166  int return_flag = 0;
167 
168  // Now test all the values
169  Scalar tol = std::numeric_limits<Scalar>::epsilon();
170 
171  if( !test_val<Scalar>(k_e_s_N2_value, k_e_s_N2_gold, tol, "Eucken-Sutherland") )
172  return_flag = 1;
173 
174  if( !test_val<Scalar>(k_e_b_N2_value, k_e_b_N2_gold, tol, "Eucken-Blottner") )
175  return_flag = 1;
176 
177 #ifdef ANTIOCH_HAVE_GSL
178  if( !test_val<Scalar>(k_e_kt_N2_value, k_e_kt_N2_gold, tol, "Eucken-KineticsTheory") )
179  return_flag = 1;
180 #endif // ANTIOCH_HAVE_GSL
181 
182  return return_flag;
183 }
184 
185 int main()
186 {
187  return (tester<double>() ||
188  tester<long double>() ||
189  tester<float>());
190 }
Container class for species viscosities.
bool test_val(Scalar value, Scalar gold, Scalar tol, std::string test)
Class storing chemical mixture properties.
Definition: ascii_parser.h:55
static const std::string & sutherland_data()
static const std::string & blottner_data()
Container class for species thermal conductivities.
Class storing chemical mixture properties.

Generated on Thu Jul 7 2016 11:09:46 for antioch-0.4.0 by  doxygen 1.8.8