antioch-0.4.0
kinetics_theory_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 #include "antioch_config.h"
28 
29 // C++
30 #include <iostream>
31 #include <iomanip>
32 #include <cmath>
33 #include <limits>
34 
35 // Antioch
39 #include "antioch/vector_utils.h"
40 
41 #ifdef ANTIOCH_HAVE_GSL
42 
43 template <typename Scalar>
44 int test_viscosity( const Scalar mu, const Scalar mu_exact, const Scalar tol )
45 {
46  using std::abs;
47 
48  int return_flag = 0;
49 
50  const double rel_error = abs( (mu - mu_exact)/mu_exact);
51 
52  if( rel_error > tol )
53  {
54  std::cerr << std::setprecision(15) << std::scientific;
55  std::cerr << "Error: Mismatch in viscosity" << std::endl
56  << "mu(T) = " << mu << std::endl
57  << "mu_exact = " << mu_exact << std::endl
58  << "rel_error = " << rel_error << std::endl
59  << "tol = " << tol << std::endl;
60  return_flag = 1;
61  }
62 
63  return return_flag;
64 }
65 
66 template <typename Scalar>
67 int tester()
68 {
69 // value for N2
70  const Scalar LJ_depth(97.530L);
71  const Scalar LJ_diameter(3.621L);
72  const Scalar dipole_moment(0.L);
73  const Scalar mass(28.016e-3L/Antioch::Constants::Avogadro<Scalar>());
74 
75  Antioch::KineticsTheoryViscosity<Scalar,Antioch::GSLSpliner> mu(LJ_depth,LJ_diameter,dipole_moment,mass);
76 
77  const Scalar T = 1500.1;
78 
79  // bc gives
80  const Scalar mu_exact_times_interp = 0.0000417395098853601937871105407365424874568203066945573066;
81 
82  int return_flag = 0;
83 
84  const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 10.;
85 
86  return_flag = test_viscosity( mu(T) * mu.Stockmayer(T), mu_exact_times_interp, tol );
87 
88  return return_flag;
89 }
90 #endif // ANTIOCH_HAVE_GSL
91 
92 int main()
93 {
94 #ifdef ANTIOCH_HAVE_GSL
95  return tester<double>() ||
96  tester<long double>() ||
97  tester<float>();
98 #else
99  // 77 return code tells Automake we skipped this.
100  return 77;
101 #endif
102 };
int tester(const std::string &testname)
int test_viscosity(const Scalar mu, const Scalar mu_exact, const Scalar tol)

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