antioch-0.4.0
blottner_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
38 
39 template <typename Scalar>
40 int test_viscosity( const Scalar mu, const Scalar mu_exact, const Scalar tol )
41 {
42  using std::abs;
43 
44  int return_flag = 0;
45 
46  const double rel_error = abs( (mu - mu_exact)/mu_exact);
47 
48  if( rel_error > tol )
49  {
50  std::cerr << "Error: Mismatch in viscosity" << std::endl
51  << "mu(T) = " << mu << std::endl
52  << "mu_exact = " << mu_exact << std::endl
53  << "rel_error = " << rel_error << std::endl
54  << "tol = " << tol << std::endl;
55  return_flag = 1;
56  }
57 
58  return return_flag;
59 }
60 
61 template <typename Scalar>
62 int tester()
63 {
64  const Scalar a = 3.14e-3;
65  const Scalar b = 2.71e-2;
66  const Scalar c = 42.0e-5;
67 
69 
70  std::cout << mu << std::endl;
71 
72  const Scalar T = 1521.2;
73 
74  // octave gives
75  const Scalar mu_exact = 0.144422234167703;
76 
77  int return_flag = 0;
78 
79  const Scalar tol = 1.0e-14;
80 
81  return_flag = test_viscosity( mu(T), mu_exact, tol );
82 
83  const Scalar a2 = 1e-3;
84  const Scalar b2 = 2e-2;
85  const Scalar c2 = 3e-5;
86 
87  mu.reset_coeffs( a2, b2, c2 );
88 
89  // octave gives
90  const Scalar mu_exact2 = 0.122172495548880;
91 
92  return_flag = test_viscosity( mu(T), mu_exact2, tol );
93 
94  return return_flag;
95 }
96 
97 int main()
98 {
99  return (tester<double>() ||
100  tester<long double>() ||
101  tester<float>());
102 }
int tester()
int main()
int test_viscosity(const Scalar mu, const Scalar mu_exact, const Scalar tol)
void reset_coeffs(const CoeffType a, const CoeffType b, const CoeffType c)

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