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 #ifndef ANTIOCH_ROTATIONAL_RELAXATION_H
28 #define ANTIOCH_ROTATIONAL_RELAXATION_H
29 
30 // Antioch
31 #include "antioch/metaprogramming_decl.h"
32 #include "antioch/math_constants.h"
33 #include "antioch/cmath_shims.h"
34 
35 // C++
36 
37 namespace Antioch
38 {
39   template <typename CoeffType>
40   class RotationalRelaxation
41   {
42       public:
43         RotationalRelaxation( CoeffType z_298, CoeffType eps_kb);
~RotationalRelaxation()44         ~RotationalRelaxation(){};
45 
46         void reset_coeffs( CoeffType rot, CoeffType depth);
47 
48         // \todo
49         // cache _eps_kb / 298
50         template <typename StateType>
ANTIOCH_AUTO(StateType)51         ANTIOCH_AUTO(StateType)
52           operator()(const StateType & T) const
53         ANTIOCH_AUTOFUNC(StateType, _z_298 * this->F(_eps_kb / 298) / this->F(StateType(_eps_kb/T)))
54 
55         //!
56         CoeffType Z_298() const
57         { return _z_298; }
58 
59         //!
eps_over_kb()60         CoeffType eps_over_kb() const
61         { return _eps_kb; }
62 
63       private:
64 
65         RotationalRelaxation();
66 
67         template <typename StateType>
68         ANTIOCH_AUTO(StateType)
69           F(const StateType & eps_T) const
70         ANTIOCH_AUTOFUNC(StateType, _one + _pi32_2 * ant_sqrt(eps_T) + _pi2_4_plus_2 * eps_T + _pi32 * ant_pow(eps_T,CoeffType(1.5))) //unambiguate pow() for vexcl
71 
72         CoeffType _z_298;
73         CoeffType _eps_kb;
74         const CoeffType _one;
75         const CoeffType _pi32_2;
76         const CoeffType _pi2_4_plus_2;
77         const CoeffType _pi32;
78   };
79 
80   template <typename CoeffType>
RotationalRelaxation(CoeffType z_298,CoeffType eps_kb)81   RotationalRelaxation<CoeffType>::RotationalRelaxation( CoeffType z_298, CoeffType eps_kb):
82                 _z_298(z_298),
83                 _eps_kb(eps_kb),
84                 _one(1),
85                 _pi32_2(ant_pow(Constants::pi<CoeffType>(),CoeffType(1.5)) / 2),
86                 _pi2_4_plus_2(Constants::pi<CoeffType>() * Constants::pi<CoeffType>() / 4 + 2),
87                 _pi32(ant_pow(Constants::pi<CoeffType>(),CoeffType(1.5)))
88   {
89      return;
90   }
91 
92   template <typename CoeffType>
93   inline
reset_coeffs(CoeffType rot,CoeffType depth)94   void RotationalRelaxation<CoeffType>::reset_coeffs( CoeffType rot, CoeffType depth)
95   {
96      _z_298 = rot;
97      _eps_kb = depth;
98   }
99 
100 }
101 
102 #endif
103