antioch-0.4.0
hercourtessen_rate.h
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 #ifndef ANTIOCH_HERCOURT_ESSEN_RATE_H
28 #define ANTIOCH_HERCOURT_ESSEN_RATE_H
29 
30 //Antioch
32 #include "antioch/kinetics_type.h"
33 #include "antioch/cmath_shims.h"
34 
35 // C++
36 #include <cmath>
37 #include <iostream>
38 #include <sstream>
39 
40 namespace Antioch
41 {
43 
56  template<typename CoeffType=double>
57  class HercourtEssenRate : public KineticsType<CoeffType>
58  {
59 
60  private:
61 
62  CoeffType _raw_Cf;
63  CoeffType _Cf;
64  CoeffType _eta;
65  CoeffType _Tref;
66 
67  public:
68 
69  HercourtEssenRate (const CoeffType Cf=0., const CoeffType eta=0., const CoeffType Tref = 1.);
71 
72  void set_Cf( const CoeffType Cf );
73  void set_eta( const CoeffType eta );
74  void set_Tref(const CoeffType Tref );
75 
77  void set_parameter(KineticsModel::Parameters parameter, CoeffType new_value);
78 
80  CoeffType get_parameter(KineticsModel::Parameters parameter) const;
81 
83  //
84  // \todo, solve this
85  template <typename VectorCoeffType>
86  void set_parameter(KineticsModel::Parameters parameter, VectorCoeffType new_value){antioch_error();}
87 
98  template <typename VectorCoeffType>
99  void reset_coefs(const VectorCoeffType & coefficients);
100 
101  CoeffType Cf() const;
102  CoeffType eta() const;
103  CoeffType Tref() const;
104 
106  template <typename StateType>
107  ANTIOCH_AUTO(StateType)
108  rate(const StateType& T) const
109  ANTIOCH_AUTOFUNC(StateType, _Cf* (ant_pow(T,_eta)))
110 
112  template <typename StateType>
113  ANTIOCH_AUTO(StateType)
114  operator()(const StateType& T) const
115  ANTIOCH_AUTOFUNC(StateType, this->rate(T))
116 
118  template <typename StateType>
119  ANTIOCH_AUTO(StateType)
120  derivative( const StateType& T ) const
121  ANTIOCH_AUTOFUNC(StateType, (*this)(T)/T*(_eta))
122 
124  template <typename StateType>
125  void rate_and_derivative(const StateType& T, StateType& rate, StateType& drate_dT) const;
126 
127 // KineticsConditions overloads
128 
130  template <typename StateType, typename VectorStateType>
131  ANTIOCH_AUTO(StateType)
132  rate(const KineticsConditions<StateType,VectorStateType>& T) const
133  ANTIOCH_AUTOFUNC(StateType, _Cf * ant_exp(_eta * T.temp_cache().lnT))
134 
136  template <typename StateType, typename VectorStateType>
137  ANTIOCH_AUTO(StateType)
138  operator()(const KineticsConditions<StateType,VectorStateType>& T) const
139  ANTIOCH_AUTOFUNC(StateType, this->rate(T))
140 
142  template <typename StateType, typename VectorStateType>
143  ANTIOCH_AUTO(StateType)
144  derivative( const KineticsConditions<StateType,VectorStateType>& T ) const
145  ANTIOCH_AUTOFUNC(StateType, (*this)(T)/T.T()*(_eta))
146 
148  template <typename StateType,typename VectorStateType>
149  void rate_and_derivative(const KineticsConditions<StateType,VectorStateType>& T, StateType& rate, StateType& drate_dT) const;
150 
152  const std::string numeric() const;
153 
154  private:
155 
156  void compute_cf();
157 
158  };
159 
160  template<typename CoeffType>
161  HercourtEssenRate<CoeffType>::HercourtEssenRate(const CoeffType Cf, const CoeffType eta, const CoeffType Tref)
163  _raw_Cf(Cf),
164  _eta(eta),
165  _Tref(Tref)
166  {
167  this->compute_cf();
168 
169  return;
170  }
171 
172  template<typename CoeffType>
174  {
175  return;
176  }
177 
178  template<typename CoeffType>
179  const std::string HercourtEssenRate<CoeffType>::numeric() const
180  {
181  std::stringstream os;
182  os << _raw_Cf;
183  os << "*(T/" << _Tref << ")^" << _eta;
184 
185  return os.str();
186  }
187 
188  /* ------------------------- Inline Functions -------------------------*/
189  template<typename CoeffType>
190  inline
191  void HercourtEssenRate<CoeffType>::set_Cf( const CoeffType Cf )
192  {
193  _raw_Cf = Cf;
194  this->compute_cf();
195 
196  return;
197  }
198 
199  template<typename CoeffType>
200  inline
202  {
203  _eta = eta;
204  this->compute_cf();
205  return;
206  }
207 
208  template<typename CoeffType>
209  inline
211  {
212  _Tref = Tref;
213  this->compute_cf();
214 
215  return;
216  }
217 
218  template<typename CoeffType>
219  template <typename VectorCoeffType>
220  inline
221  void HercourtEssenRate<CoeffType>::reset_coefs(const VectorCoeffType & coefficients)
222  {
223  antioch_assert_greater(coefficients.size(),1);
224  antioch_assert_less(coefficients.size(),4);
225  if(coefficients.size() == 3)this->set_Tref(coefficients[2]);
226  this->set_Cf(coefficients[0]);
227  this->set_eta(coefficients[1]);
228  }
229 
230  template<typename CoeffType>
231  inline
233  {
234  switch(parameter)
235  {
237  {
238  this->set_Cf(new_value);
239  }
240  break;
242  {
243  this->set_eta(new_value);
244  }
245  break;
247  {
248  this->set_Tref(new_value);
249  }
250  break;
251  default:
252  {
253  antioch_error();
254  }
255  break;
256  }
257  }
258 
259  template<typename CoeffType>
260  inline
262  {
263  switch(parameter)
264  {
266  {
267  return this->Cf();
268  }
269  break;
271  {
272  return this->eta();
273  }
274  break;
276  {
277  return this->Tref();
278  }
279  break;
280  default:
281  {
282  antioch_error();
283  }
284  break;
285  }
286 
287  return 0;
288  }
289 
290  template<typename CoeffType>
291  inline
293  { return _Cf; }
294 
295  template<typename CoeffType>
296  inline
298  { return _eta; }
299 
300  template<typename CoeffType>
301  inline
303  { return _Tref; }
304 
305  template<typename CoeffType>
306  template<typename StateType>
307  inline
308  void HercourtEssenRate<CoeffType>::rate_and_derivative( const StateType& T,
309  StateType& rate,
310  StateType& drate_dT) const
311  {
312  rate = (*this)(T);
313  drate_dT = rate/T*(_eta);
314  return;
315  }
316 
317  template<typename CoeffType>
318  inline
320  {
321  _Cf = _raw_Cf * ant_pow(KineticsModel::Tref<CoeffType>()/_Tref,_eta);
322 
323  return;
324  }
325 
326  template<typename CoeffType>
327  template <typename StateType,typename VectorStateType>
328  inline
330  StateType& rate,
331  StateType& drate_dT) const
332  {
333  rate = (*this)(cond);
334  drate_dT = rate/cond.T() * _eta;
335  return;
336  }
337 
338 } // end namespace Antioch
339 
340 #endif // ANTIOCH_HERCOURT_ESSEN_RATE_H
void set_parameter(KineticsModel::Parameters parameter, VectorCoeffType new_value)
for compatibility purpose with photochemistry (particle flux reactions)
_Cf VectorStateType VectorStateType derivative(const KineticsConditions< StateType, VectorStateType > &T) const ANTIOCH_AUTOFUNC(StateType
base class for kinetics models
Definition: kinetics_type.h:82
const std::string numeric() const
print equation
#define antioch_assert_greater(expr1, expr2)
#define antioch_assert_less(expr1, expr2)
void set_parameter(KineticsModel::Parameters parameter, CoeffType new_value)
set one parameter, characterized by enum
#define antioch_error()
void set_Tref(const CoeffType Tref)
void reset_coefs(const VectorCoeffType &coefficients)
reset the coeffs
void set_eta(const CoeffType eta)
_Cf * ant_exp(_eta *T.temp_cache().lnT)) template< typename StateType
_Cf * ant_pow(T, _eta))) template< typename StateType > operator()(const StateType &T) const template< typename StateType > derivative(const StateType &T) const ANTIOCH_AUTOFUNC(StateType
_Cf(*) StateType StateType &drate_d const)
CoeffType get_parameter(KineticsModel::Parameters parameter) const
get one parameter, characterized by enum
#define ANTIOCH_AUTOFUNC(Type, Expr)
const ANTIOCH_AUTO(StateType) KineticsTheoryThermalConductivity< ThermoEvaluator
Hercourt-Essen rate equation.
_Cf(* this)(T)/T *(_eta)) template< typename StateType > void rate_and_derivative(const StateType &T
Simultaneously evaluate the rate and its derivative at T.
The parameters are reduced parameters.
void set_Cf(const CoeffType Cf)
HercourtEssenRate(const CoeffType Cf=0., const CoeffType eta=0., const CoeffType Tref=1.)
const StateType & T() const
This class contains the conditions of the chemistry.
_Cf VectorStateType VectorStateType(*) VectorStateType voi rate_and_derivative)(const KineticsConditions< StateType, VectorStateType > &T, StateType &rate, StateType &drate_dT) const

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