antioch-0.4.0
eucken_thermal_cond_unit.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 // $Id$
28 //
29 //--------------------------------------------------------------------------
30 //--------------------------------------------------------------------------
31 
32 // C++
33 #include <iostream>
34 #include <cmath>
35 
36 // Antioch
39 
40 template <typename Scalar>
41 int test_k( const Scalar k, const Scalar k_exact, const Scalar tol )
42 {
43  using std::abs;
44 
45  int return_flag = 0;
46 
47  const Scalar rel_error = abs( (k - k_exact)/k_exact);
48 
49  if( rel_error > tol )
50  {
51  std::cerr << "Error: Mismatch in thermal conductivity" << std::endl
52  << "k = " << k << std::endl
53  << "k_exact = " << k_exact << std::endl
54  << "rel_error = " << rel_error << std::endl
55  << "tol = " << tol << std::endl;
56  return_flag = 1;
57  }
58 
59  return return_flag;
60 }
61 
62 template <typename Scalar>
63 int tester()
64 {
65  std::vector<std::string> species_str_list;
66  const unsigned int n_species = 5;
67  species_str_list.reserve(n_species);
68  species_str_list.push_back( "N2" );
69  species_str_list.push_back( "O2" );
70  species_str_list.push_back( "N" );
71  species_str_list.push_back( "O" );
72  species_str_list.push_back( "NO" );
73 
74  const Scalar Mm_N = 14.008e-3L;
75  const Scalar Mm_O = 16.000e-3L;
76  const Scalar Mm_N2 = 2.L * Mm_N;
77  const Scalar Mm_O2 = 2.L * Mm_O;
78  const Scalar Mm_NO = Mm_N + Mm_O;
79 
80  Antioch::ChemicalMixture<Scalar> chem_mixture( species_str_list );
81 
82  const Scalar R_N2 = Antioch::Constants::R_universal<Scalar>()/Mm_N2;
83  const Scalar R_O2 = Antioch::Constants::R_universal<Scalar>()/Mm_O2;
84  const Scalar R_N = Antioch::Constants::R_universal<Scalar>()/Mm_N;
85  const Scalar R_O = Antioch::Constants::R_universal<Scalar>()/Mm_O;
86  const Scalar R_NO = Antioch::Constants::R_universal<Scalar>()/Mm_NO;
87 
88  Antioch::StatMechThermodynamics<Scalar> thermo( chem_mixture );
89 
91 
92  const Scalar mu = 3.14e-3;
93 
94  // octave gives
95  const Scalar k_N2_trans_exact = 2.5*mu*1.5*R_N2;
96  const Scalar k_N_trans_exact = 2.5*mu*1.5*R_N;
97  const Scalar k_O2_trans_exact = 2.5*mu*1.5*R_O2;
98  const Scalar k_O_trans_exact = 2.5*mu*1.5*R_O;
99  const Scalar k_NO_trans_exact = 2.5*mu*1.5*R_NO;
100 
101  int return_flag = 0;
102 
103  const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 2;
104 
105  int return_flag_temp = 0;
106  return_flag_temp = test_k( k.trans(0, mu), k_N2_trans_exact, tol );
107  if( return_flag_temp != 0 ) return_flag = 1;
108 
109  return_flag_temp = test_k( k.trans(1, mu), k_O2_trans_exact, tol );
110  if( return_flag_temp != 0 ) return_flag = 1;
111 
112  return_flag_temp = test_k( k.trans(2, mu), k_N_trans_exact, tol );
113  if( return_flag_temp != 0 ) return_flag = 1;
114 
115  return_flag_temp = test_k( k.trans(3, mu), k_O_trans_exact, tol );
116  if( return_flag_temp != 0 ) return_flag = 1;
117 
118  return_flag_temp = test_k( k.trans(4, mu), k_NO_trans_exact, tol );
119  if( return_flag_temp != 0 ) return_flag = 1;
120 
121  return return_flag;
122 }
123 
124 int main()
125 {
126  return (tester<double>() ||
127 // tester<long double>() ||
128  tester<float>());
129 }
int test_k(const Scalar k, const Scalar k_exact, const Scalar tol)
trans(const unsigned int s, const StateType &mu) const ANTIOCH_AUTOFUNC(StateType
Species conductivity based on Eucken relation.
Class storing chemical mixture properties.
int tester()

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