antioch-0.4.0
rotational_relaxation_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 // Antioch
30 
31 // C++
32 #include <iostream>
33 #include <iomanip>
34 #include <limits>
35 #include <cmath>
36 
37 const long double pi(3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825);
38 
39 template <typename Scalar>
40 Scalar F(const Scalar & x)
41 {
42  return 1.L + std::pow(pi,1.5)/2.L * std::sqrt(x)
43  + (pi*pi/4.L + 2.L) * x
44  + std::pow(pi * x,1.5);
45 }
46 
47 template <typename Scalar>
48 Scalar Z(const Scalar & T, const Scalar & eps_kb, const Scalar & z_298)
49 {
50  return z_298 * F(eps_kb / 298.L) / F(eps_kb / T);
51 }
52 
53 
54 template <typename Scalar>
55 int tester()
56 {
57  using std::abs;
58 
59  int return_flag = 0;
60  const Scalar tol = (std::numeric_limits<Scalar>::epsilon() * 10 < 5e-17)?5e-17:
61  std::numeric_limits<Scalar>::epsilon() * 10;
62 
63  const Scalar eps_kb = 97.53L; // N2 value
64  const Scalar z_298 = 4.0L; // N2 value
65 
66  Antioch::RotationalRelaxation<Scalar> rot(z_298,eps_kb);
67 
68  for(Scalar T = 300.1; T <= 2500.1; T += 10.)
69  {
70  Scalar z = rot(T);
71  Scalar z_exact = Z(T,eps_kb,z_298);
72 
73  if( abs( (z - z_exact)/z_exact) > tol )
74  {
75  std::cout << std::scientific << std::setprecision(16)
76  << "Error: Mismatch in rotational relaxation values." << std::endl
77  << " T = " << T << std::endl
78  << " z = " << z << std::endl
79  << " z_exact = " << z_exact << std::endl
80  << " relative error = " << std::abs(z - z_exact)/z_exact << std::endl
81  << " tolerance = " << tol << std::endl;
82 
83  return_flag = 1;
84  }
85  }
86 
87  return return_flag;
88 }
89 
90 int main()
91 {
92  return (tester<double>() ||
93  tester<long double>() ||
94  tester<float>());
95 }
Scalar Z(const Scalar &T, const Scalar &eps_kb, const Scalar &z_298)
Scalar F(const Scalar &x)
Antioch::enable_if_c< Antioch::is_valarray< T >::value, typename Antioch::state_type< T >::type >::type pow(const T &in, const T2 &n)
const long double pi(3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825)
Scalar z(const Scalar &T, const Scalar &eps_kb, const Scalar &z_298)

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