antioch-0.4.0
mixture_viscosity_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
37 #include "antioch_config.h"
43 #include "antioch/gsl_spliner.h"
44 #include "antioch/vector_utils.h"
45 
50 
51 template <typename Scalar>
52 int test_values( Scalar test_value, Scalar exact_value, Scalar tol )
53 {
54  int return_flag = 0;
55  Scalar error = std::abs(test_value - exact_value);
56 
57  if( error > tol )
58  {
59  std::cout << std::setprecision(16) << std::scientific;
60 
61  std::cout << "ERROR: Value exceeds tolerance!" << std::endl
62  << "test_value = " << test_value << std::endl
63  << "exact_value = " << exact_value << std::endl
64  << "error = " << error << std::endl
65  << "tol = " << tol << std::endl;
66 
67  return_flag = 1;
68  }
69 
70  return return_flag;
71 }
72 
73 template <typename Scalar>
74 int tester()
75 {
76  std::vector<std::string> species_str_list;
77  const unsigned int n_species = 2;
78  species_str_list.reserve(n_species);
79  species_str_list.push_back( "N2" );
80  species_str_list.push_back( "O2" );
81 
82  Antioch::ChemicalMixture<Scalar> chem_mixture( species_str_list );
83 
84  Antioch::TransportMixture<Scalar> tran_mixture( chem_mixture );
85 
86  Antioch::SutherlandViscosity<Scalar> s_N2(1.399306e-06, 1.066667e+02);
87  Antioch::SutherlandViscosity<Scalar> s_O2(1.693411e-06, 1.270000e+02);
88 
89  Antioch::BlottnerViscosity<Scalar> b_N2(2.68142000000e-02, 3.17783800000e-01, -1.13155513000e+01);
90  Antioch::BlottnerViscosity<Scalar> b_O2(4.49290000000e-02, -8.26158000000e-02, -9.20194750000e+00);
91 
92 #ifdef ANTIOCH_HAVE_GSL
93  Antioch::KineticsTheoryViscosity<Scalar, Antioch::GSLSpliner> k_N2(97.530, 3.621, 0.0, chem_mixture.M(0)/Antioch::Constants::Avogadro<Scalar>());
94  Antioch::KineticsTheoryViscosity<Scalar, Antioch::GSLSpliner> k_O2(107.400, 3.458, 0.0, chem_mixture.M(1)/Antioch::Constants::Avogadro<Scalar>() );
95 #endif // ANTIOCH_HAVE_GSL
96 
98  s_mu_mixture(tran_mixture);
99 
101  b_mu_mixture(tran_mixture);
102 
103 #ifdef ANTIOCH_HAVE_GSL
105  k_mu_mixture(tran_mixture);
106 #endif // ANTIOCH_HAVE_GSL
107 
108  Antioch::read_sutherland_data_ascii<Scalar>( s_mu_mixture, Antioch::DefaultFilename::sutherland_data() );
109  Antioch::read_blottner_data_ascii<Scalar>( b_mu_mixture, Antioch::DefaultFilename::blottner_data() );
110 
111 #ifdef ANTIOCH_HAVE_GSL
112  Antioch::build_kinetics_theory_viscosity<Scalar>(k_mu_mixture);
113 #endif // ANTIOCH_HAVE_GSL
114 
115  std::cout << s_mu_mixture << std::endl;
116  std::cout << b_mu_mixture << std::endl;
117 
118 #ifdef ANTIOCH_HAVE_GSL
119  std::cout << k_mu_mixture << std::endl;
120 #endif // ANTIOCH_HAVE_GSL
121 
122  const Scalar T = 1500.1;
123 
124  std::cout << "Sutherland:" << std::endl;
125  for( unsigned int s = 0; s < n_species; s++ )
126  {
127  std::cout << "mu(" << species_str_list[s] << ") = " << s_mu_mixture(s, T) << std::endl;
128  }
129 
130  std::cout << "Blottner:" << std::endl;
131  for( unsigned int s = 0; s < n_species; s++ )
132  {
133  std::cout << "mu(" << species_str_list[s] << ") = " << b_mu_mixture(s, T) << std::endl;
134  }
135 
136 #ifdef ANTIOCH_HAVE_GSL
137  std::cout << "Kinetic Theory:" << std::endl;
138  for( unsigned int s = 0; s < n_species; s++ )
139  {
140  std::cout << "mu(" << species_str_list[s] << ") = " << k_mu_mixture(s, T) << std::endl;
141  }
142 #endif // ANTIOCH_HAVE_GSL
143 
144  int return_flag = 0;
145 
146  Scalar tol = 2.0*std::numeric_limits<Scalar>::epsilon();
147  return_flag = test_values( s_mu_mixture(0, T), s_N2(T), tol ) ||
148  test_values( s_mu_mixture(1, T), s_O2(T), tol ) ||
149  test_values( b_mu_mixture(0, T), b_N2(T), tol ) ||
150  test_values( b_mu_mixture(1, T), b_O2(T), tol );
151 
152 #ifdef ANTIOCH_HAVE_GSL
153  return_flag = test_values( k_mu_mixture(0, T), k_N2(T), tol ) ||
154  test_values( k_mu_mixture(1, T), k_O2(T), tol );
155 #endif // ANTIOCH_HAVE_GSL
156 
157  return return_flag;
158 }
159 
160 int main()
161 {
162  return (tester<double>() ||
163  tester<long double>() ||
164  tester<float>());
165 }
Container class for species viscosities.
int tester()
CoeffType M(const unsigned int s) const
Molecular weight (molar mass) for species s in kg/mol.
int test_values(Scalar test_value, Scalar exact_value, Scalar tol)
Class storing chemical mixture properties.
Definition: ascii_parser.h:55
static const std::string & sutherland_data()
static const std::string & blottner_data()
Class storing chemical mixture properties.
int main()

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