antioch-0.4.0
sutherland_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 #include <limits>
36 
37 // Antioch
39 
40 
41 template <typename Scalar>
42 int test_viscosity( const Scalar mu, const Scalar mu_exact, const Scalar tol )
43 {
44  using std::abs;
45 
46  int return_flag = 0;
47 
48  const Scalar rel_error = abs( (mu - mu_exact)/mu_exact);
49 
50  if( rel_error > tol )
51  {
52  std::cerr << "Error: Mismatch in viscosity" << std::endl
53  << "mu(T) = " << mu << std::endl
54  << "mu_exact = " << mu_exact << std::endl
55  << "rel_error = " << rel_error << std::endl
56  << "tol = " << tol << std::endl;
57  return_flag = 1;
58  }
59 
60  return return_flag;
61 }
62 
63 
64 template <typename Scalar>
65 int tester()
66 {
67  const Scalar mu_ref = 1.0e-3L;
68  const Scalar T_ref = 300.0L;
69 
70  Antioch::SutherlandViscosity<Scalar> mu(mu_ref,T_ref);
71 
72  std::cout << mu << std::endl;
73 
74  const Scalar T = 1521.2L;
75 
76  // bc with scale=40 gives
77  const Scalar mu_exact = .0325778060534850406481862157435995107036L;
78 
79  int return_flag = 0;
80 
81  const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 10;
82 
83  return_flag = test_viscosity( mu(T), mu_exact, tol );
84 
85  const Scalar mu_ref2 = 3.14159e-3L;
86  const Scalar T_ref2 = 420.42L;
87 
88  mu.reset_coeffs(mu_ref2,T_ref2);
89 
90  // bc with scale=40 gives
91  const Scalar mu_exact2 = .0959985656417205050367745642313443587197L;
92 
93  return_flag = test_viscosity( mu(T), mu_exact2, tol );
94 
95  return return_flag;
96 }
97 
98 
99 int main()
100 {
101  return (tester<double>() ||
102  tester<long double>() ||
103  tester<float>());
104 }
int test_viscosity(const Scalar mu, const Scalar mu_exact, const Scalar tol)
int tester()
void reset_coeffs(const CoeffType mu_ref, const CoeffType T_ref)

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